@@ -4,14 +4,11 @@ import type { HTMLAttributes, PropsWithChildren, FC } from "react";
4
4
import { MONOSPACE_FONT_FAMILY } from "theme/constants" ;
5
5
import { DisabledBadge , EnabledBadge } from "../Badges/Badges" ;
6
6
7
- export const OptionName : FC < PropsWithChildren > = ( props ) => {
8
- const { children } = props ;
9
-
7
+ export const OptionName : FC < PropsWithChildren > = ( { children } ) => {
10
8
return < span css = { { display : "block" } } > { children } </ span > ;
11
9
} ;
12
10
13
- export const OptionDescription : FC < PropsWithChildren > = ( props ) => {
14
- const { children } = props ;
11
+ export const OptionDescription : FC < PropsWithChildren > = ( { children } ) => {
15
12
const theme = useTheme ( ) ;
16
13
17
14
return (
@@ -36,31 +33,20 @@ export const OptionValue: FC<OptionValueProps> = (props) => {
36
33
const { children : value } = props ;
37
34
const theme = useTheme ( ) ;
38
35
39
- const optionStyles = css `
40
- font-size : 14px ;
41
- font-family : ${ MONOSPACE_FONT_FAMILY } ;
42
- overflow-wrap : anywhere;
43
- user-select : all;
44
-
45
- & ul {
46
- padding : 16px ;
47
- }
48
- ` ;
49
-
50
36
if ( typeof value === "boolean" ) {
51
37
return value ? < EnabledBadge /> : < DisabledBadge /> ;
52
38
}
53
39
54
40
if ( typeof value === "number" ) {
55
- return < span css = { optionStyles } > { value } </ span > ;
41
+ return < span css = { styles . option } > { value } </ span > ;
56
42
}
57
43
58
44
if ( ! value || value . length === 0 ) {
59
- return < span css = { optionStyles } > Not set</ span > ;
45
+ return < span css = { styles . option } > Not set</ span > ;
60
46
}
61
47
62
48
if ( typeof value === "string" ) {
63
- return < span css = { optionStyles } > { value } </ span > ;
49
+ return < span css = { styles . option } > { value } </ span > ;
64
50
}
65
51
66
52
if ( typeof value === "object" && ! Array . isArray ( value ) ) {
@@ -72,7 +58,7 @@ export const OptionValue: FC<OptionValueProps> = (props) => {
72
58
< li
73
59
key = { option }
74
60
css = { [
75
- optionStyles ,
61
+ styles . option ,
76
62
! isEnabled && {
77
63
marginLeft : 32 ,
78
64
color : theme . palette . text . disabled ,
@@ -107,24 +93,27 @@ export const OptionValue: FC<OptionValueProps> = (props) => {
107
93
return (
108
94
< ul css = { { listStylePosition : "inside" } } >
109
95
{ value . map ( ( item ) => (
110
- < li key = { item } css = { optionStyles } >
96
+ < li key = { item } css = { styles . option } >
111
97
{ item }
112
98
</ li >
113
99
) ) }
114
100
</ ul >
115
101
) ;
116
102
}
117
103
118
- return < span css = { optionStyles } > { JSON . stringify ( value ) } </ span > ;
104
+ return < span css = { styles . option } > { JSON . stringify ( value ) } </ span > ;
119
105
} ;
120
106
121
107
interface OptionConfigProps extends HTMLAttributes < HTMLDivElement > {
122
108
source ?: boolean ;
123
109
}
124
110
125
111
// OptionConfig takes a source bool to indicate if the Option is the source of the configured value.
126
- export const OptionConfig = ( props : OptionConfigProps ) => {
127
- const { children, source, ...attrs } = props ;
112
+ export const OptionConfig : FC < OptionConfigProps > = ( {
113
+ children,
114
+ source,
115
+ ...attrs
116
+ } ) => {
128
117
const theme = useTheme ( ) ;
129
118
const borderColor = source
130
119
? theme . palette . primary . main
@@ -156,8 +145,11 @@ interface OptionConfigFlagProps extends HTMLAttributes<HTMLDivElement> {
156
145
source ?: boolean ;
157
146
}
158
147
159
- export const OptionConfigFlag = ( props : OptionConfigFlagProps ) => {
160
- const { children, source, ...attrs } = props ;
148
+ export const OptionConfigFlag : FC < OptionConfigFlagProps > = ( {
149
+ children,
150
+ source,
151
+ ...attrs
152
+ } ) => {
161
153
const theme = useTheme ( ) ;
162
154
163
155
return (
@@ -178,3 +170,16 @@ export const OptionConfigFlag = (props: OptionConfigFlagProps) => {
178
170
</ div >
179
171
) ;
180
172
} ;
173
+
174
+ const styles = {
175
+ option : css `
176
+ font-size : 14px ;
177
+ font-family : ${ MONOSPACE_FONT_FAMILY } ;
178
+ overflow-wrap : anywhere;
179
+ user-select : all;
180
+
181
+ & ul {
182
+ padding : 16px ;
183
+ }
184
+ ` ,
185
+ } ;
0 commit comments