@atomazing-org/design-system 1.0.73 → 1.0.74

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/README.MD CHANGED
@@ -1,277 +1,345 @@
1
- @atomazing-org/design-system
2
-
3
- Modern MUI + Emotion design system with a ready theme factory, extended typography, global styles, component overrides, animations, and handy utilities.
4
-
5
- Contents
6
- - Introduction
7
- - Installation
8
- - Quick Start
9
- - Provider Props
10
- - Dynamic Themes (array)
11
- - Theme Switching (UI)
12
- - Dark Mode Control
13
- - Extended Palette (4 variants)
14
- - Palette Overrides
15
- - Using Palette In SX
16
- - Typography Variants
17
- - Global Styles
18
- - Animations
19
- - Components
20
- - Utilities
21
- - SSR Notes
22
- - Peer Dependencies
23
-
24
- Introduction
25
- The package streamlines consistent theming across apps: dark/light mode, typography variants, global styles, and component defaults. Built on MUI v7 + Emotion.
26
-
27
- Installation
28
- ```bash
29
- npm install @atomazing-org/design-system
30
- npm install @mui/material @mui/icons-material @emotion/react @emotion/styled @emotion/css
31
- ```
32
-
33
- Quick Start
34
- ```tsx
35
- import { ThemeProviderWrapper } from '@atomazing-org/design-system';
36
-
37
- export function App() {
38
- return (
39
- <ThemeProviderWrapper>
40
- {/* your app */}
41
- </ThemeProviderWrapper>
42
- );
43
- }
44
- ```
45
-
46
- If `themes` is not provided, the provider falls back to a single "Default" theme using the current palette brand color.
47
-
48
- Provider Props
49
- - `themes?: { name: string; primaryColor: string; secondaryColor?: string }[]`
50
- - `fontFamily?: string`
51
- - `colorPaletteOverride?: Partial<ColorPaletteType>`
52
-
53
- Dynamic Themes (array)
54
- Provide a fully dynamic list of themes to the provider. This takes priority over static defaults.
55
-
56
- ```tsx
57
- <ThemeProviderWrapper
58
- themes={[
59
- { name: 'Blue', primaryColor: '#3B82F6' },
60
- {
61
- name: 'Aurora',
62
- primaryColor: '#00E952',
63
- secondaryColor: '#011926',
64
- background: {
65
- light: { default: '#F0FFF6', paper: '#FFFFFF' },
66
- dark: { default: '#071B13', paper: '#0E2A1F' },
67
- },
68
- },
69
- { name: 'Gray', primaryColor: '#64748B' },
70
- ]}
71
- >
72
- {/* ... */}
73
- </ThemeProviderWrapper>
74
- ```
75
-
76
- Theme Switching (UI)
77
- Use the theme context to read and change the active theme.
78
-
79
- ```tsx
80
- import { useThemeSettings } from '@atomazing-org/design-system';
81
- import { ToggleButton, ToggleButtonGroup } from '@mui/material';
82
-
83
- export function ThemeToggle() {
84
- const { theme, setTheme } = useThemeSettings();
85
- const options = ['Blue', 'Green', 'Gray'];
86
-
87
- return (
88
- <ToggleButtonGroup
89
- size="small"
90
- exclusive
91
- color="brand"
92
- value={theme}
93
- onChange={(_, v) => v && setTheme(v)}
94
- >
95
- {options.map((o) => (
96
- <ToggleButton key={o} value={o}>{o}</ToggleButton>
97
- ))}
98
- </ToggleButtonGroup>
99
- );
100
- }
101
- ```
102
-
103
- Dark Mode Control
104
- Use `useThemeSettings()` to read and set dark mode. Modes: `light | dark | system | auto`.
105
-
106
- ```tsx
107
- import { useThemeSettings, darkModeOptions } from '@atomazing-org/design-system';
108
- import { RadioGroup, FormControlLabel, Radio } from '@mui/material';
109
-
110
- export function DarkModeSelector() {
111
- const { darkMode, setDarkMode } = useThemeSettings();
112
- const options = darkModeOptions; // label + icon
113
-
114
- return (
115
- <RadioGroup
116
- row
117
- value={darkMode}
118
- onChange={(e) => setDarkMode(e.target.value as any)}
119
- >
120
- {options.map((o) => (
121
- <FormControlLabel key={o.value} value={o.value} control={<Radio />} label={o.label} />
122
- ))}
123
- </RadioGroup>
124
- );
125
- }
126
- ```
127
-
128
- Extended Palette (4 variants)
129
- The design system adds four typed colors to the MUI palette, available on common components via the `color` prop:
130
-
131
- - brand: project brand color (uses the active theme `primary`).
132
- - neutral: neutral/gray scale color (from the design-system palette).
133
- - accent: supporting accent color (from palette `accent`).
134
- - muted: soft/desaturated color (based on neutral by default).
135
-
136
- Supported components: `Button`, `Chip`, `Badge`, `Alert`.
137
-
138
- ```tsx
139
- import { Button, Chip, Alert } from '@mui/material';
140
-
141
- <Button color="brand" variant="contained">Brand</Button>
142
- <Button color="neutral" variant="outlined">Neutral</Button>
143
- <Chip color="accent" label="Accent" />
144
- <Alert color="muted" variant="filled">Muted Alert</Alert>
145
- ```
146
-
147
- Palette Overrides
148
- Override base palette tokens for the whole app.
149
-
150
- ```tsx
151
- <ThemeProviderWrapper
152
- colorPaletteOverride={{
153
- brand: '#4F46E5',
154
- accent: '#F59E0B',
155
- muted: '#94A3B8',
156
- neutral: '#64748B',
157
- success: '#16A34A',
158
- warning: '#D97706',
159
- error: '#DC2626',
160
- info: '#0284C7',
161
- }}
162
- >
163
- {/* ... */}
164
- </ThemeProviderWrapper>
165
- ```
166
-
167
- Using Palette In SX
168
- ```tsx
169
- import { Box } from '@mui/material';
170
-
171
- <Box sx={{ bgcolor: (t) => t.palette.accent.main, color: (t) => t.palette.getContrastText(t.palette.accent.main) }}>
172
- Accent surface
173
- </Box>
174
- ```
175
-
176
- Typography Variants
177
- Extra variants are available (mapping to `<p>`/headers). Examples:
178
-
179
- ```tsx
180
- import { Typography } from '@mui/material';
181
-
182
- <Typography variant="text_md_regular">Body text</Typography>
183
- <Typography variant="text_sm_bold">Strong caption</Typography>
184
- <Typography variant="header_lg_bold">Section Title</Typography>
185
- <Typography variant="header_md_semibold">Semibold Heading</Typography>
186
- ```
187
-
188
- Global Styles
189
- `ThemeProviderWrapper` injects global styles via Emotion. You can also set a custom font family:
190
-
191
- ```tsx
192
- <ThemeProviderWrapper fontFamily="Inter, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif">
193
- {/* ... */}
194
- </ThemeProviderWrapper>
195
- ```
196
-
197
- Animations
198
- Keyframes ready for use in Emotion/MUI `sx`:
199
-
200
- ```tsx
201
- import { keyframes } from '@emotion/react';
202
- import { fadeIn, slideIn, scale, pulseAnimation, progressPulse } from '@atomazing-org/design-system';
203
- import styled from '@emotion/styled';
204
-
205
- const Card = styled.div`
206
- animation: ${fadeIn} 300ms ease-in both;
207
- `;
208
-
209
- const Glowing = styled.div`
210
- animation: ${progressPulse('#9FA9EA')} 2s ease-in-out infinite;
211
- `;
212
- ```
213
-
214
- Components
215
- - ErrorBoundary
216
- ```tsx
217
- import { ErrorBoundary } from '@atomazing-org/design-system';
218
-
219
- <ErrorBoundary>
220
- <App />
221
- </ErrorBoundary>
222
- ```
223
-
224
- - Loading
225
- ```tsx
226
- import { Loading } from '@atomazing-org/design-system';
227
-
228
- <Loading />
229
- ```
230
-
231
- - PathName / DialogBtn
232
- ```tsx
233
- import { PathName, DialogBtn } from '@atomazing-org/design-system';
234
-
235
- <PathName>/settings/profile</PathName>
236
- <DialogBtn variant="contained" color="brand">OK</DialogBtn>
237
- ```
238
-
239
- Utilities
240
- ```tsx
241
- import {
242
- getFontColor, isFontLight, isHexColor,
243
- timeAgo, timeAgoFromStart,
244
- useResponsiveDisplay, useSystemTheme,
245
- displayGreeting, getDayIdentifier,
246
- systemInfo,
247
- } from '@atomazing-org/design-system';
248
-
249
- // Colors
250
- getFontColor('#ffffff'); // '#101727' | '#f0f0f0'
251
- isFontLight('#222');
252
- isHexColor('#abc');
253
-
254
- // Time
255
- timeAgo(new Date(Date.now() - 3600_000));
256
- timeAgoFromStart(new Date(Date.now() + 90_000));
257
-
258
- // Device
259
- const isMobile = useResponsiveDisplay(768);
260
- const sysTheme = useSystemTheme(); // 'light' | 'dark' | 'unknown'
261
-
262
- // Misc
263
- displayGreeting(); // Good morning / afternoon / evening
264
- getDayIdentifier(new Date()); // 'YYYY-MM-DD'
265
- console.log(systemInfo.os, systemInfo.browser);
266
- ```
267
-
268
- SSR Notes
269
- - The library guards `localStorage`/`navigator`. Use normally in SSR apps; hydration updates settings on client.
270
- - For Next.js, place the provider in a client boundary (e.g., `layout.tsx` with `"use client"`).
271
-
272
- Peer Dependencies
273
- - `@mui/material` ^7
274
- - `@mui/icons-material` ^7
275
- - `@emotion/react` ^11
276
- - `@emotion/styled` ^11
277
- - `@emotion/css` ^11 (optional)
1
+ @atomazing-org/design-system
2
+
3
+ Modern MUI + Emotion design system with a ready theme factory, extended typography, global styles, component overrides, animations, and handy utilities.
4
+
5
+ Contents
6
+ - Introduction
7
+ - Installation
8
+ - Quick Start
9
+ - Provider Props
10
+ - Dynamic Themes (array)
11
+ - Theme Switching (UI)
12
+ - Dark Mode Control
13
+ - Extended Palette (4 variants)
14
+ - Palette Overrides
15
+ - Using Palette In SX
16
+ - Typography Variants
17
+ - Global Styles
18
+ - Animations
19
+ - Components
20
+ - Utilities
21
+ - SSR Notes
22
+ - Peer Dependencies
23
+
24
+ Introduction
25
+ The package streamlines consistent theming across apps: dark/light mode, typography variants, global styles, and component defaults. Built on MUI v7 + Emotion.
26
+
27
+ Installation
28
+ ```bash
29
+ npm install @atomazing-org/design-system
30
+ npm install @mui/material @mui/icons-material @emotion/react @emotion/styled @emotion/css
31
+ ```
32
+
33
+ Quick Start
34
+ ```tsx
35
+ import { ThemeProviderWrapper } from '@atomazing-org/design-system';
36
+
37
+ export function App() {
38
+ return (
39
+ <ThemeProviderWrapper>
40
+ {/* your app */}
41
+ </ThemeProviderWrapper>
42
+ );
43
+ }
44
+ ```
45
+
46
+ If `themes` is not provided, the provider falls back to a single "Default" theme using the current palette brand color.
47
+
48
+ Provider Props
49
+ - `themes?: ThemesProp` (single theme may omit `name`, multiple themes require `name`)
50
+ - `fontFamily?: string`
51
+ - `colorPaletteOverride?: Partial<ColorPaletteType>`
52
+ `ThemeOptions` is the MUI theme options type from `@mui/material/styles`.
53
+
54
+ Theme Names
55
+ Single theme can omit `name` (defaults to `"Default"`). Multiple themes require a non-empty `name` for each theme.
56
+
57
+ Before (single theme required a name):
58
+ ```tsx
59
+ <ThemeProviderWrapper
60
+ themes={[
61
+ {
62
+ name: 'Blue',
63
+ palette: { primary: { main: '#3B82F6' } },
64
+ },
65
+ ]}
66
+ />
67
+ ```
68
+
69
+ After (single theme name omitted):
70
+ ```tsx
71
+ <ThemeProviderWrapper
72
+ themes={[
73
+ {
74
+ palette: { primary: { main: '#3B82F6' } },
75
+ },
76
+ ]}
77
+ />
78
+ ```
79
+
80
+ Multiple themes (name required):
81
+ ```tsx
82
+ <ThemeProviderWrapper
83
+ themes={[
84
+ {
85
+ name: 'BrandA',
86
+ palette: { primary: { main: '#00A3FF' } },
87
+ },
88
+ {
89
+ name: 'BrandB',
90
+ palette: { primary: { main: '#10B981' } },
91
+ },
92
+ ]}
93
+ />
94
+ ```
95
+
96
+ Dynamic Themes (array)
97
+ Provide a fully dynamic list of `ThemeOptions` overrides. Names are required when supplying multiple themes. Provider-controlled `palette.mode` always wins.
98
+
99
+ Minimal example (primary color only):
100
+ ```tsx
101
+ <ThemeProviderWrapper
102
+ themes={[
103
+ {
104
+ name: 'Blue',
105
+ palette: {
106
+ primary: { main: '#3B82F6' },
107
+ },
108
+ },
109
+ ]}
110
+ >
111
+ {/* ... */}
112
+ </ThemeProviderWrapper>
113
+ ```
114
+
115
+ Advanced example (palette + components overrides):
116
+ ```tsx
117
+ <ThemeProviderWrapper
118
+ themes={[
119
+ {
120
+ name: 'BrandA',
121
+ palette: {
122
+ primary: { main: '#00A3FF' },
123
+ background: { default: '#F7FAFF', paper: '#FFFFFF' },
124
+ },
125
+ components: {
126
+ MuiButton: {
127
+ styleOverrides: {
128
+ root: { textTransform: 'none' },
129
+ },
130
+ },
131
+ },
132
+ },
133
+ ]}
134
+ >
135
+ {/* ... */}
136
+ </ThemeProviderWrapper>
137
+ ```
138
+
139
+ Migration Notes (breaking)
140
+ - Legacy `themes` shape (`primaryColor`, `secondaryColor`, `background`) removed.
141
+ - `themeOverrides` prop removed.
142
+ - Use `themes: ThemesProp` for customization (single theme may omit `name`, multiple themes require `name`).
143
+
144
+ Theme Switching (UI)
145
+ Use the theme context to read and change the active theme.
146
+
147
+ ```tsx
148
+ import { useThemeSettings } from '@atomazing-org/design-system';
149
+ import { ToggleButton, ToggleButtonGroup } from '@mui/material';
150
+
151
+ export function ThemeToggle() {
152
+ const { theme, setTheme } = useThemeSettings();
153
+ const options = ['Blue', 'Green', 'Gray'];
154
+
155
+ return (
156
+ <ToggleButtonGroup
157
+ size="small"
158
+ exclusive
159
+ color="brand"
160
+ value={theme}
161
+ onChange={(_, v) => v && setTheme(v)}
162
+ >
163
+ {options.map((o) => (
164
+ <ToggleButton key={o} value={o}>{o}</ToggleButton>
165
+ ))}
166
+ </ToggleButtonGroup>
167
+ );
168
+ }
169
+ ```
170
+
171
+ Dark Mode Control
172
+ Use `useThemeSettings()` to read and set dark mode. Modes: `light | dark | system | auto`.
173
+
174
+ ```tsx
175
+ import { useThemeSettings, darkModeOptions } from '@atomazing-org/design-system';
176
+ import { RadioGroup, FormControlLabel, Radio } from '@mui/material';
177
+
178
+ export function DarkModeSelector() {
179
+ const { darkMode, setDarkMode } = useThemeSettings();
180
+ const options = darkModeOptions; // label + icon
181
+
182
+ return (
183
+ <RadioGroup
184
+ row
185
+ value={darkMode}
186
+ onChange={(e) => setDarkMode(e.target.value as any)}
187
+ >
188
+ {options.map((o) => (
189
+ <FormControlLabel key={o.value} value={o.value} control={<Radio />} label={o.label} />
190
+ ))}
191
+ </RadioGroup>
192
+ );
193
+ }
194
+ ```
195
+
196
+ Extended Palette (4 variants)
197
+ The design system adds four typed colors to the MUI palette, available on common components via the `color` prop:
198
+
199
+ - brand: project brand color (uses the active theme `primary`).
200
+ - neutral: neutral/gray scale color (from the design-system palette).
201
+ - accent: supporting accent color (from palette `accent`).
202
+ - muted: soft/desaturated color (based on neutral by default).
203
+
204
+ Supported components: `Button`, `Chip`, `Badge`, `Alert`.
205
+
206
+ ```tsx
207
+ import { Button, Chip, Alert } from '@mui/material';
208
+
209
+ <Button color="brand" variant="contained">Brand</Button>
210
+ <Button color="neutral" variant="outlined">Neutral</Button>
211
+ <Chip color="accent" label="Accent" />
212
+ <Alert color="muted" variant="filled">Muted Alert</Alert>
213
+ ```
214
+
215
+ Palette Overrides
216
+ Override base palette tokens for the whole app.
217
+
218
+ ```tsx
219
+ <ThemeProviderWrapper
220
+ colorPaletteOverride={{
221
+ brand: '#4F46E5',
222
+ accent: '#F59E0B',
223
+ muted: '#94A3B8',
224
+ neutral: '#64748B',
225
+ success: '#16A34A',
226
+ warning: '#D97706',
227
+ error: '#DC2626',
228
+ info: '#0284C7',
229
+ }}
230
+ >
231
+ {/* ... */}
232
+ </ThemeProviderWrapper>
233
+ ```
234
+
235
+ Using Palette In SX
236
+ ```tsx
237
+ import { Box } from '@mui/material';
238
+
239
+ <Box sx={{ bgcolor: (t) => t.palette.accent.main, color: (t) => t.palette.getContrastText(t.palette.accent.main) }}>
240
+ Accent surface
241
+ </Box>
242
+ ```
243
+
244
+ Typography Variants
245
+ Extra variants are available (mapping to `<p>`/headers). Examples:
246
+
247
+ ```tsx
248
+ import { Typography } from '@mui/material';
249
+
250
+ <Typography variant="text_md_regular">Body text</Typography>
251
+ <Typography variant="text_sm_bold">Strong caption</Typography>
252
+ <Typography variant="header_lg_bold">Section Title</Typography>
253
+ <Typography variant="header_md_semibold">Semibold Heading</Typography>
254
+ ```
255
+
256
+ Global Styles
257
+ `ThemeProviderWrapper` injects global styles via Emotion. You can also set a custom font family:
258
+
259
+ ```tsx
260
+ <ThemeProviderWrapper fontFamily="Inter, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif">
261
+ {/* ... */}
262
+ </ThemeProviderWrapper>
263
+ ```
264
+
265
+ Animations
266
+ Keyframes ready for use in Emotion/MUI `sx`:
267
+
268
+ ```tsx
269
+ import { keyframes } from '@emotion/react';
270
+ import { fadeIn, slideIn, scale, pulseAnimation, progressPulse } from '@atomazing-org/design-system';
271
+ import styled from '@emotion/styled';
272
+
273
+ const Card = styled.div`
274
+ animation: ${fadeIn} 300ms ease-in both;
275
+ `;
276
+
277
+ const Glowing = styled.div`
278
+ animation: ${progressPulse('#9FA9EA')} 2s ease-in-out infinite;
279
+ `;
280
+ ```
281
+
282
+ Components
283
+ - ErrorBoundary
284
+ ```tsx
285
+ import { ErrorBoundary } from '@atomazing-org/design-system';
286
+
287
+ <ErrorBoundary>
288
+ <App />
289
+ </ErrorBoundary>
290
+ ```
291
+
292
+ - Loading
293
+ ```tsx
294
+ import { Loading } from '@atomazing-org/design-system';
295
+
296
+ <Loading />
297
+ ```
298
+
299
+ - PathName / DialogBtn
300
+ ```tsx
301
+ import { PathName, DialogBtn } from '@atomazing-org/design-system';
302
+
303
+ <PathName>/settings/profile</PathName>
304
+ <DialogBtn variant="contained" color="brand">OK</DialogBtn>
305
+ ```
306
+
307
+ Utilities
308
+ ```tsx
309
+ import {
310
+ getFontColor, isFontLight, isHexColor,
311
+ timeAgo, timeAgoFromStart,
312
+ useResponsiveDisplay, useSystemTheme,
313
+ displayGreeting, getDayIdentifier,
314
+ systemInfo,
315
+ } from '@atomazing-org/design-system';
316
+
317
+ // Colors
318
+ getFontColor('#ffffff'); // '#101727' | '#f0f0f0'
319
+ isFontLight('#222');
320
+ isHexColor('#abc');
321
+
322
+ // Time
323
+ timeAgo(new Date(Date.now() - 3600_000));
324
+ timeAgoFromStart(new Date(Date.now() + 90_000));
325
+
326
+ // Device
327
+ const isMobile = useResponsiveDisplay(768);
328
+ const sysTheme = useSystemTheme(); // 'light' | 'dark' | 'unknown'
329
+
330
+ // Misc
331
+ displayGreeting(); // Good morning / afternoon / evening
332
+ getDayIdentifier(new Date()); // 'YYYY-MM-DD'
333
+ console.log(systemInfo.os, systemInfo.browser);
334
+ ```
335
+
336
+ SSR Notes
337
+ - The library guards `localStorage`/`navigator`. Use normally in SSR apps; hydration updates settings on client.
338
+ - For Next.js, place the provider in a client boundary (e.g., `layout.tsx` with `"use client"`).
339
+
340
+ Peer Dependencies
341
+ - `@mui/material` ^7
342
+ - `@mui/icons-material` ^7
343
+ - `@emotion/react` ^11
344
+ - `@emotion/styled` ^11
345
+ - `@emotion/css` ^11 (optional)