@cdx-ui/components 0.0.1-beta.4 → 0.0.1-beta.40
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.
- package/README.md +18 -11
- package/lib/commonjs/components/Avatar/index.js +1 -1
- package/lib/commonjs/components/Avatar/styles.js +36 -29
- package/lib/commonjs/components/Avatar/styles.js.map +1 -1
- package/lib/commonjs/components/Button/styles.js +2 -2
- package/lib/commonjs/components/Button/styles.js.map +1 -1
- package/lib/commonjs/components/CLAUDE.md +90 -0
- package/lib/commonjs/components/Card/index.js +22 -4
- package/lib/commonjs/components/Card/index.js.map +1 -1
- package/lib/commonjs/components/Card/styles.js +27 -5
- package/lib/commonjs/components/Card/styles.js.map +1 -1
- package/lib/commonjs/components/Checkbox/index.js +5 -29
- package/lib/commonjs/components/Checkbox/index.js.map +1 -1
- package/lib/commonjs/components/Checkbox/styles.js +39 -47
- package/lib/commonjs/components/Checkbox/styles.js.map +1 -1
- package/lib/commonjs/components/Chip/index.js +78 -9
- package/lib/commonjs/components/Chip/index.js.map +1 -1
- package/lib/commonjs/components/Chip/styles.js +207 -21
- package/lib/commonjs/components/Chip/styles.js.map +1 -1
- package/lib/commonjs/components/Field/index.js +8 -2
- package/lib/commonjs/components/Field/index.js.map +1 -1
- package/lib/commonjs/components/Field/styles.js +4 -4
- package/lib/commonjs/components/Field/styles.js.map +1 -1
- package/lib/commonjs/components/Heading/styles.js +1 -1
- package/lib/commonjs/components/Heading/styles.js.map +1 -1
- package/lib/commonjs/components/Icon/index.js +1 -2
- package/lib/commonjs/components/Icon/index.js.map +1 -1
- package/lib/commonjs/components/IconButton/index.js +6 -1
- package/lib/commonjs/components/IconButton/index.js.map +1 -1
- package/lib/commonjs/components/IconButton/styles.js +135 -10
- package/lib/commonjs/components/IconButton/styles.js.map +1 -1
- package/lib/commonjs/components/Input/styles.js +7 -6
- package/lib/commonjs/components/Input/styles.js.map +1 -1
- package/lib/commonjs/components/ListItem/index.js +283 -0
- package/lib/commonjs/components/ListItem/index.js.map +1 -0
- package/lib/commonjs/components/ListItem/styles.js +130 -0
- package/lib/commonjs/components/ListItem/styles.js.map +1 -0
- package/lib/commonjs/components/ProgressSegmented/index.js +22 -10
- package/lib/commonjs/components/ProgressSegmented/index.js.map +1 -1
- package/lib/commonjs/components/Radio/index.js +167 -0
- package/lib/commonjs/components/Radio/index.js.map +1 -0
- package/lib/commonjs/components/Radio/styles.js +31 -0
- package/lib/commonjs/components/Radio/styles.js.map +1 -0
- package/lib/commonjs/components/Text/styles.js +2 -2
- package/lib/commonjs/components/Text/styles.js.map +1 -1
- package/lib/commonjs/components/Tile/index.js +251 -0
- package/lib/commonjs/components/Tile/index.js.map +1 -0
- package/lib/commonjs/components/Tile/styles.js +52 -0
- package/lib/commonjs/components/Tile/styles.js.map +1 -0
- package/lib/commonjs/components/index.js +36 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/figma/Avatar.figma.js +54 -0
- package/lib/commonjs/figma/Avatar.figma.js.map +1 -0
- package/lib/commonjs/figma/Button.figma.js +28 -11
- package/lib/commonjs/figma/Button.figma.js.map +1 -1
- package/lib/commonjs/figma/CLAUDE.md +30 -0
- package/lib/commonjs/figma/Card.Header.figma.js +28 -0
- package/lib/commonjs/figma/Card.Header.figma.js.map +1 -0
- package/lib/commonjs/figma/Card.figma.js +42 -0
- package/lib/commonjs/figma/Card.figma.js.map +1 -0
- package/lib/commonjs/figma/Checkbox.figma.js +55 -0
- package/lib/commonjs/figma/Checkbox.figma.js.map +1 -0
- package/lib/commonjs/figma/Chip.figma.js +68 -0
- package/lib/commonjs/figma/Chip.figma.js.map +1 -0
- package/lib/commonjs/figma/Field.Input.figma.js +57 -0
- package/lib/commonjs/figma/Field.Input.figma.js.map +1 -0
- package/lib/commonjs/figma/Field.Select.figma.js +57 -0
- package/lib/commonjs/figma/Field.Select.figma.js.map +1 -0
- package/lib/commonjs/figma/Heading.figma.js +30 -0
- package/lib/commonjs/figma/Heading.figma.js.map +1 -0
- package/lib/commonjs/figma/Icon.figma.js +20 -0
- package/lib/commonjs/figma/Icon.figma.js.map +1 -0
- package/lib/commonjs/figma/IconButton.figma.js +47 -0
- package/lib/commonjs/figma/IconButton.figma.js.map +1 -0
- package/lib/commonjs/figma/Input.figma.js +52 -0
- package/lib/commonjs/figma/Input.figma.js.map +1 -0
- package/lib/commonjs/figma/ProgressSegmented.figma.js +39 -0
- package/lib/commonjs/figma/ProgressSegmented.figma.js.map +1 -0
- package/lib/commonjs/figma/Radio.figma.js +38 -0
- package/lib/commonjs/figma/Radio.figma.js.map +1 -0
- package/lib/commonjs/figma/Select.figma.js +53 -0
- package/lib/commonjs/figma/Select.figma.js.map +1 -0
- package/lib/commonjs/figma/Text.figma.js +29 -0
- package/lib/commonjs/figma/Text.figma.js.map +1 -0
- package/lib/commonjs/figma/icons.figma.batch.js +27 -0
- package/lib/commonjs/figma/icons.figma.batch.js.map +1 -0
- package/lib/commonjs/figma/icons.figma.batch.json +17705 -0
- package/lib/commonjs/styles/primitives.js +42 -5
- package/lib/commonjs/styles/primitives.js.map +1 -1
- package/lib/module/components/Avatar/index.js +1 -1
- package/lib/module/components/Avatar/styles.js +36 -29
- package/lib/module/components/Avatar/styles.js.map +1 -1
- package/lib/module/components/Button/styles.js +2 -2
- package/lib/module/components/Button/styles.js.map +1 -1
- package/lib/module/components/CLAUDE.md +90 -0
- package/lib/module/components/Card/index.js +23 -4
- package/lib/module/components/Card/index.js.map +1 -1
- package/lib/module/components/Card/styles.js +27 -5
- package/lib/module/components/Card/styles.js.map +1 -1
- package/lib/module/components/Checkbox/index.js +6 -30
- package/lib/module/components/Checkbox/index.js.map +1 -1
- package/lib/module/components/Checkbox/styles.js +40 -48
- package/lib/module/components/Checkbox/styles.js.map +1 -1
- package/lib/module/components/Chip/index.js +82 -13
- package/lib/module/components/Chip/index.js.map +1 -1
- package/lib/module/components/Chip/styles.js +206 -20
- package/lib/module/components/Chip/styles.js.map +1 -1
- package/lib/module/components/Field/index.js +9 -3
- package/lib/module/components/Field/index.js.map +1 -1
- package/lib/module/components/Field/styles.js +4 -4
- package/lib/module/components/Field/styles.js.map +1 -1
- package/lib/module/components/Heading/styles.js +1 -1
- package/lib/module/components/Heading/styles.js.map +1 -1
- package/lib/module/components/Icon/index.js +1 -2
- package/lib/module/components/Icon/index.js.map +1 -1
- package/lib/module/components/IconButton/index.js +6 -1
- package/lib/module/components/IconButton/index.js.map +1 -1
- package/lib/module/components/IconButton/styles.js +135 -10
- package/lib/module/components/IconButton/styles.js.map +1 -1
- package/lib/module/components/Input/styles.js +7 -6
- package/lib/module/components/Input/styles.js.map +1 -1
- package/lib/module/components/ListItem/index.js +226 -0
- package/lib/module/components/ListItem/index.js.map +1 -0
- package/lib/module/components/ListItem/styles.js +127 -0
- package/lib/module/components/ListItem/styles.js.map +1 -0
- package/lib/module/components/ProgressSegmented/index.js +23 -11
- package/lib/module/components/ProgressSegmented/index.js.map +1 -1
- package/lib/module/components/Radio/index.js +164 -0
- package/lib/module/components/Radio/index.js.map +1 -0
- package/lib/module/components/Radio/styles.js +27 -0
- package/lib/module/components/Radio/styles.js.map +1 -0
- package/lib/module/components/Text/styles.js +2 -2
- package/lib/module/components/Text/styles.js.map +1 -1
- package/lib/module/components/Tile/index.js +243 -0
- package/lib/module/components/Tile/index.js.map +1 -0
- package/lib/module/components/Tile/styles.js +48 -0
- package/lib/module/components/Tile/styles.js.map +1 -0
- package/lib/module/components/index.js +3 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/figma/Avatar.figma.js +48 -0
- package/lib/module/figma/Avatar.figma.js.map +1 -0
- package/lib/module/figma/Button.figma.js +28 -11
- package/lib/module/figma/Button.figma.js.map +1 -1
- package/lib/module/figma/CLAUDE.md +30 -0
- package/lib/module/figma/Card.Header.figma.js +22 -0
- package/lib/module/figma/Card.Header.figma.js.map +1 -0
- package/lib/module/figma/Card.figma.js +36 -0
- package/lib/module/figma/Card.figma.js.map +1 -0
- package/lib/module/figma/Checkbox.figma.js +49 -0
- package/lib/module/figma/Checkbox.figma.js.map +1 -0
- package/lib/module/figma/Chip.figma.js +62 -0
- package/lib/module/figma/Chip.figma.js.map +1 -0
- package/lib/module/figma/Field.Input.figma.js +51 -0
- package/lib/module/figma/Field.Input.figma.js.map +1 -0
- package/lib/module/figma/Field.Select.figma.js +51 -0
- package/lib/module/figma/Field.Select.figma.js.map +1 -0
- package/lib/module/figma/Heading.figma.js +24 -0
- package/lib/module/figma/Heading.figma.js.map +1 -0
- package/lib/module/figma/Icon.figma.js +14 -0
- package/lib/module/figma/Icon.figma.js.map +1 -0
- package/lib/module/figma/IconButton.figma.js +41 -0
- package/lib/module/figma/IconButton.figma.js.map +1 -0
- package/lib/module/figma/Input.figma.js +46 -0
- package/lib/module/figma/Input.figma.js.map +1 -0
- package/lib/module/figma/ProgressSegmented.figma.js +33 -0
- package/lib/module/figma/ProgressSegmented.figma.js.map +1 -0
- package/lib/module/figma/Radio.figma.js +32 -0
- package/lib/module/figma/Radio.figma.js.map +1 -0
- package/lib/module/figma/Select.figma.js +47 -0
- package/lib/module/figma/Select.figma.js.map +1 -0
- package/lib/module/figma/Text.figma.js +23 -0
- package/lib/module/figma/Text.figma.js.map +1 -0
- package/lib/module/figma/icons.figma.batch.js +22 -0
- package/lib/module/figma/icons.figma.batch.js.map +1 -0
- package/lib/module/figma/icons.figma.batch.json +17705 -0
- package/lib/module/styles/primitives.js +42 -5
- package/lib/module/styles/primitives.js.map +1 -1
- package/lib/typescript/components/Avatar/styles.d.ts +4 -4
- package/lib/typescript/components/Avatar/styles.d.ts.map +1 -1
- package/lib/typescript/components/Card/index.d.ts +4 -3
- package/lib/typescript/components/Card/index.d.ts.map +1 -1
- package/lib/typescript/components/Card/styles.d.ts +13 -3
- package/lib/typescript/components/Card/styles.d.ts.map +1 -1
- package/lib/typescript/components/Checkbox/index.d.ts +1 -2
- package/lib/typescript/components/Checkbox/index.d.ts.map +1 -1
- package/lib/typescript/components/Checkbox/styles.d.ts +4 -14
- package/lib/typescript/components/Checkbox/styles.d.ts.map +1 -1
- package/lib/typescript/components/Chip/index.d.ts +19 -6
- package/lib/typescript/components/Chip/index.d.ts.map +1 -1
- package/lib/typescript/components/Chip/styles.d.ts +13 -4
- package/lib/typescript/components/Chip/styles.d.ts.map +1 -1
- package/lib/typescript/components/Field/FieldLabel.web.d.ts +2 -2
- package/lib/typescript/components/Field/FieldLabel.web.d.ts.map +1 -1
- package/lib/typescript/components/Field/index.d.ts.map +1 -1
- package/lib/typescript/components/Field/styles.d.ts.map +1 -1
- package/lib/typescript/components/Heading/styles.d.ts +1 -1
- package/lib/typescript/components/Icon/index.d.ts.map +1 -1
- package/lib/typescript/components/IconButton/index.d.ts.map +1 -1
- package/lib/typescript/components/IconButton/styles.d.ts +6 -2
- package/lib/typescript/components/IconButton/styles.d.ts.map +1 -1
- package/lib/typescript/components/Input/styles.d.ts.map +1 -1
- package/lib/typescript/components/ListItem/index.d.ts +49 -0
- package/lib/typescript/components/ListItem/index.d.ts.map +1 -0
- package/lib/typescript/components/ListItem/styles.d.ts +30 -0
- package/lib/typescript/components/ListItem/styles.d.ts.map +1 -0
- package/lib/typescript/components/ProgressSegmented/index.d.ts +14 -3
- package/lib/typescript/components/ProgressSegmented/index.d.ts.map +1 -1
- package/lib/typescript/components/Radio/index.d.ts +40 -0
- package/lib/typescript/components/Radio/index.d.ts.map +1 -0
- package/lib/typescript/components/Radio/styles.d.ts +8 -0
- package/lib/typescript/components/Radio/styles.d.ts.map +1 -0
- package/lib/typescript/components/Stack/styles.d.ts +2 -2
- package/lib/typescript/components/Text/styles.d.ts +1 -1
- package/lib/typescript/components/Tile/index.d.ts +70 -0
- package/lib/typescript/components/Tile/index.d.ts.map +1 -0
- package/lib/typescript/components/Tile/styles.d.ts +18 -0
- package/lib/typescript/components/Tile/styles.d.ts.map +1 -0
- package/lib/typescript/components/index.d.ts +3 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/figma/Avatar.figma.d.ts +8 -0
- package/lib/typescript/figma/Avatar.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Button.figma.d.ts.map +1 -1
- package/lib/typescript/figma/Card.Header.figma.d.ts +8 -0
- package/lib/typescript/figma/Card.Header.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Card.figma.d.ts +8 -0
- package/lib/typescript/figma/Card.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Checkbox.figma.d.ts +8 -0
- package/lib/typescript/figma/Checkbox.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Chip.figma.d.ts +8 -0
- package/lib/typescript/figma/Chip.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Field.Input.figma.d.ts +8 -0
- package/lib/typescript/figma/Field.Input.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Field.Select.figma.d.ts +8 -0
- package/lib/typescript/figma/Field.Select.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Heading.figma.d.ts +8 -0
- package/lib/typescript/figma/Heading.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Icon.figma.d.ts +8 -0
- package/lib/typescript/figma/Icon.figma.d.ts.map +1 -0
- package/lib/typescript/figma/IconButton.figma.d.ts +8 -0
- package/lib/typescript/figma/IconButton.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Input.figma.d.ts +8 -0
- package/lib/typescript/figma/Input.figma.d.ts.map +1 -0
- package/lib/typescript/figma/ProgressSegmented.figma.d.ts +8 -0
- package/lib/typescript/figma/ProgressSegmented.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Radio.figma.d.ts +8 -0
- package/lib/typescript/figma/Radio.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Select.figma.d.ts +8 -0
- package/lib/typescript/figma/Select.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Text.figma.d.ts +8 -0
- package/lib/typescript/figma/Text.figma.d.ts.map +1 -0
- package/lib/typescript/figma/icons.figma.batch.d.ts +14 -0
- package/lib/typescript/figma/icons.figma.batch.d.ts.map +1 -0
- package/lib/typescript/styles/primitives.d.ts +38 -0
- package/lib/typescript/styles/primitives.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/components/Avatar/index.tsx +1 -1
- package/src/components/Avatar/styles.ts +49 -34
- package/src/components/Button/styles.ts +2 -2
- package/src/components/CLAUDE.md +90 -0
- package/src/components/Card/index.tsx +41 -16
- package/src/components/Card/styles.ts +43 -23
- package/src/components/Checkbox/index.tsx +8 -19
- package/src/components/Checkbox/styles.ts +82 -86
- package/src/components/Chip/index.tsx +104 -27
- package/src/components/Chip/styles.ts +232 -18
- package/src/components/Field/FieldLabel.web.tsx +1 -1
- package/src/components/Field/index.tsx +10 -3
- package/src/components/Field/styles.ts +5 -4
- package/src/components/Heading/styles.ts +1 -1
- package/src/components/Icon/index.tsx +1 -2
- package/src/components/IconButton/index.tsx +3 -2
- package/src/components/IconButton/styles.ts +136 -10
- package/src/components/Input/styles.ts +14 -9
- package/src/components/ListItem/index.tsx +285 -0
- package/src/components/ListItem/styles.ts +153 -0
- package/src/components/ProgressSegmented/index.tsx +49 -14
- package/src/components/Radio/index.tsx +192 -0
- package/src/components/Radio/styles.ts +59 -0
- package/src/components/Text/styles.ts +2 -2
- package/src/components/Tile/index.tsx +296 -0
- package/src/components/Tile/styles.ts +82 -0
- package/src/components/index.ts +3 -0
- package/src/styles/primitives.ts +42 -5
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
import { cva, type VariantProps } from 'class-variance-authority';
|
|
2
|
-
import { COLOR_BG_MUTED, COLOR_TEXT_SECONDARY, RADIUS_FULL } from '../../styles/primitives';
|
|
3
2
|
|
|
4
3
|
// ── Root ─────────────────────────────────────────────────
|
|
5
4
|
|
|
6
5
|
export const avatarRootVariants = cva(
|
|
7
|
-
[
|
|
6
|
+
[
|
|
7
|
+
'rounded-[var(--border-radius-round)]',
|
|
8
|
+
'relative items-center justify-center',
|
|
9
|
+
'bg-surface-tertiary',
|
|
10
|
+
],
|
|
8
11
|
{
|
|
9
12
|
variants: {
|
|
10
13
|
size: {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
'2xs': 'w-3 h-3',
|
|
15
|
+
xs: 'w-[18px] h-[18px]',
|
|
16
|
+
sm: 'w-6 h-6',
|
|
17
|
+
md: 'w-8 h-8',
|
|
18
|
+
lg: 'w-10 h-10',
|
|
19
|
+
xl: 'w-12 h-12',
|
|
20
|
+
'2xl': 'w-14 h-14',
|
|
16
21
|
},
|
|
17
22
|
},
|
|
18
23
|
defaultVariants: {
|
|
19
|
-
size: '
|
|
24
|
+
size: 'md',
|
|
20
25
|
},
|
|
21
26
|
},
|
|
22
27
|
);
|
|
@@ -25,59 +30,69 @@ export const avatarRootVariants = cva(
|
|
|
25
30
|
|
|
26
31
|
export const avatarImageVariants = cva([
|
|
27
32
|
'absolute top-0 left-0 w-full h-full',
|
|
28
|
-
|
|
33
|
+
'rounded-[var(--border-radius-round)]',
|
|
29
34
|
'overflow-hidden',
|
|
35
|
+
'border border-stroke-secondary',
|
|
30
36
|
]);
|
|
31
37
|
|
|
32
38
|
// ── Text ─────────────────────────────────────────────────
|
|
33
39
|
|
|
34
|
-
export const avatarTextVariants = cva([
|
|
40
|
+
export const avatarTextVariants = cva(['text-content-primary', 'font-medium'], {
|
|
35
41
|
variants: {
|
|
36
42
|
size: {
|
|
43
|
+
'2xs': 'text-[6px]',
|
|
44
|
+
xs: 'text-[9px]',
|
|
37
45
|
sm: 'text-xs',
|
|
38
|
-
md: 'text-
|
|
39
|
-
lg: 'text-
|
|
40
|
-
xl: 'text-
|
|
41
|
-
'2xl': 'text-
|
|
46
|
+
md: 'text-base',
|
|
47
|
+
lg: 'text-xl',
|
|
48
|
+
xl: 'text-2xl',
|
|
49
|
+
'2xl': 'text-[28px]',
|
|
42
50
|
},
|
|
43
51
|
},
|
|
44
52
|
defaultVariants: {
|
|
45
|
-
size: '
|
|
53
|
+
size: 'md',
|
|
46
54
|
},
|
|
47
55
|
});
|
|
48
56
|
|
|
49
57
|
// ── Icon ─────────────────────────────────────────────────
|
|
50
58
|
|
|
51
|
-
export const avatarIconVariants = cva([
|
|
59
|
+
export const avatarIconVariants = cva(['text-content-primary'], {
|
|
52
60
|
variants: {
|
|
53
61
|
size: {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
'2xs': 'size-1.5',
|
|
63
|
+
xs: 'size-[9px]',
|
|
64
|
+
sm: 'size-3',
|
|
65
|
+
md: 'size-4',
|
|
66
|
+
lg: 'size-5',
|
|
67
|
+
xl: 'size-6',
|
|
68
|
+
'2xl': 'size-7',
|
|
59
69
|
},
|
|
60
70
|
},
|
|
61
71
|
defaultVariants: {
|
|
62
|
-
size: '
|
|
72
|
+
size: 'md',
|
|
63
73
|
},
|
|
64
74
|
});
|
|
65
75
|
|
|
66
76
|
// ── Badge ────────────────────────────────────────────────
|
|
67
77
|
|
|
68
|
-
export const avatarBadgeVariants = cva(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
78
|
+
export const avatarBadgeVariants = cva(
|
|
79
|
+
['absolute border-white', 'rounded-[var(--border-radius-round)]', 'bottom-0 right-0'],
|
|
80
|
+
{
|
|
81
|
+
variants: {
|
|
82
|
+
size: {
|
|
83
|
+
'2xs': 'w-1.5 h-1.5 border translate-x-[21%] translate-y-[21%]',
|
|
84
|
+
xs: 'w-2 h-2 border translate-x-[17%] translate-y-[17%]',
|
|
85
|
+
sm: 'w-2.5 h-2.5 border-2 translate-x-[15%] translate-y-[15%]',
|
|
86
|
+
md: 'w-3 h-3 border-2 translate-x-[11%] translate-y-[11%]',
|
|
87
|
+
lg: 'w-3.5 h-3.5 border-2 translate-x-[8%] translate-y-[8%]',
|
|
88
|
+
xl: 'w-4 h-4 border-2 translate-x-[6%] translate-y-[6%]',
|
|
89
|
+
'2xl': 'w-5 h-5 border-2 translate-x-[9%] translate-y-[9%]',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
defaultVariants: {
|
|
93
|
+
size: 'md',
|
|
76
94
|
},
|
|
77
95
|
},
|
|
78
|
-
|
|
79
|
-
size: 'lg',
|
|
80
|
-
},
|
|
81
|
-
});
|
|
96
|
+
);
|
|
82
97
|
|
|
83
98
|
export type AvatarVariantProps = VariantProps<typeof avatarRootVariants>;
|
|
@@ -10,7 +10,7 @@ export const buttonRootVariants = cva(
|
|
|
10
10
|
'rounded-[var(--border-radius-button)]',
|
|
11
11
|
'web:outline-none web:focus:outline-none web:focus-visible:outline-none',
|
|
12
12
|
TRANSITION_COLORS,
|
|
13
|
-
'data-[disabled=true]:opacity-[--opacity-disabled]',
|
|
13
|
+
'data-[disabled=true]:opacity-[var(--opacity-disabled)]',
|
|
14
14
|
DISABLED_CURSOR,
|
|
15
15
|
'web:data-[focus-visible=true]:ring-2 web:data-[focus-visible=true]:ring-[--color-stroke-focus] web:data-[focus-visible=true]:ring-offset-2',
|
|
16
16
|
],
|
|
@@ -29,7 +29,7 @@ export const buttonRootVariants = cva(
|
|
|
29
29
|
info: [],
|
|
30
30
|
},
|
|
31
31
|
size: {
|
|
32
|
-
default: 'h-
|
|
32
|
+
default: 'h-11 px-4 gap-2',
|
|
33
33
|
small: 'h-8 px-3 gap-1.5',
|
|
34
34
|
},
|
|
35
35
|
fullWidth: {
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Components — authoring & styling conventions
|
|
2
|
+
|
|
3
|
+
Auto-loaded when working in `packages/components/src/components/**`. Covers both the
|
|
4
|
+
styled component files (`index.tsx`) and their co-located CVA variant files (`styles.ts`).
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Component Authoring (`index.tsx`)
|
|
9
|
+
|
|
10
|
+
Styled components in `@cdx-ui/components` follow a consistent pattern. Read the full guides before making changes:
|
|
11
|
+
|
|
12
|
+
- `docs/internal/practices/composition.md` — compound component pattern, naming conventions
|
|
13
|
+
- `docs/internal/practices/types.md` — prop types, `I*Props` vs `*Props`, exporting
|
|
14
|
+
- `docs/internal/practices/styling.md` — `cn()`, CVA, token classes, `Platform.select()`
|
|
15
|
+
- `docs/internal/practices/state.md` — `useControllableState`, `composeEventHandlers`
|
|
16
|
+
- `docs/internal/practices/data-attributes.md` — `data-[state]` and `data-slot`
|
|
17
|
+
|
|
18
|
+
### Pattern summary
|
|
19
|
+
|
|
20
|
+
Each component follows this structure (see `Button/index.tsx` as the canonical example):
|
|
21
|
+
|
|
22
|
+
1. **Imports** — RN base components, primitive from `@cdx-ui/primitives`, `cn` + style context from `@cdx-ui/utils`, variant functions from `./styles`
|
|
23
|
+
2. **Scope constant** — `const SCOPE = 'COMPONENT_NAME'` for `withStyleContext` / `useStyleContext`
|
|
24
|
+
3. **Root wrapping** — `const Root = withStyleContext(BaseRNComponent, SCOPE)`
|
|
25
|
+
4. **Primitive instantiation** — `const Primitive = createComponent({ Root, Text, ... })` using the primitive factory
|
|
26
|
+
5. **Styled sub-components** — each wraps a single element, uses `forwardRef`, destructures variant props with defaults, computes `cn(variantFn({ ...variants }), className)`, passes `context` to the primitive root
|
|
27
|
+
6. **Compound export** — `Object.assign(RootComponent, { Sub1, Sub2 }) as CompoundType`
|
|
28
|
+
|
|
29
|
+
### Key rules
|
|
30
|
+
|
|
31
|
+
- Props interface extends RN base props + primitive `I*Props` + CVA `VariantProps` + `{ className?: string }`
|
|
32
|
+
- Always accept and spread `style` alongside `className`
|
|
33
|
+
- Variant defaults in destructuring must match CVA `defaultVariants`
|
|
34
|
+
- `displayName` set on every exported sub-component
|
|
35
|
+
- `className` is merged last via `cn()` so consumer overrides always win
|
|
36
|
+
- Never hardcode colors — use semantic token classes (`bg-surface-*`, `text-content-*`, `border-stroke-*`)
|
|
37
|
+
- Event handlers composed via `composeEventHandlers` from `@cdx-ui/utils`
|
|
38
|
+
- Third-party libraries fully abstracted — no adopted library types leak to consumers
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Styling Conventions (`styles.ts`)
|
|
43
|
+
|
|
44
|
+
Variant definitions live in co-located `styles.ts` files using CVA. Read the full guides before making changes:
|
|
45
|
+
|
|
46
|
+
- `docs/internal/practices/styling.md` — `cn()`, CVA, token architecture, dark mode, `Platform.select()`
|
|
47
|
+
- `docs/internal/practices/data-attributes.md` — `data-[state]` selectors for interaction states
|
|
48
|
+
|
|
49
|
+
### Pattern summary
|
|
50
|
+
|
|
51
|
+
Each `styles.ts` exports CVA variant functions and their derived `VariantProps` types (see `Button/styles.ts` as the canonical example):
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import { Platform } from 'react-native';
|
|
55
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
56
|
+
import { DISABLED_CURSOR, TRANSITION_COLORS } from '../../styles/primitives';
|
|
57
|
+
|
|
58
|
+
export const componentRootVariants = cva(
|
|
59
|
+
[
|
|
60
|
+
/* base classes */
|
|
61
|
+
],
|
|
62
|
+
{
|
|
63
|
+
variants: {
|
|
64
|
+
/* variant axes */
|
|
65
|
+
},
|
|
66
|
+
compoundVariants: [
|
|
67
|
+
/* variant × variant combinations */
|
|
68
|
+
],
|
|
69
|
+
defaultVariants: {
|
|
70
|
+
/* defaults matching the component's destructured defaults */
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
export type ComponentVariantProps = VariantProps<typeof componentRootVariants>;
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Key rules
|
|
79
|
+
|
|
80
|
+
- **Semantic token classes only** — use `bg-surface-action-strong`, `text-content-primary`, `border-stroke-primary`, etc. Never hardcode hex colors, `bg-white`, `text-black`, or raw Tailwind color scales for themed values.
|
|
81
|
+
- **`data-[state]` selectors** — use `data-[disabled=true]:`, `data-[hover=true]:`, `data-[active=true]:`, `data-[focus-visible=true]:` for interaction states. Primitives emit these data attributes.
|
|
82
|
+
- **`Platform.select()`** for platform-specific classes — web gets `data-[hover=true]` styles (hover exists on web); native responds only to `data-[active=true]` (press). Always set `default` (native) and `web` keys.
|
|
83
|
+
- **Shared style primitives** — import `DISABLED_CURSOR`, `TRANSITION_COLORS`, etc. from `../../styles/primitives` for cross-component consistency.
|
|
84
|
+
- **`web:` prefix** for web-only utilities — e.g., `web:outline-none`, `web:focus-visible:ring-2`.
|
|
85
|
+
- **`compoundVariants`** for variant × variant combinations where simple variant merging is insufficient.
|
|
86
|
+
- **`defaultVariants`** must match the destructured defaults in the component's `index.tsx`.
|
|
87
|
+
- **One `cva()` per sub-component** — root, text, icon, spinner, etc. each get their own variant function.
|
|
88
|
+
- **Export `VariantProps` types** — derived via `VariantProps<typeof variantFn>` for the component layer to consume.
|
|
89
|
+
- **No dynamic string construction** — all Tailwind class names must be statically detectable by the Tailwind scanner.
|
|
90
|
+
- **CSS variables for token values** — use `rounded-[var(--border-radius-button)]` syntax when referencing design tokens not mapped to Tailwind utilities.
|
|
@@ -1,31 +1,48 @@
|
|
|
1
1
|
import { forwardRef, type ReactNode } from 'react';
|
|
2
2
|
import { View, type ViewProps } from 'react-native';
|
|
3
|
-
import { cn } from '@cdx-ui/utils';
|
|
3
|
+
import { cn, useStyleContext, withStyleContext } from '@cdx-ui/utils';
|
|
4
4
|
import {
|
|
5
5
|
cardContentVariants,
|
|
6
6
|
cardFooterVariants,
|
|
7
7
|
cardHeaderVariants,
|
|
8
8
|
cardRootVariants,
|
|
9
|
+
type CardContentVariantProps,
|
|
10
|
+
type CardFooterVariantProps,
|
|
11
|
+
type CardVariantProps,
|
|
9
12
|
} from './styles';
|
|
10
13
|
|
|
11
14
|
// =============================================================================
|
|
12
15
|
// STYLED ROOT COMPONENT
|
|
13
16
|
// =============================================================================
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
const SCOPE = 'CARD';
|
|
19
|
+
|
|
20
|
+
const Root = withStyleContext(View, SCOPE);
|
|
21
|
+
|
|
22
|
+
const useCardStyleContext = () => useStyleContext(SCOPE) as CardVariantProps;
|
|
23
|
+
|
|
24
|
+
export interface CardProps extends ViewProps, CardVariantProps {
|
|
16
25
|
className?: string;
|
|
17
26
|
children?: ReactNode;
|
|
18
27
|
}
|
|
19
28
|
|
|
20
|
-
const CardRoot = forwardRef<View, CardProps>(
|
|
21
|
-
|
|
29
|
+
const CardRoot = forwardRef<View, CardProps>(
|
|
30
|
+
({ className, children, style, fullBleed, ...props }, ref) => {
|
|
31
|
+
const computedClassName = cn(cardRootVariants(), className);
|
|
22
32
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
33
|
+
return (
|
|
34
|
+
<Root
|
|
35
|
+
ref={ref}
|
|
36
|
+
className={computedClassName}
|
|
37
|
+
style={style}
|
|
38
|
+
context={{ fullBleed }}
|
|
39
|
+
{...props}
|
|
40
|
+
>
|
|
41
|
+
{children}
|
|
42
|
+
</Root>
|
|
43
|
+
);
|
|
44
|
+
},
|
|
45
|
+
);
|
|
29
46
|
|
|
30
47
|
CardRoot.displayName = 'Card';
|
|
31
48
|
|
|
@@ -56,14 +73,18 @@ CardHeader.displayName = 'Card.Header';
|
|
|
56
73
|
// STYLED CONTENT COMPONENT
|
|
57
74
|
// =============================================================================
|
|
58
75
|
|
|
59
|
-
export interface CardContentProps extends ViewProps {
|
|
76
|
+
export interface CardContentProps extends ViewProps, CardContentVariantProps {
|
|
60
77
|
className?: string;
|
|
61
78
|
children?: ReactNode;
|
|
62
79
|
}
|
|
63
80
|
|
|
64
81
|
const CardContent = forwardRef<View, CardContentProps>(
|
|
65
|
-
({ className, children, style, ...props }, ref) => {
|
|
66
|
-
const
|
|
82
|
+
({ className, children, style, fullBleed, ...props }, ref) => {
|
|
83
|
+
const { fullBleed: fullBleedFromContext } = useCardStyleContext();
|
|
84
|
+
const computedClassName = cn(
|
|
85
|
+
cardContentVariants({ fullBleed: fullBleed ?? fullBleedFromContext }),
|
|
86
|
+
className,
|
|
87
|
+
);
|
|
67
88
|
|
|
68
89
|
return (
|
|
69
90
|
<View ref={ref} className={computedClassName} style={style} {...props}>
|
|
@@ -79,14 +100,18 @@ CardContent.displayName = 'Card.Content';
|
|
|
79
100
|
// STYLED FOOTER COMPONENT
|
|
80
101
|
// =============================================================================
|
|
81
102
|
|
|
82
|
-
export interface CardFooterProps extends ViewProps {
|
|
103
|
+
export interface CardFooterProps extends ViewProps, CardFooterVariantProps {
|
|
83
104
|
className?: string;
|
|
84
105
|
children?: ReactNode;
|
|
85
106
|
}
|
|
86
107
|
|
|
87
108
|
const CardFooter = forwardRef<View, CardFooterProps>(
|
|
88
|
-
({ className, children, style, ...props }, ref) => {
|
|
89
|
-
const
|
|
109
|
+
({ className, children, style, fullBleed, ...props }, ref) => {
|
|
110
|
+
const { fullBleed: fullBleedFromContext } = useCardStyleContext();
|
|
111
|
+
const computedClassName = cn(
|
|
112
|
+
cardFooterVariants({ fullBleed: fullBleed ?? fullBleedFromContext }),
|
|
113
|
+
className,
|
|
114
|
+
);
|
|
90
115
|
|
|
91
116
|
return (
|
|
92
117
|
<View ref={ref} className={computedClassName} style={style} {...props}>
|
|
@@ -1,27 +1,31 @@
|
|
|
1
|
-
import { cva } from 'class-variance-authority';
|
|
2
|
-
import {
|
|
3
|
-
COLOR_BG_PRIMARY,
|
|
4
|
-
COLOR_BORDER_DEFAULT,
|
|
5
|
-
COLOR_TEXT_PRIMARY,
|
|
6
|
-
RADIUS_SM,
|
|
7
|
-
SHADOW_SM,
|
|
8
|
-
} from '../../styles/primitives';
|
|
1
|
+
import { cva, VariantProps } from 'class-variance-authority';
|
|
9
2
|
|
|
10
3
|
// ── Root ────────────────────────────────────────────────────
|
|
11
4
|
|
|
12
|
-
export const cardRootVariants = cva(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
]
|
|
5
|
+
export const cardRootVariants = cva(
|
|
6
|
+
[
|
|
7
|
+
'bg-surface-primary',
|
|
8
|
+
'border border-stroke-secondary',
|
|
9
|
+
'rounded-[var(--border-radius-default)]',
|
|
10
|
+
'overflow-hidden',
|
|
11
|
+
],
|
|
12
|
+
{
|
|
13
|
+
variants: {
|
|
14
|
+
fullBleed: {
|
|
15
|
+
true: '',
|
|
16
|
+
false: '',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
);
|
|
19
21
|
|
|
20
22
|
// ── Header ──────────────────────────────────────────────────
|
|
21
23
|
|
|
22
24
|
export const cardHeaderVariants = cva([
|
|
23
|
-
'
|
|
24
|
-
|
|
25
|
+
'border-t-8 border-t-surface-brand-strong',
|
|
26
|
+
'border-b border-solid border-b-stroke-secondary',
|
|
27
|
+
'flex-row items-center justify-between gap-0.5',
|
|
28
|
+
'px-5 py-3',
|
|
25
29
|
]);
|
|
26
30
|
|
|
27
31
|
// ── Title ───────────────────────────────────────────────────
|
|
@@ -30,12 +34,28 @@ export const cardTitleVariants = cva(['flex-1']);
|
|
|
30
34
|
|
|
31
35
|
// ── Content ─────────────────────────────────────────────────
|
|
32
36
|
|
|
33
|
-
export const cardContentVariants = cva([
|
|
37
|
+
export const cardContentVariants = cva(['text-content-primary', 'p-5'], {
|
|
38
|
+
variants: {
|
|
39
|
+
fullBleed: {
|
|
40
|
+
true: 'p-0',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
});
|
|
34
44
|
|
|
35
45
|
// ── Footer ──────────────────────────────────────────────────
|
|
36
46
|
|
|
37
|
-
export const cardFooterVariants = cva([
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
export const cardFooterVariants = cva(['flex-col items-stretch gap-2'], {
|
|
48
|
+
variants: {
|
|
49
|
+
fullBleed: {
|
|
50
|
+
true: 'p-5',
|
|
51
|
+
false: 'px-5 pb-5 pt-0',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
defaultVariants: {
|
|
55
|
+
fullBleed: false,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export type CardVariantProps = VariantProps<typeof cardRootVariants>;
|
|
60
|
+
export type CardContentVariantProps = VariantProps<typeof cardContentVariants>;
|
|
61
|
+
export type CardFooterVariantProps = VariantProps<typeof cardFooterVariants>;
|
|
@@ -2,10 +2,9 @@ import { forwardRef, type ReactNode } from 'react';
|
|
|
2
2
|
import { Pressable, Text, type TextProps, View, type ViewProps } from 'react-native';
|
|
3
3
|
import { Check, CheckIndeterminateSmall } from '@cdx-ui/icons';
|
|
4
4
|
import { createCheckbox, type ICheckboxProps } from '@cdx-ui/primitives';
|
|
5
|
-
import { cn
|
|
5
|
+
import { cn } from '@cdx-ui/utils';
|
|
6
6
|
import { Icon, IconProps } from '../Icon';
|
|
7
7
|
import {
|
|
8
|
-
type CheckboxVariantProps,
|
|
9
8
|
checkboxGroupVariants,
|
|
10
9
|
checkboxIconVariants,
|
|
11
10
|
checkboxIndicatorVariants,
|
|
@@ -13,14 +12,8 @@ import {
|
|
|
13
12
|
checkboxRootVariants,
|
|
14
13
|
} from './styles';
|
|
15
14
|
|
|
16
|
-
const SCOPE = 'CHECKBOX';
|
|
17
|
-
|
|
18
|
-
const Root = withStyleContext(Pressable, SCOPE);
|
|
19
|
-
|
|
20
|
-
const useCheckboxStyleContext = () => useStyleContext(SCOPE) as CheckboxVariantProps;
|
|
21
|
-
|
|
22
15
|
const CheckboxPrimitive = createCheckbox({
|
|
23
|
-
Root,
|
|
16
|
+
Root: Pressable,
|
|
24
17
|
Indicator: View,
|
|
25
18
|
Icon: View,
|
|
26
19
|
Label: Text,
|
|
@@ -31,14 +24,14 @@ const CheckboxPrimitive = createCheckbox({
|
|
|
31
24
|
// CHECKBOX ROOT
|
|
32
25
|
// =============================================================================
|
|
33
26
|
|
|
34
|
-
export interface CheckboxProps extends ICheckboxProps
|
|
27
|
+
export interface CheckboxProps extends ICheckboxProps {
|
|
35
28
|
className?: string;
|
|
36
29
|
children?: ReactNode;
|
|
37
30
|
}
|
|
38
31
|
|
|
39
32
|
const CheckboxRoot = forwardRef<View, CheckboxProps>(
|
|
40
|
-
({
|
|
41
|
-
const computedClassName = cn(checkboxRootVariants(
|
|
33
|
+
({ className, isIndeterminate, children, style, ...props }, ref) => {
|
|
34
|
+
const computedClassName = cn(checkboxRootVariants(), className);
|
|
42
35
|
|
|
43
36
|
return (
|
|
44
37
|
<CheckboxPrimitive
|
|
@@ -46,7 +39,6 @@ const CheckboxRoot = forwardRef<View, CheckboxProps>(
|
|
|
46
39
|
className={computedClassName}
|
|
47
40
|
isIndeterminate={isIndeterminate}
|
|
48
41
|
style={style}
|
|
49
|
-
context={{ size }}
|
|
50
42
|
{...props}
|
|
51
43
|
>
|
|
52
44
|
<CheckboxIndicator>
|
|
@@ -73,8 +65,7 @@ export interface CheckboxIndicatorProps extends ViewProps {
|
|
|
73
65
|
|
|
74
66
|
const CheckboxIndicator = forwardRef<View, CheckboxIndicatorProps>(
|
|
75
67
|
({ className, children, style, ...props }, ref) => {
|
|
76
|
-
const
|
|
77
|
-
const computedClassName = cn(checkboxIndicatorVariants({ size }), className);
|
|
68
|
+
const computedClassName = cn(checkboxIndicatorVariants(), className);
|
|
78
69
|
|
|
79
70
|
return (
|
|
80
71
|
<CheckboxPrimitive.Indicator
|
|
@@ -98,8 +89,7 @@ CheckboxIndicator.displayName = 'Checkbox.Indicator';
|
|
|
98
89
|
export interface CheckboxIconProps extends Omit<IconProps, 'children'> {}
|
|
99
90
|
|
|
100
91
|
const CheckboxIcon = ({ className, style, ...props }: CheckboxIconProps) => {
|
|
101
|
-
const
|
|
102
|
-
const computedClassName = cn(checkboxIconVariants({ size }), className);
|
|
92
|
+
const computedClassName = cn(checkboxIconVariants(), className);
|
|
103
93
|
|
|
104
94
|
return <Icon className={computedClassName} style={style} {...props} />;
|
|
105
95
|
};
|
|
@@ -117,8 +107,7 @@ export interface CheckboxLabelProps extends TextProps {
|
|
|
117
107
|
|
|
118
108
|
const CheckboxLabel = forwardRef<Text, CheckboxLabelProps>(
|
|
119
109
|
({ className, children, style, ...props }, ref) => {
|
|
120
|
-
const
|
|
121
|
-
const computedClassName = cn(checkboxLabelVariants({ size }), className);
|
|
110
|
+
const computedClassName = cn(checkboxLabelVariants(), className);
|
|
122
111
|
|
|
123
112
|
return (
|
|
124
113
|
<CheckboxPrimitive.Label
|