@tujyane/alf 1.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 (87) hide show
  1. package/README.md +226 -0
  2. package/dist/atoms/common.d.ts +992 -0
  3. package/dist/atoms/common.d.ts.map +1 -0
  4. package/dist/atoms/common.js +1067 -0
  5. package/dist/atoms/common.js.map +1 -0
  6. package/dist/atoms/index.d.ts +2 -0
  7. package/dist/atoms/index.d.ts.map +1 -0
  8. package/dist/atoms/index.js +18 -0
  9. package/dist/atoms/index.js.map +1 -0
  10. package/dist/atoms/index.native.d.ts +1020 -0
  11. package/dist/atoms/index.native.d.ts.map +1 -0
  12. package/dist/atoms/index.native.js +119 -0
  13. package/dist/atoms/index.native.js.map +1 -0
  14. package/dist/atoms/types.d.ts +3 -0
  15. package/dist/atoms/types.d.ts.map +1 -0
  16. package/dist/atoms/types.js +3 -0
  17. package/dist/atoms/types.js.map +1 -0
  18. package/dist/index.d.ts +23 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +64 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/palette.d.ts +72 -0
  23. package/dist/palette.d.ts.map +1 -0
  24. package/dist/palette.js +152 -0
  25. package/dist/palette.js.map +1 -0
  26. package/dist/platform/index.d.ts +45 -0
  27. package/dist/platform/index.d.ts.map +1 -0
  28. package/dist/platform/index.js +55 -0
  29. package/dist/platform/index.js.map +1 -0
  30. package/dist/platform/index.native.d.ts +16 -0
  31. package/dist/platform/index.native.d.ts.map +1 -0
  32. package/dist/platform/index.native.js +20 -0
  33. package/dist/platform/index.native.js.map +1 -0
  34. package/dist/themes.d.ts +151 -0
  35. package/dist/themes.d.ts.map +1 -0
  36. package/dist/themes.js +191 -0
  37. package/dist/themes.js.map +1 -0
  38. package/dist/tokens.d.ts +49 -0
  39. package/dist/tokens.d.ts.map +1 -0
  40. package/dist/tokens.js +52 -0
  41. package/dist/tokens.js.map +1 -0
  42. package/dist/utils/alpha.d.ts +2 -0
  43. package/dist/utils/alpha.d.ts.map +1 -0
  44. package/dist/utils/alpha.js +30 -0
  45. package/dist/utils/alpha.js.map +1 -0
  46. package/dist/utils/flatten/index.d.ts +3 -0
  47. package/dist/utils/flatten/index.d.ts.map +1 -0
  48. package/dist/utils/flatten/index.js +9 -0
  49. package/dist/utils/flatten/index.js.map +1 -0
  50. package/dist/utils/flatten/index.native.d.ts +3 -0
  51. package/dist/utils/flatten/index.native.d.ts.map +1 -0
  52. package/dist/utils/flatten/index.native.js +6 -0
  53. package/dist/utils/flatten/index.native.js.map +1 -0
  54. package/dist/utils/flatten/index.web.d.ts +3 -0
  55. package/dist/utils/flatten/index.web.d.ts.map +1 -0
  56. package/dist/utils/flatten/index.web.js +6 -0
  57. package/dist/utils/flatten/index.web.js.map +1 -0
  58. package/dist/utils/index.d.ts +5 -0
  59. package/dist/utils/index.d.ts.map +1 -0
  60. package/dist/utils/index.js +21 -0
  61. package/dist/utils/index.js.map +1 -0
  62. package/dist/utils/leading.d.ts +14 -0
  63. package/dist/utils/leading.d.ts.map +1 -0
  64. package/dist/utils/leading.js +64 -0
  65. package/dist/utils/leading.js.map +1 -0
  66. package/dist/utils/select.d.ts +7 -0
  67. package/dist/utils/select.d.ts.map +1 -0
  68. package/dist/utils/select.js +16 -0
  69. package/dist/utils/select.js.map +1 -0
  70. package/package.json +45 -0
  71. package/src/atoms/common.ts +1049 -0
  72. package/src/atoms/index.native.ts +84 -0
  73. package/src/atoms/index.ts +1 -0
  74. package/src/atoms/types.ts +11 -0
  75. package/src/index.tsx +46 -0
  76. package/src/palette.ts +237 -0
  77. package/src/platform/index.native.ts +16 -0
  78. package/src/platform/index.ts +54 -0
  79. package/src/themes.ts +332 -0
  80. package/src/tokens.ts +54 -0
  81. package/src/utils/alpha.ts +25 -0
  82. package/src/utils/flatten/index.native.ts +3 -0
  83. package/src/utils/flatten/index.ts +8 -0
  84. package/src/utils/flatten/index.web.ts +3 -0
  85. package/src/utils/index.ts +4 -0
  86. package/src/utils/leading.ts +30 -0
  87. package/src/utils/select.ts +19 -0
@@ -0,0 +1,84 @@
1
+ import { StyleSheet } from "react-native";
2
+
3
+ import * as common from "./common";
4
+ import { ios, isFabric } from "../platform";
5
+
6
+ export const atoms = {
7
+ ...common.atoms,
8
+ fixed: {
9
+ position: "absolute",
10
+ },
11
+ sticky: {},
12
+ overflow_auto: {},
13
+ flex_0: {
14
+ flex: 0,
15
+ },
16
+ border: {
17
+ borderWidth: StyleSheet.hairlineWidth,
18
+ },
19
+ border_t: {
20
+ borderTopWidth: StyleSheet.hairlineWidth,
21
+ },
22
+ border_b: {
23
+ borderBottomWidth: StyleSheet.hairlineWidth,
24
+ },
25
+ border_l: {
26
+ borderLeftWidth: StyleSheet.hairlineWidth,
27
+ },
28
+ border_r: {
29
+ borderRightWidth: StyleSheet.hairlineWidth,
30
+ },
31
+ border_x: {
32
+ borderLeftWidth: StyleSheet.hairlineWidth,
33
+ borderRightWidth: StyleSheet.hairlineWidth,
34
+ },
35
+ border_y: {
36
+ borderTopWidth: StyleSheet.hairlineWidth,
37
+ borderBottomWidth: StyleSheet.hairlineWidth,
38
+ },
39
+ border_transparent: {
40
+ borderColor: "transparent",
41
+ },
42
+ curve_circular: ios({
43
+ borderCurve: "circular",
44
+ }),
45
+ curve_continuous: ios({
46
+ borderCurve: "continuous",
47
+ }),
48
+ shadow_sm: isFabric
49
+ ? {}
50
+ : {
51
+ shadowRadius: 4,
52
+ shadowOpacity: 0.1,
53
+ elevation: 8,
54
+ shadowOffset: {
55
+ width: 0,
56
+ height: 4,
57
+ },
58
+ },
59
+ shadow_md: isFabric
60
+ ? {}
61
+ : {
62
+ shadowRadius: 8,
63
+ shadowOpacity: 0.1,
64
+ elevation: 16,
65
+ shadowOffset: {
66
+ width: 0,
67
+ height: 8,
68
+ },
69
+ },
70
+ shadow_lg: isFabric
71
+ ? {}
72
+ : {
73
+ shadowRadius: 16,
74
+ shadowOpacity: 0.1,
75
+ elevation: 32,
76
+ shadowOffset: {
77
+ width: 0,
78
+ height: 16,
79
+ },
80
+ },
81
+ inline: {},
82
+ block: {},
83
+ pointer: {},
84
+ } as const;
@@ -0,0 +1 @@
1
+ export * from "./common";
@@ -0,0 +1,11 @@
1
+ import { type ViewStyle } from "react-native";
2
+
3
+ export type ShadowStyle = Pick<
4
+ ViewStyle,
5
+ | "shadowColor"
6
+ | "shadowOpacity"
7
+ | "shadowRadius"
8
+ | "elevation"
9
+ | "shadowOffset"
10
+ | "boxShadow"
11
+ >;
package/src/index.tsx ADDED
@@ -0,0 +1,46 @@
1
+ import { type StyleProp, type TextStyle, type ViewStyle } from "react-native";
2
+ import { createContext, useContext, useMemo } from "react";
3
+
4
+ import { themes, type Theme } from "./themes";
5
+
6
+ export * from "./atoms";
7
+ export * from "./palette";
8
+ export * from "./themes";
9
+ export * from "./platform";
10
+ export * as tokens from "./tokens";
11
+ export * as utils from "./utils";
12
+
13
+ export type TextStyleProp = {
14
+ style?: StyleProp<TextStyle>;
15
+ };
16
+
17
+ export type ViewStyleProp = {
18
+ style?: StyleProp<ViewStyle>;
19
+ };
20
+
21
+ export const Context = createContext({
22
+ theme: themes.light,
23
+ });
24
+ Context.displayName = "AlfContext";
25
+
26
+ export function Provider<T extends string, A extends Record<T, Theme>>({
27
+ children,
28
+ activeTheme,
29
+ themes,
30
+ }: React.PropsWithChildren<{
31
+ activeTheme: T;
32
+ themes: A;
33
+ }>) {
34
+ const value = useMemo(
35
+ () => ({
36
+ theme: themes[activeTheme],
37
+ }),
38
+ [activeTheme, themes]
39
+ );
40
+
41
+ return <Context.Provider value={value}>{children}</Context.Provider>;
42
+ }
43
+
44
+ export function useTheme() {
45
+ return useContext(Context).theme;
46
+ }
package/src/palette.ts ADDED
@@ -0,0 +1,237 @@
1
+ export type Palette = {
2
+ white: string;
3
+ black: string;
4
+ like: string;
5
+
6
+ primary_25: string;
7
+ primary_50: string;
8
+ primary_100: string;
9
+ primary_200: string;
10
+ primary_300: string;
11
+ primary_400: string;
12
+ primary_500: string;
13
+ primary_600: string;
14
+ primary_700: string;
15
+ primary_800: string;
16
+ primary_900: string;
17
+
18
+ positive_25: string;
19
+ positive_50: string;
20
+ positive_100: string;
21
+ positive_200: string;
22
+ positive_300: string;
23
+ positive_400: string;
24
+ positive_500: string;
25
+ positive_600: string;
26
+ positive_700: string;
27
+ positive_800: string;
28
+ positive_900: string;
29
+ positive_950: string;
30
+ positive_975: string;
31
+
32
+ negative_25: string;
33
+ negative_50: string;
34
+ negative_100: string;
35
+ negative_200: string;
36
+ negative_300: string;
37
+ negative_400: string;
38
+ negative_500: string;
39
+ negative_600: string;
40
+ negative_700: string;
41
+ negative_800: string;
42
+ negative_900: string;
43
+ negative_950: string;
44
+ negative_975: string;
45
+
46
+ // Additional semantic scales
47
+ warning_100: string;
48
+ warning_200: string;
49
+ warning_300: string;
50
+ warning_400: string;
51
+ warning_500: string;
52
+ warning_600: string;
53
+ warning_700: string;
54
+ warning_800: string;
55
+ warning_900: string;
56
+
57
+ info_100: string;
58
+ info_200: string;
59
+ info_300: string;
60
+ info_400: string;
61
+ info_500: string;
62
+ info_600: string;
63
+ info_700: string;
64
+ info_800: string;
65
+ info_900: string;
66
+
67
+ secondary_100: string;
68
+ secondary_200: string;
69
+ secondary_300: string;
70
+ secondary_400: string;
71
+ secondary_500: string;
72
+ secondary_600: string;
73
+ secondary_700: string;
74
+ secondary_800: string;
75
+ secondary_900: string;
76
+ };
77
+
78
+ export const DEFAULT_PALETTE: Palette = {
79
+ white: "#FFFFFF",
80
+ black: "#000000",
81
+ like: "#EC4899",
82
+
83
+ // Primary
84
+ primary_25: "#F9FAFB",
85
+ primary_50: "#EFF2F6",
86
+ primary_100: "#0E64FD",
87
+ primary_200: "#AC58FC",
88
+ primary_300: "#834875",
89
+ primary_400: "#853671",
90
+ primary_500: "#356353",
91
+ primary_600: "#264626",
92
+ primary_700: "#143747",
93
+ primary_800: "#102537",
94
+ primary_900: "#04060F",
95
+
96
+ // Success
97
+ positive_25: "#ECFEF5",
98
+ positive_50: "#D3FDE8",
99
+ positive_100: "#F9FC02",
100
+ positive_200: "#EBAA6",
101
+ positive_300: "#03F179",
102
+ positive_400: "#1C1445",
103
+ positive_500: "#2C0323",
104
+ positive_600: "#778519",
105
+ positive_700: "#858711",
106
+ positive_800: "#407008",
107
+ positive_900: "#886506",
108
+ positive_950: "#032A17",
109
+ positive_975: "#021D0F",
110
+
111
+ // Error
112
+ negative_25: "#FFF5F7",
113
+ negative_50: "#FEE7EC",
114
+ negative_100: "#FFD73",
115
+ negative_200: "#FC646",
116
+ negative_300: "#F74274",
117
+ negative_400: "#FF7559",
118
+ negative_500: "#F74423",
119
+ negative_600: "#0B2799",
120
+ negative_700: "#871112",
121
+ negative_800: "#930118",
122
+ negative_900: "#7A0619",
123
+ negative_950: "#430413",
124
+ negative_975: "#30030D",
125
+
126
+ // Warning
127
+ warning_100: "#FFE207",
128
+ warning_200: "#7FEF80",
129
+ warning_300: "#F16486",
130
+ warning_400: "#F03688",
131
+ warning_500: "#FFC72A",
132
+ warning_600: "#0F432A",
133
+ warning_700: "#973210",
134
+ warning_800: "#953213",
135
+ warning_900: "#7A0108",
136
+
137
+ // Info
138
+ info_100: "#0C53FF",
139
+ info_200: "#BA85FF",
140
+ info_300: "#9603FF",
141
+ info_400: "#7EC2FF",
142
+ info_500: "#5448FF",
143
+ info_600: "#258058",
144
+ info_700: "#2A4669",
145
+ info_800: "#144393",
146
+ info_900: "#1032FA",
147
+
148
+ // Secondary
149
+ secondary_100: "#EC6744",
150
+ secondary_200: "#C52463",
151
+ secondary_300: "#00438F",
152
+ secondary_400: "#569750",
153
+ secondary_500: "#F450CC",
154
+ secondary_600: "#131835",
155
+ secondary_700: "#DD171F",
156
+ secondary_800: "#05CC19",
157
+ secondary_900: "#640815",
158
+ };
159
+
160
+ export function invertPalette(palette: Palette): Palette {
161
+ return {
162
+ white: palette.white,
163
+ black: palette.black,
164
+ like: palette.like,
165
+
166
+ primary_25: palette.primary_50,
167
+ primary_50: palette.primary_25,
168
+ primary_100: palette.primary_900,
169
+ primary_200: palette.primary_800,
170
+ primary_300: palette.primary_700,
171
+ primary_400: palette.primary_600,
172
+ primary_500: palette.primary_500,
173
+ primary_600: palette.primary_400,
174
+ primary_700: palette.primary_300,
175
+ primary_800: palette.primary_200,
176
+ primary_900: palette.primary_100,
177
+
178
+ positive_25: palette.positive_975,
179
+ positive_50: palette.positive_950,
180
+ positive_100: palette.positive_900,
181
+ positive_200: palette.positive_800,
182
+ positive_300: palette.positive_700,
183
+ positive_400: palette.positive_600,
184
+ positive_500: palette.positive_500,
185
+ positive_600: palette.positive_400,
186
+ positive_700: palette.positive_300,
187
+ positive_800: palette.positive_200,
188
+ positive_900: palette.positive_100,
189
+ positive_950: palette.positive_50,
190
+ positive_975: palette.positive_25,
191
+
192
+ negative_25: palette.negative_975,
193
+ negative_50: palette.negative_950,
194
+ negative_100: palette.negative_900,
195
+ negative_200: palette.negative_800,
196
+ negative_300: palette.negative_700,
197
+ negative_400: palette.negative_600,
198
+ negative_500: palette.negative_500,
199
+ negative_600: palette.negative_400,
200
+ negative_700: palette.negative_300,
201
+ negative_800: palette.negative_200,
202
+ negative_900: palette.negative_100,
203
+ negative_950: palette.negative_50,
204
+ negative_975: palette.negative_25,
205
+
206
+ // New scales invert
207
+ warning_100: palette.warning_900,
208
+ warning_200: palette.warning_800,
209
+ warning_300: palette.warning_700,
210
+ warning_400: palette.warning_600,
211
+ warning_500: palette.warning_500,
212
+ warning_600: palette.warning_400,
213
+ warning_700: palette.warning_300,
214
+ warning_800: palette.warning_200,
215
+ warning_900: palette.warning_100,
216
+
217
+ info_100: palette.info_900,
218
+ info_200: palette.info_800,
219
+ info_300: palette.info_700,
220
+ info_400: palette.info_600,
221
+ info_500: palette.info_500,
222
+ info_600: palette.info_400,
223
+ info_700: palette.info_300,
224
+ info_800: palette.info_200,
225
+ info_900: palette.info_100,
226
+
227
+ secondary_100: palette.secondary_900,
228
+ secondary_200: palette.secondary_800,
229
+ secondary_300: palette.secondary_700,
230
+ secondary_400: palette.secondary_600,
231
+ secondary_500: palette.secondary_500,
232
+ secondary_600: palette.secondary_400,
233
+ secondary_700: palette.secondary_300,
234
+ secondary_800: palette.secondary_200,
235
+ secondary_900: palette.secondary_100,
236
+ };
237
+ }
@@ -0,0 +1,16 @@
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;
6
+ export const isWeb = false;
7
+
8
+ // @ts-ignore
9
+ export const isFabric = Boolean(global?.nativeFabricUIManager);
10
+
11
+ export const web = (value: any) => (isWeb ? value : undefined);
12
+ export const ios = (value: any) => (isIOS ? value : undefined);
13
+ export const android = (value: any) => (isAndroid ? value : undefined);
14
+ export const native = (value: any) => (isNative ? value : undefined);
15
+
16
+ export const platform = Platform.select;
@@ -0,0 +1,54 @@
1
+ import { type Platform } from "react-native";
2
+
3
+ export const isIOS = false;
4
+ export const isAndroid = false;
5
+ export const isNative = false;
6
+ export const isWeb = true;
7
+ // @ts-ignore
8
+ export const isFabric = Boolean(global?.nativeFabricUIManager);
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
+ 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
+ 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
+ export const native = (value: any) => (isNative ? value : undefined);
45
+
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"];