@allternit/gizzi-code 1.0.0
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/WORKSPACE_INTEGRATION.md +290 -0
- package/chat-sessions/sessions-index.json +98 -0
- package/package.json +43 -0
- package/package.json.original +31 -0
- package/package.json.publish +47 -0
- package/src/bootstrap/state.d.ts +169 -0
- package/src/bootstrap/state.js +261 -0
- package/src/bootstrap/state.ts +371 -0
- package/src/context/pack-builder.d.ts +24 -0
- package/src/context/pack-builder.js +281 -0
- package/src/context/pack-builder.ts +334 -0
- package/src/hooks/useExitOnCtrlCD.d.ts +86 -0
- package/src/hooks/useExitOnCtrlCD.js +130 -0
- package/src/hooks/useExitOnCtrlCD.ts +202 -0
- package/src/hooks/useKeybinding.d.ts +89 -0
- package/src/hooks/useKeybinding.js +163 -0
- package/src/hooks/useKeybinding.ts +226 -0
- package/src/hooks/useTerminalSize.d.ts +41 -0
- package/src/hooks/useTerminalSize.js +90 -0
- package/src/hooks/useTerminalSize.ts +117 -0
- package/src/index.d.ts +23 -0
- package/src/index.js +24 -0
- package/src/index.ts +132 -0
- package/src/runtime/brand/brand.d.ts +488 -0
- package/src/runtime/brand/brand.js +464 -0
- package/src/runtime/brand/brand.ts +667 -0
- package/src/runtime/services/tokenEstimation.d.ts +187 -0
- package/src/runtime/services/tokenEstimation.js +423 -0
- package/src/runtime/services/tokenEstimation.ts +547 -0
- package/src/runtime/tools/Tool.d.ts +239 -0
- package/src/runtime/tools/Tool.js +285 -0
- package/src/runtime/tools/Tool.ts +524 -0
- package/src/scheduler/TaskScheduler.d.ts +98 -0
- package/src/scheduler/TaskScheduler.js +201 -0
- package/src/scheduler/TaskScheduler.ts +259 -0
- package/src/state/AppStateStore.d.ts +347 -0
- package/src/state/AppStateStore.js +439 -0
- package/src/state/AppStateStore.ts +658 -0
- package/src/state/WorkspaceStateStore.d.ts +43 -0
- package/src/state/WorkspaceStateStore.js +224 -0
- package/src/state/WorkspaceStateStore.ts +297 -0
- package/src/types/message.d.ts +190 -0
- package/src/types/message.js +77 -0
- package/src/types/message.ts +277 -0
- package/src/utils/format.d.ts +126 -0
- package/src/utils/format.js +230 -0
- package/src/utils/format.ts +336 -0
- package/src/utils/fullscreen.d.ts +161 -0
- package/src/utils/fullscreen.js +277 -0
- package/src/utils/fullscreen.ts +382 -0
- package/src/utils/sessionStorage.d.ts +210 -0
- package/src/utils/sessionStorage.js +435 -0
- package/src/utils/sessionStorage.ts +559 -0
- package/src/watcher/WorkspaceWatcher.d.ts +70 -0
- package/src/watcher/WorkspaceWatcher.js +191 -0
- package/src/watcher/WorkspaceWatcher.ts +251 -0
- package/src/workspace/loader.d.ts +30 -0
- package/src/workspace/loader.js +117 -0
- package/src/workspace/loader.ts +171 -0
- package/src/workspace/types.d.ts +91 -0
- package/src/workspace/types.js +7 -0
- package/src/workspace/types.ts +122 -0
- package/threads/thread_1775361175022.json +9 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Branding utilities and configuration for gizzi-code
|
|
3
|
+
* @module runtime/brand/brand
|
|
4
|
+
*
|
|
5
|
+
* Provides centralized brand constants, color schemes, and theming
|
|
6
|
+
* configuration for the gizzi-code runtime environment.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Brand name constants
|
|
10
|
+
* @constant {Readonly<{FULL: string; SHORT: string; CODE: string; PACKAGE: string}>}
|
|
11
|
+
*/
|
|
12
|
+
export const Brand = {
|
|
13
|
+
/** Full brand name */
|
|
14
|
+
FULL: 'gizzi-code',
|
|
15
|
+
/** Short brand name */
|
|
16
|
+
SHORT: 'gizzi',
|
|
17
|
+
/** Code identifier */
|
|
18
|
+
CODE: 'gizzi-code',
|
|
19
|
+
/** Package name */
|
|
20
|
+
PACKAGE: '@gizzi/code',
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Brand version information
|
|
24
|
+
* @constant {Readonly<{MAJOR: number; MINOR: number; PATCH: number; STRING: string}>}
|
|
25
|
+
*/
|
|
26
|
+
export const BrandVersion = {
|
|
27
|
+
/** Major version */
|
|
28
|
+
MAJOR: 0,
|
|
29
|
+
/** Minor version */
|
|
30
|
+
MINOR: 1,
|
|
31
|
+
/** Patch version */
|
|
32
|
+
PATCH: 0,
|
|
33
|
+
/** Full version string */
|
|
34
|
+
STRING: '0.1.0',
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Default light theme color palette
|
|
38
|
+
* @constant {Readonly<BrandColorPalette>}
|
|
39
|
+
*/
|
|
40
|
+
export const LightColors = {
|
|
41
|
+
primary: '#2563eb',
|
|
42
|
+
secondary: '#64748b',
|
|
43
|
+
accent: '#8b5cf6',
|
|
44
|
+
background: '#ffffff',
|
|
45
|
+
surface: '#f8fafc',
|
|
46
|
+
text: '#0f172a',
|
|
47
|
+
textMuted: '#64748b',
|
|
48
|
+
error: '#ef4444',
|
|
49
|
+
warning: '#f59e0b',
|
|
50
|
+
success: '#10b981',
|
|
51
|
+
info: '#3b82f6',
|
|
52
|
+
border: '#e2e8f0',
|
|
53
|
+
divider: '#cbd5e1',
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Default dark theme color palette
|
|
57
|
+
* @constant {Readonly<BrandColorPalette>}
|
|
58
|
+
*/
|
|
59
|
+
export const DarkColors = {
|
|
60
|
+
primary: '#3b82f6',
|
|
61
|
+
secondary: '#94a3b8',
|
|
62
|
+
accent: '#a78bfa',
|
|
63
|
+
background: '#0f172a',
|
|
64
|
+
surface: '#1e293b',
|
|
65
|
+
text: '#f8fafc',
|
|
66
|
+
textMuted: '#94a3b8',
|
|
67
|
+
error: '#f87171',
|
|
68
|
+
warning: '#fbbf24',
|
|
69
|
+
success: '#34d399',
|
|
70
|
+
info: '#60a5fa',
|
|
71
|
+
border: '#334155',
|
|
72
|
+
divider: '#475569',
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* High contrast theme for accessibility
|
|
76
|
+
* @constant {Readonly<BrandColorPalette>}
|
|
77
|
+
*/
|
|
78
|
+
export const HighContrastColors = {
|
|
79
|
+
primary: '#005fcc',
|
|
80
|
+
secondary: '#404040',
|
|
81
|
+
accent: '#6622cc',
|
|
82
|
+
background: '#000000',
|
|
83
|
+
surface: '#0a0a0a',
|
|
84
|
+
text: '#ffffff',
|
|
85
|
+
textMuted: '#cccccc',
|
|
86
|
+
error: '#ff3333',
|
|
87
|
+
warning: '#ffaa00',
|
|
88
|
+
success: '#00cc66',
|
|
89
|
+
info: '#0099ff',
|
|
90
|
+
border: '#666666',
|
|
91
|
+
divider: '#555555',
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Complete brand color scheme
|
|
95
|
+
* @constant {Readonly<BrandColorScheme>}
|
|
96
|
+
*/
|
|
97
|
+
export const BrandColors = {
|
|
98
|
+
light: LightColors,
|
|
99
|
+
dark: DarkColors,
|
|
100
|
+
highContrast: HighContrastColors,
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Default brand typography
|
|
104
|
+
* @constant {Readonly<BrandTypography>}
|
|
105
|
+
*/
|
|
106
|
+
export const BrandTypography = {
|
|
107
|
+
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
|
|
108
|
+
fontFamilyMono: 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',
|
|
109
|
+
baseSize: 16,
|
|
110
|
+
lineHeight: 1.5,
|
|
111
|
+
weights: {
|
|
112
|
+
normal: 400,
|
|
113
|
+
medium: 500,
|
|
114
|
+
semibold: 600,
|
|
115
|
+
bold: 700,
|
|
116
|
+
},
|
|
117
|
+
scale: {
|
|
118
|
+
xs: 0.75, // 12px
|
|
119
|
+
sm: 0.875, // 14px
|
|
120
|
+
base: 1, // 16px
|
|
121
|
+
lg: 1.125, // 18px
|
|
122
|
+
xl: 1.25, // 20px
|
|
123
|
+
'2xl': 1.5, // 24px
|
|
124
|
+
'3xl': 1.875, // 30px
|
|
125
|
+
'4xl': 2.25, // 36px
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Brand spacing configuration (in rem units base)
|
|
130
|
+
* @constant {Readonly<Record<string, number>>}
|
|
131
|
+
*/
|
|
132
|
+
export const BrandSpacing = {
|
|
133
|
+
none: 0,
|
|
134
|
+
xs: 0.25, // 4px
|
|
135
|
+
sm: 0.5, // 8px
|
|
136
|
+
md: 1, // 16px
|
|
137
|
+
lg: 1.5, // 24px
|
|
138
|
+
xl: 2, // 32px
|
|
139
|
+
'2xl': 3, // 48px
|
|
140
|
+
'3xl': 4, // 64px
|
|
141
|
+
'4xl': 6, // 96px
|
|
142
|
+
'5xl': 8, // 128px
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Brand border radius values
|
|
146
|
+
* @constant {Readonly<Record<string, string>>}
|
|
147
|
+
*/
|
|
148
|
+
export const BrandBorderRadius = {
|
|
149
|
+
none: '0',
|
|
150
|
+
sm: '0.125rem', // 2px
|
|
151
|
+
md: '0.25rem', // 4px
|
|
152
|
+
lg: '0.5rem', // 8px
|
|
153
|
+
xl: '0.75rem', // 12px
|
|
154
|
+
'2xl': '1rem', // 16px
|
|
155
|
+
full: '9999px',
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Brand shadow values
|
|
159
|
+
* @constant {Readonly<Record<string, string>>}
|
|
160
|
+
*/
|
|
161
|
+
export const BrandShadows = {
|
|
162
|
+
none: 'none',
|
|
163
|
+
sm: '0 1px 2px 0 rgb(0 0 0 / 0.05)',
|
|
164
|
+
md: '0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)',
|
|
165
|
+
lg: '0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)',
|
|
166
|
+
xl: '0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)',
|
|
167
|
+
'2xl': '0 25px 50px -12px rgb(0 0 0 / 0.25)',
|
|
168
|
+
inner: 'inset 0 2px 4px 0 rgb(0 0 0 / 0.05)',
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* Brand breakpoints for responsive design
|
|
172
|
+
* @constant {Readonly<Record<string, number>>}
|
|
173
|
+
*/
|
|
174
|
+
export const BrandBreakpoints = {
|
|
175
|
+
xs: 0,
|
|
176
|
+
sm: 640,
|
|
177
|
+
md: 768,
|
|
178
|
+
lg: 1024,
|
|
179
|
+
xl: 1280,
|
|
180
|
+
'2xl': 1536,
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Animation timing values
|
|
184
|
+
* @constant {Readonly<Record<string, number>>}
|
|
185
|
+
*/
|
|
186
|
+
export const BrandAnimation = {
|
|
187
|
+
instant: 0,
|
|
188
|
+
fast: 100,
|
|
189
|
+
normal: 200,
|
|
190
|
+
slow: 300,
|
|
191
|
+
slower: 500,
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* Easing functions
|
|
195
|
+
* @constant {Readonly<Record<string, string>>}
|
|
196
|
+
*/
|
|
197
|
+
export const BrandEasing = {
|
|
198
|
+
linear: 'linear',
|
|
199
|
+
ease: 'ease',
|
|
200
|
+
easeIn: 'ease-in',
|
|
201
|
+
easeOut: 'ease-out',
|
|
202
|
+
easeInOut: 'ease-in-out',
|
|
203
|
+
spring: 'cubic-bezier(0.34, 1.56, 0.64, 1)',
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Complete brand configuration
|
|
207
|
+
* @constant {Readonly<BrandConfig>}
|
|
208
|
+
*/
|
|
209
|
+
export const BrandConfig = {
|
|
210
|
+
name: Brand,
|
|
211
|
+
version: BrandVersion,
|
|
212
|
+
colors: BrandColors,
|
|
213
|
+
typography: BrandTypography,
|
|
214
|
+
spacing: BrandSpacing,
|
|
215
|
+
borderRadius: BrandBorderRadius,
|
|
216
|
+
shadows: BrandShadows,
|
|
217
|
+
breakpoints: BrandBreakpoints,
|
|
218
|
+
animation: BrandAnimation,
|
|
219
|
+
easing: BrandEasing,
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* Get brand colors for a specific theme mode
|
|
223
|
+
*
|
|
224
|
+
* @param {ThemeMode} mode - Theme mode to get colors for
|
|
225
|
+
* @param {BrandColorScheme} colors - Color scheme to use (defaults to BrandColors)
|
|
226
|
+
* @returns {BrandColorPalette} Color palette for the specified mode
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* ```typescript
|
|
230
|
+
* const darkColors = getBrandColors('dark');
|
|
231
|
+
* console.log(darkColors.background); // '#0f172a'
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
export function getBrandColors(mode, colors = BrandColors) {
|
|
235
|
+
switch (mode) {
|
|
236
|
+
case 'light':
|
|
237
|
+
return colors.light;
|
|
238
|
+
case 'dark':
|
|
239
|
+
return colors.dark;
|
|
240
|
+
case 'high-contrast':
|
|
241
|
+
return colors.highContrast;
|
|
242
|
+
case 'auto':
|
|
243
|
+
// Auto-detect based on system preference
|
|
244
|
+
if (typeof window !== 'undefined' && window.matchMedia) {
|
|
245
|
+
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
246
|
+
return prefersDark ? colors.dark : colors.light;
|
|
247
|
+
}
|
|
248
|
+
return colors.light;
|
|
249
|
+
default:
|
|
250
|
+
return colors.light;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Convert hex color to RGB values
|
|
255
|
+
*
|
|
256
|
+
* @param {HexColor} hex - Hex color value
|
|
257
|
+
* @returns {RGBColor | null} RGB values or null if invalid
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```typescript
|
|
261
|
+
* const rgb = hexToRgb('#2563eb');
|
|
262
|
+
* console.log(rgb); // { r: 37, g: 99, b: 235 }
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
export function hexToRgb(hex) {
|
|
266
|
+
const cleanHex = hex.replace('#', '');
|
|
267
|
+
if (!/^[0-9a-fA-F]{6}$/.test(cleanHex)) {
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
const r = parseInt(cleanHex.substring(0, 2), 16);
|
|
271
|
+
const g = parseInt(cleanHex.substring(2, 4), 16);
|
|
272
|
+
const b = parseInt(cleanHex.substring(4, 6), 16);
|
|
273
|
+
return { r, g, b };
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Convert RGB values to hex color
|
|
277
|
+
*
|
|
278
|
+
* @param {number} r - Red value (0-255)
|
|
279
|
+
* @param {number} g - Green value (0-255)
|
|
280
|
+
* @param {number} b - Blue value (0-255)
|
|
281
|
+
* @returns {HexColor} Hex color value
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```typescript
|
|
285
|
+
* const hex = rgbToHex(37, 99, 235);
|
|
286
|
+
* console.log(hex); // '#2563eb'
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
export function rgbToHex(r, g, b) {
|
|
290
|
+
const clamp = (n) => Math.max(0, Math.min(255, n));
|
|
291
|
+
const toHex = (n) => clamp(n).toString(16).padStart(2, '0');
|
|
292
|
+
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Convert hex color to RGBA with alpha
|
|
296
|
+
*
|
|
297
|
+
* @param {HexColor} hex - Hex color value
|
|
298
|
+
* @param {number} alpha - Alpha value (0-1)
|
|
299
|
+
* @returns {string} RGBA color string
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```typescript
|
|
303
|
+
* const rgba = hexToRgba('#2563eb', 0.5);
|
|
304
|
+
* console.log(rgba); // 'rgba(37, 99, 235, 0.5)'
|
|
305
|
+
* ```
|
|
306
|
+
*/
|
|
307
|
+
export function hexToRgba(hex, alpha) {
|
|
308
|
+
const rgb = hexToRgb(hex);
|
|
309
|
+
if (!rgb) {
|
|
310
|
+
throw new Error(`Invalid hex color: ${hex}`);
|
|
311
|
+
}
|
|
312
|
+
return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${Math.max(0, Math.min(1, alpha))})`;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Lighten a hex color by a percentage
|
|
316
|
+
*
|
|
317
|
+
* @param {HexColor} hex - Hex color value
|
|
318
|
+
* @param {number} percent - Percentage to lighten (0-100)
|
|
319
|
+
* @returns {HexColor} Lightened hex color
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* ```typescript
|
|
323
|
+
* const lightBlue = lightenColor('#2563eb', 20);
|
|
324
|
+
* ```
|
|
325
|
+
*/
|
|
326
|
+
export function lightenColor(hex, percent) {
|
|
327
|
+
const rgb = hexToRgb(hex);
|
|
328
|
+
if (!rgb) {
|
|
329
|
+
throw new Error(`Invalid hex color: ${hex}`);
|
|
330
|
+
}
|
|
331
|
+
const amount = Math.floor((255 * percent) / 100);
|
|
332
|
+
return rgbToHex(rgb.r + amount, rgb.g + amount, rgb.b + amount);
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Darken a hex color by a percentage
|
|
336
|
+
*
|
|
337
|
+
* @param {HexColor} hex - Hex color value
|
|
338
|
+
* @param {number} percent - Percentage to darken (0-100)
|
|
339
|
+
* @returns {HexColor} Darkened hex color
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* ```typescript
|
|
343
|
+
* const darkBlue = darkenColor('#2563eb', 20);
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
export function darkenColor(hex, percent) {
|
|
347
|
+
const rgb = hexToRgb(hex);
|
|
348
|
+
if (!rgb) {
|
|
349
|
+
throw new Error(`Invalid hex color: ${hex}`);
|
|
350
|
+
}
|
|
351
|
+
const amount = Math.floor((255 * percent) / 100);
|
|
352
|
+
return rgbToHex(rgb.r - amount, rgb.g - amount, rgb.b - amount);
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Check if a color is light (for determining text contrast)
|
|
356
|
+
*
|
|
357
|
+
* @param {HexColor} hex - Hex color value
|
|
358
|
+
* @returns {boolean} True if the color is light
|
|
359
|
+
*
|
|
360
|
+
* @example
|
|
361
|
+
* ```typescript
|
|
362
|
+
* const isLight = isLightColor('#ffffff'); // true
|
|
363
|
+
* const isDark = isLightColor('#000000'); // false
|
|
364
|
+
* ```
|
|
365
|
+
*/
|
|
366
|
+
export function isLightColor(hex) {
|
|
367
|
+
const rgb = hexToRgb(hex);
|
|
368
|
+
if (!rgb) {
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
// Calculate relative luminance
|
|
372
|
+
const luminance = (0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b) / 255;
|
|
373
|
+
return luminance > 0.5;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Get the appropriate text color (light or dark) for contrast against a background
|
|
377
|
+
*
|
|
378
|
+
* @param {HexColor} backgroundColor - Background hex color
|
|
379
|
+
* @returns {{ light: HexColor; dark: HexColor }} Text colors for contrast
|
|
380
|
+
*
|
|
381
|
+
* @example
|
|
382
|
+
* ```typescript
|
|
383
|
+
* const textColors = getContrastText('#2563eb');
|
|
384
|
+
* console.log(textColors.light); // '#ffffff' (use this for dark backgrounds)
|
|
385
|
+
* ```
|
|
386
|
+
*/
|
|
387
|
+
export function getContrastText(backgroundColor) {
|
|
388
|
+
return {
|
|
389
|
+
light: '#ffffff',
|
|
390
|
+
dark: '#0f172a',
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Get the best text color for contrast against a background
|
|
395
|
+
*
|
|
396
|
+
* @param {HexColor} backgroundColor - Background hex color
|
|
397
|
+
* @returns {HexColor} Best text color for contrast
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* ```typescript
|
|
401
|
+
* const textColor = getBestContrastText('#0f172a'); // '#ffffff'
|
|
402
|
+
* ```
|
|
403
|
+
*/
|
|
404
|
+
export function getBestContrastText(backgroundColor) {
|
|
405
|
+
return isLightColor(backgroundColor) ? '#0f172a' : '#ffffff';
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* CSS custom properties (variables) generator for brand colors
|
|
409
|
+
*
|
|
410
|
+
* @param {ThemeMode} mode - Theme mode
|
|
411
|
+
* @returns {Record<string, string>} CSS variable names and values
|
|
412
|
+
*
|
|
413
|
+
* @example
|
|
414
|
+
* ```typescript
|
|
415
|
+
* const cssVars = generateCSSVariables('dark');
|
|
416
|
+
* // { '--gizzi-primary': '#3b82f6', ... }
|
|
417
|
+
* ```
|
|
418
|
+
*/
|
|
419
|
+
export function generateCSSVariables(mode) {
|
|
420
|
+
const colors = getBrandColors(mode);
|
|
421
|
+
const prefix = '--gizzi';
|
|
422
|
+
return {
|
|
423
|
+
[`${prefix}-primary`]: colors.primary,
|
|
424
|
+
[`${prefix}-secondary`]: colors.secondary,
|
|
425
|
+
[`${prefix}-accent`]: colors.accent,
|
|
426
|
+
[`${prefix}-background`]: colors.background,
|
|
427
|
+
[`${prefix}-surface`]: colors.surface,
|
|
428
|
+
[`${prefix}-text`]: colors.text,
|
|
429
|
+
[`${prefix}-text-muted`]: colors.textMuted,
|
|
430
|
+
[`${prefix}-error`]: colors.error,
|
|
431
|
+
[`${prefix}-warning`]: colors.warning,
|
|
432
|
+
[`${prefix}-success`]: colors.success,
|
|
433
|
+
[`${prefix}-info`]: colors.info,
|
|
434
|
+
[`${prefix}-border`]: colors.border,
|
|
435
|
+
[`${prefix}-divider`]: colors.divider,
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
// Default export
|
|
439
|
+
export default {
|
|
440
|
+
Brand,
|
|
441
|
+
BrandVersion,
|
|
442
|
+
BrandColors,
|
|
443
|
+
BrandConfig,
|
|
444
|
+
LightColors,
|
|
445
|
+
DarkColors,
|
|
446
|
+
HighContrastColors,
|
|
447
|
+
BrandTypography,
|
|
448
|
+
BrandSpacing,
|
|
449
|
+
BrandBorderRadius,
|
|
450
|
+
BrandShadows,
|
|
451
|
+
BrandBreakpoints,
|
|
452
|
+
BrandAnimation,
|
|
453
|
+
BrandEasing,
|
|
454
|
+
getBrandColors,
|
|
455
|
+
hexToRgb,
|
|
456
|
+
rgbToHex,
|
|
457
|
+
hexToRgba,
|
|
458
|
+
lightenColor,
|
|
459
|
+
darkenColor,
|
|
460
|
+
isLightColor,
|
|
461
|
+
getContrastText,
|
|
462
|
+
getBestContrastText,
|
|
463
|
+
generateCSSVariables,
|
|
464
|
+
};
|