@basic-ui/material 1.0.0-alpha.32 → 1.0.0-alpha.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/build/cjs/index.js +92 -21
  2. package/build/cjs/index.js.map +1 -1
  3. package/build/esm/BottomSheet/BottomSheet.d.ts +1 -1
  4. package/build/esm/BottomSheet/BottomSheetSurface.d.ts +1 -1
  5. package/build/esm/Button/Button.d.ts +1 -1
  6. package/build/esm/CheckBox/CheckBox.d.ts +1 -1
  7. package/build/esm/Chip/ButtonChip.d.ts +1 -1
  8. package/build/esm/Chip/ChoiceChip.d.ts +1 -1
  9. package/build/esm/Combobox/Combobox.d.ts +7 -7
  10. package/build/esm/Dialog/Dialog.d.ts +1 -1
  11. package/build/esm/Dialog/DialogBackdrop.d.ts +1 -1
  12. package/build/esm/Dialog/DialogSurface.d.ts +1 -1
  13. package/build/esm/Menu/Menu.d.ts +5 -5
  14. package/build/esm/NavRail/NavRailItem.d.ts +3 -3
  15. package/build/esm/RadioButton/RadioGroup.d.ts +1 -1
  16. package/build/esm/Select/CustomContainerExample.d.ts +3 -0
  17. package/build/esm/Select/CustomContainerExample.js +59 -0
  18. package/build/esm/Select/CustomContainerExample.js.map +1 -0
  19. package/build/esm/Select/Select.d.ts +21 -7
  20. package/build/esm/Select/Select.js +52 -10
  21. package/build/esm/Select/Select.js.map +1 -1
  22. package/build/esm/Select/context.d.ts +5 -4
  23. package/build/esm/Select/context.js +2 -1
  24. package/build/esm/Select/context.js.map +1 -1
  25. package/build/esm/Select/defaultRender.d.ts +2 -1
  26. package/build/esm/Select/defaultRender.js +33 -4
  27. package/build/esm/Select/defaultRender.js.map +1 -1
  28. package/build/esm/SelectItem/SelectItem.d.ts +7 -3
  29. package/build/esm/SelectItem/SelectItem.js +14 -3
  30. package/build/esm/SelectItem/SelectItem.js.map +1 -1
  31. package/build/esm/Slider/Slider.d.ts +6 -6
  32. package/build/esm/Snackbar/Snackbar.d.ts +1 -1
  33. package/build/esm/Switch/Switch.d.ts +1 -1
  34. package/build/esm/Tab/Tab.d.ts +1 -1
  35. package/build/esm/Tab/TabList.d.ts +1 -1
  36. package/build/esm/Tab/TabPanel.d.ts +1 -1
  37. package/build/esm/TabIndicator/TabIndicator.d.ts +1 -1
  38. package/build/esm/Table/TableHead.d.ts +1 -1
  39. package/build/esm/TextField/FilledContainer.d.ts +4 -1
  40. package/build/esm/TextField/FilledContainer.js +5 -5
  41. package/build/esm/TextField/FilledContainer.js.map +1 -1
  42. package/build/esm/TextField/TextField.d.ts +1 -1
  43. package/build/esm/ThemeExplorer/ThemeBuilder.js +13 -2
  44. package/build/esm/ThemeExplorer/ThemeBuilder.js.map +1 -1
  45. package/build/esm/ThemeExplorer/ThemeColors.js +33 -15
  46. package/build/esm/ThemeExplorer/ThemeColors.js.map +1 -1
  47. package/build/esm/ThemeExplorer/components.d.ts +1 -1
  48. package/build/esm/ThemeExplorer/components.js +11 -13
  49. package/build/esm/ThemeExplorer/components.js.map +1 -1
  50. package/build/esm/ThemeExplorer/makeColorScheme.d.ts +32 -4
  51. package/build/esm/ThemeExplorer/makeColorScheme.js +41 -8
  52. package/build/esm/ThemeExplorer/makeColorScheme.js.map +1 -1
  53. package/build/esm/Tooltip/Tooltip.d.ts +1 -1
  54. package/build/esm/theme/theme.js +2 -2
  55. package/build/esm/theme/theme.js.map +1 -1
  56. package/build/tsconfig-build.tsbuildinfo +1 -1
  57. package/package.json +3 -3
  58. package/src/Select/CustomContainerExample.tsx +59 -0
  59. package/src/Select/Select.story.tsx +68 -69
  60. package/src/Select/Select.tsx +99 -27
  61. package/src/Select/SelectMultiple.story.tsx +215 -0
  62. package/src/Select/context.ts +5 -3
  63. package/src/Select/defaultRender.tsx +49 -0
  64. package/src/SelectItem/SelectItem.tsx +68 -46
  65. package/src/TextField/FilledContainer.tsx +6 -5
  66. package/src/ThemeExplorer/ThemeBuilder.tsx +16 -5
  67. package/src/ThemeExplorer/ThemeColors.tsx +39 -15
  68. package/src/ThemeExplorer/components.tsx +12 -20
  69. package/src/ThemeExplorer/makeColorScheme.tsx +39 -6
  70. package/src/theme/theme.ts +2 -2
  71. package/src/Select/defaultRender.ts +0 -19
@@ -0,0 +1,215 @@
1
+ import { useState } from 'react';
2
+
3
+ import { Select } from './';
4
+ import { SelectItem } from '../SelectItem';
5
+ import { Box } from '../Box';
6
+ import { CheckBox } from '../CheckBox';
7
+
8
+ export default {
9
+ title: 'components/Select/Multiple',
10
+ };
11
+
12
+ const SearchIcon = (props: any) => (
13
+ <svg
14
+ xmlns="http://www.w3.org/2000/svg"
15
+ height={24}
16
+ width={24}
17
+ viewBox="0 0 48 48"
18
+ fill="currentColor"
19
+ {...props}
20
+ >
21
+ <path d="M39.8 41.95 26.65 28.8q-1.5 1.3-3.5 2.025-2 .725-4.25.725-5.4 0-9.15-3.75T6 18.75q0-5.3 3.75-9.05 3.75-3.75 9.1-3.75 5.3 0 9.025 3.75 3.725 3.75 3.725 9.05 0 2.15-.7 4.15-.7 2-2.1 3.75L42 39.75Zm-20.95-13.4q4.05 0 6.9-2.875Q28.6 22.8 28.6 18.75t-2.85-6.925Q22.9 8.95 18.85 8.95q-4.1 0-6.975 2.875T9 18.75q0 4.05 2.875 6.925t6.975 2.875Z" />
22
+ </svg>
23
+ );
24
+
25
+ type OptionType =
26
+ | ''
27
+ | '10'
28
+ | '20'
29
+ | '30'
30
+ | '40'
31
+ | '50'
32
+ | '60'
33
+ | '70'
34
+ | '80'
35
+ | '90'
36
+ | '100'
37
+ | '110'
38
+ | '120'
39
+ | '130';
40
+
41
+ const Example = ({
42
+ variant,
43
+ native = false,
44
+ }: {
45
+ variant?: 'outlined' | 'filled';
46
+ native?: boolean;
47
+ }) => {
48
+ const [error, setError] = useState<boolean | string>(false);
49
+ const [color, setColor] = useState<'primary' | 'secondary'>('primary');
50
+
51
+ /* eslint-disable react/no-children-prop */
52
+ const children = [
53
+ <SelectItem<OptionType> key={1} value={'10'}>
54
+ Ten
55
+ </SelectItem>,
56
+ <SelectItem<OptionType> key={2} value={'20'}>
57
+ Twenty
58
+ </SelectItem>,
59
+ <SelectItem<OptionType> key={3} value={'30'}>
60
+ Thirty
61
+ </SelectItem>,
62
+ <SelectItem<OptionType> key={4} value={'40'}>
63
+ Fourty
64
+ </SelectItem>,
65
+ <SelectItem<OptionType> key={5} value={'50'}>
66
+ Fifty
67
+ </SelectItem>,
68
+ <SelectItem<OptionType> key={6} value={'60'}>
69
+ Sixty
70
+ </SelectItem>,
71
+ <SelectItem<OptionType> key={7} value={'70'}>
72
+ Seventy
73
+ </SelectItem>,
74
+ <SelectItem<OptionType> key={8} value={'80'}>
75
+ Eighty
76
+ </SelectItem>,
77
+ <SelectItem<OptionType> key={9} value={'90'}>
78
+ Ninety
79
+ </SelectItem>,
80
+ <SelectItem<OptionType> key={10} value={'100'}>
81
+ One Hundred
82
+ </SelectItem>,
83
+ <SelectItem<OptionType> key={11} value={'110'}>
84
+ One Hundred Ten
85
+ </SelectItem>,
86
+ <SelectItem<OptionType> key={12} value={'120'}>
87
+ One Hundred Twenty
88
+ </SelectItem>,
89
+ <SelectItem<OptionType> key={13} value={'130'}>
90
+ One Hundred Thirty
91
+ </SelectItem>,
92
+ ];
93
+
94
+ return (
95
+ <Box p={3}>
96
+ {/* <CheckBox
97
+ checked={Boolean(error)}
98
+ onChange={(e) =>
99
+ setError(e.target.checked ? 'This field is required' : false)
100
+ }
101
+ >
102
+ Has Error
103
+ </CheckBox>
104
+ <Box width={230} display="inline-block">
105
+ <Select<'primary' | 'secondary'>
106
+ value={color}
107
+ onChange={(e, value) => setColor(value)}
108
+ label="Color"
109
+ >
110
+ <SelectItem<'primary' | 'secondary'> value="primary">
111
+ Primary
112
+ </SelectItem>
113
+ <SelectItem<'primary' | 'secondary'> value="secondary">
114
+ Secondary
115
+ </SelectItem>
116
+ </Select>
117
+ </Box> */}
118
+ <Box m={3} bg="surface">
119
+ <Box mb={3} width={230}>
120
+ <Select<OptionType>
121
+ error={error}
122
+ color={color}
123
+ native={native}
124
+ multiple
125
+ variant={variant}
126
+ label="Standard"
127
+ helperText="Helper text"
128
+ children={children}
129
+ placeholder="Empty"
130
+ />
131
+ </Box>
132
+ <Box mb={3} width={230}>
133
+ <Select<OptionType>
134
+ error={error}
135
+ color={color}
136
+ native={native}
137
+ multiple
138
+ variant={variant}
139
+ label="Standard"
140
+ defaultValue={['20']}
141
+ helperText="Helper text"
142
+ children={children}
143
+ />
144
+ </Box>
145
+ <Box mb={3} width={230}>
146
+ <Select<OptionType>
147
+ error={error}
148
+ color={color}
149
+ native={native}
150
+ multiple
151
+ variant={variant}
152
+ label="Standard"
153
+ children={children}
154
+ />
155
+ </Box>
156
+ <Box mb={3} width={230}>
157
+ <Select<OptionType>
158
+ error={error}
159
+ color={color}
160
+ native={native}
161
+ multiple
162
+ variant={variant}
163
+ label="Disabled"
164
+ helperText="Helper text"
165
+ disabled
166
+ children={children}
167
+ />
168
+ </Box>
169
+ <Box mb={3} width={230}>
170
+ <Select<OptionType>
171
+ error={error}
172
+ color={color}
173
+ native={native}
174
+ multiple
175
+ variant={variant}
176
+ label=""
177
+ helperText="Helper text"
178
+ children={children}
179
+ />
180
+ </Box>
181
+ <Box mb={3} width={230}>
182
+ <Select<OptionType>
183
+ error={error}
184
+ color={color}
185
+ native={native}
186
+ multiple
187
+ variant={variant}
188
+ label=""
189
+ helperText="Helper text"
190
+ children={children}
191
+ leadingIcon={<SearchIcon />}
192
+ />
193
+ </Box>
194
+ <Box mb={3} width={230}>
195
+ <Select<OptionType>
196
+ error={error}
197
+ color={color}
198
+ native={native}
199
+ multiple
200
+ variant={variant}
201
+ label="Standard"
202
+ helperText="Helper text"
203
+ children={children}
204
+ leadingIcon={<SearchIcon />}
205
+ />
206
+ </Box>
207
+ </Box>
208
+ </Box>
209
+ );
210
+ };
211
+
212
+ export const Filled = () => <Example variant="filled" />;
213
+ export const Outlined = () => <Example variant="outlined" />;
214
+ export const FilledNative = () => <Example variant="filled" native />;
215
+ export const OutlinedNative = () => <Example variant="outlined" native />;
@@ -2,19 +2,21 @@ import type { MouseEvent, KeyboardEvent } from 'react';
2
2
  import { useContext, createContext } from 'react';
3
3
 
4
4
  // Select Component
5
- export interface SelectContextProps {
5
+ export interface SelectContextProps<ValueType extends string> {
6
6
  native: boolean;
7
- value?: string;
7
+ value?: ValueType | ValueType[];
8
8
  onSelect: (
9
9
  e: MouseEvent<HTMLLIElement> | KeyboardEvent<HTMLLIElement>
10
10
  ) => void;
11
+ multiple: boolean;
11
12
  }
12
13
 
13
- const selectContext = createContext<SelectContextProps>({
14
+ const selectContext = createContext<SelectContextProps<string>>({
14
15
  native: false,
15
16
  onSelect: () => {
16
17
  // noop
17
18
  },
19
+ multiple: false,
18
20
  });
19
21
  export const { Provider: SelectProvider } = selectContext;
20
22
  export const useSelectContext = () => useContext(selectContext);
@@ -0,0 +1,49 @@
1
+ import type { ReactNode } from 'react';
2
+ import { Children, isValidElement } from 'react';
3
+
4
+ import { Box } from '../Box';
5
+
6
+ export const makeDefaultRender =
7
+ <T extends string>(children?: ReactNode) =>
8
+ (val: T | '' | undefined): ReactNode => {
9
+ if (children && val !== undefined) {
10
+ const allChildren = Children.toArray(children);
11
+ for (let i = 0; i < allChildren.length; i++) {
12
+ const child = allChildren[i];
13
+ if (isValidElement(child) && String(child.props.value) === val) {
14
+ return child.props.children;
15
+ }
16
+ }
17
+ }
18
+ return val || undefined;
19
+ };
20
+
21
+ export const makeDefaultMultipleRender =
22
+ <T extends string>(children?: ReactNode) =>
23
+ (val: T[] | undefined): ReactNode => {
24
+ const ret = [];
25
+ if (children && val !== undefined && val.length > 0) {
26
+ const set = new Set<string>(val);
27
+ const allChildren = Children.toArray(children);
28
+ for (let i = 0; i < allChildren.length; i++) {
29
+ const child = allChildren[i];
30
+ if (isValidElement(child) && set.has(String(child.props.value))) {
31
+ ret.push(child.props.children);
32
+ }
33
+ }
34
+ }
35
+
36
+ return (
37
+ <Box
38
+ as="span"
39
+ sx={{
40
+ maxWidth: '100%',
41
+ overflow: 'hidden',
42
+ textOverflow: 'ellipsis',
43
+ whiteSpace: 'nowrap',
44
+ }}
45
+ >
46
+ {ret.join(', ')}
47
+ </Box>
48
+ );
49
+ };
@@ -1,3 +1,4 @@
1
+ import type { ForwardedRef, ReactElement, Ref } from 'react';
1
2
  import { forwardRef } from 'react';
2
3
  import { wrapEvent, MenuItem as MenuItemCore } from '@basic-ui/core';
3
4
  import type { MenuItemProps as MenuItemPropsCore } from '@basic-ui/core';
@@ -14,57 +15,78 @@ const MenuItem = forwardRef<HTMLLIElement, MenuItemProps>(
14
15
  )
15
16
  );
16
17
 
17
- export type SelectItemProps = MenuItemProps;
18
+ export interface SelectItemProps<ValueType extends string>
19
+ extends MenuItemProps {
20
+ value: ValueType;
21
+ }
18
22
 
19
23
  const ZERO_WIDTH_SPACE = '\u200b';
20
- export const SelectItem = forwardRef<HTMLLIElement, MenuItemProps>(
21
- function SelectItem(props, forwardedRef) {
22
- const {
23
- as: Comp = MenuItem,
24
- onSelect: onSelectProp,
25
- children,
26
- value: valueProp,
27
- disabled,
28
- ...otherProps
29
- } = props;
30
- const { native, onSelect, value: selectedValue } = useSelectContext();
31
- const value =
32
- valueProp !== undefined && valueProp !== null
33
- ? String(valueProp)
34
- : (children as string);
24
+ export const SelectItem = forwardRef(function SelectItem<
25
+ ValueType extends string
26
+ >(
27
+ props: SelectItemProps<ValueType>,
28
+ forwardedRef: ForwardedRef<HTMLLIElement>
29
+ ) {
30
+ const {
31
+ as: Comp = MenuItem,
32
+ onSelect: onSelectProp,
33
+ children,
34
+ value: valueProp,
35
+ disabled,
36
+ onKeyDown,
37
+ ...otherProps
38
+ } = props;
39
+ const {
40
+ native,
41
+ onSelect,
42
+ value: selectedValue,
43
+ multiple,
44
+ } = useSelectContext();
45
+ const value =
46
+ valueProp !== undefined && valueProp !== null
47
+ ? String(valueProp)
48
+ : (children as string);
35
49
 
36
- if (native) {
37
- return (
38
- <option
39
- ref={forwardedRef}
40
- value={value}
41
- disabled={disabled}
42
- {...(otherProps as any)}
43
- >
44
- {children}
45
- </option>
46
- );
47
- }
48
-
49
- if (children === undefined && disabled) {
50
- return null;
51
- }
52
-
53
- const selected = value === String(selectedValue);
50
+ if (native) {
54
51
  return (
55
- <Comp
56
- as={MenuItem}
57
- onSelect={wrapEvent(onSelectProp, onSelect as any)}
58
- data-value={value}
59
- disabled={disabled}
52
+ <option
60
53
  ref={forwardedRef}
61
- role="option"
62
- aria-selected={selected ? 'true' : undefined}
63
- selected={selected}
64
- {...otherProps}
54
+ value={value}
55
+ disabled={disabled}
56
+ {...(otherProps as any)}
65
57
  >
66
- {children || ZERO_WIDTH_SPACE}
67
- </Comp>
58
+ {children}
59
+ </option>
68
60
  );
69
61
  }
70
- );
62
+
63
+ if (children === undefined && disabled) {
64
+ return null;
65
+ }
66
+
67
+ let selected = false;
68
+ if (multiple && Array.isArray(selectedValue)) {
69
+ selected = Boolean(selectedValue.find((v) => v === value));
70
+ } else {
71
+ selected = value === String(selectedValue);
72
+ }
73
+ return (
74
+ <Comp
75
+ as={MenuItem}
76
+ onSelect={wrapEvent(onSelectProp, onSelect as any)}
77
+ data-value={value}
78
+ disabled={disabled}
79
+ ref={forwardedRef}
80
+ role="option"
81
+ aria-selected={selected ? 'true' : undefined}
82
+ selected={selected}
83
+ {...otherProps}
84
+ >
85
+ {children || ZERO_WIDTH_SPACE}
86
+ </Comp>
87
+ );
88
+ }) as <ValueType extends string>(
89
+ p: SelectItemProps<ValueType> & {
90
+ ref?: Ref<HTMLLIElement>;
91
+ }
92
+ ) => ReactElement;
@@ -24,9 +24,10 @@ const makeSelector = (
24
24
  `input:${state} ~ &,` +
25
25
  `select:${state} ~ &,` +
26
26
  `button:${state} ~ &,` +
27
- `textarea:${state} ~ &`;
27
+ `textarea:${state} ~ &,` +
28
+ `[role="button"]:${state} ~ &`;
28
29
 
29
- const Overlay = (props: { forceActive?: boolean }) => {
30
+ export const FilledContainerOverlay = (props: { forceActive?: boolean }) => {
30
31
  const { forceActive } = props;
31
32
  const theme = useTheme();
32
33
 
@@ -60,7 +61,7 @@ const Overlay = (props: { forceActive?: boolean }) => {
60
61
  );
61
62
  };
62
63
 
63
- const BorderBottom = () => (
64
+ const FilledContainerBorderBottom = () => (
64
65
  <Box
65
66
  __css={{
66
67
  position: 'absolute',
@@ -163,8 +164,8 @@ export const FilledContainer = forwardRef<HTMLDivElement, FilledContainerProps>(
163
164
 
164
165
  {children}
165
166
 
166
- <Overlay forceActive={active} />
167
- <BorderBottom />
167
+ <FilledContainerOverlay forceActive={active} />
168
+ <FilledContainerBorderBottom />
168
169
  <LineRipple active={active || error} color={color} />
169
170
  </Box>
170
171
  );
@@ -1,9 +1,10 @@
1
1
  import type { ComponentType } from 'react';
2
2
  import { useState, useMemo, useEffect } from 'react';
3
3
  import {
4
- CorePalette,
5
4
  argbFromHex,
6
5
  hexFromArgb,
6
+ TonalPalette,
7
+ HCT,
7
8
  } from '@material/material-color-utilities';
8
9
  import type { Color } from '@basic-ui/color-picker';
9
10
  import { toColor } from '@basic-ui/color-picker';
@@ -98,10 +99,20 @@ const ThemeBuilderImpl = (props: ThemeBuilderProps) => {
98
99
  'primary'
99
100
  );
100
101
 
101
- const { a1, a2, a3, error, n1, n2 } = useMemo(
102
- () => CorePalette.of(argbFromHex(primaryColor.hex)),
103
- [primaryColor.hex]
104
- );
102
+ const { a1, a2, a3, error, n1, n2 } = useMemo(() => {
103
+ /* This is from CorePalette.of(...) */
104
+ const argb = argbFromHex(primaryColor.hex);
105
+ const hct = HCT.fromInt(argb);
106
+ const hue = hct.hue;
107
+ return {
108
+ a1: TonalPalette.fromHueAndChroma(hue, Math.max(48, hct.chroma)),
109
+ a2: TonalPalette.fromHueAndChroma(hue, 16),
110
+ a3: TonalPalette.fromHueAndChroma(hue + 60, 24),
111
+ n1: TonalPalette.fromHueAndChroma(hue, 6),
112
+ n2: TonalPalette.fromHueAndChroma(hue, 8),
113
+ error: TonalPalette.fromHueAndChroma(25, 84),
114
+ };
115
+ }, [primaryColor.hex]);
105
116
 
106
117
  const [secondaryColor, secondaryColorTonal, setSecondaryColor] =
107
118
  useDeferredColor('secondary', a2);
@@ -43,33 +43,57 @@ export const ThemeColors = memo(
43
43
  <ColorRow
44
44
  colors={[
45
45
  {
46
- token: `background`,
47
- bg: scheme.background,
48
- color: scheme.on.background,
46
+ token: `surface-dim`,
47
+ bg: scheme['surface-dim'],
48
+ color: scheme.on['surface'],
49
49
  },
50
50
  {
51
- token: `on.background`,
52
- bg: scheme.on.background,
53
- color: scheme.background,
51
+ token: `surface`,
52
+ bg: scheme['surface'],
53
+ color: scheme.on['surface'],
54
54
  },
55
55
  {
56
- token: `surface`,
57
- bg: scheme.surface,
58
- color: scheme.on.surface,
56
+ token: `surface-bright`,
57
+ bg: scheme['surface-bright'],
58
+ color: scheme.on['surface'],
59
59
  },
60
+ ]}
61
+ />
62
+ <ColorRow
63
+ colors={[
60
64
  {
61
- token: `on.surface`,
62
- bg: scheme.on.surface,
63
- color: scheme.surface,
65
+ token: `surface-container-lowest`,
66
+ bg: scheme['surface-container-lowest'],
67
+ color: scheme.on['surface'],
68
+ },
69
+ {
70
+ token: `surface-container-low`,
71
+ bg: scheme['surface-container-low'],
72
+ color: scheme.on['surface'],
73
+ },
74
+ {
75
+ token: `surface-container`,
76
+ bg: scheme['surface-container'],
77
+ color: scheme.on['surface'],
78
+ },
79
+ {
80
+ token: `surface-container-high`,
81
+ bg: scheme['surface-container-high'],
82
+ color: scheme.on['surface'],
83
+ },
84
+ {
85
+ token: `surface-container-highest`,
86
+ bg: scheme['surface-container-highest'],
87
+ color: scheme.on['surface'],
64
88
  },
65
89
  ]}
66
90
  />
67
91
  <ColorRow
68
92
  colors={[
69
93
  {
70
- token: `surface-variant`,
71
- bg: scheme['surface-variant'],
72
- color: scheme.on['surface-variant'],
94
+ token: `on.surface`,
95
+ bg: scheme.on['surface'],
96
+ color: scheme['surface'],
73
97
  },
74
98
  {
75
99
  token: `on.surface-variant`,
@@ -10,9 +10,9 @@ export const ColorItem = memo(
10
10
  token: string;
11
11
  style: CSSProperties;
12
12
  height?: number;
13
- width: string;
13
+ flex: number;
14
14
  }) => {
15
- const { token, style, width, height = '100%' } = props;
15
+ const { token, style, flex, height = '100%' } = props;
16
16
  const [computedColor, setComputedColor] = useState<string>();
17
17
  const hslColor = computedColor
18
18
  ? parseToHsl(computedColor)
@@ -43,7 +43,7 @@ export const ColorItem = memo(
43
43
  >
44
44
  <Text
45
45
  as="div"
46
- variant="body-small"
46
+ variant="body-medium"
47
47
  style={style}
48
48
  ref={(ref: HTMLDivElement | null) => {
49
49
  if (ref) {
@@ -51,12 +51,10 @@ export const ColorItem = memo(
51
51
  }
52
52
  }}
53
53
  sx={{
54
- width,
54
+ flex,
55
55
  height,
56
- px: '10px',
57
- py: '10px',
58
- fontSize: '11px',
59
- lineHeight: '11px',
56
+ px: '12px',
57
+ py: '12px',
60
58
  textOverflow: 'ellipsis',
61
59
  overflow: 'hidden',
62
60
  }}
@@ -80,27 +78,21 @@ export const ColorRow = memo(
80
78
  display="flex"
81
79
  sx={{
82
80
  ':first-of-type': {
83
- borderTopLeftRadius: 'extra-large',
84
- borderTopRightRadius: 'extra-large',
81
+ borderTopLeftRadius: 'large',
82
+ borderTopRightRadius: 'large',
85
83
  overflow: 'hidden',
86
84
  },
87
85
  ':last-of-type': {
88
- borderBottomLeftRadius: 'extra-large',
89
- borderBottomRightRadius: 'extra-large',
86
+ borderBottomLeftRadius: 'large',
87
+ borderBottomRightRadius: 'large',
90
88
  overflow: 'hidden',
91
89
  },
92
90
  height,
93
91
  }}
94
92
  >
95
- {colors.map(({ token, bg, color }, idx) => (
93
+ {colors.map(({ token, bg, color }) => (
96
94
  <ColorItem
97
- width={
98
- colors.length % 2 === 1
99
- ? idx === colors.length - 1
100
- ? '50%'
101
- : '25%'
102
- : '33.33%'
103
- }
95
+ flex={1}
104
96
  key={token}
105
97
  token={token}
106
98
  style={{ backgroundColor: bg, color: color }}