@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
package/README.md ADDED
@@ -0,0 +1,226 @@
1
+ ### Tujyane Application Layout Framework (ALF)
2
+
3
+ Modern, typed primitives for building consistent application layouts across web and React Native targets.
4
+
5
+ ## Overview
6
+
7
+ ALF provides:
8
+
9
+ - **Theme provider**: Context-driven theming with `Provider`, `useTheme`, and predefined `themes` and `palette`.
10
+ - **Atoms**: Minimal, composable building blocks exposed via `src/atoms`.
11
+ - **Tokens**: Design tokens exported as `tokens` for consistent spacing, typography, and colors.
12
+ - **Utilities**: Helper utilities like `alpha`, `leading`, `flatten`, and `select` for style composition.
13
+ - **Platform helpers**: `platform.select` wrapper and guards (`web`, `ios`, `android`, `native`) to keep code portable.
14
+
15
+ The package re-exports from `src/index.tsx` so consumers can import from a single entrypoint.
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ pnpm add @tujyane/alf
21
+ # or
22
+ npm install @tujyane/alf
23
+ # or
24
+ yarn add @tujyane/alf
25
+ ```
26
+
27
+ Peer dependencies expected:
28
+
29
+ - `react`
30
+ - `react-native` (for shared types like `ViewStyle`, even on web)
31
+
32
+ ## Quick Start
33
+
34
+ ```tsx
35
+ import { Provider, themes } from "@tujyane/alf";
36
+
37
+ export function App() {
38
+ return (
39
+ <Provider
40
+ activeTheme="light"
41
+ themes={{ light: themes.light, dark: themes.dark }}
42
+ >
43
+ {/* app routes/components */}
44
+ </Provider>
45
+ );
46
+ }
47
+ ```
48
+
49
+ Access the theme anywhere:
50
+
51
+ ```tsx
52
+ import { useTheme } from "@tujyane/alf";
53
+
54
+ export const Header = () => {
55
+ const theme = useTheme();
56
+ return (
57
+ <header style={{ backgroundColor: theme.background, color: theme.text }}>
58
+ My App
59
+ </header>
60
+ );
61
+ };
62
+ ```
63
+
64
+ ## Exports
65
+
66
+ From `src/index.tsx`:
67
+
68
+ - `Provider`: React provider to set the active theme.
69
+ - `useTheme`: Hook to read the current theme (returns `Theme` with `scheme`, `palette`, `semantic`, `atoms`).
70
+ - `Context`: Internal context (typed) for advanced usage.
71
+ - `themes`: Theme presets (`light`, `dark`).
72
+ - `palette`: Color palette helpers.
73
+ - `platform`: Platform helpers and selectors.
74
+ - `tokens`: Design tokens namespace (spacing, typography, borders).
75
+ - `utils`: Utility helpers namespace (alpha, leading, flatten, select).
76
+ - `TextStyleProp`, `ViewStyleProp`: Convenience prop types for components.
77
+ - `atoms`: All atoms from `src/atoms` are re-exported.
78
+
79
+ ## Theming
80
+
81
+ ```tsx
82
+ import { Provider, themes } from "@tujyane/alf";
83
+
84
+ type ThemeKey = "light" | "dark";
85
+
86
+ const appThemes = { light: themes.light, dark: themes.dark } as const;
87
+
88
+ export const Root = ({ children }: React.PropsWithChildren) => (
89
+ <Provider<ThemeKey, typeof appThemes> activeTheme="light" themes={appThemes}>
90
+ {children}
91
+ </Provider>
92
+ );
93
+ ```
94
+
95
+ `useTheme()` returns the active `Theme` object so you can style components consistently.
96
+
97
+ ## Design System
98
+
99
+ ### Color Scales
100
+
101
+ The framework provides semantic color scales mapped from the palette:
102
+
103
+ - **Primary** (neutral): `primary_25` through `primary_900` - used for text, backgrounds, and borders
104
+ - **Success**: `positive_100` through `positive_900` - green/success states
105
+ - **Error**: `negative_100` through `negative_900` - red/error states
106
+ - **Warning**: `warning_100` through `warning_900` - yellow/warning states
107
+ - **Info**: `info_100` through `info_900` - blue/information states
108
+ - **Secondary**: `secondary_100` through `secondary_900` - accent colors
109
+
110
+ ### Theme Atoms
111
+
112
+ Access pre-composed atoms via `theme.atoms`:
113
+
114
+ **Base (using primary neutral scale):**
115
+
116
+ - Text: `text`, `text_low`, `text_medium`, `text_high`, `text_inverted`
117
+ - Backgrounds: `bg`, `bg_25`, `bg_50`
118
+ - Borders: `border_low`, `border_medium`, `border_high`
119
+
120
+ **Semantic (using color scales):**
121
+
122
+ - Text: `text_primary`, `text_success`, `text_error`, `text_warning`, `text_info`, `text_secondary`
123
+ - Backgrounds: `bg_primary`, `bg_success`, `bg_error`, `bg_warning`, `bg_info`, `bg_secondary`
124
+ - Borders: `border_primary`, `border_success`, `border_error`, `border_warning`, `border_info`, `border_secondary`
125
+
126
+ ```tsx
127
+ import { useTheme } from "@tujyane/alf";
128
+
129
+ const Button = () => {
130
+ const theme = useTheme();
131
+ return (
132
+ <button style={{ ...theme.atoms.bg_primary, ...theme.atoms.text_inverted }}>
133
+ Click me
134
+ </button>
135
+ );
136
+ };
137
+ ```
138
+
139
+ ### Accessing Semantic Colors
140
+
141
+ ```tsx
142
+ const theme = useTheme();
143
+
144
+ // Access semantic color scales directly
145
+ const primaryColor = theme.semantic.primary[500];
146
+ const errorText = theme.semantic.error[900];
147
+ ```
148
+
149
+ ## Platform Helpers
150
+
151
+ The framework exposes safe platform helpers in `src/platform/index.ts`:
152
+
153
+ - `web(value)`, `ios(value)`, `android(value)`, `native(value)`: Return `value` on the matching platform, `undefined` otherwise.
154
+ - `platform(selectors)`: Equivalent to `Platform.select` returning the `web` option on web builds.
155
+
156
+ Usage:
157
+
158
+ ```ts
159
+ import { web, android, platform } from "@tujyane/alf";
160
+
161
+ const maybeWebOnly = web({ behavior: "sticky" });
162
+
163
+ const style = platform({
164
+ web: { cursor: "pointer" },
165
+ android: { elevation: 2 },
166
+ default: {},
167
+ });
168
+ ```
169
+
170
+ ## Utilities
171
+
172
+ Available under the `utils` namespace:
173
+
174
+ - `alpha(color, amount)`: Apply alpha to a color.
175
+ - `leading(value)`: Compute leading (line-height) helpers.
176
+ - `flatten(...)`: Flatten style arrays into a single object.
177
+ - `select(map, key)`: Safe selection helper.
178
+
179
+ Import examples:
180
+
181
+ ```ts
182
+ import { utils } from "@tujyane/alf";
183
+
184
+ const translucent = utils.alpha("#000", 0.2);
185
+ ```
186
+
187
+ ## Atoms and Types
188
+
189
+ - All atoms are re-exported from `src/atoms` via `src/atoms/index.ts`.
190
+ - Reusable types like `ShadowStyle` are defined in `src/atoms/types.ts`.
191
+
192
+ ```ts
193
+ import { ShadowStyle } from "@tujyane/alf";
194
+ ```
195
+
196
+ ## Contributing
197
+
198
+ 1. Clone the repo
199
+ 2. Install dependencies
200
+
201
+ ```bash
202
+ pnpm i
203
+ ```
204
+
205
+ 3. Build
206
+
207
+ ```bash
208
+ pnpm build
209
+ ```
210
+
211
+ 4. Develop against a local app or storybook of your choice.
212
+
213
+ ## FAQ
214
+
215
+ - Why React Native types on web?
216
+ - We use `react-native` types like `ViewStyle` for cross-platform consistency. On web, they compile to plain objects.
217
+
218
+ - How do I add new themes?
219
+ - Export them from `src/themes.ts` and pass via `Provider` as the `themes` prop.
220
+
221
+ - Can I tree-shake utilities?
222
+ - Yes, everything is module-scoped and re-exported. Use ESM imports for best results.
223
+
224
+ ## License
225
+
226
+ MIT