@cdx-ui/components 0.1.7 → 0.2.0
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/coverage.svg +1 -1
- package/lib/commonjs/components/ColorArea/ColorAreaPaint.js +78 -0
- package/lib/commonjs/components/ColorArea/ColorAreaPaint.js.map +1 -0
- package/lib/commonjs/components/ColorArea/ColorAreaPaint.web.js +31 -0
- package/lib/commonjs/components/ColorArea/ColorAreaPaint.web.js.map +1 -0
- package/lib/commonjs/components/ColorArea/index.js +57 -0
- package/lib/commonjs/components/ColorArea/index.js.map +1 -0
- package/lib/commonjs/components/ColorArea/styles.js +12 -0
- package/lib/commonjs/components/ColorArea/styles.js.map +1 -0
- package/lib/commonjs/components/ColorField/index.js +138 -0
- package/lib/commonjs/components/ColorField/index.js.map +1 -0
- package/lib/commonjs/components/ColorField/styles.js +14 -0
- package/lib/commonjs/components/ColorField/styles.js.map +1 -0
- package/lib/commonjs/components/ColorPicker/index.js +88 -0
- package/lib/commonjs/components/ColorPicker/index.js.map +1 -0
- package/lib/commonjs/components/ColorPicker/styles.js +22 -0
- package/lib/commonjs/components/ColorPicker/styles.js.map +1 -0
- package/lib/commonjs/components/ColorSlider/ColorSliderRailPaint.js +68 -0
- package/lib/commonjs/components/ColorSlider/ColorSliderRailPaint.js.map +1 -0
- package/lib/commonjs/components/ColorSlider/ColorSliderRailPaint.web.js +41 -0
- package/lib/commonjs/components/ColorSlider/ColorSliderRailPaint.web.js.map +1 -0
- package/lib/commonjs/components/ColorSlider/index.js +123 -0
- package/lib/commonjs/components/ColorSlider/index.js.map +1 -0
- package/lib/commonjs/components/ColorSlider/styles.js +50 -0
- package/lib/commonjs/components/ColorSlider/styles.js.map +1 -0
- package/lib/commonjs/components/ColorSwatch/index.js +54 -0
- package/lib/commonjs/components/ColorSwatch/index.js.map +1 -0
- package/lib/commonjs/components/ColorSwatch/styles.js +25 -0
- package/lib/commonjs/components/ColorSwatch/styles.js.map +1 -0
- package/lib/commonjs/components/ColorSwatchPicker/index.js +110 -0
- package/lib/commonjs/components/ColorSwatchPicker/index.js.map +1 -0
- package/lib/commonjs/components/ColorSwatchPicker/styles.js +17 -0
- package/lib/commonjs/components/ColorSwatchPicker/styles.js.map +1 -0
- package/lib/commonjs/components/Heading/styles.js +3 -0
- package/lib/commonjs/components/Heading/styles.js.map +1 -1
- package/lib/commonjs/components/Icon/index.js +27 -3
- package/lib/commonjs/components/Icon/index.js.map +1 -1
- package/lib/commonjs/components/Icon/styles.js +19 -0
- package/lib/commonjs/components/Icon/styles.js.map +1 -0
- package/lib/commonjs/components/Text/index.js +13 -4
- package/lib/commonjs/components/Text/index.js.map +1 -1
- package/lib/commonjs/components/Text/styles.js +39 -3
- package/lib/commonjs/components/Text/styles.js.map +1 -1
- package/lib/commonjs/components/Toast/hooks.js +0 -1
- package/lib/commonjs/components/Toast/hooks.js.map +1 -1
- package/lib/commonjs/components/Toast/index.js +9 -6
- package/lib/commonjs/components/Toast/index.js.map +1 -1
- package/lib/commonjs/components/Toast/styles.js +36 -19
- package/lib/commonjs/components/Toast/styles.js.map +1 -1
- package/lib/commonjs/components/ToggleButton/index.js +5 -4
- package/lib/commonjs/components/ToggleButton/index.js.map +1 -1
- package/lib/commonjs/components/index.js +68 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/components/picker/surfaces.js +9 -2
- package/lib/commonjs/components/picker/surfaces.js.map +1 -1
- package/lib/commonjs/figma/Icon.figma.js +30 -3
- package/lib/commonjs/figma/Icon.figma.js.map +1 -1
- package/lib/commonjs/figma/Text.figma.js +15 -1
- package/lib/commonjs/figma/Text.figma.js.map +1 -1
- package/lib/commonjs/providers/toast/insets-container.js +15 -3
- package/lib/commonjs/providers/toast/insets-container.js.map +1 -1
- package/lib/commonjs/providers/toast/provider.js +1 -0
- package/lib/commonjs/providers/toast/provider.js.map +1 -1
- package/lib/commonjs/styles/constants.js +14 -1
- package/lib/commonjs/styles/constants.js.map +1 -1
- package/lib/module/components/ColorArea/ColorAreaPaint.js +74 -0
- package/lib/module/components/ColorArea/ColorAreaPaint.js.map +1 -0
- package/lib/module/components/ColorArea/ColorAreaPaint.web.js +27 -0
- package/lib/module/components/ColorArea/ColorAreaPaint.web.js.map +1 -0
- package/lib/module/components/ColorArea/index.js +53 -0
- package/lib/module/components/ColorArea/index.js.map +1 -0
- package/lib/module/components/ColorArea/styles.js +8 -0
- package/lib/module/components/ColorArea/styles.js.map +1 -0
- package/lib/module/components/ColorField/index.js +134 -0
- package/lib/module/components/ColorField/index.js.map +1 -0
- package/lib/module/components/ColorField/styles.js +10 -0
- package/lib/module/components/ColorField/styles.js.map +1 -0
- package/lib/module/components/ColorPicker/index.js +79 -0
- package/lib/module/components/ColorPicker/index.js.map +1 -0
- package/lib/module/components/ColorPicker/styles.js +18 -0
- package/lib/module/components/ColorPicker/styles.js.map +1 -0
- package/lib/module/components/ColorSlider/ColorSliderRailPaint.js +64 -0
- package/lib/module/components/ColorSlider/ColorSliderRailPaint.js.map +1 -0
- package/lib/module/components/ColorSlider/ColorSliderRailPaint.web.js +37 -0
- package/lib/module/components/ColorSlider/ColorSliderRailPaint.web.js.map +1 -0
- package/lib/module/components/ColorSlider/index.js +119 -0
- package/lib/module/components/ColorSlider/index.js.map +1 -0
- package/lib/module/components/ColorSlider/styles.js +46 -0
- package/lib/module/components/ColorSlider/styles.js.map +1 -0
- package/lib/module/components/ColorSwatch/index.js +50 -0
- package/lib/module/components/ColorSwatch/index.js.map +1 -0
- package/lib/module/components/ColorSwatch/styles.js +21 -0
- package/lib/module/components/ColorSwatch/styles.js.map +1 -0
- package/lib/module/components/ColorSwatchPicker/index.js +106 -0
- package/lib/module/components/ColorSwatchPicker/index.js.map +1 -0
- package/lib/module/components/ColorSwatchPicker/styles.js +13 -0
- package/lib/module/components/ColorSwatchPicker/styles.js.map +1 -0
- package/lib/module/components/Heading/styles.js +3 -0
- package/lib/module/components/Heading/styles.js.map +1 -1
- package/lib/module/components/Icon/index.js +27 -3
- package/lib/module/components/Icon/index.js.map +1 -1
- package/lib/module/components/Icon/styles.js +16 -0
- package/lib/module/components/Icon/styles.js.map +1 -0
- package/lib/module/components/Text/index.js +14 -5
- package/lib/module/components/Text/index.js.map +1 -1
- package/lib/module/components/Text/styles.js +38 -2
- package/lib/module/components/Text/styles.js.map +1 -1
- package/lib/module/components/Toast/hooks.js +0 -1
- package/lib/module/components/Toast/hooks.js.map +1 -1
- package/lib/module/components/Toast/index.js +10 -7
- package/lib/module/components/Toast/index.js.map +1 -1
- package/lib/module/components/Toast/styles.js +35 -19
- package/lib/module/components/Toast/styles.js.map +1 -1
- package/lib/module/components/ToggleButton/index.js +3 -3
- package/lib/module/components/ToggleButton/index.js.map +1 -1
- package/lib/module/components/index.js +6 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/picker/surfaces.js +10 -3
- package/lib/module/components/picker/surfaces.js.map +1 -1
- package/lib/module/figma/Icon.figma.js +30 -3
- package/lib/module/figma/Icon.figma.js.map +1 -1
- package/lib/module/figma/Text.figma.js +15 -1
- package/lib/module/figma/Text.figma.js.map +1 -1
- package/lib/module/providers/toast/insets-container.js +15 -4
- package/lib/module/providers/toast/insets-container.js.map +1 -1
- package/lib/module/providers/toast/provider.js +2 -1
- package/lib/module/providers/toast/provider.js.map +1 -1
- package/lib/module/styles/constants.js +13 -0
- package/lib/module/styles/constants.js.map +1 -1
- package/lib/typescript/components/Alert/index.d.ts +1 -1
- package/lib/typescript/components/Alert/index.d.ts.map +1 -1
- package/lib/typescript/components/Avatar/index.d.ts +1 -1
- package/lib/typescript/components/Avatar/index.d.ts.map +1 -1
- package/lib/typescript/components/Badge/styles.d.ts +3 -3
- package/lib/typescript/components/Breadcrumbs/styles.d.ts +1 -1
- package/lib/typescript/components/Button/index.d.ts +1 -1
- package/lib/typescript/components/Button/index.d.ts.map +1 -1
- package/lib/typescript/components/Button/styles.d.ts +4 -4
- package/lib/typescript/components/Checkbox/index.d.ts +1 -1
- package/lib/typescript/components/Checkbox/index.d.ts.map +1 -1
- package/lib/typescript/components/Chip/index.d.ts +1 -1
- package/lib/typescript/components/Chip/index.d.ts.map +1 -1
- package/lib/typescript/components/Chip/styles.d.ts +3 -3
- package/lib/typescript/components/ColorArea/ColorAreaPaint.d.ts +5 -0
- package/lib/typescript/components/ColorArea/ColorAreaPaint.d.ts.map +1 -0
- package/lib/typescript/components/ColorArea/ColorAreaPaint.web.d.ts +5 -0
- package/lib/typescript/components/ColorArea/ColorAreaPaint.web.d.ts.map +1 -0
- package/lib/typescript/components/ColorArea/index.d.ts +20 -0
- package/lib/typescript/components/ColorArea/index.d.ts.map +1 -0
- package/lib/typescript/components/ColorArea/styles.d.ts +4 -0
- package/lib/typescript/components/ColorArea/styles.d.ts.map +1 -0
- package/lib/typescript/components/ColorField/index.d.ts +41 -0
- package/lib/typescript/components/ColorField/index.d.ts.map +1 -0
- package/lib/typescript/components/ColorField/styles.d.ts +13 -0
- package/lib/typescript/components/ColorField/styles.d.ts.map +1 -0
- package/lib/typescript/components/ColorPicker/index.d.ts +28 -0
- package/lib/typescript/components/ColorPicker/index.d.ts.map +1 -0
- package/lib/typescript/components/ColorPicker/styles.d.ts +9 -0
- package/lib/typescript/components/ColorPicker/styles.d.ts.map +1 -0
- package/lib/typescript/components/ColorSlider/ColorSliderRailPaint.d.ts +5 -0
- package/lib/typescript/components/ColorSlider/ColorSliderRailPaint.d.ts.map +1 -0
- package/lib/typescript/components/ColorSlider/ColorSliderRailPaint.web.d.ts +5 -0
- package/lib/typescript/components/ColorSlider/ColorSliderRailPaint.web.d.ts.map +1 -0
- package/lib/typescript/components/ColorSlider/index.d.ts +33 -0
- package/lib/typescript/components/ColorSlider/index.d.ts.map +1 -0
- package/lib/typescript/components/ColorSlider/styles.d.ts +14 -0
- package/lib/typescript/components/ColorSlider/styles.d.ts.map +1 -0
- package/lib/typescript/components/ColorSwatch/index.d.ts +19 -0
- package/lib/typescript/components/ColorSwatch/index.d.ts.map +1 -0
- package/lib/typescript/components/ColorSwatch/styles.d.ts +7 -0
- package/lib/typescript/components/ColorSwatch/styles.d.ts.map +1 -0
- package/lib/typescript/components/ColorSwatchPicker/index.d.ts +37 -0
- package/lib/typescript/components/ColorSwatchPicker/index.d.ts.map +1 -0
- package/lib/typescript/components/ColorSwatchPicker/styles.d.ts +5 -0
- package/lib/typescript/components/ColorSwatchPicker/styles.d.ts.map +1 -0
- package/lib/typescript/components/Divider/index.d.ts +1 -1
- package/lib/typescript/components/Divider/index.d.ts.map +1 -1
- package/lib/typescript/components/Heading/styles.d.ts.map +1 -1
- package/lib/typescript/components/Icon/index.d.ts +14 -22
- package/lib/typescript/components/Icon/index.d.ts.map +1 -1
- package/lib/typescript/components/Icon/styles.d.ts +6 -0
- package/lib/typescript/components/Icon/styles.d.ts.map +1 -0
- package/lib/typescript/components/IconButton/styles.d.ts +2 -2
- package/lib/typescript/components/Input/index.d.ts +1 -1
- package/lib/typescript/components/Input/index.d.ts.map +1 -1
- package/lib/typescript/components/Link/index.d.ts +1 -1
- package/lib/typescript/components/Link/index.d.ts.map +1 -1
- package/lib/typescript/components/Menu/index.d.ts +2 -2
- package/lib/typescript/components/Menu/index.d.ts.map +1 -1
- package/lib/typescript/components/Select/index.d.ts +1 -1
- package/lib/typescript/components/Select/index.d.ts.map +1 -1
- package/lib/typescript/components/Slider/styles.d.ts +3 -3
- package/lib/typescript/components/Text/index.d.ts +40 -3
- package/lib/typescript/components/Text/index.d.ts.map +1 -1
- package/lib/typescript/components/Text/styles.d.ts +9 -0
- package/lib/typescript/components/Text/styles.d.ts.map +1 -1
- package/lib/typescript/components/Toast/hooks.d.ts +1 -1
- package/lib/typescript/components/Toast/hooks.d.ts.map +1 -1
- package/lib/typescript/components/Toast/index.d.ts.map +1 -1
- package/lib/typescript/components/Toast/styles.d.ts +4 -0
- package/lib/typescript/components/Toast/styles.d.ts.map +1 -1
- package/lib/typescript/components/Toast/types.d.ts +1 -1
- package/lib/typescript/components/Toast/types.d.ts.map +1 -1
- package/lib/typescript/components/ToggleButton/index.d.ts +5 -3
- package/lib/typescript/components/ToggleButton/index.d.ts.map +1 -1
- package/lib/typescript/components/index.d.ts +6 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/components/picker/surfaces.d.ts +5 -1
- package/lib/typescript/components/picker/surfaces.d.ts.map +1 -1
- package/lib/typescript/figma/Icon.figma.d.ts.map +1 -1
- package/lib/typescript/figma/Text.figma.d.ts.map +1 -1
- package/lib/typescript/providers/toast/insets-container.d.ts +12 -0
- package/lib/typescript/providers/toast/insets-container.d.ts.map +1 -1
- package/lib/typescript/providers/toast/types.d.ts +5 -0
- package/lib/typescript/providers/toast/types.d.ts.map +1 -1
- package/lib/typescript/styles/constants.d.ts +10 -0
- package/lib/typescript/styles/constants.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/components/Alert/index.tsx +1 -1
- package/src/components/Avatar/index.tsx +1 -1
- package/src/components/Button/index.tsx +1 -1
- package/src/components/Checkbox/index.tsx +1 -1
- package/src/components/Chip/index.tsx +1 -1
- package/src/components/ColorArea/ColorAreaPaint.tsx +51 -0
- package/src/components/ColorArea/ColorAreaPaint.web.tsx +31 -0
- package/src/components/ColorArea/index.tsx +71 -0
- package/src/components/ColorArea/styles.ts +18 -0
- package/src/components/ColorField/index.tsx +181 -0
- package/src/components/ColorField/styles.ts +20 -0
- package/src/components/ColorPicker/index.tsx +110 -0
- package/src/components/ColorPicker/styles.ts +33 -0
- package/src/components/ColorSlider/ColorSliderRailPaint.tsx +60 -0
- package/src/components/ColorSlider/ColorSliderRailPaint.web.tsx +33 -0
- package/src/components/ColorSlider/index.tsx +147 -0
- package/src/components/ColorSlider/styles.ts +72 -0
- package/src/components/ColorSwatch/index.tsx +56 -0
- package/src/components/ColorSwatch/styles.ts +24 -0
- package/src/components/ColorSwatchPicker/index.tsx +150 -0
- package/src/components/ColorSwatchPicker/styles.ts +32 -0
- package/src/components/Divider/index.tsx +1 -1
- package/src/components/Heading/styles.ts +3 -0
- package/src/components/Icon/index.tsx +46 -6
- package/src/components/Icon/styles.ts +15 -0
- package/src/components/Input/index.tsx +1 -1
- package/src/components/Link/index.tsx +1 -1
- package/src/components/Menu/index.tsx +2 -2
- package/src/components/Select/index.tsx +1 -1
- package/src/components/Text/index.tsx +32 -5
- package/src/components/Text/styles.ts +39 -1
- package/src/components/Toast/hooks.ts +0 -1
- package/src/components/Toast/index.tsx +14 -8
- package/src/components/Toast/styles.ts +47 -19
- package/src/components/Toast/types.ts +1 -1
- package/src/components/ToggleButton/index.tsx +9 -7
- package/src/components/index.ts +6 -0
- package/src/components/picker/surfaces.tsx +15 -2
- package/src/providers/toast/insets-container.tsx +23 -9
- package/src/providers/toast/provider.tsx +2 -2
- package/src/providers/toast/types.ts +5 -0
- package/src/styles/constants.ts +13 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { forwardRef, type ReactNode } from 'react';
|
|
2
|
+
import { Text, View, type PressableStateCallbackType, type TextProps } from 'react-native';
|
|
3
|
+
import {
|
|
4
|
+
ColorSliderRail as ColorSliderRailPrimitive,
|
|
5
|
+
ColorSliderRoot as ColorSliderRootPrimitive,
|
|
6
|
+
ColorSliderThumb as ColorSliderThumbPrimitive,
|
|
7
|
+
Slot,
|
|
8
|
+
dataAttributes,
|
|
9
|
+
mergeDataAttributes,
|
|
10
|
+
useColorSliderContext,
|
|
11
|
+
type IColorSliderProps,
|
|
12
|
+
type IColorSliderRailProps,
|
|
13
|
+
type IColorSliderThumbProps,
|
|
14
|
+
} from '@cdx-ui/primitives';
|
|
15
|
+
import { cn } from '@cdx-ui/utils';
|
|
16
|
+
import { ColorSliderRailPaint } from './ColorSliderRailPaint';
|
|
17
|
+
import {
|
|
18
|
+
colorSliderOutputVariants,
|
|
19
|
+
colorSliderRailVariants,
|
|
20
|
+
colorSliderThumbVariants,
|
|
21
|
+
colorSliderVariants,
|
|
22
|
+
} from './styles';
|
|
23
|
+
|
|
24
|
+
export type ColorSliderProps = IColorSliderProps & {
|
|
25
|
+
readonly asChild?: boolean;
|
|
26
|
+
readonly className?: string;
|
|
27
|
+
readonly children?: ReactNode;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const ColorSliderRoot = forwardRef<View, ColorSliderProps>(
|
|
31
|
+
({ asChild, className, style, orientation = 'horizontal', children, ...props }, ref) => (
|
|
32
|
+
<ColorSliderRootPrimitive
|
|
33
|
+
ref={ref}
|
|
34
|
+
asChild={asChild}
|
|
35
|
+
className={cn(colorSliderVariants({ orientation }), className)}
|
|
36
|
+
style={style}
|
|
37
|
+
orientation={orientation}
|
|
38
|
+
{...props}
|
|
39
|
+
{...mergeDataAttributes(props, dataAttributes({ slot: 'color-slider' }))}
|
|
40
|
+
>
|
|
41
|
+
{children}
|
|
42
|
+
</ColorSliderRootPrimitive>
|
|
43
|
+
),
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
ColorSliderRoot.displayName = 'ColorSlider';
|
|
47
|
+
|
|
48
|
+
export interface ColorSliderRailProps extends IColorSliderRailProps {
|
|
49
|
+
readonly className?: string;
|
|
50
|
+
readonly children?: ReactNode;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const ColorSliderRail = forwardRef<View, ColorSliderRailProps>(
|
|
54
|
+
({ asChild, className, style, hitSlop, children, ...props }, ref) => {
|
|
55
|
+
const { orientation, thumbSize } = useColorSliderContext();
|
|
56
|
+
const endCap =
|
|
57
|
+
orientation === 'vertical'
|
|
58
|
+
? { top: thumbSize.height / 2, bottom: thumbSize.height / 2 }
|
|
59
|
+
: { left: thumbSize.width / 2, right: thumbSize.width / 2 };
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<ColorSliderRailPrimitive
|
|
63
|
+
ref={ref}
|
|
64
|
+
asChild={asChild}
|
|
65
|
+
className={cn(colorSliderRailVariants({ orientation }), className)}
|
|
66
|
+
style={style}
|
|
67
|
+
hitSlop={hitSlop ?? endCap}
|
|
68
|
+
{...props}
|
|
69
|
+
{...mergeDataAttributes(props, dataAttributes({ slot: 'color-slider-rail' }))}
|
|
70
|
+
>
|
|
71
|
+
<ColorSliderRailPaint />
|
|
72
|
+
{children}
|
|
73
|
+
</ColorSliderRailPrimitive>
|
|
74
|
+
);
|
|
75
|
+
},
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
ColorSliderRail.displayName = 'ColorSlider.Rail';
|
|
79
|
+
|
|
80
|
+
export interface ColorSliderThumbProps extends IColorSliderThumbProps {
|
|
81
|
+
readonly className?: string;
|
|
82
|
+
readonly children?: ReactNode;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const ColorSliderThumb = forwardRef<View, ColorSliderThumbProps>(
|
|
86
|
+
({ className, style, children, ...props }, ref) => {
|
|
87
|
+
const { value } = useColorSliderContext();
|
|
88
|
+
const fillStyle = { backgroundColor: value.toString('hex') };
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<ColorSliderThumbPrimitive
|
|
92
|
+
ref={ref}
|
|
93
|
+
className={cn(colorSliderThumbVariants(), className)}
|
|
94
|
+
style={
|
|
95
|
+
typeof style === 'function'
|
|
96
|
+
? (state: PressableStateCallbackType) => [fillStyle, style(state)]
|
|
97
|
+
: [fillStyle, style]
|
|
98
|
+
}
|
|
99
|
+
{...props}
|
|
100
|
+
{...mergeDataAttributes(props, dataAttributes({ slot: 'color-slider-thumb' }))}
|
|
101
|
+
>
|
|
102
|
+
{children}
|
|
103
|
+
</ColorSliderThumbPrimitive>
|
|
104
|
+
);
|
|
105
|
+
},
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
ColorSliderThumb.displayName = 'ColorSlider.Thumb';
|
|
109
|
+
|
|
110
|
+
export interface ColorSliderOutputProps extends TextProps {
|
|
111
|
+
readonly asChild?: boolean;
|
|
112
|
+
readonly className?: string;
|
|
113
|
+
readonly children?: ReactNode;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const ColorSliderOutput = forwardRef<Text, ColorSliderOutputProps>(
|
|
117
|
+
({ asChild, className, style, children, ...props }, ref) => {
|
|
118
|
+
const { valueLabel } = useColorSliderContext();
|
|
119
|
+
const Comp = asChild ? Slot : Text;
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<Comp
|
|
123
|
+
ref={ref}
|
|
124
|
+
className={cn(colorSliderOutputVariants(), className)}
|
|
125
|
+
style={style}
|
|
126
|
+
{...props}
|
|
127
|
+
{...mergeDataAttributes(props, dataAttributes({ slot: 'color-slider-output' }))}
|
|
128
|
+
>
|
|
129
|
+
{children ?? valueLabel}
|
|
130
|
+
</Comp>
|
|
131
|
+
);
|
|
132
|
+
},
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
ColorSliderOutput.displayName = 'ColorSlider.Output';
|
|
136
|
+
|
|
137
|
+
type ColorSliderCompoundComponent = typeof ColorSliderRoot & {
|
|
138
|
+
Rail: typeof ColorSliderRail;
|
|
139
|
+
Thumb: typeof ColorSliderThumb;
|
|
140
|
+
Output: typeof ColorSliderOutput;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export const ColorSlider = Object.assign(ColorSliderRoot, {
|
|
144
|
+
Rail: ColorSliderRail,
|
|
145
|
+
Thumb: ColorSliderThumb,
|
|
146
|
+
Output: ColorSliderOutput,
|
|
147
|
+
}) as ColorSliderCompoundComponent;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import { cva, type VariantProps } from '@cdx-ui/utils';
|
|
3
|
+
import { DISABLED_CURSOR } from '../../styles/constants';
|
|
4
|
+
|
|
5
|
+
export const colorSliderVariants = cva(
|
|
6
|
+
[
|
|
7
|
+
'relative select-none',
|
|
8
|
+
'data-[disabled=true]:opacity-[var(--opacity-disabled)]',
|
|
9
|
+
DISABLED_CURSOR,
|
|
10
|
+
],
|
|
11
|
+
{
|
|
12
|
+
variants: {
|
|
13
|
+
orientation: {
|
|
14
|
+
horizontal: 'w-full',
|
|
15
|
+
vertical: 'h-48',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
defaultVariants: {
|
|
19
|
+
orientation: 'horizontal',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
// The rail inset equals the `size-5` thumb's radius so the thumb sits flush inside the pill ends.
|
|
25
|
+
export const colorSliderRailVariants = cva(['relative touch-none'], {
|
|
26
|
+
variants: {
|
|
27
|
+
orientation: {
|
|
28
|
+
horizontal: 'mx-2.5 h-5 w-auto',
|
|
29
|
+
vertical: 'my-2.5 w-5 flex-1',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
defaultVariants: {
|
|
33
|
+
orientation: 'horizontal',
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export const colorSliderRailPaintVariants = cva(
|
|
38
|
+
['absolute overflow-hidden rounded-[var(--border-radius-round)]'],
|
|
39
|
+
{
|
|
40
|
+
variants: {
|
|
41
|
+
orientation: {
|
|
42
|
+
horizontal: '-inset-x-2.5 inset-y-0',
|
|
43
|
+
vertical: '-inset-y-2.5 inset-x-0',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
defaultVariants: {
|
|
47
|
+
orientation: 'horizontal',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
export const colorSliderThumbVariants = cva([
|
|
53
|
+
'z-2 box-border size-5 rounded-[var(--border-radius-round)]',
|
|
54
|
+
'border-2 border-surface-primary shadow-md',
|
|
55
|
+
'transition-[transform,box-shadow,opacity] duration-150',
|
|
56
|
+
'data-[dragging=true]:transition-none',
|
|
57
|
+
'web:outline-none web:active:cursor-grabbing',
|
|
58
|
+
Platform.select({
|
|
59
|
+
default: 'data-[focus=true]:scale-105',
|
|
60
|
+
web: [
|
|
61
|
+
'web:cursor-grab',
|
|
62
|
+
'data-[hover=true]:scale-110',
|
|
63
|
+
'data-[dragging=true]:scale-110',
|
|
64
|
+
'data-[focus-visible=true]:ring-4',
|
|
65
|
+
'data-[focus-visible=true]:ring-stroke-focus',
|
|
66
|
+
].join(' '),
|
|
67
|
+
}),
|
|
68
|
+
]);
|
|
69
|
+
|
|
70
|
+
export const colorSliderOutputVariants = cva(['text-sm font-medium text-content-primary']);
|
|
71
|
+
|
|
72
|
+
export type ColorSliderVariantProps = VariantProps<typeof colorSliderVariants>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { forwardRef, type ComponentRef } from 'react';
|
|
2
|
+
import { View, type ViewProps } from 'react-native';
|
|
3
|
+
import {
|
|
4
|
+
Slot,
|
|
5
|
+
dataAttributes,
|
|
6
|
+
mergeDataAttributes,
|
|
7
|
+
useOptionalColorPickerContext,
|
|
8
|
+
type Color,
|
|
9
|
+
} from '@cdx-ui/primitives';
|
|
10
|
+
import { cn } from '@cdx-ui/utils';
|
|
11
|
+
import { colorSwatchVariants, type ColorSwatchVariantProps } from './styles';
|
|
12
|
+
|
|
13
|
+
export interface ColorSwatchProps extends ViewProps, ColorSwatchVariantProps {
|
|
14
|
+
asChild?: boolean;
|
|
15
|
+
color?: Color;
|
|
16
|
+
/** Visual dimension. `xs` = 16, `sm` = 24, and `lg` = 40. */
|
|
17
|
+
size?: 'xs' | 'sm' | 'lg';
|
|
18
|
+
/** Swatch outline shape. */
|
|
19
|
+
shape?: 'circle' | 'square';
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface ColorSwatchViewProps extends ColorSwatchProps {
|
|
24
|
+
slot: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const ColorSwatchView = forwardRef<ComponentRef<typeof View>, ColorSwatchViewProps>(
|
|
28
|
+
({ asChild, color, size = 'sm', shape = 'circle', slot, className, style, ...props }, ref) => {
|
|
29
|
+
const Comp = asChild ? Slot : View;
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<Comp
|
|
33
|
+
ref={ref}
|
|
34
|
+
className={cn(colorSwatchVariants({ size, shape }), className)}
|
|
35
|
+
style={[color ? { backgroundColor: color.toString('hex') } : undefined, style]}
|
|
36
|
+
{...props}
|
|
37
|
+
{...mergeDataAttributes(props, dataAttributes({ slot }))}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
},
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
ColorSwatchView.displayName = 'ColorSwatchView';
|
|
44
|
+
|
|
45
|
+
export const ColorSwatch = forwardRef<ComponentRef<typeof View>, ColorSwatchProps>(
|
|
46
|
+
({ color: colorProp, ...props }, ref) => {
|
|
47
|
+
const picker = useOptionalColorPickerContext();
|
|
48
|
+
const color = colorProp ?? picker?.value;
|
|
49
|
+
|
|
50
|
+
return <ColorSwatchView ref={ref} color={color} slot="color-swatch" {...props} />;
|
|
51
|
+
},
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
ColorSwatch.displayName = 'ColorSwatch';
|
|
55
|
+
|
|
56
|
+
export type { ColorSwatchVariantProps };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { cva, type VariantProps } from '@cdx-ui/utils';
|
|
2
|
+
|
|
3
|
+
export const colorSwatchVariants = cva(
|
|
4
|
+
['shrink-0 overflow-hidden border border-stroke-secondary'],
|
|
5
|
+
{
|
|
6
|
+
variants: {
|
|
7
|
+
size: {
|
|
8
|
+
xs: 'size-4',
|
|
9
|
+
sm: 'size-6',
|
|
10
|
+
lg: 'size-10',
|
|
11
|
+
},
|
|
12
|
+
shape: {
|
|
13
|
+
circle: 'rounded-[var(--border-radius-round)]',
|
|
14
|
+
square: 'rounded-[var(--border-radius-default)]',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
defaultVariants: {
|
|
18
|
+
size: 'sm',
|
|
19
|
+
shape: 'circle',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export type ColorSwatchVariantProps = VariantProps<typeof colorSwatchVariants>;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { forwardRef, type ReactNode } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { Check } from '@cdx-ui/icons';
|
|
4
|
+
import {
|
|
5
|
+
ColorSwatchPickerItem as ColorSwatchPickerItemPrimitive,
|
|
6
|
+
ColorSwatchPickerRoot as ColorSwatchPickerRootPrimitive,
|
|
7
|
+
Slot,
|
|
8
|
+
dataAttributes,
|
|
9
|
+
mergeDataAttributes,
|
|
10
|
+
useColorSwatchPickerItemContext,
|
|
11
|
+
useRadioContext,
|
|
12
|
+
type IColorSwatchPickerItemProps,
|
|
13
|
+
type IColorSwatchPickerProps,
|
|
14
|
+
} from '@cdx-ui/primitives';
|
|
15
|
+
import { cn } from '@cdx-ui/utils';
|
|
16
|
+
import { Icon, type IconProps } from '../Icon';
|
|
17
|
+
import { ColorSwatchView, type ColorSwatchProps } from '../ColorSwatch';
|
|
18
|
+
import {
|
|
19
|
+
colorSwatchPickerIndicatorIconVariants,
|
|
20
|
+
colorSwatchPickerIndicatorVariants,
|
|
21
|
+
colorSwatchPickerItemVariants,
|
|
22
|
+
colorSwatchPickerVariants,
|
|
23
|
+
} from './styles';
|
|
24
|
+
|
|
25
|
+
export interface ColorSwatchPickerProps extends IColorSwatchPickerProps {
|
|
26
|
+
asChild?: boolean;
|
|
27
|
+
className?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const ColorSwatchPickerRoot = forwardRef<View, ColorSwatchPickerProps>(
|
|
31
|
+
({ asChild, className, style, children, ...props }, ref) => (
|
|
32
|
+
<ColorSwatchPickerRootPrimitive
|
|
33
|
+
ref={ref}
|
|
34
|
+
asChild={asChild}
|
|
35
|
+
className={cn(colorSwatchPickerVariants(), className)}
|
|
36
|
+
style={style}
|
|
37
|
+
{...props}
|
|
38
|
+
{...mergeDataAttributes(props, dataAttributes({ slot: 'color-swatch-picker' }))}
|
|
39
|
+
>
|
|
40
|
+
{children}
|
|
41
|
+
</ColorSwatchPickerRootPrimitive>
|
|
42
|
+
),
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
ColorSwatchPickerRoot.displayName = 'ColorSwatchPicker';
|
|
46
|
+
|
|
47
|
+
export interface ColorSwatchPickerItemProps extends IColorSwatchPickerItemProps {
|
|
48
|
+
asChild?: boolean;
|
|
49
|
+
className?: string;
|
|
50
|
+
children?: ReactNode;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const ColorSwatchPickerItem = forwardRef<View, ColorSwatchPickerItemProps>(
|
|
54
|
+
({ asChild, className, style, children, ...props }, ref) => (
|
|
55
|
+
<ColorSwatchPickerItemPrimitive
|
|
56
|
+
ref={ref}
|
|
57
|
+
asChild={asChild}
|
|
58
|
+
className={cn(colorSwatchPickerItemVariants(), className)}
|
|
59
|
+
style={style}
|
|
60
|
+
{...props}
|
|
61
|
+
{...mergeDataAttributes(props, dataAttributes({ slot: 'color-swatch-picker-item' }))}
|
|
62
|
+
>
|
|
63
|
+
{children}
|
|
64
|
+
</ColorSwatchPickerItemPrimitive>
|
|
65
|
+
),
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
ColorSwatchPickerItem.displayName = 'ColorSwatchPicker.Item';
|
|
69
|
+
|
|
70
|
+
export interface ColorSwatchPickerSwatchProps extends Omit<ColorSwatchProps, 'color'> {}
|
|
71
|
+
|
|
72
|
+
const ColorSwatchPickerSwatch = forwardRef<View, ColorSwatchPickerSwatchProps>((props, ref) => {
|
|
73
|
+
const { color } = useColorSwatchPickerItemContext();
|
|
74
|
+
|
|
75
|
+
return <ColorSwatchView ref={ref} color={color} slot="color-swatch-picker-swatch" {...props} />;
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
ColorSwatchPickerSwatch.displayName = 'ColorSwatchPicker.Swatch';
|
|
79
|
+
|
|
80
|
+
export interface ColorSwatchPickerIndicatorProps extends Omit<IconProps, 'as' | 'children'> {
|
|
81
|
+
asChild?: boolean;
|
|
82
|
+
as?: IconProps['as'];
|
|
83
|
+
className?: string;
|
|
84
|
+
children?: ReactNode;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const ColorSwatchPickerIndicator = ({
|
|
88
|
+
asChild,
|
|
89
|
+
as = Check,
|
|
90
|
+
className,
|
|
91
|
+
style,
|
|
92
|
+
children,
|
|
93
|
+
...props
|
|
94
|
+
}: ColorSwatchPickerIndicatorProps) => {
|
|
95
|
+
const { isChecked } = useRadioContext();
|
|
96
|
+
|
|
97
|
+
if (!isChecked) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const computedClassName = cn(colorSwatchPickerIndicatorIconVariants(), className);
|
|
102
|
+
const slotData = mergeDataAttributes(
|
|
103
|
+
props,
|
|
104
|
+
dataAttributes({ slot: 'color-swatch-picker-indicator' }),
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<View
|
|
109
|
+
className={colorSwatchPickerIndicatorVariants()}
|
|
110
|
+
accessibilityElementsHidden
|
|
111
|
+
aria-hidden
|
|
112
|
+
{...slotData}
|
|
113
|
+
>
|
|
114
|
+
{asChild ? (
|
|
115
|
+
<Slot
|
|
116
|
+
className={computedClassName}
|
|
117
|
+
style={style}
|
|
118
|
+
accessibilityElementsHidden
|
|
119
|
+
aria-hidden
|
|
120
|
+
{...props}
|
|
121
|
+
>
|
|
122
|
+
{children}
|
|
123
|
+
</Slot>
|
|
124
|
+
) : (
|
|
125
|
+
<Icon
|
|
126
|
+
as={as}
|
|
127
|
+
className={computedClassName}
|
|
128
|
+
style={style}
|
|
129
|
+
accessibilityElementsHidden
|
|
130
|
+
aria-hidden
|
|
131
|
+
{...props}
|
|
132
|
+
/>
|
|
133
|
+
)}
|
|
134
|
+
</View>
|
|
135
|
+
);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
ColorSwatchPickerIndicator.displayName = 'ColorSwatchPicker.Indicator';
|
|
139
|
+
|
|
140
|
+
type ColorSwatchPickerCompoundComponent = typeof ColorSwatchPickerRoot & {
|
|
141
|
+
Item: typeof ColorSwatchPickerItem;
|
|
142
|
+
Swatch: typeof ColorSwatchPickerSwatch;
|
|
143
|
+
Indicator: typeof ColorSwatchPickerIndicator;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export const ColorSwatchPicker = Object.assign(ColorSwatchPickerRoot, {
|
|
147
|
+
Item: ColorSwatchPickerItem,
|
|
148
|
+
Swatch: ColorSwatchPickerSwatch,
|
|
149
|
+
Indicator: ColorSwatchPickerIndicator,
|
|
150
|
+
}) as ColorSwatchPickerCompoundComponent;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import { cva } from '@cdx-ui/utils';
|
|
3
|
+
import { DISABLED_CURSOR, TRANSITION_COLORS } from '../../styles/constants';
|
|
4
|
+
|
|
5
|
+
export const colorSwatchPickerVariants = cva([
|
|
6
|
+
'w-full flex-row flex-wrap justify-center gap-x-1 gap-y-2',
|
|
7
|
+
]);
|
|
8
|
+
|
|
9
|
+
export const colorSwatchPickerItemVariants = cva([
|
|
10
|
+
'relative min-h-11 min-w-11 items-center justify-center',
|
|
11
|
+
'rounded-[var(--border-radius-default)]',
|
|
12
|
+
TRANSITION_COLORS,
|
|
13
|
+
DISABLED_CURSOR,
|
|
14
|
+
'data-[disabled=true]:opacity-[var(--opacity-disabled)]',
|
|
15
|
+
'web:outline-none',
|
|
16
|
+
'web:data-[focus-visible=true]:ring-2',
|
|
17
|
+
'web:data-[focus-visible=true]:ring-stroke-focus',
|
|
18
|
+
'web:data-[focus-visible=true]:ring-offset-2',
|
|
19
|
+
Platform.select({
|
|
20
|
+
default: 'data-[active=true]:bg-surface-action-tint-active',
|
|
21
|
+
web: [
|
|
22
|
+
'data-[hover=true]:bg-surface-action-tint-hover',
|
|
23
|
+
'data-[active=true]:data-[hover=true]:bg-surface-action-tint-active',
|
|
24
|
+
].join(' '),
|
|
25
|
+
}),
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
export const colorSwatchPickerIndicatorVariants = cva([
|
|
29
|
+
'pointer-events-none absolute inset-0 z-10 items-center justify-center',
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
export const colorSwatchPickerIndicatorIconVariants = cva('size-4 text-[var(--color-white)]');
|
|
@@ -22,7 +22,7 @@ export interface DividerProps extends ViewProps {
|
|
|
22
22
|
children?: ReactNode;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export interface DividerLabelProps extends TextProps {
|
|
25
|
+
export interface DividerLabelProps extends Omit<TextProps, 'color'> {
|
|
26
26
|
/** Renders the consumer's child element in place of the default `Text` host. */
|
|
27
27
|
asChild?: boolean;
|
|
28
28
|
className?: string;
|
|
@@ -1,13 +1,30 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
1
2
|
import { withUniwind } from 'uniwind';
|
|
2
3
|
import { cn } from '@cdx-ui/utils';
|
|
3
4
|
import type { ForgeIcon, ForgeIconProps } from '@cdx-ui/icons';
|
|
5
|
+
import { CONTENT_COLOR } from '../../styles/constants';
|
|
6
|
+
import { iconStyle, type IconVariantProps } from './styles';
|
|
4
7
|
|
|
5
|
-
export type
|
|
8
|
+
export type IconColor = NonNullable<IconVariantProps['color']>;
|
|
9
|
+
|
|
10
|
+
type SvgColor = NonNullable<ForgeIconProps['color']>;
|
|
11
|
+
|
|
12
|
+
export type IconProps = Omit<ForgeIconProps, 'color'> & {
|
|
13
|
+
/**
|
|
14
|
+
* Semantic content color, mapped to the matching `text-content-*` token.
|
|
15
|
+
*
|
|
16
|
+
* Any other value is deprecated: it is passed to the SVG unchanged, as before
|
|
17
|
+
* the semantic colors existed, and warns once in development.
|
|
18
|
+
* @default 'primary'
|
|
19
|
+
*/
|
|
20
|
+
color?: IconColor | (string & {}) | Exclude<SvgColor, string>;
|
|
6
21
|
className?: string; // TODO: Why does this need to specified manually?
|
|
7
22
|
as: ForgeIcon;
|
|
8
23
|
};
|
|
9
24
|
|
|
10
|
-
|
|
25
|
+
type IconImplProps = ForgeIconProps & Pick<IconProps, 'as' | 'className'>;
|
|
26
|
+
|
|
27
|
+
function IconImpl({ as: IconComponent, ...props }: IconImplProps) {
|
|
11
28
|
return <IconComponent {...props} />;
|
|
12
29
|
}
|
|
13
30
|
|
|
@@ -41,19 +58,42 @@ const StyledIcon = withUniwind(withUniwind(IconImpl), {
|
|
|
41
58
|
* import { Icon } from '@cdx-ui/components';
|
|
42
59
|
* import { ArrowRight } from '@cdx-ui/icons';
|
|
43
60
|
*
|
|
44
|
-
* <Icon as={ArrowRight} className="
|
|
61
|
+
* <Icon as={ArrowRight} color="action" className="size-4" />
|
|
45
62
|
* ```
|
|
46
63
|
*
|
|
47
64
|
* @param {ForgeIcon} as - The Forge icon component to render.
|
|
48
|
-
* @param {
|
|
65
|
+
* @param {IconColor} color - Semantic content color. Defaults to `primary`.
|
|
66
|
+
* @param {string} className - Utility classes for size and placement, merged after the defaults.
|
|
49
67
|
* @param {number} size - Icon size (overrides the size class).
|
|
50
68
|
* @param {...ForgeIconProps} ...props - Additional icon props passed to the "as" icon.
|
|
51
69
|
*/
|
|
52
|
-
|
|
70
|
+
let hasWarnedIconRawColor = false;
|
|
71
|
+
|
|
72
|
+
function isIconColor(color: NonNullable<IconProps['color']>): color is IconColor {
|
|
73
|
+
return typeof color === 'string' && Object.prototype.hasOwnProperty.call(CONTENT_COLOR, color);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function Icon({ as: IconComponent, color = 'primary', className, ...props }: IconProps) {
|
|
77
|
+
const isSemantic = isIconColor(color);
|
|
78
|
+
const semanticColor = isSemantic ? color : null;
|
|
79
|
+
const rawColor = isSemantic ? undefined : color;
|
|
80
|
+
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
if (__DEV__ && rawColor !== undefined && !hasWarnedIconRawColor) {
|
|
83
|
+
hasWarnedIconRawColor = true;
|
|
84
|
+
console.warn(
|
|
85
|
+
`[Icon] Passing a raw \`color\` value is deprecated and will be removed in a future major release. Use a semantic color (${Object.keys(CONTENT_COLOR).join(', ')}) instead.`,
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
}, [rawColor]);
|
|
89
|
+
|
|
90
|
+
// A raw color skips the color class and reaches the SVG directly; `withUniwind`
|
|
91
|
+
// only maps `color` from `className` when the prop is undefined.
|
|
53
92
|
return (
|
|
54
93
|
<StyledIcon
|
|
55
94
|
as={IconComponent}
|
|
56
|
-
className={cn(
|
|
95
|
+
className={cn(iconStyle({ color: semanticColor }), className)}
|
|
96
|
+
color={rawColor}
|
|
57
97
|
{...props}
|
|
58
98
|
/>
|
|
59
99
|
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { cva, type VariantProps } from '@cdx-ui/utils';
|
|
2
|
+
import { CONTENT_COLOR } from '../../styles/constants';
|
|
3
|
+
|
|
4
|
+
// `shrink-0` matters on web only: react-native-svg renders a bare `<svg>`, which
|
|
5
|
+
// falls back to the browser's `flex-shrink: 1`. Yoga already defaults to 0.
|
|
6
|
+
export const iconStyle = cva(['size-5 shrink-0'], {
|
|
7
|
+
variants: {
|
|
8
|
+
color: CONTENT_COLOR,
|
|
9
|
+
},
|
|
10
|
+
defaultVariants: {
|
|
11
|
+
color: 'primary',
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export type IconVariantProps = VariantProps<typeof iconStyle>;
|
|
@@ -151,7 +151,7 @@ InputSlot.displayName = 'Input.Slot';
|
|
|
151
151
|
// INPUT ICON
|
|
152
152
|
// =============================================================================
|
|
153
153
|
|
|
154
|
-
export interface InputIconProps extends Omit<IconProps, 'children' | 'as'> {
|
|
154
|
+
export interface InputIconProps extends Omit<IconProps, 'children' | 'as' | 'color'> {
|
|
155
155
|
/** Render the consumer's child element in place of the default icon host. */
|
|
156
156
|
asChild?: boolean;
|
|
157
157
|
/**
|
|
@@ -91,7 +91,7 @@ LinkLabel.displayName = 'Link.Label';
|
|
|
91
91
|
// STYLED ICON COMPONENT
|
|
92
92
|
// =============================================================================
|
|
93
93
|
|
|
94
|
-
export interface LinkIconProps extends Omit<IconProps, 'children'> {}
|
|
94
|
+
export interface LinkIconProps extends Omit<IconProps, 'children' | 'color'> {}
|
|
95
95
|
|
|
96
96
|
const LinkIcon = ({ className, style, as, ...props }: LinkIconProps) => {
|
|
97
97
|
const { visited } = useLinkInteractionContext();
|
|
@@ -422,7 +422,7 @@ const MenuItemLabel = forwardRef<Text, MenuItemLabelProps>(
|
|
|
422
422
|
|
|
423
423
|
MenuItemLabel.displayName = 'Menu.ItemLabel';
|
|
424
424
|
|
|
425
|
-
export interface MenuItemIconProps extends Omit<IconProps, 'as' | 'children'> {
|
|
425
|
+
export interface MenuItemIconProps extends Omit<IconProps, 'as' | 'children' | 'color'> {
|
|
426
426
|
asChild?: boolean;
|
|
427
427
|
as?: IconProps['as'];
|
|
428
428
|
position?: IconSlotPosition;
|
|
@@ -508,7 +508,7 @@ const MenuItemShortcut = forwardRef<Text, MenuItemShortcutProps>(
|
|
|
508
508
|
|
|
509
509
|
MenuItemShortcut.displayName = 'Menu.ItemShortcut';
|
|
510
510
|
|
|
511
|
-
export interface MenuItemIndicatorProps extends Omit<IconProps, 'as' | 'children'> {
|
|
511
|
+
export interface MenuItemIndicatorProps extends Omit<IconProps, 'as' | 'children' | 'color'> {
|
|
512
512
|
asChild?: boolean;
|
|
513
513
|
as?: IconProps['as'];
|
|
514
514
|
isChecked?: boolean;
|
|
@@ -191,7 +191,7 @@ SelectValue.displayName = 'Select.Value';
|
|
|
191
191
|
// STYLED ICON (styled-only, reads context for state=open / invalid)
|
|
192
192
|
// =============================================================================
|
|
193
193
|
|
|
194
|
-
export interface SelectIconProps extends Omit<IconProps, 'children' | 'as'> {
|
|
194
|
+
export interface SelectIconProps extends Omit<IconProps, 'children' | 'as' | 'color'> {
|
|
195
195
|
asChild?: boolean;
|
|
196
196
|
/**
|
|
197
197
|
* Forge icon component to render. Required unless `asChild` is set, in which
|