@tujyane/alf 1.2.1 → 2.0.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.
Files changed (81) hide show
  1. package/dist/atoms/common.d.ts +3 -33
  2. package/dist/atoms/common.d.ts.map +1 -1
  3. package/dist/atoms/common.js +3 -36
  4. package/dist/atoms/common.js.map +1 -1
  5. package/dist/atoms/index.d.ts +999 -1
  6. package/dist/atoms/index.d.ts.map +1 -1
  7. package/dist/atoms/index.js +103 -4
  8. package/dist/atoms/index.js.map +1 -1
  9. package/dist/index.d.ts +10 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +20 -2
  12. package/dist/index.js.map +1 -1
  13. package/dist/palette.d.ts +76 -33
  14. package/dist/palette.d.ts.map +1 -1
  15. package/dist/palette.js +119 -75
  16. package/dist/palette.js.map +1 -1
  17. package/dist/platform/index.d.ts +9 -40
  18. package/dist/platform/index.d.ts.map +1 -1
  19. package/dist/platform/index.js +6 -44
  20. package/dist/platform/index.js.map +1 -1
  21. package/dist/themes.d.ts +109 -0
  22. package/dist/themes.d.ts.map +1 -0
  23. package/dist/themes.js +123 -0
  24. package/dist/themes.js.map +1 -0
  25. package/dist/tokens.d.ts +1 -0
  26. package/dist/tokens.d.ts.map +1 -1
  27. package/dist/tokens.js +1 -0
  28. package/dist/tokens.js.map +1 -1
  29. package/dist/utils/index.d.ts +3 -1
  30. package/dist/utils/index.d.ts.map +1 -1
  31. package/dist/utils/index.js +4 -1
  32. package/dist/utils/index.js.map +1 -1
  33. package/dist/utils/leading.d.ts +1 -2
  34. package/dist/utils/leading.d.ts.map +1 -1
  35. package/dist/utils/leading.js +5 -14
  36. package/dist/utils/leading.js.map +1 -1
  37. package/dist/utils/select.d.ts +7 -0
  38. package/dist/utils/select.d.ts.map +1 -0
  39. package/dist/utils/select.js +14 -0
  40. package/dist/utils/select.js.map +1 -0
  41. package/package.json +1 -1
  42. package/src/atoms/common.ts +3 -38
  43. package/src/atoms/index.ts +82 -1
  44. package/src/index.tsx +31 -1
  45. package/src/palette.ts +140 -111
  46. package/src/platform/index.ts +6 -46
  47. package/src/themes.ts +231 -0
  48. package/src/tokens.ts +1 -0
  49. package/src/utils/index.ts +5 -1
  50. package/src/utils/leading.ts +5 -13
  51. package/src/utils/select.ts +17 -0
  52. package/dist/atoms/index.native.d.ts +0 -1020
  53. package/dist/atoms/index.native.d.ts.map +0 -1
  54. package/dist/atoms/index.native.js +0 -119
  55. package/dist/atoms/index.native.js.map +0 -1
  56. package/dist/platform/index.native.d.ts +0 -16
  57. package/dist/platform/index.native.d.ts.map +0 -1
  58. package/dist/platform/index.native.js +0 -20
  59. package/dist/platform/index.native.js.map +0 -1
  60. package/dist/semantic.d.ts +0 -21
  61. package/dist/semantic.d.ts.map +0 -1
  62. package/dist/semantic.js +0 -73
  63. package/dist/semantic.js.map +0 -1
  64. package/dist/utils/flatten/index.d.ts +0 -3
  65. package/dist/utils/flatten/index.d.ts.map +0 -1
  66. package/dist/utils/flatten/index.js +0 -9
  67. package/dist/utils/flatten/index.js.map +0 -1
  68. package/dist/utils/flatten/index.native.d.ts +0 -3
  69. package/dist/utils/flatten/index.native.d.ts.map +0 -1
  70. package/dist/utils/flatten/index.native.js +0 -6
  71. package/dist/utils/flatten/index.native.js.map +0 -1
  72. package/dist/utils/flatten/index.web.d.ts +0 -3
  73. package/dist/utils/flatten/index.web.d.ts.map +0 -1
  74. package/dist/utils/flatten/index.web.js +0 -6
  75. package/dist/utils/flatten/index.web.js.map +0 -1
  76. package/src/atoms/index.native.ts +0 -84
  77. package/src/platform/index.native.ts +0 -16
  78. package/src/semantic.ts +0 -91
  79. package/src/utils/flatten/index.native.ts +0 -3
  80. package/src/utils/flatten/index.ts +0 -8
  81. package/src/utils/flatten/index.web.ts +0 -3
package/src/palette.ts CHANGED
@@ -1,11 +1,22 @@
1
1
  export type Palette = {
2
2
  white: string;
3
3
  black: string;
4
- stroke_primary: string;
5
- text_primary: string;
6
- text_secondary: string;
7
- primary: string;
8
- secondary: string;
4
+
5
+ contrast_0: string;
6
+ contrast_25: string;
7
+ contrast_50: string;
8
+ contrast_100: string;
9
+ contrast_200: string;
10
+ contrast_300: string;
11
+ contrast_400: string;
12
+ contrast_500: string;
13
+ contrast_600: string;
14
+ contrast_700: string;
15
+ contrast_800: string;
16
+ contrast_900: string;
17
+ contrast_950: string;
18
+ contrast_975: string;
19
+ contrast_1000: string;
9
20
 
10
21
  primary_25: string;
11
22
  primary_50: string;
@@ -18,6 +29,8 @@ export type Palette = {
18
29
  primary_700: string;
19
30
  primary_800: string;
20
31
  primary_900: string;
32
+ primary_950: string;
33
+ primary_975: string;
21
34
 
22
35
  positive_25: string;
23
36
  positive_50: string;
@@ -46,121 +59,137 @@ export type Palette = {
46
59
  negative_900: string;
47
60
  negative_950: string;
48
61
  negative_975: string;
49
-
50
- // Additional semantic scales
51
- warning_100: string;
52
- warning_200: string;
53
- warning_300: string;
54
- warning_400: string;
55
- warning_500: string;
56
- warning_600: string;
57
- warning_700: string;
58
- warning_800: string;
59
- warning_900: string;
60
-
61
- info_100: string;
62
- info_200: string;
63
- info_300: string;
64
- info_400: string;
65
- info_500: string;
66
- info_600: string;
67
- info_700: string;
68
- info_800: string;
69
- info_900: string;
70
-
71
- secondary_100: string;
72
- secondary_200: string;
73
- secondary_300: string;
74
- secondary_400: string;
75
- secondary_500: string;
76
- secondary_600: string;
77
- secondary_700: string;
78
- secondary_800: string;
79
- secondary_900: string;
80
62
  };
81
63
 
82
- export const palette: Palette = {
64
+ const STATIC_VALUES = {
83
65
  white: "#FFFFFF",
84
66
  black: "#000000",
85
- stroke_primary: "#E8F2F2",
86
- text_primary: "#020204",
87
- text_secondary: "#625F6E",
88
- primary: "#4372B8",
89
- secondary: "#2D3F60",
67
+ };
68
+
69
+ export const DEFAULT_PALETTE: Palette = {
70
+ white: STATIC_VALUES.white,
71
+ black: STATIC_VALUES.black,
90
72
 
91
- // Primary
92
- primary_25: "#F8FAFB",
93
- primary_50: "#F8FAFB",
94
- primary_100: "#D6E4FD",
95
- primary_200: "#AEC8FC",
96
- primary_300: "#85A8F8",
97
- primary_400: "#658DF1",
98
- primary_500: "#3563E9",
99
- primary_600: "#264BC8",
100
- primary_700: "#1A37A7",
101
- primary_800: "#102587",
102
- primary_900: "#0A196F",
73
+ contrast_0: "#FFFFFF",
74
+ contrast_25: "#F9FAFB",
75
+ contrast_50: "#EFF2F6",
76
+ contrast_100: "#DCE2EA",
77
+ contrast_200: "#C0CAD8",
78
+ contrast_300: "#A5B2C5",
79
+ contrast_400: "#8798B0",
80
+ contrast_500: "#667B99",
81
+ contrast_600: "#526580",
82
+ contrast_700: "#405168",
83
+ contrast_800: "#313F54",
84
+ contrast_900: "#232E3E",
85
+ contrast_950: "#19222E",
86
+ contrast_975: "#111822",
87
+ contrast_1000: "#000000",
103
88
 
104
- // Success
105
- positive_25: "#F0FDF4",
106
- positive_50: "#F0FDF4",
107
- positive_100: "#DCFCE7",
108
- positive_200: "#BBF7D0",
109
- positive_300: "#86EFAC",
110
- positive_400: "#4ADE80",
111
- positive_500: "#22C55E",
112
- positive_600: "#16A34A",
113
- positive_700: "#15803D",
114
- positive_800: "#166534",
115
- positive_900: "#14532D",
116
- positive_950: "#0A2818",
117
- positive_975: "#051C0F",
89
+ primary_25: "#F5F9FF",
90
+ primary_50: "#edf1fb",
91
+ primary_100: "#dae2f8",
92
+ primary_200: "#b5c6f1",
93
+ primary_300: "#8dabeb",
94
+ primary_400: "#5f91e4",
95
+ primary_500: "#4577c4",
96
+ primary_600: "#365e9d",
97
+ primary_700: "#274778",
98
+ primary_800: "#193054",
99
+ primary_900: "#0c1b34",
100
+ primary_950: "#061123",
101
+ primary_975: "#061123",
102
+
103
+ positive_25: "#ECFEF5",
104
+ positive_50: "#D3FDE8",
105
+ positive_100: "#A3FACF",
106
+ positive_200: "#6AF6B0",
107
+ positive_300: "#2CF28F",
108
+ positive_400: "#0DD370",
109
+ positive_500: "#09B35E",
110
+ positive_600: "#04904A",
111
+ positive_700: "#036D38",
112
+ positive_800: "#04522B",
113
+ positive_900: "#033F21",
114
+ positive_950: "#032A17",
115
+ positive_975: "#021D0F",
118
116
 
119
- // Error
120
117
  negative_25: "#FFF5F7",
121
- negative_50: "#FFF5F7",
122
- negative_100: "#FFE7D3",
123
- negative_200: "#FFC8A6",
124
- negative_300: "#FFA37A",
125
- negative_400: "#FF7F59",
126
- negative_500: "#FF4423",
127
- negative_600: "#DB2719",
128
- negative_700: "#B71112",
129
- negative_800: "#930B16",
130
- negative_900: "#7A0619",
131
- negative_950: "#4D0410",
118
+ negative_50: "#FEE7EC",
119
+ negative_100: "#FDD3DD",
120
+ negative_200: "#FBBBCA",
121
+ negative_300: "#F891A9",
122
+ negative_400: "#F65A7F",
123
+ negative_500: "#E91646",
124
+ negative_600: "#CA123D",
125
+ negative_700: "#A71134",
126
+ negative_800: "#7F0B26",
127
+ negative_900: "#5F071C",
128
+ negative_950: "#430413",
132
129
  negative_975: "#30030D",
130
+ };
133
131
 
134
- // Warning
135
- warning_100: "#FFF8D7",
136
- warning_200: "#FFEFB0",
137
- warning_300: "#FFE488",
138
- warning_400: "#FFD96B",
139
- warning_500: "#FFC73A",
140
- warning_600: "#DBA32A",
141
- warning_700: "#B7821D",
142
- warning_800: "#936312",
143
- warning_900: "#7A4D0B",
132
+ export function invertPalette(palette: Palette) {
133
+ return {
134
+ white: palette.white,
135
+ black: palette.black,
144
136
 
145
- // Info
146
- info_100: "#DCF3FF",
147
- info_200: "#BAE5FF",
148
- info_300: "#98D3FF",
149
- info_400: "#7EC2FF",
150
- info_500: "#54A6FF",
151
- info_600: "#3D81DB",
152
- info_700: "#2A60B7",
153
- info_800: "#1A4393",
154
- info_900: "#102E7A",
137
+ contrast_0: palette.contrast_1000,
138
+ contrast_25: palette.contrast_975,
139
+ contrast_50: palette.contrast_950,
140
+ contrast_100: palette.contrast_900,
141
+ contrast_200: palette.contrast_800,
142
+ contrast_300: palette.contrast_700,
143
+ contrast_400: palette.contrast_600,
144
+ contrast_500: palette.contrast_500,
145
+ contrast_600: palette.contrast_400,
146
+ contrast_700: palette.contrast_300,
147
+ contrast_800: palette.contrast_200,
148
+ contrast_900: palette.contrast_100,
149
+ contrast_950: palette.contrast_50,
150
+ contrast_975: palette.contrast_25,
151
+ contrast_1000: palette.contrast_0,
155
152
 
156
- // Secondary
157
- secondary_100: "#E0E9F4",
158
- secondary_200: "#C3D4E9",
159
- secondary_300: "#90A3BF",
160
- secondary_400: "#596780",
161
- secondary_500: "#1A202C",
162
- secondary_600: "#131825",
163
- secondary_700: "#0D121F",
164
- secondary_800: "#080C19",
165
- secondary_900: "#040815",
166
- };
153
+ primary_25: palette.primary_975,
154
+ primary_50: palette.primary_950,
155
+ primary_100: palette.primary_900,
156
+ primary_200: palette.primary_800,
157
+ primary_300: palette.primary_700,
158
+ primary_400: palette.primary_600,
159
+ primary_500: palette.primary_500,
160
+ primary_600: palette.primary_400,
161
+ primary_700: palette.primary_300,
162
+ primary_800: palette.primary_200,
163
+ primary_900: palette.primary_100,
164
+ primary_950: palette.primary_50,
165
+ primary_975: palette.primary_25,
166
+
167
+ positive_25: palette.positive_975,
168
+ positive_50: palette.positive_950,
169
+ positive_100: palette.positive_900,
170
+ positive_200: palette.positive_800,
171
+ positive_300: palette.positive_700,
172
+ positive_400: palette.positive_600,
173
+ positive_500: palette.positive_500,
174
+ positive_600: palette.positive_400,
175
+ positive_700: palette.positive_300,
176
+ positive_800: palette.positive_200,
177
+ positive_900: palette.positive_100,
178
+ positive_950: palette.positive_50,
179
+ positive_975: palette.positive_25,
180
+
181
+ negative_25: palette.negative_975,
182
+ negative_50: palette.negative_950,
183
+ negative_100: palette.negative_900,
184
+ negative_200: palette.negative_800,
185
+ negative_300: palette.negative_700,
186
+ negative_400: palette.negative_600,
187
+ negative_500: palette.negative_500,
188
+ negative_600: palette.negative_400,
189
+ negative_700: palette.negative_300,
190
+ negative_800: palette.negative_200,
191
+ negative_900: palette.negative_100,
192
+ negative_950: palette.negative_50,
193
+ negative_975: palette.negative_25,
194
+ };
195
+ }
@@ -1,54 +1,14 @@
1
- import { type Platform } from "react-native";
1
+ import { Platform } from "react-native";
2
+
3
+ export const isIOS = Platform.OS === "ios";
4
+ export const isAndroid = Platform.OS === "android";
5
+ export const isNative = true;
2
6
 
3
- export const isIOS = false;
4
- export const isAndroid = false;
5
- export const isNative = false;
6
- export const isWeb = true;
7
7
  // @ts-ignore
8
8
  export const isFabric = Boolean(global?.nativeFabricUIManager);
9
9
 
10
- /**
11
- * Identity function on web. Returns nothing on other platforms.
12
- *
13
- * Note: Platform splitting does not tree-shake away the other platforms,
14
- * so don't do stuff like e.g. rely on platform-specific imports. Use
15
- * platform-split files instead.
16
- */
17
- export const web = (value: any) => (isWeb ? value : undefined);
18
-
19
- /**
20
- * Identity function on iOS. Returns nothing on other platforms.
21
- *
22
- * Note: Platform splitting does not tree-shake away the other platforms,
23
- * so don't do stuff like e.g. rely on platform-specific imports. Use
24
- * platform-split files instead.
25
- */
26
10
  export const ios = (value: any) => (isIOS ? value : undefined);
27
-
28
- /**
29
- * Identity function on Android. Returns nothing on other platforms..
30
- *
31
- * Note: Platform splitting does not tree-shake away the other platforms,
32
- * so don't do stuff like e.g. rely on platform-specific imports. Use
33
- * platform-split files instead.
34
- */
35
11
  export const android = (value: any) => (isAndroid ? value : undefined);
36
-
37
- /**
38
- * Identity function on iOS and Android. Returns nothing on web.
39
- *
40
- * Note: Platform splitting does not tree-shake away the other platforms,
41
- * so don't do stuff like e.g. rely on platform-specific imports. Use
42
- * platform-split files instead.
43
- */
44
12
  export const native = (value: any) => (isNative ? value : undefined);
45
13
 
46
- /**
47
- * Note: Platform splitting does not tree-shake away the other platforms,
48
- * so don't do stuff like e.g. rely on platform-specific imports. Use
49
- * platform-split files instead.
50
- */
51
- export const platform = ((specifics) => {
52
- // @ts-ignore
53
- return specifics.web || specifics.default;
54
- }) as Platform["select"];
14
+ export const platform = Platform.select;
package/src/themes.ts ADDED
@@ -0,0 +1,231 @@
1
+ import { atoms } from "./atoms";
2
+ import { alpha } from "./utils/alpha";
3
+
4
+ import { Palette, DEFAULT_PALETTE, invertPalette } from "./palette";
5
+ import { type ShadowStyle } from "./atoms/types";
6
+
7
+ export const themes = createThemes({
8
+ defaultPalette: DEFAULT_PALETTE,
9
+ });
10
+
11
+ export type ThemeAtoms = {
12
+ text: {
13
+ color: string;
14
+ };
15
+ text_contrast_low: {
16
+ color: string;
17
+ };
18
+ text_contrast_medium: {
19
+ color: string;
20
+ };
21
+ text_contrast_high: {
22
+ color: string;
23
+ };
24
+ text_inverted: {
25
+ color: string;
26
+ };
27
+ bg: {
28
+ backgroundColor: string;
29
+ };
30
+ bg_contrast_25: {
31
+ backgroundColor: string;
32
+ };
33
+ bg_contrast_50: {
34
+ backgroundColor: string;
35
+ };
36
+ bg_contrast_100: {
37
+ backgroundColor: string;
38
+ };
39
+ bg_contrast_200: {
40
+ backgroundColor: string;
41
+ };
42
+ bg_contrast_300: {
43
+ backgroundColor: string;
44
+ };
45
+ bg_contrast_400: {
46
+ backgroundColor: string;
47
+ };
48
+ bg_contrast_500: {
49
+ backgroundColor: string;
50
+ };
51
+ bg_contrast_600: {
52
+ backgroundColor: string;
53
+ };
54
+ bg_contrast_700: {
55
+ backgroundColor: string;
56
+ };
57
+ bg_contrast_800: {
58
+ backgroundColor: string;
59
+ };
60
+ bg_contrast_900: {
61
+ backgroundColor: string;
62
+ };
63
+ bg_contrast_950: {
64
+ backgroundColor: string;
65
+ };
66
+ bg_contrast_975: {
67
+ backgroundColor: string;
68
+ };
69
+ border_contrast_low: {
70
+ borderColor: string;
71
+ };
72
+ border_contrast_medium: {
73
+ borderColor: string;
74
+ };
75
+ border_contrast_high: {
76
+ borderColor: string;
77
+ };
78
+ shadow_sm: ShadowStyle;
79
+ shadow_md: ShadowStyle;
80
+ shadow_lg: ShadowStyle;
81
+ };
82
+
83
+ /**
84
+ * Categorical representation of the theme
85
+ */
86
+ export type ThemeScheme = "light" | "dark";
87
+
88
+ /**
89
+ * Specific theme name, including low-contrast variants
90
+ */
91
+ export type ThemeName = "light" | "dark";
92
+
93
+ /**
94
+ * A theme object, containing the color palette and atoms for the theme
95
+ */
96
+ export type Theme = {
97
+ scheme: ThemeScheme;
98
+ name: ThemeName;
99
+ palette: Palette;
100
+ atoms: ThemeAtoms;
101
+ };
102
+
103
+ export function createTheme({
104
+ scheme,
105
+ name,
106
+ palette,
107
+ options = {},
108
+ }: {
109
+ scheme: ThemeScheme;
110
+ name: ThemeName;
111
+ palette: Palette;
112
+ options?: {
113
+ shadowOpacity?: number;
114
+ };
115
+ }): Theme {
116
+ const shadowOpacity = options.shadowOpacity ?? 0.1;
117
+ const shadowColor = alpha(palette.black, shadowOpacity);
118
+ return {
119
+ scheme,
120
+ name,
121
+ palette,
122
+ atoms: {
123
+ text: {
124
+ color: palette.contrast_1000,
125
+ },
126
+ text_contrast_low: {
127
+ color: palette.contrast_400,
128
+ },
129
+ text_contrast_medium: {
130
+ color: palette.contrast_700,
131
+ },
132
+ text_contrast_high: {
133
+ color: palette.contrast_900,
134
+ },
135
+ text_inverted: {
136
+ color: palette.contrast_0,
137
+ },
138
+ bg: {
139
+ backgroundColor: palette.contrast_0,
140
+ },
141
+ bg_contrast_25: {
142
+ backgroundColor: palette.contrast_25,
143
+ },
144
+ bg_contrast_50: {
145
+ backgroundColor: palette.contrast_50,
146
+ },
147
+ bg_contrast_100: {
148
+ backgroundColor: palette.contrast_100,
149
+ },
150
+ bg_contrast_200: {
151
+ backgroundColor: palette.contrast_200,
152
+ },
153
+ bg_contrast_300: {
154
+ backgroundColor: palette.contrast_300,
155
+ },
156
+ bg_contrast_400: {
157
+ backgroundColor: palette.contrast_400,
158
+ },
159
+ bg_contrast_500: {
160
+ backgroundColor: palette.contrast_500,
161
+ },
162
+ bg_contrast_600: {
163
+ backgroundColor: palette.contrast_600,
164
+ },
165
+ bg_contrast_700: {
166
+ backgroundColor: palette.contrast_700,
167
+ },
168
+ bg_contrast_800: {
169
+ backgroundColor: palette.contrast_800,
170
+ },
171
+ bg_contrast_900: {
172
+ backgroundColor: palette.contrast_900,
173
+ },
174
+ bg_contrast_950: {
175
+ backgroundColor: palette.contrast_950,
176
+ },
177
+ bg_contrast_975: {
178
+ backgroundColor: palette.contrast_975,
179
+ },
180
+ border_contrast_low: {
181
+ borderColor: palette.contrast_100,
182
+ },
183
+ border_contrast_medium: {
184
+ borderColor: palette.contrast_200,
185
+ },
186
+ border_contrast_high: {
187
+ borderColor: palette.contrast_300,
188
+ },
189
+ shadow_sm: {
190
+ ...atoms.shadow_sm,
191
+ shadowColor: palette.black,
192
+ boxShadow: `0 4px 6px -1px ${shadowColor}, 0 2px 4px -2px ${shadowColor}`,
193
+ },
194
+ shadow_md: {
195
+ ...atoms.shadow_md,
196
+ shadowColor: palette.black,
197
+ boxShadow: `0 10px 15px -3px ${shadowColor}, 0 4px 6px -4px ${shadowColor}`,
198
+ },
199
+ shadow_lg: {
200
+ ...atoms.shadow_lg,
201
+ shadowColor: palette.black,
202
+ boxShadow: `0 20px 25px -5px ${shadowColor}, 0 8px 10px -6px ${shadowColor}`,
203
+ },
204
+ },
205
+ };
206
+ }
207
+
208
+ export function createThemes({ defaultPalette }: { defaultPalette: Palette }): {
209
+ light: Theme;
210
+ dark: Theme;
211
+ } {
212
+ const light = createTheme({
213
+ scheme: "light",
214
+ name: "light",
215
+ palette: defaultPalette,
216
+ });
217
+
218
+ const dark = createTheme({
219
+ scheme: "dark",
220
+ name: "dark",
221
+ palette: invertPalette(defaultPalette),
222
+ options: {
223
+ shadowOpacity: 0.4,
224
+ },
225
+ });
226
+
227
+ return {
228
+ light,
229
+ dark,
230
+ };
231
+ }
package/src/tokens.ts CHANGED
@@ -38,6 +38,7 @@ export const borderRadius = {
38
38
  sm: 8,
39
39
  md: 12,
40
40
  lg: 16,
41
+ xl: 20,
41
42
  full: 999,
42
43
  } as const;
43
44
 
@@ -1,3 +1,7 @@
1
+ import { StyleSheet } from "react-native";
2
+
1
3
  export * from "./alpha";
2
4
  export * from "./leading";
3
- export * from "./flatten";
5
+ export * from "./select";
6
+
7
+ export const flatten = StyleSheet.flatten;
@@ -1,12 +1,10 @@
1
1
  import { type TextStyle } from "react-native";
2
2
 
3
- import { isWeb } from "../platform";
4
3
  import * as tokens from "../tokens";
5
4
 
6
5
  /**
7
6
  * Util to calculate lineHeight from a text size atom and a leading atom (which
8
- * are unitless). On native, this will evaluate to a rounded pixel value. On
9
- * web, it will be a unitless string.
7
+ * are unitless). this will evaluate to a rounded pixel value.
10
8
  *
11
9
  * Example:
12
10
  * `leading({
@@ -17,14 +15,8 @@ import * as tokens from "../tokens";
17
15
  export function leading(textStyle: TextStyle): Pick<TextStyle, "lineHeight"> {
18
16
  const lineHeight = textStyle?.lineHeight || tokens.lineHeight.snug;
19
17
 
20
- if (isWeb) {
21
- return {
22
- lineHeight: String(lineHeight) as unknown as TextStyle["lineHeight"],
23
- };
24
- } else {
25
- const size = textStyle?.fontSize || tokens.fontSize.sm;
26
- return {
27
- lineHeight: Math.round(size * lineHeight),
28
- };
29
- }
18
+ const size = textStyle?.fontSize || tokens.fontSize.sm;
19
+ return {
20
+ lineHeight: Math.round(size * lineHeight),
21
+ };
30
22
  }
@@ -0,0 +1,17 @@
1
+ import { type ThemeName } from "../themes";
2
+
3
+ export function select<T>(
4
+ name: ThemeName,
5
+ options:
6
+ | (Record<ThemeName, T> & { default?: undefined })
7
+ | (Partial<Record<ThemeName, T>> & { default: T }),
8
+ ): T {
9
+ switch (name) {
10
+ case "light":
11
+ return options.light as T;
12
+ case "dark":
13
+ return options.dark as T;
14
+ default:
15
+ return options.default as T;
16
+ }
17
+ }