@atomazing-org/design-system 1.0.70 → 1.0.72

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