@shohojdhara/atomix 0.3.4 → 0.3.6
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 +101 -199
- package/atomix.config.ts +241 -0
- package/dist/atomix.css +269 -189
- package/dist/atomix.css.map +1 -0
- package/dist/atomix.min.css +15179 -11
- package/dist/atomix.min.css.map +1 -0
- package/dist/charts.d.ts +1929 -0
- package/dist/charts.js +6477 -0
- package/dist/charts.js.map +1 -0
- package/dist/core.d.ts +1289 -0
- package/dist/core.js +3373 -0
- package/dist/core.js.map +1 -0
- package/dist/forms.d.ts +1085 -0
- package/dist/forms.js +2466 -0
- package/dist/forms.js.map +1 -0
- package/dist/heavy.d.ts +636 -0
- package/dist/heavy.js +4566 -0
- package/dist/heavy.js.map +1 -0
- package/dist/index.d.ts +5171 -4792
- package/dist/index.esm.js +6098 -4563
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +6291 -4747
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/layout.d.ts +300 -0
- package/dist/layout.js +336 -0
- package/dist/layout.js.map +1 -0
- package/dist/theme.d.ts +2122 -0
- package/dist/theme.js +6084 -0
- package/dist/theme.js.map +1 -0
- package/package.json +59 -27
- package/scripts/atomix-cli.js +544 -16
- package/scripts/cli/__tests__/cli-commands.test.js +204 -0
- package/scripts/cli/__tests__/utils.test.js +201 -0
- package/scripts/cli/__tests__/vitest.config.js +26 -0
- package/scripts/cli/interactive-init.js +1 -1
- package/scripts/cli/token-manager.js +32 -7
- package/scripts/cli/utils.js +347 -0
- package/src/components/Accordion/Accordion.stories.tsx +50 -17
- package/src/components/Accordion/Accordion.tsx +5 -54
- package/src/components/Accordion/index.ts +1 -1
- package/src/components/AtomixGlass/AtomixGlass.tsx +65 -31
- package/src/components/AtomixGlass/AtomixGlassContainer.tsx +11 -4
- package/src/components/AtomixGlass/stories/AtomixGlass.stories.tsx +1 -32
- package/src/components/AtomixGlass/stories/Examples.stories.tsx +2 -2
- package/src/components/AtomixGlass/stories/shared-components.tsx +0 -31
- package/src/components/Avatar/Avatar.stories.tsx +7 -0
- package/src/components/Avatar/Avatar.tsx +3 -3
- package/src/components/Badge/Badge.stories.tsx +91 -13
- package/src/components/Badge/Badge.tsx +3 -3
- package/src/components/Block/Block.stories.tsx +7 -23
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +7 -0
- package/src/components/Breadcrumb/Breadcrumb.tsx +3 -3
- package/src/components/Button/Button.stories.tsx +141 -22
- package/src/components/Button/ButtonGroup.stories.tsx +315 -0
- package/src/components/Button/ButtonGroup.tsx +67 -0
- package/src/components/Button/index.ts +2 -0
- package/src/components/Callout/Callout.stories.tsx +8 -6
- package/src/components/Card/Card.stories.tsx +82 -28
- package/src/components/Card/ElevationCard.tsx +1 -1
- package/src/components/Chart/AnimatedChart.tsx +19 -18
- package/src/components/Chart/AreaChart.tsx +5 -2
- package/src/components/Chart/BarChart.tsx +1 -1
- package/src/components/Chart/BubbleChart.tsx +6 -6
- package/src/components/Chart/CandlestickChart.tsx +0 -1
- package/src/components/Chart/Chart.stories.tsx +5 -7
- package/src/components/Chart/Chart.tsx +0 -16
- package/src/components/Chart/ChartRenderer.tsx +1 -1
- package/src/components/Chart/ChartToolbar.tsx +1 -0
- package/src/components/Chart/DonutChart.tsx +0 -1
- package/src/components/Chart/FunnelChart.tsx +1 -2
- package/src/components/Chart/GaugeChart.tsx +0 -1
- package/src/components/Chart/HeatmapChart.tsx +0 -1
- package/src/components/Chart/LineChart.tsx +0 -1
- package/src/components/Chart/MultiAxisChart.tsx +0 -1
- package/src/components/Chart/PieChart.tsx +0 -1
- package/src/components/Chart/RadarChart.tsx +19 -13
- package/src/components/Chart/ScatterChart.tsx +3 -4
- package/src/components/Chart/TreemapChart.tsx +2 -1
- package/src/components/Chart/WaterfallChart.tsx +0 -2
- package/src/components/Chart/types.ts +12 -2
- package/src/components/Chart/utils.ts +4 -3
- package/src/components/ColorModeToggle/ColorModeToggle.stories.tsx +7 -0
- package/src/components/DataTable/DataTable.stories.tsx +23 -16
- package/src/components/DataTable/DataTable.tsx +3 -3
- package/src/components/DatePicker/DatePicker.stories.tsx +27 -19
- package/src/components/Dropdown/Dropdown.stories.tsx +11 -19
- package/src/components/Dropdown/Dropdown.tsx +12 -9
- package/src/components/EdgePanel/EdgePanel.stories.tsx +1 -0
- package/src/components/Footer/Footer.stories.tsx +8 -6
- package/src/components/Footer/FooterLink.tsx +9 -2
- package/src/components/Footer/FooterSection.tsx +3 -3
- package/src/components/Form/Checkbox.stories.tsx +7 -0
- package/src/components/Form/Checkbox.tsx +3 -3
- package/src/components/Form/Form.stories.tsx +7 -0
- package/src/components/Form/FormGroup.stories.tsx +9 -1
- package/src/components/Form/Input.stories.tsx +69 -16
- package/src/components/Form/Input.tsx +4 -2
- package/src/components/Form/Radio.stories.tsx +9 -1
- package/src/components/Form/Radio.tsx +3 -3
- package/src/components/Form/Select.stories.tsx +9 -1
- package/src/components/Form/Select.tsx +3 -3
- package/src/components/Form/Textarea.stories.tsx +10 -2
- package/src/components/Form/Textarea.tsx +4 -2
- package/src/components/Hero/Hero.stories.tsx +7 -0
- package/src/components/List/List.stories.tsx +10 -3
- package/src/components/List/List.tsx +3 -3
- package/src/components/List/ListGroup.tsx +3 -1
- package/src/components/Messages/Messages.stories.tsx +8 -7
- package/src/components/Modal/Modal.stories.tsx +17 -6
- package/src/components/Modal/Modal.tsx +3 -3
- package/src/components/Navigation/Menu/MegaMenu.tsx +9 -3
- package/src/components/Navigation/Menu/Menu.stories.tsx +7 -0
- package/src/components/Navigation/Menu/Menu.tsx +9 -3
- package/src/components/Navigation/Nav/Nav.stories.tsx +7 -0
- package/src/components/Navigation/Navbar/Navbar.stories.tsx +1 -0
- package/src/components/Navigation/SideMenu/SideMenu.stories.tsx +1 -1
- package/src/components/Pagination/Pagination.stories.tsx +188 -111
- package/src/components/Pagination/Pagination.tsx +88 -7
- package/src/components/PhotoViewer/PhotoViewer.stories.tsx +10 -5
- package/src/components/PhotoViewer/PhotoViewerImage.tsx +2 -2
- package/src/components/Popover/Popover.stories.tsx +191 -115
- package/src/components/Popover/Popover.tsx +4 -4
- package/src/components/ProductReview/ProductReview.stories.tsx +80 -58
- package/src/components/Progress/Progress.stories.tsx +79 -49
- package/src/components/Progress/Progress.tsx +6 -2
- package/src/components/Rating/Rating.stories.tsx +109 -84
- package/src/components/Rating/Rating.tsx +5 -2
- package/src/components/River/River.stories.tsx +194 -114
- package/src/components/SectionIntro/SectionIntro.stories.tsx +19 -9
- package/src/components/Slider/Slider.stories.tsx +7 -0
- package/src/components/Slider/Slider.tsx +10 -9
- package/src/components/Spinner/Spinner.stories.tsx +15 -11
- package/src/components/Spinner/Spinner.tsx +3 -3
- package/src/components/Steps/Steps.stories.tsx +132 -98
- package/src/components/Tabs/Tabs.stories.tsx +163 -112
- package/src/components/Tabs/Tabs.tsx +3 -3
- package/src/components/Testimonial/Testimonial.stories.tsx +114 -68
- package/src/components/Todo/Todo.stories.tsx +38 -12
- package/src/components/Toggle/Toggle.stories.tsx +61 -28
- package/src/components/Tooltip/Tooltip.stories.tsx +318 -200
- package/src/components/Tooltip/Tooltip.tsx +3 -3
- package/src/components/Upload/Upload.stories.tsx +122 -84
- package/src/components/VideoPlayer/VideoPlayer.stories.tsx +7 -24
- package/src/components/index.ts +6 -2
- package/src/layouts/MasonryGrid/MasonryGrid.tsx +2 -2
- package/src/lib/composables/useAtomixGlass.ts +2 -3
- package/src/lib/composables/useChartPerformance.ts +102 -78
- package/src/lib/composables/useChartScale.ts +10 -0
- package/src/lib/composables/useHero.ts +9 -2
- package/src/lib/composables/useHeroBackgroundSlider.ts +5 -3
- package/src/lib/composables/useNavbar.ts +0 -10
- package/src/lib/composables/useSideMenu.ts +1 -0
- package/src/lib/composables/useVideoPlayer.ts +3 -2
- package/src/lib/config/loader.ts +57 -14
- package/src/lib/constants/components.ts +10 -0
- package/src/lib/hooks/index.ts +0 -1
- package/src/lib/hooks/useComponentCustomization.ts +11 -15
- package/src/lib/hooks/usePerformanceMonitor.ts +149 -0
- package/src/lib/patterns/index.ts +2 -2
- package/src/lib/patterns/slots.tsx +2 -2
- package/src/lib/theme/README.md +174 -0
- package/src/lib/theme/adapters/index.ts +31 -0
- package/src/lib/theme/adapters/themeAdapter.ts +287 -0
- package/src/lib/theme/config/__tests__/configLoader.test.ts +207 -0
- package/src/lib/theme/config/configLoader.ts +254 -0
- package/src/lib/theme/config/loader.ts +37 -48
- package/src/lib/theme/config/types.ts +2 -2
- package/src/lib/theme/config/validator.ts +15 -91
- package/src/lib/theme/{constants.ts → constants/constants.ts} +0 -18
- package/src/lib/theme/constants/index.ts +8 -0
- package/src/lib/theme/core/ThemeRegistry.ts +19 -6
- package/src/lib/theme/core/__tests__/createTheme.test.ts +132 -0
- package/src/lib/theme/core/composeTheme.ts +155 -0
- package/src/lib/theme/core/createTheme.ts +94 -0
- package/src/lib/theme/{createTheme.ts → core/createThemeObject.ts} +10 -6
- package/src/lib/theme/core/index.ts +5 -19
- package/src/lib/theme/devtools/Comparator.tsx +346 -22
- package/src/lib/theme/devtools/IMPROVEMENTS.md +139 -38
- package/src/lib/theme/devtools/Inspector.tsx +335 -51
- package/src/lib/theme/devtools/LiveEditor.tsx +489 -112
- package/src/lib/theme/devtools/Preview.tsx +471 -221
- package/src/lib/theme/{core → devtools}/ThemeValidator.ts +6 -3
- package/src/lib/theme/devtools/index.ts +14 -4
- package/src/lib/theme/devtools/useHistory.ts +130 -0
- package/src/lib/theme/errors/index.ts +12 -0
- package/src/lib/theme/generators/cssFile.ts +79 -0
- package/src/lib/theme/generators/generateCSS.ts +89 -0
- package/src/lib/theme/{generateCSSVariables.ts → generators/generateCSSVariables.ts} +4 -14
- package/src/lib/theme/generators/index.ts +19 -0
- package/src/lib/theme/i18n/rtl.ts +7 -7
- package/src/lib/theme/index.ts +120 -15
- package/src/lib/theme/runtime/ThemeApplicator.ts +53 -95
- package/src/lib/theme/{ThemeContext.tsx → runtime/ThemeContext.tsx} +1 -1
- package/src/lib/theme/runtime/ThemeErrorBoundary.tsx +4 -4
- package/src/lib/theme/runtime/ThemeProvider.tsx +456 -179
- package/src/lib/theme/runtime/index.ts +1 -2
- package/src/lib/theme/runtime/useTheme.ts +1 -2
- package/src/lib/theme/test/testTheme.ts +385 -0
- package/src/lib/theme/tokens/index.ts +12 -0
- package/src/lib/theme/tokens/tokens.ts +721 -0
- package/src/lib/theme/types.ts +6 -42
- package/src/lib/theme/{utils.ts → utils/domUtils.ts} +2 -2
- package/src/lib/theme/utils/index.ts +11 -0
- package/src/lib/theme/utils/injectCSS.ts +90 -0
- package/src/lib/theme/utils/themeHelpers.ts +78 -0
- package/src/lib/theme/{themeUtils.ts → utils/themeUtils.ts} +1 -1
- package/src/lib/theme-tools.ts +8 -9
- package/src/lib/types/components.ts +93 -34
- package/src/lib/types/partProps.ts +0 -16
- package/src/lib/utils/componentUtils.ts +1 -1
- package/src/lib/utils/fontPreloader.ts +148 -0
- package/src/lib/utils/index.ts +11 -0
- package/src/lib/utils/memoryMonitor.ts +189 -0
- package/src/styles/01-settings/_settings.design-tokens.scss +4 -1
- package/src/styles/01-settings/_settings.fonts.scss +2 -5
- package/src/styles/02-tools/_tools.button.scss +66 -79
- package/src/styles/06-components/_components.atomix-glass.scss +13 -3
- package/src/styles/06-components/_components.navbar.scss +0 -6
- package/src/styles/06-components/_components.pagination.scss +88 -0
- package/scripts/build-themes.js +0 -208
- package/scripts/sync-theme-config.js +0 -309
- package/src/components/AtomixGlass/atomixGLass.old.tsx +0 -1263
- package/src/lib/theme/composeTheme.ts +0 -370
- package/src/lib/theme/core/ThemeCache.ts +0 -283
- package/src/lib/theme/core/ThemeEngine.test.ts +0 -146
- package/src/lib/theme/core/ThemeEngine.ts +0 -657
- package/src/lib/theme/createThemeFromConfig.ts +0 -132
- package/src/lib/theme/devtools/CLI.ts +0 -364
- package/src/lib/theme/runtime/ThemeManager.test.ts +0 -192
- package/src/lib/theme/runtime/ThemeManager.ts +0 -442
- package/src/styles/03-generic/_generated-root.css +0 -5
- package/src/themes/README.md +0 -442
- package/src/themes/themes.config.js +0 -35
- /package/src/lib/theme/{cssVariableMapper.ts → adapters/cssVariableMapper.ts} +0 -0
- /package/src/lib/theme/{errors.ts → errors/errors.ts} +0 -0
package/src/lib/theme/types.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* TypeScript types and interfaces for the Atomix Design System theme management system.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type { ThemeManager as ThemeManagerType } from './runtime/ThemeManager';
|
|
8
7
|
import type { PartStyleProps } from '../types/partProps';
|
|
9
8
|
|
|
10
9
|
/**
|
|
@@ -42,39 +41,6 @@ export interface ThemeMetadata {
|
|
|
42
41
|
dependencies?: string[];
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
/**
|
|
46
|
-
* Theme manager configuration options
|
|
47
|
-
*/
|
|
48
|
-
export interface ThemeManagerConfig {
|
|
49
|
-
/** Available themes metadata */
|
|
50
|
-
themes: Record<string, ThemeMetadata>;
|
|
51
|
-
/** Default theme to use */
|
|
52
|
-
defaultTheme?: string | Theme;
|
|
53
|
-
/** Base path for theme CSS files */
|
|
54
|
-
basePath?: string;
|
|
55
|
-
/** CDN path for theme CSS files (optional) */
|
|
56
|
-
cdnPath?: string | null;
|
|
57
|
-
/** Themes to preload on initialization */
|
|
58
|
-
preload?: string[];
|
|
59
|
-
/** Enable lazy loading of themes */
|
|
60
|
-
lazy?: boolean;
|
|
61
|
-
/** localStorage key for persistence */
|
|
62
|
-
storageKey?: string;
|
|
63
|
-
/** Data attribute name for theme */
|
|
64
|
-
dataAttribute?: string;
|
|
65
|
-
/** Enable persistence */
|
|
66
|
-
enablePersistence?: boolean;
|
|
67
|
-
/** Custom CSS file extension */
|
|
68
|
-
cssExtension?: string;
|
|
69
|
-
/** Use minified CSS files */
|
|
70
|
-
useMinified?: boolean;
|
|
71
|
-
/** Callback when theme changes */
|
|
72
|
-
onThemeChange?: (theme: string | Theme) => void;
|
|
73
|
-
/** Callback when theme load fails */
|
|
74
|
-
onError?: (error: Error, themeName: string) => void;
|
|
75
|
-
/** RTL configuration */
|
|
76
|
-
rtl?: import('./i18n/rtl').RTLConfig;
|
|
77
|
-
}
|
|
78
44
|
|
|
79
45
|
/**
|
|
80
46
|
* Theme change event payload
|
|
@@ -160,7 +126,7 @@ export interface UseThemeOptions {
|
|
|
160
126
|
/** Custom storage key */
|
|
161
127
|
storageKey?: string;
|
|
162
128
|
/** Callback when theme changes */
|
|
163
|
-
onChange?: (theme: string | Theme) => void;
|
|
129
|
+
onChange?: (theme: string | Theme | import('./tokens').DesignTokens) => void;
|
|
164
130
|
}
|
|
165
131
|
|
|
166
132
|
/**
|
|
@@ -171,8 +137,8 @@ export interface UseThemeReturn {
|
|
|
171
137
|
theme: string;
|
|
172
138
|
/** Current active theme object (for JS themes) */
|
|
173
139
|
activeTheme: Theme | null;
|
|
174
|
-
/** Function to change theme */
|
|
175
|
-
setTheme: (theme: string | Theme
|
|
140
|
+
/** Function to change theme (supports string, Theme, or DesignTokens) */
|
|
141
|
+
setTheme: (theme: string | Theme | import('./tokens').DesignTokens | Partial<import('./tokens').DesignTokens>, options?: ThemeLoadOptions) => Promise<void>;
|
|
176
142
|
/** Available themes */
|
|
177
143
|
availableThemes: ThemeMetadata[];
|
|
178
144
|
/** Whether a theme is currently loading */
|
|
@@ -268,7 +234,7 @@ export interface ThemeProviderProps {
|
|
|
268
234
|
/** Use minified CSS */
|
|
269
235
|
useMinified?: boolean;
|
|
270
236
|
/** Callback when theme changes */
|
|
271
|
-
onThemeChange?: (theme: string | Theme) => void;
|
|
237
|
+
onThemeChange?: (theme: string | Theme | import('./tokens').DesignTokens) => void;
|
|
272
238
|
/** Callback on error */
|
|
273
239
|
onError?: (error: Error, themeName: string) => void;
|
|
274
240
|
}
|
|
@@ -281,8 +247,8 @@ export interface ThemeContextValue {
|
|
|
281
247
|
theme: string;
|
|
282
248
|
/** Current active theme object (for JS themes) */
|
|
283
249
|
activeTheme: Theme | null;
|
|
284
|
-
/** Set theme function */
|
|
285
|
-
setTheme: (theme: string | Theme
|
|
250
|
+
/** Set theme function (supports string, Theme, or DesignTokens) */
|
|
251
|
+
setTheme: (theme: string | Theme | import('./tokens').DesignTokens | Partial<import('./tokens').DesignTokens>, options?: ThemeLoadOptions) => Promise<void>;
|
|
286
252
|
/** Available themes */
|
|
287
253
|
availableThemes: ThemeMetadata[];
|
|
288
254
|
/** Loading state */
|
|
@@ -293,8 +259,6 @@ export interface ThemeContextValue {
|
|
|
293
259
|
isThemeLoaded: (themeName: string) => boolean;
|
|
294
260
|
/** Preload theme */
|
|
295
261
|
preloadTheme: (themeName: string) => Promise<void>;
|
|
296
|
-
/** Theme manager instance */
|
|
297
|
-
themeManager: ThemeManagerType;
|
|
298
262
|
}
|
|
299
263
|
|
|
300
264
|
// ============================================================================
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* and theme validation.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { ThemeMetadata, ThemeValidationResult } from '
|
|
9
|
-
import { THEME_LINK_ID_PREFIX } from '
|
|
8
|
+
import type { ThemeMetadata, ThemeValidationResult } from '../types';
|
|
9
|
+
import { THEME_LINK_ID_PREFIX } from '../constants/constants';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Check if code is running in a browser environment
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSS Injection Utilities
|
|
3
|
+
*
|
|
4
|
+
* Inject CSS into HTML head via <style> element.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Check if running in browser environment
|
|
9
|
+
*/
|
|
10
|
+
function isBrowser(): boolean {
|
|
11
|
+
return typeof document !== 'undefined';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Inject CSS into HTML head via <style> element
|
|
16
|
+
*
|
|
17
|
+
* Creates or updates a style element in the document head.
|
|
18
|
+
* If an element with the same ID exists, it will be updated.
|
|
19
|
+
*
|
|
20
|
+
* @param css - CSS string to inject
|
|
21
|
+
* @param id - Style element ID (default: 'atomix-theme')
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const css = ':root { --atomix-color-primary: #7AFFD7; }';
|
|
26
|
+
* injectCSS(css);
|
|
27
|
+
*
|
|
28
|
+
* // With custom ID
|
|
29
|
+
* injectCSS(css, 'my-custom-theme');
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export function injectCSS(
|
|
33
|
+
css: string,
|
|
34
|
+
id: string = 'atomix-theme'
|
|
35
|
+
): void {
|
|
36
|
+
if (!isBrowser()) {
|
|
37
|
+
console.warn('injectCSS: Not in browser environment, CSS not injected');
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let styleElement = document.getElementById(id) as HTMLStyleElement | null;
|
|
42
|
+
|
|
43
|
+
if (!styleElement) {
|
|
44
|
+
styleElement = document.createElement('style');
|
|
45
|
+
styleElement.id = id;
|
|
46
|
+
styleElement.setAttribute('data-atomix-theme', 'true');
|
|
47
|
+
document.head.appendChild(styleElement);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
styleElement.textContent = css;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Remove injected CSS from DOM
|
|
55
|
+
*
|
|
56
|
+
* Removes the style element with the given ID from the document head.
|
|
57
|
+
*
|
|
58
|
+
* @param id - Style element ID to remove (default: 'atomix-theme')
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* removeCSS(); // Removes default 'atomix-theme'
|
|
63
|
+
* removeCSS('my-custom-theme'); // Removes custom ID
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export function removeCSS(id: string = 'atomix-theme'): void {
|
|
67
|
+
if (!isBrowser()) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const styleElement = document.getElementById(id);
|
|
72
|
+
if (styleElement) {
|
|
73
|
+
styleElement.remove();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Check if CSS is already injected
|
|
79
|
+
*
|
|
80
|
+
* @param id - Style element ID to check (default: 'atomix-theme')
|
|
81
|
+
* @returns True if style element exists
|
|
82
|
+
*/
|
|
83
|
+
export function isCSSInjected(id: string = 'atomix-theme'): boolean {
|
|
84
|
+
if (!isBrowser()) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return document.getElementById(id) !== null;
|
|
89
|
+
}
|
|
90
|
+
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme Helper Functions
|
|
3
|
+
*
|
|
4
|
+
* Utility functions for working with themes and DesignTokens
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { Theme } from '../types';
|
|
8
|
+
import type { DesignTokens } from '../tokens/tokens';
|
|
9
|
+
import { createDesignTokensFromTheme } from '../adapters/themeAdapter';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Get DesignTokens from current theme
|
|
13
|
+
*
|
|
14
|
+
* Converts a Theme object to DesignTokens. Useful when you need to
|
|
15
|
+
* work with DesignTokens but have a Theme object.
|
|
16
|
+
*
|
|
17
|
+
* @param theme - Theme object to convert
|
|
18
|
+
* @returns DesignTokens object
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* // If you have a Theme object, convert it to DesignTokens
|
|
23
|
+
* const tokens = getDesignTokensFromTheme(theme);
|
|
24
|
+
* // Now you can use tokens with unified theme system
|
|
25
|
+
* const css = createTheme(tokens);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function getDesignTokensFromTheme(theme: Theme | null): DesignTokens | null {
|
|
29
|
+
if (!theme) return null;
|
|
30
|
+
return createDesignTokensFromTheme(theme);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Check if a value is DesignTokens
|
|
35
|
+
*
|
|
36
|
+
* Type guard to check if an object is DesignTokens format.
|
|
37
|
+
*
|
|
38
|
+
* @param value - Value to check
|
|
39
|
+
* @returns True if value is DesignTokens
|
|
40
|
+
*/
|
|
41
|
+
export function isDesignTokens(value: unknown): value is DesignTokens {
|
|
42
|
+
if (!value || typeof value !== 'object') return false;
|
|
43
|
+
|
|
44
|
+
// DesignTokens is a flat object with string keys, no nested structures
|
|
45
|
+
const obj = value as Record<string, unknown>;
|
|
46
|
+
|
|
47
|
+
// Check for absence of Theme-specific properties
|
|
48
|
+
if ('palette' in obj || 'typography' in obj || '__isJSTheme' in obj) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Check if it has DesignTokens-like structure (flat string keys)
|
|
53
|
+
const keys = Object.keys(obj);
|
|
54
|
+
if (keys.length === 0) return false;
|
|
55
|
+
|
|
56
|
+
// Check if keys look like DesignTokens (kebab-case, no nesting)
|
|
57
|
+
const hasDesignTokenKeys = keys.some(key =>
|
|
58
|
+
/^[a-z]+(-[a-z0-9]+)*$/.test(key) &&
|
|
59
|
+
typeof obj[key] === 'string'
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
return hasDesignTokenKeys;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Check if a value is a Theme object
|
|
67
|
+
*
|
|
68
|
+
* Type guard to check if an object is a Theme.
|
|
69
|
+
*
|
|
70
|
+
* @param value - Value to check
|
|
71
|
+
* @returns True if value is Theme
|
|
72
|
+
*/
|
|
73
|
+
export function isThemeObject(value: unknown): value is Theme {
|
|
74
|
+
if (!value || typeof value !== 'object') return false;
|
|
75
|
+
const obj = value as Record<string, unknown>;
|
|
76
|
+
return '__isJSTheme' in obj || ('palette' in obj && 'typography' in obj);
|
|
77
|
+
}
|
|
78
|
+
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* spacing helpers, and theme value accessors.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { Theme, SpacingFunction, SpacingOptions } from '
|
|
8
|
+
import type { Theme, SpacingFunction, SpacingOptions } from '../types';
|
|
9
9
|
|
|
10
10
|
// ============================================================================
|
|
11
11
|
// Color Manipulation Utilities
|
package/src/lib/theme-tools.ts
CHANGED
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { Theme, ThemeMetadata } from './theme/types';
|
|
8
|
-
import {
|
|
9
|
-
import { extendTheme, mergeTheme } from './theme/composeTheme';
|
|
10
|
-
import { generateCSSVariables } from './theme/generateCSSVariables';
|
|
8
|
+
import { createThemeObject } from './theme/core/createThemeObject';
|
|
9
|
+
import { extendTheme, mergeTheme } from './theme/core/composeTheme';
|
|
10
|
+
import { generateCSSVariables } from './theme/generators/generateCSSVariables';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Quick theme creator with sensible defaults
|
|
14
14
|
*/
|
|
15
15
|
export function quickTheme(name: string, primaryColor: string, secondaryColor?: string): Theme {
|
|
16
|
-
return
|
|
16
|
+
return createThemeObject({
|
|
17
17
|
name,
|
|
18
18
|
palette: {
|
|
19
19
|
primary: { main: primaryColor },
|
|
@@ -32,7 +32,7 @@ export function createDarkVariant(lightTheme: Theme): Theme {
|
|
|
32
32
|
mode: 'dark',
|
|
33
33
|
background: {
|
|
34
34
|
default: '#121212',
|
|
35
|
-
|
|
35
|
+
subtle: '#1e1e1e',
|
|
36
36
|
},
|
|
37
37
|
text: {
|
|
38
38
|
primary: '#ffffff',
|
|
@@ -119,7 +119,6 @@ export function importTheme(json: string): Theme {
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
//
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
export { RTLManager } from './theme/i18n/rtl';
|
|
122
|
+
// Note: createTheme, extendTheme, mergeTheme, and generateCSSVariables
|
|
123
|
+
// are already exported from './theme' module. Import them directly from there.
|
|
124
|
+
// This file only exports theme-tools specific utilities.
|
|
@@ -560,6 +560,36 @@ export interface ButtonProps extends BaseComponentProps {
|
|
|
560
560
|
style?: React.CSSProperties;
|
|
561
561
|
}
|
|
562
562
|
|
|
563
|
+
/**
|
|
564
|
+
* ButtonGroup component properties
|
|
565
|
+
*/
|
|
566
|
+
export interface ButtonGroupProps extends BaseComponentProps {
|
|
567
|
+
/**
|
|
568
|
+
* ButtonGroup children (should be Button components)
|
|
569
|
+
*/
|
|
570
|
+
children?: ReactNode;
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* Additional CSS class names
|
|
574
|
+
*/
|
|
575
|
+
className?: string;
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Inline style for the component root element
|
|
579
|
+
*/
|
|
580
|
+
style?: React.CSSProperties;
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* ARIA label for accessibility
|
|
584
|
+
*/
|
|
585
|
+
'aria-label'?: string;
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* ARIA role for the button group
|
|
589
|
+
*/
|
|
590
|
+
role?: string;
|
|
591
|
+
}
|
|
592
|
+
|
|
563
593
|
/**
|
|
564
594
|
* Badge component properties
|
|
565
595
|
*/
|
|
@@ -716,6 +746,27 @@ export interface AccordionProps extends BaseComponentProps {
|
|
|
716
746
|
*/
|
|
717
747
|
icon?: ReactNode;
|
|
718
748
|
|
|
749
|
+
/**
|
|
750
|
+
* Whether the accordion is open
|
|
751
|
+
*/
|
|
752
|
+
isOpen?: boolean;
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* Whether the accordion is disabled
|
|
756
|
+
*/
|
|
757
|
+
disabled?: boolean;
|
|
758
|
+
|
|
759
|
+
onOpenChange?: (open: boolean) => void;
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* Optional open handler
|
|
763
|
+
*/
|
|
764
|
+
onOpen?: () => void;
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* Optional close handler
|
|
768
|
+
*/
|
|
769
|
+
onClose?: () => void;
|
|
719
770
|
/**
|
|
720
771
|
* Glass morphism effect for the accordion
|
|
721
772
|
* Can be a boolean to enable with default settings, or an object with AtomixGlassProps to customize the effect
|
|
@@ -996,6 +1047,24 @@ export interface SpinnerProps extends BaseComponentProps {
|
|
|
996
1047
|
glass?: AtomixGlassProps | boolean;
|
|
997
1048
|
}
|
|
998
1049
|
|
|
1050
|
+
/**
|
|
1051
|
+
* Icon size options
|
|
1052
|
+
*/
|
|
1053
|
+
export type IconSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
1054
|
+
|
|
1055
|
+
/**
|
|
1056
|
+
* Icon weight/style options
|
|
1057
|
+
*/
|
|
1058
|
+
export type IconWeight = 'thin' | 'light' | 'regular' | 'bold' | 'fill' | 'duotone';
|
|
1059
|
+
|
|
1060
|
+
/**
|
|
1061
|
+
* Phosphor icon type - excludes internal Phosphor exports
|
|
1062
|
+
*/
|
|
1063
|
+
export type PhosphorIconsType = Exclude<
|
|
1064
|
+
keyof typeof import('@phosphor-icons/react'),
|
|
1065
|
+
'IconContext' | 'IconBase' | 'createIcon' | 'default' | 'SSR'
|
|
1066
|
+
>;
|
|
1067
|
+
|
|
999
1068
|
/**
|
|
1000
1069
|
* Navbar position options
|
|
1001
1070
|
*/
|
|
@@ -1702,6 +1771,16 @@ export interface PaginationProps extends BaseComponentProps {
|
|
|
1702
1771
|
*/
|
|
1703
1772
|
showPrevNextButtons?: boolean;
|
|
1704
1773
|
|
|
1774
|
+
/**
|
|
1775
|
+
* Whether to show search input for jumping to a specific page
|
|
1776
|
+
*/
|
|
1777
|
+
showSearch?: boolean;
|
|
1778
|
+
|
|
1779
|
+
/**
|
|
1780
|
+
* Placeholder text for the search input
|
|
1781
|
+
*/
|
|
1782
|
+
searchPlaceholder?: string;
|
|
1783
|
+
|
|
1705
1784
|
/**
|
|
1706
1785
|
* Custom class for the pagination container
|
|
1707
1786
|
*/
|
|
@@ -2728,18 +2807,28 @@ export interface BreadcrumbItem {
|
|
|
2728
2807
|
active?: boolean;
|
|
2729
2808
|
|
|
2730
2809
|
/**
|
|
2731
|
-
* Icon name from Phosphor Icons
|
|
2810
|
+
* Icon name from Phosphor Icons or ReactNode
|
|
2732
2811
|
*/
|
|
2733
|
-
icon?: string;
|
|
2812
|
+
icon?: string | ReactNode;
|
|
2734
2813
|
|
|
2735
2814
|
/**
|
|
2736
2815
|
* Optional click handler
|
|
2737
2816
|
*/
|
|
2738
|
-
onClick?: (event: MouseEvent) => void;
|
|
2817
|
+
onClick?: (event: React.MouseEvent<HTMLAnchorElement>) => void;
|
|
2818
|
+
|
|
2819
|
+
/**
|
|
2820
|
+
* Custom style for the breadcrumb item
|
|
2821
|
+
*/
|
|
2822
|
+
style?: React.CSSProperties;
|
|
2823
|
+
|
|
2824
|
+
/**
|
|
2825
|
+
* Additional className
|
|
2826
|
+
*/
|
|
2827
|
+
className?: string;
|
|
2739
2828
|
}
|
|
2740
2829
|
|
|
2741
2830
|
/**
|
|
2742
|
-
* Breadcrumb options interface
|
|
2831
|
+
* Breadcrumb options interface (for vanilla JS)
|
|
2743
2832
|
*/
|
|
2744
2833
|
export interface BreadcrumbOptions {
|
|
2745
2834
|
/**
|
|
@@ -6227,36 +6316,6 @@ export interface FooterSocialLinkProps extends BaseComponentProps {
|
|
|
6227
6316
|
*/
|
|
6228
6317
|
export type GlassMode = 'standard' | 'polar' | 'prominent' | 'shader';
|
|
6229
6318
|
|
|
6230
|
-
/**
|
|
6231
|
-
* Glass container size configuration
|
|
6232
|
-
*/
|
|
6233
|
-
export interface GlassSize {
|
|
6234
|
-
/**
|
|
6235
|
-
* Width of the glass container
|
|
6236
|
-
*/
|
|
6237
|
-
width: number;
|
|
6238
|
-
|
|
6239
|
-
/**
|
|
6240
|
-
* Height of the glass container
|
|
6241
|
-
*/
|
|
6242
|
-
height: number;
|
|
6243
|
-
}
|
|
6244
|
-
|
|
6245
|
-
/**
|
|
6246
|
-
* Mouse position coordinates
|
|
6247
|
-
*/
|
|
6248
|
-
export interface MousePosition {
|
|
6249
|
-
/**
|
|
6250
|
-
* X coordinate
|
|
6251
|
-
*/
|
|
6252
|
-
x: number;
|
|
6253
|
-
|
|
6254
|
-
/**
|
|
6255
|
-
* Y coordinate
|
|
6256
|
-
*/
|
|
6257
|
-
y: number;
|
|
6258
|
-
}
|
|
6259
|
-
|
|
6260
6319
|
/**
|
|
6261
6320
|
* Glass container component properties
|
|
6262
6321
|
*/
|
|
@@ -384,22 +384,6 @@ export function mergePartStyles(
|
|
|
384
384
|
};
|
|
385
385
|
}
|
|
386
386
|
|
|
387
|
-
/**
|
|
388
|
-
* Utility function to apply part styles to props
|
|
389
|
-
*/
|
|
390
|
-
export function applyPartStyles<T extends Record<string, any>>(
|
|
391
|
-
props: T,
|
|
392
|
-
part?: PartStyleProps
|
|
393
|
-
): T {
|
|
394
|
-
if (!part) return props;
|
|
395
|
-
|
|
396
|
-
return {
|
|
397
|
-
...props,
|
|
398
|
-
className: [props.className, part.className].filter(Boolean).join(' '),
|
|
399
|
-
style: { ...props.style, ...part.style },
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
|
|
403
387
|
/**
|
|
404
388
|
* Map of component names to their part types
|
|
405
389
|
*/
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import type { PartStyleProps } from '../types/partProps';
|
|
9
|
-
import { cssVarsToStyle } from '../theme/cssVariableMapper';
|
|
9
|
+
import { cssVarsToStyle } from '../theme/adapters/cssVariableMapper';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Merge multiple class names
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Font Preloading Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities for preloading fonts to improve performance
|
|
5
|
+
* and prevent Flash of Invisible Text (FOIT).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface FontPreloadConfig {
|
|
9
|
+
/**
|
|
10
|
+
* Font family name
|
|
11
|
+
*/
|
|
12
|
+
family: string;
|
|
13
|
+
/**
|
|
14
|
+
* Font file path (relative to public/assets/fonts or absolute URL)
|
|
15
|
+
*/
|
|
16
|
+
path: string;
|
|
17
|
+
/**
|
|
18
|
+
* Font weight
|
|
19
|
+
*/
|
|
20
|
+
weight?: string | number;
|
|
21
|
+
/**
|
|
22
|
+
* Font style
|
|
23
|
+
*/
|
|
24
|
+
style?: 'normal' | 'italic';
|
|
25
|
+
/**
|
|
26
|
+
* Font format (woff2 is preferred)
|
|
27
|
+
*/
|
|
28
|
+
format?: 'woff2' | 'woff';
|
|
29
|
+
/**
|
|
30
|
+
* Cross-origin setting
|
|
31
|
+
*/
|
|
32
|
+
crossorigin?: 'anonymous' | 'use-credentials';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Creates a preload link element for a font
|
|
37
|
+
*
|
|
38
|
+
* @param config - Font preload configuration
|
|
39
|
+
* @returns HTML link element for preloading
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```tsx
|
|
43
|
+
* const preloadLink = createFontPreloadLink({
|
|
44
|
+
* family: 'Nunito Sans',
|
|
45
|
+
* path: '/fonts/nunito-sans/nunito-sans-regular.woff2',
|
|
46
|
+
* weight: 400
|
|
47
|
+
* });
|
|
48
|
+
* document.head.appendChild(preloadLink);
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export function createFontPreloadLink(config: FontPreloadConfig): HTMLLinkElement {
|
|
52
|
+
const {
|
|
53
|
+
path,
|
|
54
|
+
format = 'woff2',
|
|
55
|
+
crossorigin = 'anonymous',
|
|
56
|
+
} = config;
|
|
57
|
+
|
|
58
|
+
const link = document.createElement('link');
|
|
59
|
+
link.rel = 'preload';
|
|
60
|
+
link.as = 'font';
|
|
61
|
+
link.href = path;
|
|
62
|
+
link.type = `font/${format}`;
|
|
63
|
+
link.crossOrigin = crossorigin;
|
|
64
|
+
|
|
65
|
+
return link;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Preloads multiple fonts
|
|
70
|
+
*
|
|
71
|
+
* @param fonts - Array of font configurations to preload
|
|
72
|
+
* @returns Array of created link elements
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```tsx
|
|
76
|
+
* const links = preloadFonts([
|
|
77
|
+
* { family: 'Nunito Sans', path: '/fonts/nunito-sans/nunito-sans-regular.woff2', weight: 400 },
|
|
78
|
+
* { family: 'Nunito Sans', path: '/fonts/nunito-sans/nunito-sans-bold.woff2', weight: 700 },
|
|
79
|
+
* ]);
|
|
80
|
+
* links.forEach(link => document.head.appendChild(link));
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export function preloadFonts(fonts: FontPreloadConfig[]): HTMLLinkElement[] {
|
|
84
|
+
return fonts.map(createFontPreloadLink);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Generates preload link HTML tags as strings
|
|
89
|
+
* Useful for server-side rendering or static HTML generation
|
|
90
|
+
*
|
|
91
|
+
* @param fonts - Array of font configurations
|
|
92
|
+
* @returns Array of HTML string representations
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```tsx
|
|
96
|
+
* const htmlTags = generateFontPreloadTags([
|
|
97
|
+
* { family: 'Nunito Sans', path: '/fonts/nunito-sans/nunito-sans-regular.woff2' },
|
|
98
|
+
* ]);
|
|
99
|
+
* // Returns: ['<link rel="preload" as="font" href="/fonts/..." type="font/woff2" crossorigin="anonymous">']
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export function generateFontPreloadTags(fonts: FontPreloadConfig[]): string[] {
|
|
103
|
+
return fonts.map((config) => {
|
|
104
|
+
const {
|
|
105
|
+
path,
|
|
106
|
+
format = 'woff2',
|
|
107
|
+
crossorigin = 'anonymous',
|
|
108
|
+
} = config;
|
|
109
|
+
|
|
110
|
+
return `<link rel="preload" as="font" href="${path}" type="font/${format}" crossorigin="${crossorigin}">`;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Default font configurations for Atomix Design System
|
|
116
|
+
* These can be used as a starting point for font preloading
|
|
117
|
+
*/
|
|
118
|
+
export const DEFAULT_ATOMIX_FONTS: FontPreloadConfig[] = [
|
|
119
|
+
{
|
|
120
|
+
family: 'Nunito Sans',
|
|
121
|
+
path: '/fonts/nunito-sans/nunito-sans-regular.woff2',
|
|
122
|
+
weight: 400,
|
|
123
|
+
style: 'normal',
|
|
124
|
+
format: 'woff2',
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
family: 'Nunito Sans',
|
|
128
|
+
path: '/fonts/nunito-sans/nunito-sans-bold.woff2',
|
|
129
|
+
weight: 700,
|
|
130
|
+
style: 'normal',
|
|
131
|
+
format: 'woff2',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
family: 'Nunito Sans',
|
|
135
|
+
path: '/fonts/nunito-sans/nunito-sans-italic.woff2',
|
|
136
|
+
weight: 400,
|
|
137
|
+
style: 'italic',
|
|
138
|
+
format: 'woff2',
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
family: 'Nunito Sans',
|
|
142
|
+
path: '/fonts/nunito-sans/nunito-sans-bold-italic.woff2',
|
|
143
|
+
weight: 700,
|
|
144
|
+
style: 'italic',
|
|
145
|
+
format: 'woff2',
|
|
146
|
+
},
|
|
147
|
+
];
|
|
148
|
+
|