@shohojdhara/atomix 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/dist/atomix.css +309 -105
  2. package/dist/atomix.min.css +3 -5
  3. package/dist/index.d.ts +804 -53
  4. package/dist/index.esm.js +16367 -16413
  5. package/dist/index.esm.js.map +1 -1
  6. package/dist/index.js +16275 -16336
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.min.js +1 -1
  9. package/dist/index.min.js.map +1 -1
  10. package/dist/themes/applemix.css +309 -105
  11. package/dist/themes/applemix.min.css +5 -7
  12. package/dist/themes/boomdevs.css +202 -10
  13. package/dist/themes/boomdevs.min.css +3 -5
  14. package/dist/themes/esrar.css +309 -105
  15. package/dist/themes/esrar.min.css +4 -6
  16. package/dist/themes/flashtrade.css +310 -105
  17. package/dist/themes/flashtrade.min.css +5 -7
  18. package/dist/themes/mashroom.css +300 -96
  19. package/dist/themes/mashroom.min.css +4 -6
  20. package/dist/themes/shaj-default.css +300 -96
  21. package/dist/themes/shaj-default.min.css +4 -6
  22. package/package.json +1 -1
  23. package/src/components/AtomixGlass/AtomixGlass.test.tsx +21 -32
  24. package/src/components/AtomixGlass/AtomixGlass.tsx +55 -42
  25. package/src/components/AtomixGlass/AtomixGlassContainer.tsx +205 -57
  26. package/src/components/AtomixGlass/GlassFilter.tsx +22 -8
  27. package/src/components/AtomixGlass/__snapshots__/AtomixGlass.test.tsx.snap +221 -0
  28. package/src/components/AtomixGlass/atomixGLass.old.tsx +0 -3
  29. package/src/components/AtomixGlass/shader-utils.ts +8 -0
  30. package/src/components/AtomixGlass/stories/AtomixGlass.stories.tsx +319 -100
  31. package/src/components/AtomixGlass/stories/Examples.stories.tsx +601 -105
  32. package/src/components/AtomixGlass/stories/Modes.stories.tsx +30 -12
  33. package/src/components/AtomixGlass/stories/Playground.stories.tsx +173 -38
  34. package/src/components/AtomixGlass/stories/ShaderVariants.stories.tsx +18 -18
  35. package/src/components/AtomixGlass/stories/shared-components.tsx +27 -5
  36. package/src/components/Button/Button.tsx +62 -17
  37. package/src/components/Callout/Callout.test.tsx +8 -14
  38. package/src/components/Card/Card.tsx +103 -1
  39. package/src/components/Card/index.ts +3 -2
  40. package/src/components/Icon/index.ts +1 -1
  41. package/src/components/Modal/Modal.stories.tsx +29 -38
  42. package/src/components/Modal/Modal.tsx +4 -4
  43. package/src/components/Navigation/SideMenu/SideMenu.tsx +49 -41
  44. package/src/components/Navigation/SideMenu/SideMenuItem.tsx +63 -24
  45. package/src/components/Popover/Popover.tsx +1 -1
  46. package/src/components/VideoPlayer/VideoPlayer.stories.tsx +977 -400
  47. package/src/components/VideoPlayer/VideoPlayer.tsx +1 -6
  48. package/src/lib/composables/shared-mouse-tracker.ts +133 -0
  49. package/src/lib/composables/useAtomixGlass.ts +303 -115
  50. package/src/lib/theme/ThemeManager.integration.test.ts +124 -0
  51. package/src/lib/theme/ThemeManager.stories.tsx +13 -13
  52. package/src/lib/theme/ThemeManager.test.ts +4 -0
  53. package/src/lib/theme/ThemeManager.ts +203 -59
  54. package/src/lib/theme/ThemeProvider.tsx +183 -33
  55. package/src/lib/theme/composeTheme.ts +375 -0
  56. package/src/lib/theme/createTheme.test.ts +475 -0
  57. package/src/lib/theme/createTheme.ts +510 -0
  58. package/src/lib/theme/generateCSSVariables.ts +713 -0
  59. package/src/lib/theme/index.ts +67 -0
  60. package/src/lib/theme/themeUtils.ts +333 -0
  61. package/src/lib/theme/types.ts +337 -8
  62. package/src/lib/theme/useTheme.test.tsx +2 -1
  63. package/src/lib/theme/useTheme.ts +6 -22
  64. package/src/lib/types/components.ts +148 -59
  65. package/src/styles/01-settings/_index.scss +2 -2
  66. package/src/styles/01-settings/_settings.badge.scss +2 -2
  67. package/src/styles/01-settings/_settings.border-radius.scss +1 -1
  68. package/src/styles/01-settings/{_settings.maps.scss → _settings.design-tokens.scss} +163 -49
  69. package/src/styles/01-settings/_settings.modal.scss +1 -1
  70. package/src/styles/01-settings/_settings.spacing.scss +14 -13
  71. package/src/styles/03-generic/_generic.root.scss +131 -50
  72. package/src/styles/05-objects/_objects.block.scss +1 -1
  73. package/src/styles/06-components/_components.atomix-glass.scss +20 -22
  74. package/src/styles/06-components/_components.badge.scss +2 -2
  75. package/src/styles/06-components/_components.button.scss +1 -1
  76. package/src/styles/06-components/_components.callout.scss +1 -1
  77. package/src/styles/06-components/_components.card.scss +74 -2
  78. package/src/styles/06-components/_components.chart.scss +1 -1
  79. package/src/styles/06-components/_components.dropdown.scss +6 -0
  80. package/src/styles/06-components/_components.footer.scss +1 -1
  81. package/src/styles/06-components/_components.list-group.scss +1 -1
  82. package/src/styles/06-components/_components.list.scss +1 -1
  83. package/src/styles/06-components/_components.menu.scss +1 -1
  84. package/src/styles/06-components/_components.messages.scss +1 -1
  85. package/src/styles/06-components/_components.modal.scss +7 -2
  86. package/src/styles/06-components/_components.navbar.scss +1 -1
  87. package/src/styles/06-components/_components.popover.scss +10 -0
  88. package/src/styles/06-components/_components.product-review.scss +1 -1
  89. package/src/styles/06-components/_components.progress.scss +1 -1
  90. package/src/styles/06-components/_components.rating.scss +1 -1
  91. package/src/styles/06-components/_components.spinner.scss +1 -1
  92. package/src/styles/99-utilities/_utilities.background.scss +1 -1
  93. package/src/styles/99-utilities/_utilities.border.scss +1 -1
  94. package/src/styles/99-utilities/_utilities.link.scss +1 -1
  95. package/src/styles/99-utilities/_utilities.text.scss +1 -1
@@ -16,6 +16,58 @@ export { default as useThemeDefault } from './useTheme';
16
16
  export { ThemeContext } from './ThemeContext';
17
17
  export { default as ThemeContextDefault } from './ThemeContext';
18
18
 
19
+ // createTheme System
20
+ export { createTheme } from './createTheme';
21
+ export { default as createThemeDefault } from './createTheme';
22
+
23
+ // CSS Variable Generation
24
+ export {
25
+ generateCSSVariables,
26
+ injectCSS,
27
+ removeInjectedCSS,
28
+ generateSectionVariables,
29
+ } from './generateCSSVariables';
30
+ export type { GenerateCSSVariablesOptions } from './generateCSSVariables';
31
+
32
+ // Theme Composition
33
+ export {
34
+ deepMerge,
35
+ mergeTheme,
36
+ extendTheme,
37
+ createThemeVariants,
38
+ overrideTheme,
39
+ composeThemes,
40
+ createThemePreset,
41
+ } from './composeTheme';
42
+
43
+ // Theme Utilities
44
+ export {
45
+ hexToRgb,
46
+ rgbToHex,
47
+ getLuminance,
48
+ getContrastRatio,
49
+ getContrastText,
50
+ lighten,
51
+ darken,
52
+ alpha,
53
+ emphasize,
54
+ createSpacing,
55
+ spacing,
56
+ getThemeValue,
57
+ isJSTheme,
58
+ breakpointUp,
59
+ breakpointDown,
60
+ breakpointBetween,
61
+ getTypography,
62
+ remToPx,
63
+ pxToRem,
64
+ getShadow,
65
+ createTransition,
66
+ getTransitionDuration,
67
+ getTransitionEasing,
68
+ getZIndex,
69
+ } from './themeUtils';
70
+
19
71
  // Types
20
72
  export type {
21
73
  ThemeMetadata,
@@ -33,6 +85,20 @@ export type {
33
85
  ThemeProviderProps,
34
86
  ThemeContextValue,
35
87
  StorageAdapter,
88
+ // createTheme System Types
89
+ PaletteColor,
90
+ PaletteOptions,
91
+ TypographyOptions,
92
+ SpacingOptions,
93
+ SpacingFunction,
94
+ BreakpointValues,
95
+ BreakpointsOptions,
96
+ ShadowOptions,
97
+ TransitionOptions,
98
+ ZIndexOptions,
99
+ ThemeCustomProperties,
100
+ ThemeOptions,
101
+ Theme,
36
102
  } from './types';
37
103
 
38
104
  // Utilities
@@ -54,3 +120,4 @@ export {
54
120
  createLocalStorageAdapter,
55
121
  debounce,
56
122
  } from './utils';
123
+
@@ -0,0 +1,333 @@
1
+ /**
2
+ * Theme Utilities
3
+ *
4
+ * Helper utilities for working with themes, including color manipulation,
5
+ * spacing helpers, and theme value accessors.
6
+ */
7
+
8
+ import type { Theme, SpacingFunction } from './types';
9
+
10
+ // ============================================================================
11
+ // Color Manipulation Utilities
12
+ // ============================================================================
13
+
14
+ /**
15
+ * Convert hex color to RGB object
16
+ */
17
+ export function hexToRgb(hex: string): { r: number; g: number; b: number } | null {
18
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
19
+ return result
20
+ ? {
21
+ r: parseInt(result[1]!, 16),
22
+ g: parseInt(result[2]!, 16),
23
+ b: parseInt(result[3]!, 16),
24
+ }
25
+ : null;
26
+ }
27
+
28
+ /**
29
+ * Convert RGB to hex color
30
+ */
31
+ export function rgbToHex(r: number, g: number, b: number): string {
32
+ const toHex = (val: number) => {
33
+ const hex = Math.round(Math.max(0, Math.min(255, val)))
34
+ .toString(16)
35
+ .padStart(2, '0');
36
+ return hex;
37
+ };
38
+ return `#${toHex(r ?? 0)}${toHex(g ?? 0)}${toHex(b ?? 0)}`;
39
+ }
40
+
41
+ /**
42
+ * Calculate relative luminance of a color
43
+ * Used for determining contrast ratios
44
+ */
45
+ export function getLuminance(color: string): number {
46
+ const rgb = hexToRgb(color);
47
+ if (!rgb) return 0;
48
+
49
+ const { r, g, b } = rgb;
50
+ const [rs, gs, bs] = [r ?? 0, g ?? 0, b ?? 0].map((c) => {
51
+ const val = c / 255;
52
+ return val <= 0.03928 ? val / 12.92 : Math.pow((val + 0.055) / 1.055, 2.4);
53
+ });
54
+
55
+ return 0.2126 * (rs ?? 0) + 0.7152 * (gs ?? 0) + 0.0722 * (bs ?? 0);
56
+ }
57
+
58
+ /**
59
+ * Calculate contrast ratio between two colors
60
+ */
61
+ export function getContrastRatio(foreground: string, background: string): number {
62
+ const lumA = getLuminance(foreground);
63
+ const lumB = getLuminance(background);
64
+ return (Math.max(lumA, lumB) + 0.05) / (Math.min(lumA, lumB) + 0.05);
65
+ }
66
+
67
+ /**
68
+ * Get appropriate contrast text color (black or white) for a background color
69
+ */
70
+ export function getContrastText(background: string, threshold: number = 3): string {
71
+ const contrastWithWhite = getContrastRatio('#FFFFFF', background);
72
+ const contrastWithBlack = getContrastRatio('#000000', background);
73
+
74
+ if (contrastWithWhite >= threshold) {
75
+ return '#FFFFFF';
76
+ }
77
+ if (contrastWithBlack >= threshold) {
78
+ return '#000000';
79
+ }
80
+
81
+ // Default to white if neither meets threshold
82
+ return contrastWithWhite > contrastWithBlack ? '#FFFFFF' : '#000000';
83
+ }
84
+
85
+ /**
86
+ * Lighten a color by a given amount
87
+ *
88
+ * @param color - Hex color string
89
+ * @param amount - Amount to lighten (0-1), default 0.2
90
+ * @returns Lightened hex color
91
+ */
92
+ export function lighten(color: string, amount: number = 0.2): string {
93
+ const rgb = hexToRgb(color);
94
+ if (!rgb) return color;
95
+
96
+ const { r, g, b } = rgb;
97
+ const lightenValue = (val: number) => Math.min(255, Math.round(val + (255 - val) * amount));
98
+
99
+ return rgbToHex(lightenValue(r), lightenValue(g), lightenValue(b));
100
+ }
101
+
102
+ /**
103
+ * Darken a color by a given amount
104
+ *
105
+ * @param color - Hex color string
106
+ * @param amount - Amount to darken (0-1), default 0.2
107
+ * @returns Darkened hex color
108
+ */
109
+ export function darken(color: string, amount: number = 0.2): string {
110
+ const rgb = hexToRgb(color);
111
+ if (!rgb) return color;
112
+
113
+ const { r, g, b } = rgb;
114
+ const darkenValue = (val: number) => Math.max(0, Math.round(val * (1 - amount)));
115
+
116
+ return rgbToHex(darkenValue(r), darkenValue(g), darkenValue(b));
117
+ }
118
+
119
+ /**
120
+ * Add alpha (opacity) to a color
121
+ *
122
+ * @param color - Hex color string
123
+ * @param opacity - Opacity value (0-1)
124
+ * @returns RGBA color string
125
+ */
126
+ export function alpha(color: string, opacity: number): string {
127
+ const rgb = hexToRgb(color);
128
+ if (!rgb) return color;
129
+
130
+ const { r, g, b } = rgb;
131
+ const clampedOpacity = Math.max(0, Math.min(1, opacity));
132
+
133
+ return `rgba(${r}, ${g}, ${b}, ${clampedOpacity})`;
134
+ }
135
+
136
+ /**
137
+ * Emphasize a color (lighten if dark, darken if light)
138
+ *
139
+ * @param color - Hex color string
140
+ * @param coefficient - Amount to emphasize (0-1), default 0.15
141
+ * @returns Emphasized hex color
142
+ */
143
+ export function emphasize(color: string, coefficient: number = 0.15): string {
144
+ const luminance = getLuminance(color);
145
+ return luminance > 0.5 ? darken(color, coefficient) : lighten(color, coefficient);
146
+ }
147
+
148
+ // ============================================================================
149
+ // Spacing Utilities
150
+ // ============================================================================
151
+
152
+ /**
153
+ * Create a spacing function with a given base unit
154
+ *
155
+ * @param base - Base spacing unit in pixels, default 4
156
+ * @returns Spacing function
157
+ */
158
+ export function createSpacing(base: number = 4): SpacingFunction {
159
+ return (...values: number[]) => {
160
+ if (values.length === 0) return '0px';
161
+ return values.map((value) => `${value * base}px`).join(' ');
162
+ };
163
+ }
164
+
165
+ /**
166
+ * Get spacing value from theme
167
+ *
168
+ * @param theme - Theme object
169
+ * @param values - Spacing multipliers
170
+ * @returns Spacing string
171
+ */
172
+ export function spacing(theme: Theme, ...values: number[]): string {
173
+ return theme.spacing(...values);
174
+ }
175
+
176
+ // ============================================================================
177
+ // Theme Value Accessors
178
+ // ============================================================================
179
+
180
+ /**
181
+ * Safely get a nested value from theme using dot notation
182
+ *
183
+ * @param theme - Theme object
184
+ * @param path - Dot-notation path (e.g., 'palette.primary.main')
185
+ * @param fallback - Fallback value if path not found
186
+ * @returns Theme value or fallback
187
+ */
188
+ export function getThemeValue<T = any>(theme: Theme, path: string, fallback?: T): T {
189
+ const keys = path.split('.');
190
+ let value: any = theme;
191
+
192
+ for (const key of keys) {
193
+ if (value && typeof value === 'object' && key in value) {
194
+ value = value[key];
195
+ } else {
196
+ return fallback as T;
197
+ }
198
+ }
199
+
200
+ return value as T;
201
+ }
202
+
203
+ /**
204
+ * Check if a theme is a JS theme (created with createTheme)
205
+ */
206
+ export function isJSTheme(theme: any): theme is Theme {
207
+ return theme && typeof theme === 'object' && theme.__isJSTheme === true;
208
+ }
209
+
210
+ // ============================================================================
211
+ // Responsive Utilities
212
+ // ============================================================================
213
+
214
+ /**
215
+ * Get media query for breakpoint up
216
+ */
217
+ export function breakpointUp(theme: Theme, key: keyof Theme['breakpoints']['values'] | number): string {
218
+ return theme.breakpoints.up(key);
219
+ }
220
+
221
+ /**
222
+ * Get media query for breakpoint down
223
+ */
224
+ export function breakpointDown(theme: Theme, key: keyof Theme['breakpoints']['values'] | number): string {
225
+ return theme.breakpoints.down(key);
226
+ }
227
+
228
+ /**
229
+ * Get media query for breakpoint between
230
+ */
231
+ export function breakpointBetween(
232
+ theme: Theme,
233
+ start: keyof Theme['breakpoints']['values'] | number,
234
+ end: keyof Theme['breakpoints']['values'] | number
235
+ ): string {
236
+ return theme.breakpoints.between(start, end);
237
+ }
238
+
239
+ // ============================================================================
240
+ // Typography Utilities
241
+ // ============================================================================
242
+
243
+ /**
244
+ * Get typography variant styles
245
+ */
246
+ export function getTypography(theme: Theme, variant: keyof Theme['typography']): any {
247
+ return theme.typography[variant] ?? {};
248
+ }
249
+
250
+ /**
251
+ * Convert rem to px based on theme font size
252
+ */
253
+ export function remToPx(theme: Theme, rem: number): number {
254
+ return rem * theme.typography.fontSize;
255
+ }
256
+
257
+ /**
258
+ * Convert px to rem based on theme font size
259
+ */
260
+ export function pxToRem(theme: Theme, px: number): string {
261
+ return `${px / theme.typography.fontSize}rem`;
262
+ }
263
+
264
+ // ============================================================================
265
+ // Shadow Utilities
266
+ // ============================================================================
267
+
268
+ /**
269
+ * Get shadow value from theme
270
+ */
271
+ export function getShadow(theme: Theme, level: keyof Theme['shadows']): string {
272
+ return theme.shadows[level] || 'none';
273
+ }
274
+
275
+ // ============================================================================
276
+ // Transition Utilities
277
+ // ============================================================================
278
+
279
+ /**
280
+ * Create a transition string
281
+ */
282
+ export function createTransition(
283
+ theme: Theme,
284
+ props: string | string[],
285
+ options?: {
286
+ duration?: keyof Theme['transitions']['duration'] | number;
287
+ easing?: keyof Theme['transitions']['easing'] | string;
288
+ delay?: number;
289
+ }
290
+ ): string {
291
+ const properties = Array.isArray(props) ? props : [props];
292
+ const duration =
293
+ typeof options?.duration === 'number'
294
+ ? options.duration
295
+ : theme.transitions.duration[options?.duration || 'standard'];
296
+ const easing =
297
+ typeof options?.easing === 'string' && !options.easing.includes('(')
298
+ ? theme.transitions.easing[options.easing as keyof Theme['transitions']['easing']]
299
+ : options?.easing || theme.transitions.easing.easeInOut;
300
+ const delay = options?.delay || 0;
301
+
302
+ return properties
303
+ .map((prop) => `${prop} ${duration}ms ${easing}${delay ? ` ${delay}ms` : ''}`)
304
+ .join(', ');
305
+ }
306
+
307
+ /**
308
+ * Get transition duration
309
+ */
310
+ export function getTransitionDuration(
311
+ theme: Theme,
312
+ key: keyof Theme['transitions']['duration']
313
+ ): number {
314
+ return theme.transitions.duration[key] ?? 300;
315
+ }
316
+
317
+ /**
318
+ * Get transition easing
319
+ */
320
+ export function getTransitionEasing(theme: Theme, key: keyof Theme['transitions']['easing']): string {
321
+ return theme.transitions.easing[key] ?? 'cubic-bezier(0.4, 0, 0.2, 1)';
322
+ }
323
+
324
+ // ============================================================================
325
+ // Z-Index Utilities
326
+ // ============================================================================
327
+
328
+ /**
329
+ * Get z-index value from theme
330
+ */
331
+ export function getZIndex(theme: Theme, key: keyof Theme['zIndex']): number {
332
+ return theme.zIndex[key] ?? 0;
333
+ }