@cdx-ui/components 0.0.1-alpha.26 → 0.0.1-alpha.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/lib/commonjs/components/Button/buttonSharedVariants.js +200 -0
  2. package/lib/commonjs/components/Button/buttonSharedVariants.js.map +1 -0
  3. package/lib/commonjs/components/Button/styles.js +21 -222
  4. package/lib/commonjs/components/Button/styles.js.map +1 -1
  5. package/lib/commonjs/components/IconButton/index.js +80 -0
  6. package/lib/commonjs/components/IconButton/index.js.map +1 -0
  7. package/lib/commonjs/components/IconButton/styles.js +91 -0
  8. package/lib/commonjs/components/IconButton/styles.js.map +1 -0
  9. package/lib/commonjs/components/index.js +12 -0
  10. package/lib/commonjs/components/index.js.map +1 -1
  11. package/lib/module/components/Button/buttonSharedVariants.js +195 -0
  12. package/lib/module/components/Button/buttonSharedVariants.js.map +1 -0
  13. package/lib/module/components/Button/styles.js +21 -223
  14. package/lib/module/components/Button/styles.js.map +1 -1
  15. package/lib/module/components/IconButton/index.js +76 -0
  16. package/lib/module/components/IconButton/index.js.map +1 -0
  17. package/lib/module/components/IconButton/styles.js +87 -0
  18. package/lib/module/components/IconButton/styles.js.map +1 -0
  19. package/lib/module/components/index.js +1 -0
  20. package/lib/module/components/index.js.map +1 -1
  21. package/lib/typescript/components/Button/buttonSharedVariants.d.ts +29 -0
  22. package/lib/typescript/components/Button/buttonSharedVariants.d.ts.map +1 -0
  23. package/lib/typescript/components/Button/styles.d.ts +6 -6
  24. package/lib/typescript/components/Button/styles.d.ts.map +1 -1
  25. package/lib/typescript/components/IconButton/index.d.ts +15 -0
  26. package/lib/typescript/components/IconButton/index.d.ts.map +1 -0
  27. package/lib/typescript/components/IconButton/styles.d.ts +16 -0
  28. package/lib/typescript/components/IconButton/styles.d.ts.map +1 -0
  29. package/lib/typescript/components/index.d.ts +1 -0
  30. package/lib/typescript/components/index.d.ts.map +1 -1
  31. package/package.json +4 -4
  32. package/src/components/Button/buttonSharedVariants.ts +281 -0
  33. package/src/components/Button/styles.ts +32 -275
  34. package/src/components/IconButton/index.tsx +93 -0
  35. package/src/components/IconButton/styles.ts +131 -0
  36. package/src/components/index.ts +1 -0
@@ -0,0 +1,131 @@
1
+ import { Platform } from 'react-native';
2
+ import { cva, type VariantProps } from 'class-variance-authority';
3
+ import {
4
+ COLOR_BORDER_DEFAULT,
5
+ DISABLED_CURSOR,
6
+ DISABLED_OPACITY,
7
+ RADIUS_FULL,
8
+ TRANSITION_COLORS,
9
+ } from '../../styles/primitives';
10
+ import {
11
+ type SharedButtonSemanticColor,
12
+ sharedGhostSurfaceCompounds,
13
+ sharedOutlineGhostForegroundTextCompounds,
14
+ } from '../Button/buttonSharedVariants';
15
+
16
+ function actionOnlyCompounds<T extends { color: SharedButtonSemanticColor }>(
17
+ compounds: T[],
18
+ ): Omit<T, 'color'>[] {
19
+ return compounds
20
+ .filter((c) => c.color === 'action')
21
+ .map((c) => {
22
+ const { color, ...rest } = c;
23
+ void color;
24
+ return rest;
25
+ });
26
+ }
27
+
28
+ /** Dark-mode hover/active surface for ghost (solid uses a separate compound with border). */
29
+ const iconButtonDarkGhostSurfaceCompounds = actionOnlyCompounds(sharedGhostSurfaceCompounds).map(
30
+ (c) => ({
31
+ variant: 'ghost' as const,
32
+ ...c,
33
+ }),
34
+ );
35
+
36
+ const iconButtonForegroundTextCompounds = actionOnlyCompounds(
37
+ sharedOutlineGhostForegroundTextCompounds,
38
+ ).map((c) => ({
39
+ variant: ['solid', 'ghost'] as ('solid' | 'ghost')[],
40
+ ...c,
41
+ }));
42
+
43
+ export const iconButtonRootVariants = cva(
44
+ [
45
+ 'flex items-center justify-center',
46
+ RADIUS_FULL,
47
+ 'web:outline-none web:focus:outline-none web:focus-visible:outline-none',
48
+ TRANSITION_COLORS,
49
+ DISABLED_OPACITY,
50
+ DISABLED_CURSOR,
51
+ 'web:data-[focus-visible=true]:ring-2 web:data-[focus-visible=true]:ring-slate-400/50 web:data-[focus-visible=true]:ring-offset-2',
52
+ ],
53
+ {
54
+ variants: {
55
+ variant: {
56
+ /** Same surface as ghost, with a light gray border (aligned with Button `outline`). */
57
+ solid: [
58
+ 'bg-transparent',
59
+ `border ${COLOR_BORDER_DEFAULT}`,
60
+ 'data-[hover=true]:bg-slate-50',
61
+ 'data-[active=true]:bg-slate-100',
62
+ ],
63
+ ghost: [
64
+ 'bg-transparent',
65
+ 'data-[hover=true]:bg-slate-50',
66
+ 'data-[active=true]:bg-slate-100',
67
+ ],
68
+ },
69
+ size: {
70
+ default: 'h-10 w-10 min-w-10 shrink-0 p-0',
71
+ small: 'h-8 w-8 min-w-8 shrink-0 p-0',
72
+ },
73
+ mode: {
74
+ light: [],
75
+ dark: [],
76
+ },
77
+ },
78
+ compoundVariants: [
79
+ ...iconButtonDarkGhostSurfaceCompounds,
80
+ {
81
+ variant: 'solid',
82
+ mode: 'dark',
83
+ className: [
84
+ 'border-slate-700',
85
+ Platform.select({
86
+ default: 'data-[active=true]:bg-slate-700',
87
+ web: 'data-[hover=true]:bg-slate-800 data-[active=true]:data-[hover=true]:bg-slate-700',
88
+ }),
89
+ ],
90
+ },
91
+ ],
92
+ defaultVariants: {
93
+ variant: 'solid',
94
+ size: 'default',
95
+ mode: 'light',
96
+ },
97
+ },
98
+ );
99
+
100
+ export const iconButtonGlyphVariants = cva([], {
101
+ variants: {
102
+ size: {
103
+ default: 'size-5',
104
+ small: 'size-4',
105
+ },
106
+ },
107
+ defaultVariants: {
108
+ size: 'default',
109
+ },
110
+ });
111
+
112
+ /** Icon fill aligned with Button outline/ghost action label colors (solid matches ghost). */
113
+ export const iconButtonIconColorVariants = cva([], {
114
+ variants: {
115
+ variant: {
116
+ solid: [],
117
+ ghost: [],
118
+ },
119
+ mode: {
120
+ light: [],
121
+ dark: [],
122
+ },
123
+ },
124
+ compoundVariants: [...iconButtonForegroundTextCompounds],
125
+ defaultVariants: {
126
+ variant: 'solid',
127
+ mode: 'light',
128
+ },
129
+ });
130
+
131
+ export type IconButtonVariantProps = VariantProps<typeof iconButtonRootVariants>;
@@ -17,3 +17,4 @@ export { HStack, VStack } from './Stack';
17
17
  export * from './Heading';
18
18
  export * from './Text';
19
19
  export * from './Icon';
20
+ export * from './IconButton';