@atomazing-org/design-system 1.0.62 → 1.0.64
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 +268 -0
- package/dist/index.d.mts +86 -60
- package/dist/index.d.ts +86 -60
- package/dist/index.js +54 -67
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -66
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -2
- package/README.MD +0 -227
package/README.md
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
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
|
+
{ name: 'Green', primaryColor: '#22C55E', secondaryColor: '#F6F9F6' },
|
|
61
|
+
{ name: 'Gray', primaryColor: '#64748B' },
|
|
62
|
+
]}
|
|
63
|
+
>
|
|
64
|
+
{/* ... */}
|
|
65
|
+
</ThemeProviderWrapper>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Theme Switching (UI)
|
|
69
|
+
Use the theme context to read and change the active theme.
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
import { useThemeSettings } from '@atomazing-org/design-system';
|
|
73
|
+
import { ToggleButton, ToggleButtonGroup } from '@mui/material';
|
|
74
|
+
|
|
75
|
+
export function ThemeToggle() {
|
|
76
|
+
const { theme, setTheme } = useThemeSettings();
|
|
77
|
+
const options = ['Blue', 'Green', 'Gray'];
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<ToggleButtonGroup
|
|
81
|
+
size="small"
|
|
82
|
+
exclusive
|
|
83
|
+
color="brand"
|
|
84
|
+
value={theme}
|
|
85
|
+
onChange={(_, v) => v && setTheme(v)}
|
|
86
|
+
>
|
|
87
|
+
{options.map((o) => (
|
|
88
|
+
<ToggleButton key={o} value={o}>{o}</ToggleButton>
|
|
89
|
+
))}
|
|
90
|
+
</ToggleButtonGroup>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Dark Mode Control
|
|
96
|
+
Use `useThemeSettings()` to read and set dark mode. Modes: `light | dark | system | auto`.
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
import { useThemeSettings, darkModeOptions } from '@atomazing-org/design-system';
|
|
100
|
+
import { RadioGroup, FormControlLabel, Radio } from '@mui/material';
|
|
101
|
+
|
|
102
|
+
export function DarkModeSelector() {
|
|
103
|
+
const { darkMode, setDarkMode } = useThemeSettings();
|
|
104
|
+
const options = darkModeOptions; // label + icon
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<RadioGroup
|
|
108
|
+
row
|
|
109
|
+
value={darkMode}
|
|
110
|
+
onChange={(e) => setDarkMode(e.target.value as any)}
|
|
111
|
+
>
|
|
112
|
+
{options.map((o) => (
|
|
113
|
+
<FormControlLabel key={o.value} value={o.value} control={<Radio />} label={o.label} />
|
|
114
|
+
))}
|
|
115
|
+
</RadioGroup>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Extended Palette (4 variants)
|
|
121
|
+
The design system adds four typed colors to the MUI palette, available on common components via the `color` prop:
|
|
122
|
+
|
|
123
|
+
- brand: project brand color (uses the active theme `primary`).
|
|
124
|
+
- neutral: neutral/gray scale color (from the design-system palette).
|
|
125
|
+
- accent: supporting accent color (from palette `accent`).
|
|
126
|
+
- muted: soft/desaturated color (based on neutral by default).
|
|
127
|
+
|
|
128
|
+
Supported components: `Button`, `Chip`, `Badge`, `Alert`.
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
import { Button, Chip, Alert } from '@mui/material';
|
|
132
|
+
|
|
133
|
+
<Button color="brand" variant="contained">Brand</Button>
|
|
134
|
+
<Button color="neutral" variant="outlined">Neutral</Button>
|
|
135
|
+
<Chip color="accent" label="Accent" />
|
|
136
|
+
<Alert color="muted" variant="filled">Muted Alert</Alert>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Palette Overrides
|
|
140
|
+
Override base palette tokens for the whole app.
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
<ThemeProviderWrapper
|
|
144
|
+
colorPaletteOverride={{
|
|
145
|
+
brand: '#4F46E5',
|
|
146
|
+
accent: '#F59E0B',
|
|
147
|
+
muted: '#94A3B8',
|
|
148
|
+
neutral: '#64748B',
|
|
149
|
+
success: '#16A34A',
|
|
150
|
+
warning: '#D97706',
|
|
151
|
+
error: '#DC2626',
|
|
152
|
+
info: '#0284C7',
|
|
153
|
+
}}
|
|
154
|
+
>
|
|
155
|
+
{/* ... */}
|
|
156
|
+
</ThemeProviderWrapper>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Using Palette In SX
|
|
160
|
+
```tsx
|
|
161
|
+
import { Box } from '@mui/material';
|
|
162
|
+
|
|
163
|
+
<Box sx={{ bgcolor: (t) => t.palette.accent.main, color: (t) => t.palette.getContrastText(t.palette.accent.main) }}>
|
|
164
|
+
Accent surface
|
|
165
|
+
</Box>
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Typography Variants
|
|
169
|
+
Extra variants are available (mapping to `<p>`/headers). Examples:
|
|
170
|
+
|
|
171
|
+
```tsx
|
|
172
|
+
import { Typography } from '@mui/material';
|
|
173
|
+
|
|
174
|
+
<Typography variant="text_md_regular">Body text</Typography>
|
|
175
|
+
<Typography variant="text_sm_bold">Strong caption</Typography>
|
|
176
|
+
<Typography variant="header_lg_bold">Section Title</Typography>
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Global Styles
|
|
180
|
+
`ThemeProviderWrapper` injects global styles via Emotion. You can also set a custom font family:
|
|
181
|
+
|
|
182
|
+
```tsx
|
|
183
|
+
<ThemeProviderWrapper fontFamily="Inter, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif">
|
|
184
|
+
{/* ... */}
|
|
185
|
+
</ThemeProviderWrapper>
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Animations
|
|
189
|
+
Keyframes ready for use in Emotion/MUI `sx`:
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
import { keyframes } from '@emotion/react';
|
|
193
|
+
import { fadeIn, slideIn, scale, pulseAnimation, progressPulse } from '@atomazing-org/design-system';
|
|
194
|
+
import styled from '@emotion/styled';
|
|
195
|
+
|
|
196
|
+
const Card = styled.div`
|
|
197
|
+
animation: ${fadeIn} 300ms ease-in both;
|
|
198
|
+
`;
|
|
199
|
+
|
|
200
|
+
const Glowing = styled.div`
|
|
201
|
+
animation: ${progressPulse('#9FA9EA')} 2s ease-in-out infinite;
|
|
202
|
+
`;
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Components
|
|
206
|
+
- ErrorBoundary
|
|
207
|
+
```tsx
|
|
208
|
+
import { ErrorBoundary } from '@atomazing-org/design-system';
|
|
209
|
+
|
|
210
|
+
<ErrorBoundary>
|
|
211
|
+
<App />
|
|
212
|
+
</ErrorBoundary>
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
- Loading
|
|
216
|
+
```tsx
|
|
217
|
+
import { Loading } from '@atomazing-org/design-system';
|
|
218
|
+
|
|
219
|
+
<Loading />
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
- PathName / DialogBtn
|
|
223
|
+
```tsx
|
|
224
|
+
import { PathName, DialogBtn } from '@atomazing-org/design-system';
|
|
225
|
+
|
|
226
|
+
<PathName>/settings/profile</PathName>
|
|
227
|
+
<DialogBtn variant="contained" color="brand">OK</DialogBtn>
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Utilities
|
|
231
|
+
```tsx
|
|
232
|
+
import {
|
|
233
|
+
getFontColor, isFontLight, isHexColor,
|
|
234
|
+
timeAgo, timeAgoFromStart,
|
|
235
|
+
useResponsiveDisplay, useSystemTheme,
|
|
236
|
+
displayGreeting, getDayIdentifier,
|
|
237
|
+
systemInfo,
|
|
238
|
+
} from '@atomazing-org/design-system';
|
|
239
|
+
|
|
240
|
+
// Colors
|
|
241
|
+
getFontColor('#ffffff'); // '#101727' | '#f0f0f0'
|
|
242
|
+
isFontLight('#222');
|
|
243
|
+
isHexColor('#abc');
|
|
244
|
+
|
|
245
|
+
// Time
|
|
246
|
+
timeAgo(new Date(Date.now() - 3600_000));
|
|
247
|
+
timeAgoFromStart(new Date(Date.now() + 90_000));
|
|
248
|
+
|
|
249
|
+
// Device
|
|
250
|
+
const isMobile = useResponsiveDisplay(768);
|
|
251
|
+
const sysTheme = useSystemTheme(); // 'light' | 'dark' | 'unknown'
|
|
252
|
+
|
|
253
|
+
// Misc
|
|
254
|
+
displayGreeting(); // Good morning / afternoon / evening
|
|
255
|
+
getDayIdentifier(new Date()); // 'YYYY-MM-DD'
|
|
256
|
+
console.log(systemInfo.os, systemInfo.browser);
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
SSR Notes
|
|
260
|
+
- The library guards `localStorage`/`navigator`. Use normally in SSR apps; hydration updates settings on client.
|
|
261
|
+
- For Next.js, place the provider in a client boundary (e.g., `layout.tsx` with `"use client"`).
|
|
262
|
+
|
|
263
|
+
Peer Dependencies
|
|
264
|
+
- `@mui/material` ^7
|
|
265
|
+
- `@mui/icons-material` ^7
|
|
266
|
+
- `@emotion/react` ^11
|
|
267
|
+
- `@emotion/styled` ^11
|
|
268
|
+
- `@emotion/css` ^11 (optional)
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _emotion_styled from '@emotion/styled';
|
|
2
2
|
import * as _emotion_react from '@emotion/react';
|
|
3
3
|
import * as React$1 from 'react';
|
|
4
|
-
import React__default, { ErrorInfo, FC, PropsWithChildren } from 'react';
|
|
4
|
+
import React__default, { ErrorInfo, ReactNode, FC, PropsWithChildren } from 'react';
|
|
5
5
|
import * as _mui_material_OverridableComponent from '@mui/material/OverridableComponent';
|
|
6
6
|
import * as _mui_material from '@mui/material';
|
|
7
7
|
import { Theme, PaletteMode } from '@mui/material';
|
|
@@ -46,7 +46,7 @@ type DarkModeOptions = "system" | "auto" | "light" | "dark";
|
|
|
46
46
|
interface OptionItem {
|
|
47
47
|
label: string;
|
|
48
48
|
value: DarkModeOptions;
|
|
49
|
-
icon:
|
|
49
|
+
icon: ReactNode;
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* Represents user-specific theme preferences stored in the application.
|
|
@@ -198,33 +198,41 @@ declare module "@mui/material/Typography" {
|
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
|
|
201
|
+
interface ColorPaletteType {
|
|
202
|
+
fontDark: string;
|
|
203
|
+
fontLight: string;
|
|
204
|
+
brand: string;
|
|
205
|
+
accent: string;
|
|
206
|
+
muted: string;
|
|
207
|
+
success: string;
|
|
208
|
+
info: string;
|
|
209
|
+
warning: string;
|
|
210
|
+
error: string;
|
|
211
|
+
neutral: string;
|
|
212
|
+
}
|
|
202
213
|
|
|
203
|
-
declare const
|
|
214
|
+
declare const darkModeOptions: OptionItem[];
|
|
204
215
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
*/
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
* @returns `true` if white text is recommended; otherwise, `false`.
|
|
226
|
-
*/
|
|
227
|
-
declare const isFontLight: (color: string) => boolean;
|
|
216
|
+
declare const defaultColorPalette: ColorPaletteType;
|
|
217
|
+
|
|
218
|
+
declare const useThemeSettings: () => ThemeContextProps;
|
|
219
|
+
|
|
220
|
+
type ThemeProviderWrapperProps = PropsWithChildren<{
|
|
221
|
+
/** Optional font stack to apply across the app. */
|
|
222
|
+
fontFamily?: string;
|
|
223
|
+
/**
|
|
224
|
+
* Optional dynamic list of themes.
|
|
225
|
+
* Takes precedence over static defaults when provided.
|
|
226
|
+
*/
|
|
227
|
+
themes?: {
|
|
228
|
+
name: string;
|
|
229
|
+
primaryColor: string;
|
|
230
|
+
secondaryColor?: string;
|
|
231
|
+
}[];
|
|
232
|
+
/** Optional color palette override (e.g., fontLight/fontDark/accent colors). */
|
|
233
|
+
colorPaletteOverride?: Partial<ColorPaletteType>;
|
|
234
|
+
}>;
|
|
235
|
+
declare const ThemeProviderWrapper: FC<ThemeProviderWrapperProps>;
|
|
228
236
|
|
|
229
237
|
/**
|
|
230
238
|
* Common component style overrides and default props shared across the design system.
|
|
@@ -232,25 +240,7 @@ declare const isFontLight: (color: string) => boolean;
|
|
|
232
240
|
*/
|
|
233
241
|
declare const commonComponentProps: Theme["components"];
|
|
234
242
|
|
|
235
|
-
declare const createCustomTheme: (primaryColor: string, mode?: PaletteMode) => Theme;
|
|
236
|
-
/**
|
|
237
|
-
* A predefined list of named themes based on the `themeConfig` definition.
|
|
238
|
-
*/
|
|
239
|
-
declare const themes: {
|
|
240
|
-
name: string;
|
|
241
|
-
MuiTheme: Theme;
|
|
242
|
-
}[];
|
|
243
|
-
/**
|
|
244
|
-
* Determines whether dark mode should be enabled based on user settings and system conditions.
|
|
245
|
-
*
|
|
246
|
-
* @param darkMode - User preference: 'light' | 'dark' | 'system' | 'auto'.
|
|
247
|
-
* @param systemTheme - Detected OS-level theme: 'light' | 'dark'.
|
|
248
|
-
* @param backgroundColor - The background color to assess contrast in 'auto' mode.
|
|
249
|
-
* @returns True if dark mode should be used.
|
|
250
|
-
*/
|
|
251
|
-
declare const isDarkMode: (darkMode: AppSettings["darkMode"], systemTheme: SystemTheme) => boolean;
|
|
252
|
-
|
|
253
|
-
declare const darkModeOptions: OptionItem[];
|
|
243
|
+
declare const createCustomTheme: (primaryColor: string, mode?: PaletteMode, secondaryColor?: string) => Theme;
|
|
254
244
|
|
|
255
245
|
/**
|
|
256
246
|
* Injects global styles into the document using Emotion.
|
|
@@ -259,7 +249,11 @@ declare const darkModeOptions: OptionItem[];
|
|
|
259
249
|
*
|
|
260
250
|
* Uses the MUI theme to dynamically adjust colors for light/dark mode.
|
|
261
251
|
*/
|
|
262
|
-
|
|
252
|
+
interface GlobalStylesProps {
|
|
253
|
+
/** Optional font stack to apply across the app. */
|
|
254
|
+
fontFamily?: string;
|
|
255
|
+
}
|
|
256
|
+
declare const GlobalStyles: FC<GlobalStylesProps>;
|
|
263
257
|
|
|
264
258
|
/**
|
|
265
259
|
* Fade in from the left with slight movement on the X-axis.
|
|
@@ -352,18 +346,39 @@ declare const installAppAnimation: {
|
|
|
352
346
|
toString: () => string;
|
|
353
347
|
} & string;
|
|
354
348
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
declare const
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
349
|
+
/** Returns the active color palette, allowing app-level overrides. */
|
|
350
|
+
declare const getColorPalette: () => ColorPaletteType;
|
|
351
|
+
/**
|
|
352
|
+
* Overrides the active color palette with app-provided values.
|
|
353
|
+
* Pass `undefined` or empty to reset to defaults.
|
|
354
|
+
*/
|
|
355
|
+
declare const setColorPaletteOverride: (override?: Partial<ColorPaletteType>) => void;
|
|
356
|
+
/** Backward-compatible live view of the active palette. */
|
|
357
|
+
declare const ColorPalette: Readonly<ColorPaletteType>;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Validates whether a given string is a valid 3- or 6-digit hex color code (e.g., "#fff" or "#ffffff").
|
|
361
|
+
*
|
|
362
|
+
* @param value - The string to check.
|
|
363
|
+
* @returns `true` if the string is a valid hex color; otherwise, `false`.
|
|
364
|
+
*/
|
|
365
|
+
declare const isHexColor: (value: string) => boolean;
|
|
366
|
+
/**
|
|
367
|
+
* Determines the ideal font color (white or black) for contrast against a given background color.
|
|
368
|
+
*
|
|
369
|
+
* Uses luminance calculation (YIQ) to ensure accessibility and visual clarity.
|
|
370
|
+
*
|
|
371
|
+
* @param backgroundColor - A valid hex color (e.g., "#ffffff").
|
|
372
|
+
* @returns A hex color string (`fontLight` or `fontDark`) suitable for overlay text.
|
|
373
|
+
*/
|
|
374
|
+
declare const getFontColor: (backgroundColor: string) => string;
|
|
375
|
+
/**
|
|
376
|
+
* Determines whether the ideal font color for a background is light (i.e., white).
|
|
377
|
+
*
|
|
378
|
+
* @param color - The background color in hex.
|
|
379
|
+
* @returns `true` if white text is recommended; otherwise, `false`.
|
|
380
|
+
*/
|
|
381
|
+
declare const isFontLight: (color: string) => boolean;
|
|
367
382
|
|
|
368
383
|
/**
|
|
369
384
|
* Returns a greeting based on the current time.
|
|
@@ -386,12 +401,23 @@ type OperatingSystem = "Windows" | "macOS" | "Linux" | "iOS" | "Android" | "Unkn
|
|
|
386
401
|
type Browser = "Chrome" | "Firefox" | "Safari" | "Edge" | "Unknown";
|
|
387
402
|
/**
|
|
388
403
|
* Basic information about the user's system (OS and browser).
|
|
404
|
+
* Safe for SSR: resolves to Unknown values on server.
|
|
389
405
|
*/
|
|
390
406
|
declare const systemInfo: {
|
|
391
407
|
os: OperatingSystem;
|
|
392
408
|
browser: Browser;
|
|
393
409
|
};
|
|
394
410
|
|
|
411
|
+
/**
|
|
412
|
+
* Determines whether dark mode should be enabled based on user settings and system conditions.
|
|
413
|
+
*
|
|
414
|
+
* @param darkMode - User preference: 'light' | 'dark' | 'system' | 'auto'.
|
|
415
|
+
* @param systemTheme - Detected OS-level theme: 'light' | 'dark'.
|
|
416
|
+
* @param backgroundColor - The background color to assess contrast in 'auto' mode.
|
|
417
|
+
* @returns True if dark mode should be used.
|
|
418
|
+
*/
|
|
419
|
+
declare const isDarkMode: (darkMode: AppSettings["darkMode"], systemTheme: SystemTheme) => boolean;
|
|
420
|
+
|
|
395
421
|
/**
|
|
396
422
|
* Converts a given date to a human-readable relative time string.
|
|
397
423
|
*
|
|
@@ -416,4 +442,4 @@ declare const useResponsiveDisplay: (breakpoint?: number) => boolean;
|
|
|
416
442
|
*/
|
|
417
443
|
declare const useSystemTheme: () => SystemTheme;
|
|
418
444
|
|
|
419
|
-
export { type AppSettings, ColorPalette, type CustomTypographyVariants, type DarkModeOptions, DialogBtn, ErrorBoundary, GlobalStyles, Loading, type OptionItem, PathName, type SystemTheme, type ThemeContextProps, ThemeProviderWrapper, commonComponentProps, createCustomTheme, darkModeOptions, displayGreeting, fadeIn, fadeInLeft, getDayIdentifier, getFontColor, installAppAnimation, isDarkMode, isFontLight, isHexColor, logoutAnimation, progressPulse, pulseAnimation, scale, slideIn, slideInBottom, systemInfo,
|
|
445
|
+
export { type AppSettings, ColorPalette, type ColorPaletteType, type CustomTypographyVariants, type DarkModeOptions, DialogBtn, ErrorBoundary, GlobalStyles, Loading, type OptionItem, PathName, type SystemTheme, type ThemeContextProps, ThemeProviderWrapper, commonComponentProps, createCustomTheme, darkModeOptions, defaultColorPalette, displayGreeting, fadeIn, fadeInLeft, getColorPalette, getDayIdentifier, getFontColor, installAppAnimation, isDarkMode, isFontLight, isHexColor, logoutAnimation, progressPulse, pulseAnimation, scale, setColorPaletteOverride, slideIn, slideInBottom, systemInfo, timeAgo, timeAgoFromStart, useResponsiveDisplay, useSystemTheme, useThemeSettings };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _emotion_styled from '@emotion/styled';
|
|
2
2
|
import * as _emotion_react from '@emotion/react';
|
|
3
3
|
import * as React$1 from 'react';
|
|
4
|
-
import React__default, { ErrorInfo, FC, PropsWithChildren } from 'react';
|
|
4
|
+
import React__default, { ErrorInfo, ReactNode, FC, PropsWithChildren } from 'react';
|
|
5
5
|
import * as _mui_material_OverridableComponent from '@mui/material/OverridableComponent';
|
|
6
6
|
import * as _mui_material from '@mui/material';
|
|
7
7
|
import { Theme, PaletteMode } from '@mui/material';
|
|
@@ -46,7 +46,7 @@ type DarkModeOptions = "system" | "auto" | "light" | "dark";
|
|
|
46
46
|
interface OptionItem {
|
|
47
47
|
label: string;
|
|
48
48
|
value: DarkModeOptions;
|
|
49
|
-
icon:
|
|
49
|
+
icon: ReactNode;
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* Represents user-specific theme preferences stored in the application.
|
|
@@ -198,33 +198,41 @@ declare module "@mui/material/Typography" {
|
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
|
|
201
|
+
interface ColorPaletteType {
|
|
202
|
+
fontDark: string;
|
|
203
|
+
fontLight: string;
|
|
204
|
+
brand: string;
|
|
205
|
+
accent: string;
|
|
206
|
+
muted: string;
|
|
207
|
+
success: string;
|
|
208
|
+
info: string;
|
|
209
|
+
warning: string;
|
|
210
|
+
error: string;
|
|
211
|
+
neutral: string;
|
|
212
|
+
}
|
|
202
213
|
|
|
203
|
-
declare const
|
|
214
|
+
declare const darkModeOptions: OptionItem[];
|
|
204
215
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
*/
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
* @returns `true` if white text is recommended; otherwise, `false`.
|
|
226
|
-
*/
|
|
227
|
-
declare const isFontLight: (color: string) => boolean;
|
|
216
|
+
declare const defaultColorPalette: ColorPaletteType;
|
|
217
|
+
|
|
218
|
+
declare const useThemeSettings: () => ThemeContextProps;
|
|
219
|
+
|
|
220
|
+
type ThemeProviderWrapperProps = PropsWithChildren<{
|
|
221
|
+
/** Optional font stack to apply across the app. */
|
|
222
|
+
fontFamily?: string;
|
|
223
|
+
/**
|
|
224
|
+
* Optional dynamic list of themes.
|
|
225
|
+
* Takes precedence over static defaults when provided.
|
|
226
|
+
*/
|
|
227
|
+
themes?: {
|
|
228
|
+
name: string;
|
|
229
|
+
primaryColor: string;
|
|
230
|
+
secondaryColor?: string;
|
|
231
|
+
}[];
|
|
232
|
+
/** Optional color palette override (e.g., fontLight/fontDark/accent colors). */
|
|
233
|
+
colorPaletteOverride?: Partial<ColorPaletteType>;
|
|
234
|
+
}>;
|
|
235
|
+
declare const ThemeProviderWrapper: FC<ThemeProviderWrapperProps>;
|
|
228
236
|
|
|
229
237
|
/**
|
|
230
238
|
* Common component style overrides and default props shared across the design system.
|
|
@@ -232,25 +240,7 @@ declare const isFontLight: (color: string) => boolean;
|
|
|
232
240
|
*/
|
|
233
241
|
declare const commonComponentProps: Theme["components"];
|
|
234
242
|
|
|
235
|
-
declare const createCustomTheme: (primaryColor: string, mode?: PaletteMode) => Theme;
|
|
236
|
-
/**
|
|
237
|
-
* A predefined list of named themes based on the `themeConfig` definition.
|
|
238
|
-
*/
|
|
239
|
-
declare const themes: {
|
|
240
|
-
name: string;
|
|
241
|
-
MuiTheme: Theme;
|
|
242
|
-
}[];
|
|
243
|
-
/**
|
|
244
|
-
* Determines whether dark mode should be enabled based on user settings and system conditions.
|
|
245
|
-
*
|
|
246
|
-
* @param darkMode - User preference: 'light' | 'dark' | 'system' | 'auto'.
|
|
247
|
-
* @param systemTheme - Detected OS-level theme: 'light' | 'dark'.
|
|
248
|
-
* @param backgroundColor - The background color to assess contrast in 'auto' mode.
|
|
249
|
-
* @returns True if dark mode should be used.
|
|
250
|
-
*/
|
|
251
|
-
declare const isDarkMode: (darkMode: AppSettings["darkMode"], systemTheme: SystemTheme) => boolean;
|
|
252
|
-
|
|
253
|
-
declare const darkModeOptions: OptionItem[];
|
|
243
|
+
declare const createCustomTheme: (primaryColor: string, mode?: PaletteMode, secondaryColor?: string) => Theme;
|
|
254
244
|
|
|
255
245
|
/**
|
|
256
246
|
* Injects global styles into the document using Emotion.
|
|
@@ -259,7 +249,11 @@ declare const darkModeOptions: OptionItem[];
|
|
|
259
249
|
*
|
|
260
250
|
* Uses the MUI theme to dynamically adjust colors for light/dark mode.
|
|
261
251
|
*/
|
|
262
|
-
|
|
252
|
+
interface GlobalStylesProps {
|
|
253
|
+
/** Optional font stack to apply across the app. */
|
|
254
|
+
fontFamily?: string;
|
|
255
|
+
}
|
|
256
|
+
declare const GlobalStyles: FC<GlobalStylesProps>;
|
|
263
257
|
|
|
264
258
|
/**
|
|
265
259
|
* Fade in from the left with slight movement on the X-axis.
|
|
@@ -352,18 +346,39 @@ declare const installAppAnimation: {
|
|
|
352
346
|
toString: () => string;
|
|
353
347
|
} & string;
|
|
354
348
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
declare const
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
349
|
+
/** Returns the active color palette, allowing app-level overrides. */
|
|
350
|
+
declare const getColorPalette: () => ColorPaletteType;
|
|
351
|
+
/**
|
|
352
|
+
* Overrides the active color palette with app-provided values.
|
|
353
|
+
* Pass `undefined` or empty to reset to defaults.
|
|
354
|
+
*/
|
|
355
|
+
declare const setColorPaletteOverride: (override?: Partial<ColorPaletteType>) => void;
|
|
356
|
+
/** Backward-compatible live view of the active palette. */
|
|
357
|
+
declare const ColorPalette: Readonly<ColorPaletteType>;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Validates whether a given string is a valid 3- or 6-digit hex color code (e.g., "#fff" or "#ffffff").
|
|
361
|
+
*
|
|
362
|
+
* @param value - The string to check.
|
|
363
|
+
* @returns `true` if the string is a valid hex color; otherwise, `false`.
|
|
364
|
+
*/
|
|
365
|
+
declare const isHexColor: (value: string) => boolean;
|
|
366
|
+
/**
|
|
367
|
+
* Determines the ideal font color (white or black) for contrast against a given background color.
|
|
368
|
+
*
|
|
369
|
+
* Uses luminance calculation (YIQ) to ensure accessibility and visual clarity.
|
|
370
|
+
*
|
|
371
|
+
* @param backgroundColor - A valid hex color (e.g., "#ffffff").
|
|
372
|
+
* @returns A hex color string (`fontLight` or `fontDark`) suitable for overlay text.
|
|
373
|
+
*/
|
|
374
|
+
declare const getFontColor: (backgroundColor: string) => string;
|
|
375
|
+
/**
|
|
376
|
+
* Determines whether the ideal font color for a background is light (i.e., white).
|
|
377
|
+
*
|
|
378
|
+
* @param color - The background color in hex.
|
|
379
|
+
* @returns `true` if white text is recommended; otherwise, `false`.
|
|
380
|
+
*/
|
|
381
|
+
declare const isFontLight: (color: string) => boolean;
|
|
367
382
|
|
|
368
383
|
/**
|
|
369
384
|
* Returns a greeting based on the current time.
|
|
@@ -386,12 +401,23 @@ type OperatingSystem = "Windows" | "macOS" | "Linux" | "iOS" | "Android" | "Unkn
|
|
|
386
401
|
type Browser = "Chrome" | "Firefox" | "Safari" | "Edge" | "Unknown";
|
|
387
402
|
/**
|
|
388
403
|
* Basic information about the user's system (OS and browser).
|
|
404
|
+
* Safe for SSR: resolves to Unknown values on server.
|
|
389
405
|
*/
|
|
390
406
|
declare const systemInfo: {
|
|
391
407
|
os: OperatingSystem;
|
|
392
408
|
browser: Browser;
|
|
393
409
|
};
|
|
394
410
|
|
|
411
|
+
/**
|
|
412
|
+
* Determines whether dark mode should be enabled based on user settings and system conditions.
|
|
413
|
+
*
|
|
414
|
+
* @param darkMode - User preference: 'light' | 'dark' | 'system' | 'auto'.
|
|
415
|
+
* @param systemTheme - Detected OS-level theme: 'light' | 'dark'.
|
|
416
|
+
* @param backgroundColor - The background color to assess contrast in 'auto' mode.
|
|
417
|
+
* @returns True if dark mode should be used.
|
|
418
|
+
*/
|
|
419
|
+
declare const isDarkMode: (darkMode: AppSettings["darkMode"], systemTheme: SystemTheme) => boolean;
|
|
420
|
+
|
|
395
421
|
/**
|
|
396
422
|
* Converts a given date to a human-readable relative time string.
|
|
397
423
|
*
|
|
@@ -416,4 +442,4 @@ declare const useResponsiveDisplay: (breakpoint?: number) => boolean;
|
|
|
416
442
|
*/
|
|
417
443
|
declare const useSystemTheme: () => SystemTheme;
|
|
418
444
|
|
|
419
|
-
export { type AppSettings, ColorPalette, type CustomTypographyVariants, type DarkModeOptions, DialogBtn, ErrorBoundary, GlobalStyles, Loading, type OptionItem, PathName, type SystemTheme, type ThemeContextProps, ThemeProviderWrapper, commonComponentProps, createCustomTheme, darkModeOptions, displayGreeting, fadeIn, fadeInLeft, getDayIdentifier, getFontColor, installAppAnimation, isDarkMode, isFontLight, isHexColor, logoutAnimation, progressPulse, pulseAnimation, scale, slideIn, slideInBottom, systemInfo,
|
|
445
|
+
export { type AppSettings, ColorPalette, type ColorPaletteType, type CustomTypographyVariants, type DarkModeOptions, DialogBtn, ErrorBoundary, GlobalStyles, Loading, type OptionItem, PathName, type SystemTheme, type ThemeContextProps, ThemeProviderWrapper, commonComponentProps, createCustomTheme, darkModeOptions, defaultColorPalette, displayGreeting, fadeIn, fadeInLeft, getColorPalette, getDayIdentifier, getFontColor, installAppAnimation, isDarkMode, isFontLight, isHexColor, logoutAnimation, progressPulse, pulseAnimation, scale, setColorPaletteOverride, slideIn, slideInBottom, systemInfo, timeAgo, timeAgoFromStart, useResponsiveDisplay, useSystemTheme, useThemeSettings };
|