|
1 | 1 | import CheckCircleOutlined from "@mui/icons-material/CheckCircleOutlined";
|
2 | 2 | import { css, useTheme } from "@emotion/react";
|
3 |
| -import type { HTMLAttributes, PropsWithChildren, FC } from "react"; |
| 3 | +import { type HTMLAttributes, type PropsWithChildren, type FC } from "react"; |
4 | 4 | import { MONOSPACE_FONT_FAMILY } from "theme/constants";
|
5 | 5 | import { DisabledBadge, EnabledBadge } from "../Badges/Badges";
|
6 | 6 |
|
@@ -104,68 +104,61 @@ export const OptionValue: FC<OptionValueProps> = (props) => {
|
104 | 104 | return <span css={styles.option}>{JSON.stringify(value)}</span>;
|
105 | 105 | };
|
106 | 106 |
|
107 |
| -interface OptionConfigProps extends HTMLAttributes<HTMLDivElement> { |
108 |
| - source?: boolean; |
109 |
| -} |
| 107 | +type OptionConfigProps = HTMLAttributes<HTMLDivElement> & { isSource: boolean }; |
110 | 108 |
|
111 |
| -// OptionConfig takes a source bool to indicate if the Option is the source of the configured value. |
112 |
| -export const OptionConfig: FC<OptionConfigProps> = ({ |
113 |
| - children, |
114 |
| - source, |
115 |
| - ...attrs |
116 |
| -}) => { |
| 109 | +// OptionConfig takes a isSource bool to indicate if the Option is the source of the configured value. |
| 110 | +export const OptionConfig = ({ isSource, ...attrs }: OptionConfigProps) => { |
117 | 111 | const theme = useTheme();
|
118 |
| - const borderColor = source ? undefined : theme.palette.divider; |
| 112 | + const borderColor = isSource |
| 113 | + ? theme.experimental.roles.active.outline |
| 114 | + : theme.palette.divider; |
119 | 115 |
|
120 | 116 | return (
|
121 | 117 | <div
|
122 | 118 | {...attrs}
|
123 |
| - css={{ |
124 |
| - fontSize: 13, |
125 |
| - fontFamily: MONOSPACE_FONT_FAMILY, |
126 |
| - fontWeight: 600, |
127 |
| - backgroundColor: source |
128 |
| - ? theme.palette.primary.dark |
129 |
| - : theme.palette.background.paper, |
130 |
| - display: "inline-flex", |
131 |
| - alignItems: "center", |
132 |
| - borderRadius: 2, |
133 |
| - padding: "0 8px", |
134 |
| - border: `1px solid ${borderColor}`, |
135 |
| - }} |
136 |
| - > |
137 |
| - {children} |
138 |
| - </div> |
| 119 | + css={[ |
| 120 | + { |
| 121 | + fontSize: 13, |
| 122 | + fontFamily: MONOSPACE_FONT_FAMILY, |
| 123 | + fontWeight: 600, |
| 124 | + backgroundColor: theme.palette.background.paper, |
| 125 | + display: "inline-flex", |
| 126 | + alignItems: "center", |
| 127 | + borderRadius: 4, |
| 128 | + padding: 6, |
| 129 | + lineHeight: 1, |
| 130 | + gap: 6, |
| 131 | + border: `1px solid ${borderColor}`, |
| 132 | + }, |
| 133 | + isSource |
| 134 | + ? { |
| 135 | + "& .OptionConfigFlag": { |
| 136 | + background: theme.experimental.roles.active.fill, |
| 137 | + }, |
| 138 | + } |
| 139 | + : undefined, |
| 140 | + ]} |
| 141 | + /> |
139 | 142 | );
|
140 | 143 | };
|
141 | 144 |
|
142 |
| -interface OptionConfigFlagProps extends HTMLAttributes<HTMLDivElement> { |
143 |
| - source?: boolean; |
144 |
| -} |
145 |
| - |
146 |
| -export const OptionConfigFlag: FC<OptionConfigFlagProps> = ({ |
147 |
| - children, |
148 |
| - source, |
149 |
| - ...attrs |
150 |
| -}) => { |
| 145 | +export const OptionConfigFlag = (props: HTMLAttributes<HTMLDivElement>) => { |
151 | 146 | const theme = useTheme();
|
152 | 147 |
|
153 | 148 | return (
|
154 | 149 | <div
|
155 |
| - {...attrs} |
| 150 | + {...props} |
| 151 | + className="OptionConfigFlag" |
156 | 152 | css={{
|
157 | 153 | fontSize: 10,
|
158 | 154 | fontWeight: 600,
|
159 |
| - margin: "0 6px 0 -4px", |
160 | 155 | display: "block",
|
161 |
| - backgroundColor: source ? "rgba(0, 0, 0, 0.7)" : theme.palette.divider, |
| 156 | + backgroundColor: theme.palette.divider, |
162 | 157 | lineHeight: 1,
|
163 | 158 | padding: "2px 4px",
|
164 |
| - borderRadius: 2, |
| 159 | + borderRadius: 1, |
165 | 160 | }}
|
166 |
| - > |
167 |
| - {children} |
168 |
| - </div> |
| 161 | + /> |
169 | 162 | );
|
170 | 163 | };
|
171 | 164 |
|
|
0 commit comments