@cdx-ui/components 0.0.1-beta.2 → 0.0.1-beta.20
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/Button/styles.js +1 -1
- package/lib/commonjs/components/Button/styles.js.map +1 -1
- package/lib/commonjs/components/Card/index.js +15 -3
- package/lib/commonjs/components/Card/index.js.map +1 -1
- package/lib/commonjs/components/Card/styles.js +17 -5
- package/lib/commonjs/components/Card/styles.js.map +1 -1
- package/lib/commonjs/components/Checkbox/styles.js +1 -1
- package/lib/commonjs/components/Checkbox/styles.js.map +1 -1
- package/lib/commonjs/components/Heading/styles.js.map +1 -1
- package/lib/commonjs/components/IconButton/styles.js +1 -1
- package/lib/commonjs/components/IconButton/styles.js.map +1 -1
- package/lib/commonjs/components/Input/styles.js +1 -1
- 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/Radio/index.js +165 -0
- package/lib/commonjs/components/Radio/index.js.map +1 -0
- package/lib/commonjs/components/Radio/styles.js +30 -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/Button.figma.js +69 -0
- package/lib/commonjs/figma/Button.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/Radio.figma.js +38 -0
- package/lib/commonjs/figma/Radio.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/styles/primitives.js +36 -3
- package/lib/commonjs/styles/primitives.js.map +1 -1
- package/lib/module/components/Button/styles.js +1 -1
- package/lib/module/components/Button/styles.js.map +1 -1
- package/lib/module/components/Card/index.js +16 -3
- package/lib/module/components/Card/index.js.map +1 -1
- package/lib/module/components/Card/styles.js +17 -5
- package/lib/module/components/Card/styles.js.map +1 -1
- package/lib/module/components/Checkbox/styles.js +2 -2
- package/lib/module/components/Checkbox/styles.js.map +1 -1
- package/lib/module/components/Heading/styles.js.map +1 -1
- package/lib/module/components/IconButton/styles.js +1 -1
- package/lib/module/components/IconButton/styles.js.map +1 -1
- package/lib/module/components/Input/styles.js +1 -1
- 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/Radio/index.js +162 -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/Button.figma.js +63 -0
- package/lib/module/figma/Button.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/Radio.figma.js +32 -0
- package/lib/module/figma/Radio.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/styles/primitives.js +36 -3
- package/lib/module/styles/primitives.js.map +1 -1
- package/lib/typescript/components/Card/index.d.ts +3 -2
- package/lib/typescript/components/Card/index.d.ts.map +1 -1
- package/lib/typescript/components/Card/styles.d.ts +9 -2
- package/lib/typescript/components/Card/styles.d.ts.map +1 -1
- package/lib/typescript/components/Checkbox/styles.d.ts.map +1 -1
- package/lib/typescript/components/Heading/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/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/Text/styles.d.ts.map +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/Button.figma.d.ts +8 -0
- package/lib/typescript/figma/Button.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/Radio.figma.d.ts +8 -0
- package/lib/typescript/figma/Radio.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/styles/primitives.d.ts +35 -0
- package/lib/typescript/styles/primitives.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/components/Button/styles.ts +1 -1
- package/src/components/Card/index.tsx +33 -13
- package/src/components/Card/styles.ts +31 -23
- package/src/components/Checkbox/styles.ts +7 -9
- package/src/components/IconButton/styles.ts +1 -1
- package/src/components/Input/styles.ts +1 -1
- package/src/components/ListItem/index.tsx +285 -0
- package/src/components/ListItem/styles.ts +153 -0
- package/src/components/Radio/index.tsx +191 -0
- package/src/components/Radio/styles.ts +59 -0
- package/src/components/Text/{styles.tsx → 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 +36 -3
- /package/src/components/Heading/{styles.tsx → styles.ts} +0 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { TRANSITION_COLORS } from '../../styles/primitives';
|
|
4
|
+
|
|
5
|
+
// ── Root (row): density, surface, separator, interactive feedback ──────────
|
|
6
|
+
|
|
7
|
+
export const listItemRootVariants = cva(
|
|
8
|
+
[
|
|
9
|
+
'flex-row self-stretch w-full px-4',
|
|
10
|
+
'data-[disabled=true]:opacity-50 data-[disabled=true]:pointer-events-none',
|
|
11
|
+
'data-[active=true]:opacity-70',
|
|
12
|
+
TRANSITION_COLORS,
|
|
13
|
+
Platform.select({
|
|
14
|
+
web: [
|
|
15
|
+
'outline-none',
|
|
16
|
+
'web:data-[hover=true]:bg-slate-50',
|
|
17
|
+
'web:focus-visible:data-[disabled=false]:bg-slate-50',
|
|
18
|
+
'web:focus-visible:data-[disabled=false]:ring-2 web:focus-visible:data-[disabled=false]:ring-slate-400/40 web:focus-visible:data-[disabled=false]:ring-offset-2',
|
|
19
|
+
].join(' '),
|
|
20
|
+
default: '',
|
|
21
|
+
}),
|
|
22
|
+
],
|
|
23
|
+
{
|
|
24
|
+
variants: {
|
|
25
|
+
size: {
|
|
26
|
+
default: 'gap-3 py-4',
|
|
27
|
+
compact: 'gap-2 py-3',
|
|
28
|
+
},
|
|
29
|
+
surface: {
|
|
30
|
+
default: 'bg-white',
|
|
31
|
+
negative: 'bg-red-50',
|
|
32
|
+
},
|
|
33
|
+
showSeparator: {
|
|
34
|
+
true: 'border-b border-solid border-stroke-secondary',
|
|
35
|
+
false: 'border-b-0',
|
|
36
|
+
},
|
|
37
|
+
crossAlign: {
|
|
38
|
+
center: 'items-center',
|
|
39
|
+
start: 'items-start',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
compoundVariants: [
|
|
43
|
+
{
|
|
44
|
+
surface: 'negative',
|
|
45
|
+
className: Platform.select({
|
|
46
|
+
web: 'web:data-[hover=true]:bg-red-100/90',
|
|
47
|
+
default: '',
|
|
48
|
+
}),
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
defaultVariants: {
|
|
52
|
+
size: 'default',
|
|
53
|
+
surface: 'default',
|
|
54
|
+
showSeparator: true,
|
|
55
|
+
crossAlign: 'center',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
// ── Leading / trailing slots ─────────────────────────────────────────────────
|
|
61
|
+
|
|
62
|
+
export const listItemLeadingSlotVariants = cva(['flex shrink-0 items-center justify-center']);
|
|
63
|
+
|
|
64
|
+
export const listItemTrailingSlotVariants = cva(['flex shrink-0 flex-row justify-end gap-2'], {
|
|
65
|
+
variants: {
|
|
66
|
+
crossAlign: {
|
|
67
|
+
center: 'items-center',
|
|
68
|
+
start: 'items-start self-start',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
defaultVariants: {
|
|
72
|
+
crossAlign: 'center',
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// ── Content stack (title / description / meta) ───────────────────────────────
|
|
77
|
+
|
|
78
|
+
export const listItemContentVariants = cva('flex min-w-0 flex-1 flex-col gap-1', {
|
|
79
|
+
variants: {
|
|
80
|
+
crossAlign: {
|
|
81
|
+
center: 'justify-center',
|
|
82
|
+
start: 'justify-start',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
defaultVariants: {
|
|
86
|
+
crossAlign: 'center',
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// ── Typography ───────────────────────────────────────────────────────────────
|
|
91
|
+
|
|
92
|
+
export const listItemTitleVariants = cva('text-content-primary font-medium', {
|
|
93
|
+
variants: {
|
|
94
|
+
size: {
|
|
95
|
+
default: 'text-base leading-snug',
|
|
96
|
+
compact: 'text-sm leading-snug',
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
defaultVariants: {
|
|
100
|
+
size: 'default',
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
export const listItemDescriptionVariants = cva('text-content-secondary', {
|
|
105
|
+
variants: {
|
|
106
|
+
size: {
|
|
107
|
+
default: 'text-sm leading-normal',
|
|
108
|
+
compact: 'text-xs leading-normal',
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
defaultVariants: {
|
|
112
|
+
size: 'default',
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
export const listItemMetaVariants = cva('text-content-tertiary', {
|
|
117
|
+
variants: {
|
|
118
|
+
size: {
|
|
119
|
+
default: 'text-xs leading-normal',
|
|
120
|
+
compact: 'text-[11px] leading-normal',
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
defaultVariants: {
|
|
124
|
+
size: 'default',
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// ── Section header (group label row inside lists / cards) ───────────────────
|
|
129
|
+
|
|
130
|
+
export const listItemSectionHeaderVariants = cva(
|
|
131
|
+
[
|
|
132
|
+
'flex-row items-center justify-between gap-2 border-b border-solid px-4 py-3',
|
|
133
|
+
'border-stroke-secondary',
|
|
134
|
+
],
|
|
135
|
+
{
|
|
136
|
+
variants: {
|
|
137
|
+
showDivider: {
|
|
138
|
+
true: ['border-t-4 border-solid border-t-surface-brand-strong/40', 'border-x-0'],
|
|
139
|
+
false: 'border-t-0',
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
defaultVariants: {
|
|
143
|
+
showDivider: true,
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
/** Default section-title typography; applied by `ListItem.SectionHeader` for string/number children. Exported for rare custom composition. */
|
|
149
|
+
export const listItemSectionHeaderLabelVariants = cva(
|
|
150
|
+
'text-xs font-semibold uppercase tracking-wide text-content-secondary',
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
export type ListItemVariantProps = VariantProps<typeof listItemRootVariants>;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { forwardRef, type ReactNode } from 'react';
|
|
2
|
+
import { Pressable, Text, type TextProps, View, type ViewProps } from 'react-native';
|
|
3
|
+
import { createRadio, dataAttributes, type IRadioProps } from '@cdx-ui/primitives';
|
|
4
|
+
import { cn } from '@cdx-ui/utils';
|
|
5
|
+
import {
|
|
6
|
+
radioGroupVariants,
|
|
7
|
+
radioIndicatorVariants,
|
|
8
|
+
radioInnerDotVariants,
|
|
9
|
+
radioLabelVariants,
|
|
10
|
+
radioRootVariants,
|
|
11
|
+
} from './styles';
|
|
12
|
+
|
|
13
|
+
// =============================================================================
|
|
14
|
+
// STYLED INDICATOR BASE
|
|
15
|
+
// =============================================================================
|
|
16
|
+
|
|
17
|
+
const RadioIndicatorBase = forwardRef<View, ViewProps & { className?: string }>(
|
|
18
|
+
({ className, children, style, ...props }, ref) => {
|
|
19
|
+
// On web, data attributes arrive as `dataSet: { checked: true }`.
|
|
20
|
+
// On native, they arrive as individual `data-checked: "true"` props.
|
|
21
|
+
const ds = (props as any).dataSet;
|
|
22
|
+
const isChecked = ds ? ds.checked === true : (props as any)['data-checked'] === 'true';
|
|
23
|
+
const isInvalid = ds ? ds.invalid === true : (props as any)['data-invalid'] === 'true';
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<View ref={ref} className={cn(radioIndicatorVariants(), className)} style={style} {...props}>
|
|
27
|
+
<View
|
|
28
|
+
className={cn(radioInnerDotVariants())}
|
|
29
|
+
{...dataAttributes({ checked: isChecked, invalid: isInvalid })}
|
|
30
|
+
/>
|
|
31
|
+
{children}
|
|
32
|
+
</View>
|
|
33
|
+
);
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
RadioIndicatorBase.displayName = 'Radio.IndicatorBase';
|
|
38
|
+
|
|
39
|
+
// =============================================================================
|
|
40
|
+
// PRIMITIVE ASSEMBLY
|
|
41
|
+
// =============================================================================
|
|
42
|
+
|
|
43
|
+
const RadioPrimitive = createRadio({
|
|
44
|
+
Root: Pressable,
|
|
45
|
+
Indicator: RadioIndicatorBase,
|
|
46
|
+
Label: Text,
|
|
47
|
+
Group: View,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// =============================================================================
|
|
51
|
+
// RADIO ROOT
|
|
52
|
+
// =============================================================================
|
|
53
|
+
|
|
54
|
+
export interface RadioProps extends IRadioProps {
|
|
55
|
+
className?: string;
|
|
56
|
+
children?: ReactNode;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const RadioRoot = forwardRef<View, RadioProps>(({ className, children, style, ...props }, ref) => {
|
|
60
|
+
const computedClassName = cn(radioRootVariants(), className);
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<RadioPrimitive ref={ref as any} className={computedClassName} style={style} {...props}>
|
|
64
|
+
{children}
|
|
65
|
+
</RadioPrimitive>
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
RadioRoot.displayName = 'Radio';
|
|
70
|
+
|
|
71
|
+
// =============================================================================
|
|
72
|
+
// RADIO INDICATOR
|
|
73
|
+
// =============================================================================
|
|
74
|
+
|
|
75
|
+
export interface RadioIndicatorProps extends ViewProps {
|
|
76
|
+
className?: string;
|
|
77
|
+
children?: ReactNode;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const RadioIndicator = forwardRef<View, RadioIndicatorProps>(
|
|
81
|
+
({ className, children, style, ...props }, ref) => {
|
|
82
|
+
return (
|
|
83
|
+
<RadioPrimitive.Indicator ref={ref as any} className={className} style={style} {...props}>
|
|
84
|
+
{children}
|
|
85
|
+
</RadioPrimitive.Indicator>
|
|
86
|
+
);
|
|
87
|
+
},
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
RadioIndicator.displayName = 'Radio.Indicator';
|
|
91
|
+
|
|
92
|
+
// =============================================================================
|
|
93
|
+
// RADIO LABEL
|
|
94
|
+
// =============================================================================
|
|
95
|
+
|
|
96
|
+
export interface RadioLabelProps extends TextProps {
|
|
97
|
+
className?: string;
|
|
98
|
+
children?: ReactNode;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const RadioLabel = forwardRef<Text, RadioLabelProps>(
|
|
102
|
+
({ className, children, style, ...props }, ref) => {
|
|
103
|
+
const computedClassName = cn(radioLabelVariants(), className);
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<RadioPrimitive.Label ref={ref as any} className={computedClassName} style={style} {...props}>
|
|
107
|
+
{children}
|
|
108
|
+
</RadioPrimitive.Label>
|
|
109
|
+
);
|
|
110
|
+
},
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
RadioLabel.displayName = 'Radio.Label';
|
|
114
|
+
|
|
115
|
+
// =============================================================================
|
|
116
|
+
// RADIO GROUP
|
|
117
|
+
// =============================================================================
|
|
118
|
+
|
|
119
|
+
export interface RadioGroupProps extends ViewProps {
|
|
120
|
+
className?: string;
|
|
121
|
+
children?: ReactNode;
|
|
122
|
+
value?: string;
|
|
123
|
+
defaultValue?: string;
|
|
124
|
+
onChange?: (value: string) => void;
|
|
125
|
+
isDisabled?: boolean;
|
|
126
|
+
isInvalid?: boolean;
|
|
127
|
+
isRequired?: boolean;
|
|
128
|
+
isReadOnly?: boolean;
|
|
129
|
+
direction?: 'column' | 'row';
|
|
130
|
+
name?: string;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const RadioGroup = forwardRef<View, RadioGroupProps>(
|
|
134
|
+
(
|
|
135
|
+
{
|
|
136
|
+
className,
|
|
137
|
+
children,
|
|
138
|
+
style,
|
|
139
|
+
direction = 'column',
|
|
140
|
+
value,
|
|
141
|
+
defaultValue,
|
|
142
|
+
onChange,
|
|
143
|
+
isDisabled,
|
|
144
|
+
isInvalid,
|
|
145
|
+
isRequired,
|
|
146
|
+
isReadOnly,
|
|
147
|
+
name,
|
|
148
|
+
...viewProps
|
|
149
|
+
},
|
|
150
|
+
ref,
|
|
151
|
+
) => {
|
|
152
|
+
const computedClassName = cn(radioGroupVariants({ direction }), className);
|
|
153
|
+
|
|
154
|
+
return (
|
|
155
|
+
<RadioPrimitive.Group
|
|
156
|
+
ref={ref as any}
|
|
157
|
+
className={computedClassName}
|
|
158
|
+
style={style}
|
|
159
|
+
value={value}
|
|
160
|
+
defaultValue={defaultValue}
|
|
161
|
+
onChange={onChange}
|
|
162
|
+
isDisabled={isDisabled}
|
|
163
|
+
isInvalid={isInvalid}
|
|
164
|
+
isRequired={isRequired}
|
|
165
|
+
isReadOnly={isReadOnly}
|
|
166
|
+
name={name}
|
|
167
|
+
{...viewProps}
|
|
168
|
+
>
|
|
169
|
+
{children}
|
|
170
|
+
</RadioPrimitive.Group>
|
|
171
|
+
);
|
|
172
|
+
},
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
RadioGroup.displayName = 'Radio.Group';
|
|
176
|
+
|
|
177
|
+
// =============================================================================
|
|
178
|
+
// COMPOUND COMPONENT
|
|
179
|
+
// =============================================================================
|
|
180
|
+
|
|
181
|
+
type RadioCompoundComponent = typeof RadioRoot & {
|
|
182
|
+
Indicator: typeof RadioIndicator;
|
|
183
|
+
Label: typeof RadioLabel;
|
|
184
|
+
Group: typeof RadioGroup;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export const Radio = Object.assign(RadioRoot, {
|
|
188
|
+
Indicator: RadioIndicator,
|
|
189
|
+
Label: RadioLabel,
|
|
190
|
+
Group: RadioGroup,
|
|
191
|
+
}) as RadioCompoundComponent;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
import { DISABLED_CURSOR, TRANSITION_COLORS } from '../../styles/primitives';
|
|
4
|
+
|
|
5
|
+
// TODO: Add hover, active, and focus-visible styles based on Figma
|
|
6
|
+
|
|
7
|
+
export const radioRootVariants = cva([
|
|
8
|
+
'flex-row items-center gap-2',
|
|
9
|
+
'data-[disabled=true]:opacity-[var(--opacity-disabled)]',
|
|
10
|
+
DISABLED_CURSOR,
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
export const radioIndicatorVariants = cva([
|
|
14
|
+
'items-center justify-center',
|
|
15
|
+
'rounded-[var(--border-radius-round)]',
|
|
16
|
+
'border-[length:var(--border-width-selected)]',
|
|
17
|
+
'h-5 w-5',
|
|
18
|
+
'border-stroke-primary',
|
|
19
|
+
'data-[checked=false]:border-slate-300',
|
|
20
|
+
'bg-surface-primary',
|
|
21
|
+
'data-[checked=true]:border-stroke-action',
|
|
22
|
+
'data-[invalid=true]:border-stroke-danger',
|
|
23
|
+
'data-[checked=true]:data-[invalid=true]:border-stroke-danger',
|
|
24
|
+
Platform.select({
|
|
25
|
+
web: [
|
|
26
|
+
TRANSITION_COLORS,
|
|
27
|
+
'data-[hover=true]:data-[checked=false]:border-slate-400',
|
|
28
|
+
'data-[hover=true]:data-[checked=false]:bg-slate-50',
|
|
29
|
+
'web:data-[focus-visible=true]:outline-none',
|
|
30
|
+
'web:data-[focus-visible=true]:ring-2 web:data-[focus-visible=true]:ring-offset-2',
|
|
31
|
+
'web:data-[focus-visible=true]:data-[checked=false]:ring-slate-400/50',
|
|
32
|
+
'web:data-[focus-visible=true]:data-[checked=true]:ring-stroke-focus',
|
|
33
|
+
'data-[invalid=true]:data-[hover=true]:border-stroke-danger',
|
|
34
|
+
'web:data-[invalid=true]:data-[focus-visible=true]:ring-stroke-danger',
|
|
35
|
+
].join(' '),
|
|
36
|
+
default: '',
|
|
37
|
+
}),
|
|
38
|
+
]);
|
|
39
|
+
|
|
40
|
+
export const radioInnerDotVariants = cva([
|
|
41
|
+
'rounded-[var(--border-radius-round)]',
|
|
42
|
+
'h-2.5 w-2.5',
|
|
43
|
+
'scale-0',
|
|
44
|
+
'data-[checked=true]:scale-100',
|
|
45
|
+
'bg-surface-action-strong',
|
|
46
|
+
'data-[invalid=true]:bg-surface-danger-strong',
|
|
47
|
+
]);
|
|
48
|
+
|
|
49
|
+
export const radioLabelVariants = cva(['body-md', 'text-content-primary']);
|
|
50
|
+
|
|
51
|
+
export const radioGroupVariants = cva([], {
|
|
52
|
+
variants: {
|
|
53
|
+
direction: {
|
|
54
|
+
column: 'gap-2',
|
|
55
|
+
row: 'flex-row gap-4',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
defaultVariants: { direction: 'column' },
|
|
59
|
+
});
|
|
@@ -3,9 +3,9 @@ import { cva, type VariantProps } from 'class-variance-authority';
|
|
|
3
3
|
|
|
4
4
|
export const textStyle = cva(
|
|
5
5
|
[
|
|
6
|
-
|
|
6
|
+
'text-content-primary',
|
|
7
7
|
Platform.select({
|
|
8
|
-
web: 'font-
|
|
8
|
+
web: 'font-body my-0 bg-transparent display-inline no-underline',
|
|
9
9
|
default: '',
|
|
10
10
|
}),
|
|
11
11
|
],
|