|
1 |
| -import { Accordion, Text } from "@mantine/core"; |
| 1 | +import { Accordion, Text, createStyles } from "@mantine/core"; |
2 | 2 | import { JSONObject } from "aiconfig";
|
3 |
| -import { memo, useState } from "react"; |
| 3 | +import { memo, useContext, useState } from "react"; |
4 | 4 | import ParametersRenderer from "./ParametersRenderer";
|
| 5 | +import AIConfigContext from "../contexts/AIConfigContext"; |
5 | 6 |
|
6 | 7 | type Props = {
|
7 | 8 | initialValue: JSONObject;
|
8 | 9 | onUpdateParameters: (newParameters: JSONObject) => void;
|
9 | 10 | };
|
10 | 11 |
|
| 12 | +const useStyles = createStyles(() => ({ |
| 13 | + parametersContainer: { |
| 14 | + margin: "16px auto 16px 36px", |
| 15 | + }, |
| 16 | + parametersContainerReadonly: { |
| 17 | + margin: "16px auto", |
| 18 | + }, |
| 19 | +})); |
| 20 | + |
11 | 21 | export default memo(function GlobalParametersContainer({
|
12 | 22 | initialValue,
|
13 | 23 | onUpdateParameters,
|
14 | 24 | }: Props) {
|
15 | 25 | const [isParametersDrawerOpen, setIsParametersDrawerOpen] = useState(false);
|
16 | 26 |
|
| 27 | + const { classes } = useStyles(); |
| 28 | + const { readOnly } = useContext(AIConfigContext); |
| 29 | + |
17 | 30 | return (
|
18 |
| - <div className="parametersContainer"> |
| 31 | + // Set local and global classname. Global will override if specified |
| 32 | + // Local is readonly or not. Global will always have parametersContainer class |
| 33 | + // and if readonly, will also have parametersContainerReadonly class (to allow overrides) |
| 34 | + <div |
| 35 | + className={`${ |
| 36 | + readOnly |
| 37 | + ? classes.parametersContainerReadonly |
| 38 | + : classes.parametersContainer |
| 39 | + } parametersContainer ${readOnly ? "parametersContainerReadonly" : ""}`} |
| 40 | + > |
19 | 41 | <Accordion
|
20 | 42 | styles={{
|
21 | 43 | item: { borderBottom: 0 },
|
|
0 commit comments