@gild-ui/core 0.0.0 → 0.1.0-alpha.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.
package/dist/theme.cjs ADDED
@@ -0,0 +1,478 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_breakpoints = require("./breakpoints.cjs");
3
+ const require_themeDefault = require("./themeDefault-CjYwGUsb.cjs");
4
+ let _umber_style_core = require("@umber-style/core");
5
+ // src/theme/spacing.ts
6
+ const spacing = (units) => units === 0 ? "0px" : `${Math.max(1, Math.round(8 * units))}px`;
7
+ // src/theme/baseTheme.ts
8
+ const shadow = {
9
+ color: "#000000",
10
+ opacity: .4
11
+ };
12
+ const shadows = Array.from({ length: 25 }, (_, elevation) => require_themeDefault.generateBoxShadow(elevation, require_themeDefault.alpha(shadow.color, shadow.opacity)));
13
+ const radii = {
14
+ sq: "0",
15
+ sm: "4px",
16
+ md: "8px",
17
+ lg: "16px"
18
+ };
19
+ const borderWidths = {
20
+ none: "0",
21
+ thin: "1px",
22
+ base: "2px",
23
+ thick: "4px"
24
+ };
25
+ const zOrder = {
26
+ appBar: 1100,
27
+ drawer: 1200,
28
+ modal: 1300,
29
+ snackbar: 1400,
30
+ tooltip: 1500
31
+ };
32
+ const transitions = {
33
+ duration: {
34
+ short: 150,
35
+ standard: 250,
36
+ long: 375
37
+ },
38
+ easing: {
39
+ standard: "cubic-bezier(0.4, 0, 0.2, 1)",
40
+ enter: "cubic-bezier(0, 0, 0.2, 1)",
41
+ exit: "cubic-bezier(0.4, 0, 1, 1)"
42
+ }
43
+ };
44
+ const fontSizes = [
45
+ 12,
46
+ 14,
47
+ 16,
48
+ 20,
49
+ 24,
50
+ 32,
51
+ 48
52
+ ];
53
+ const lineHeights = {
54
+ none: 1,
55
+ tight: 1.2,
56
+ snug: 1.35,
57
+ base: 1.5,
58
+ relaxed: 1.625,
59
+ loose: 2
60
+ };
61
+ const letterSpacings = {
62
+ tighter: "-0.05em",
63
+ tight: "-0.025em",
64
+ normal: "0em",
65
+ wide: "0.05em",
66
+ wider: "0.1em",
67
+ widest: "0.2em"
68
+ };
69
+ const fonts = {
70
+ body: "'Space Grotesk Variable', 'Space Grotesk', sans-serif",
71
+ heading: "'Space Grotesk Variable', 'Space Grotesk', sans-serif",
72
+ mono: "'JetBrains Mono Variable', 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace"
73
+ };
74
+ const fontWeights = {
75
+ thin: 100,
76
+ extraLight: 200,
77
+ light: 300,
78
+ normal: 400,
79
+ medium: 500,
80
+ semiBold: 600,
81
+ bold: 700,
82
+ extraBold: 800,
83
+ black: 900
84
+ };
85
+ const avatar = {
86
+ sm: spacing(4),
87
+ md: spacing(5),
88
+ lg: spacing(6),
89
+ xl: spacing(7)
90
+ };
91
+ const icon = {
92
+ sm: "1rem",
93
+ md: "1.25rem",
94
+ lg: "1.5rem"
95
+ };
96
+ const sizes = {
97
+ sm: {
98
+ paddingTop: .5,
99
+ paddingBottom: .5,
100
+ paddingLeft: 1.5,
101
+ paddingRight: 1.5,
102
+ fontSize: 0
103
+ },
104
+ md: {
105
+ paddingTop: 1,
106
+ paddingBottom: 1,
107
+ paddingLeft: 2,
108
+ paddingRight: 2,
109
+ fontSize: 1
110
+ },
111
+ lg: {
112
+ paddingTop: 1.5,
113
+ paddingBottom: 1.5,
114
+ paddingLeft: 3,
115
+ paddingRight: 3,
116
+ fontSize: 1
117
+ }
118
+ };
119
+ const space = {
120
+ 0: 0,
121
+ .125: spacing(.125),
122
+ .25: spacing(.25),
123
+ .5: spacing(.5),
124
+ .75: spacing(.75),
125
+ 1: spacing(1),
126
+ 1.25: spacing(1.25),
127
+ 1.5: spacing(1.5),
128
+ 1.75: spacing(1.75),
129
+ 2: spacing(2),
130
+ 3: spacing(3),
131
+ 4: spacing(4),
132
+ 5: spacing(5),
133
+ 6: spacing(6),
134
+ 7: spacing(7),
135
+ 8: spacing(8),
136
+ 9: spacing(9),
137
+ 10: spacing(10),
138
+ auto: "auto"
139
+ };
140
+ const breakpoints = require_breakpoints.withBreakpointHelpers({
141
+ xs: "0px",
142
+ sm: "600px",
143
+ md: "840px",
144
+ lg: "1200px",
145
+ xl: "1600px"
146
+ });
147
+ const layout = {
148
+ xs: {
149
+ bars: { top: 8 },
150
+ panels: {
151
+ start: {
152
+ mode: "hidden",
153
+ width: "280px",
154
+ railWidth: 9
155
+ },
156
+ end: {
157
+ mode: "hidden",
158
+ width: "360px",
159
+ railWidth: 9
160
+ }
161
+ },
162
+ content: {
163
+ columns: 4,
164
+ margin: 2,
165
+ gutter: 2,
166
+ mode: "fluid"
167
+ }
168
+ },
169
+ sm: {
170
+ panels: { start: { mode: "collapsed" } },
171
+ content: {
172
+ columns: 8,
173
+ margin: 4
174
+ }
175
+ },
176
+ md: {
177
+ panels: { end: { mode: "overlay" } },
178
+ content: {
179
+ columns: 12,
180
+ margin: 3,
181
+ gutter: 3
182
+ }
183
+ },
184
+ lg: {
185
+ panels: { end: { width: "412px" } },
186
+ content: {
187
+ mode: "fixed",
188
+ maxWidth: "1200px"
189
+ }
190
+ },
191
+ xl: {
192
+ panels: {
193
+ start: { mode: "inline" },
194
+ end: { mode: "inline" }
195
+ },
196
+ content: { maxWidth: "1600px" }
197
+ }
198
+ };
199
+ const typography = {
200
+ h1: {
201
+ element: "h1",
202
+ fontSize: 6,
203
+ fontWeight: "bold"
204
+ },
205
+ h2: {
206
+ element: "h2",
207
+ fontSize: 5,
208
+ fontWeight: "bold"
209
+ },
210
+ h3: {
211
+ element: "h3",
212
+ fontSize: 4,
213
+ fontWeight: "bold"
214
+ },
215
+ h4: {
216
+ element: "h4",
217
+ fontSize: 3,
218
+ fontWeight: "bold"
219
+ },
220
+ h5: {
221
+ element: "h5",
222
+ fontSize: 2,
223
+ fontWeight: "bold"
224
+ },
225
+ h6: {
226
+ element: "h6",
227
+ fontSize: 1,
228
+ fontWeight: "semiBold"
229
+ },
230
+ subtitle1: {
231
+ element: "h6",
232
+ fontSize: 2,
233
+ fontWeight: "medium"
234
+ },
235
+ subtitle2: {
236
+ element: "h6",
237
+ fontSize: 1,
238
+ fontWeight: "medium"
239
+ },
240
+ body1: {
241
+ element: "p",
242
+ fontSize: 2,
243
+ fontWeight: "normal"
244
+ },
245
+ body2: {
246
+ element: "p",
247
+ fontSize: 1,
248
+ fontWeight: "normal"
249
+ },
250
+ caption: {
251
+ element: "span",
252
+ fontSize: 0,
253
+ fontWeight: "normal"
254
+ },
255
+ overline: {
256
+ element: "span",
257
+ fontSize: 0,
258
+ fontWeight: "medium",
259
+ textTransform: "uppercase",
260
+ letterSpacing: "wider"
261
+ },
262
+ button: {
263
+ element: "span",
264
+ fontSize: 1,
265
+ fontWeight: "medium",
266
+ textTransform: "uppercase",
267
+ letterSpacing: "wide"
268
+ },
269
+ inherit: { element: "span" }
270
+ };
271
+ /**
272
+ * The package's complete default theme (dark-schemed). Raw hex only - palettes
273
+ * belong to the consumer, who builds brand themes with `createTheme(baseTheme, ...)`.
274
+ *
275
+ * What is not a CSS value stays what it is (`asIs`, which `defineTheme` writes into the theme's
276
+ * `$modes`): breakpoints, transitions, sizes, typography, layout, and `components` and
277
+ * `defaults`, which an app's themes fill. Every other token is a CSS variable.
278
+ */
279
+ const baseTheme = (0, _umber_style_core.defineTheme)({
280
+ name: "base",
281
+ switch: { thumb: "#FFFFFF" },
282
+ radii,
283
+ borderWidths,
284
+ fontSizes,
285
+ lineHeights,
286
+ typography: (0, _umber_style_core.asIs)(typography),
287
+ letterSpacings,
288
+ fontWeights,
289
+ fonts,
290
+ avatar,
291
+ icon,
292
+ sizes: (0, _umber_style_core.asIs)(sizes),
293
+ space,
294
+ breakpoints: (0, _umber_style_core.asIs)(breakpoints),
295
+ layout: (0, _umber_style_core.asIs)(layout),
296
+ zOrder,
297
+ transitions: (0, _umber_style_core.asIs)(transitions),
298
+ blur: "12px",
299
+ colorScheme: "dark",
300
+ palette: {
301
+ default: {
302
+ main: "#262626",
303
+ light: "#363636",
304
+ dark: "#0E0E0E",
305
+ contrastText: "#F2F3F4"
306
+ },
307
+ primary: {
308
+ main: "#00FC40",
309
+ light: "#9CFF93",
310
+ dark: "#006413",
311
+ contrastText: "#000000"
312
+ },
313
+ secondary: {
314
+ main: "#b3eeb1",
315
+ light: "#d4f9d2",
316
+ dark: "#5acc57",
317
+ contrastText: "#000000"
318
+ },
319
+ success: {
320
+ main: "#009928",
321
+ light: "#00FC40",
322
+ dark: "#006413",
323
+ contrastText: "#FFFFFF"
324
+ },
325
+ error: {
326
+ main: "#FF3B30",
327
+ light: "#FF9590",
328
+ dark: "#E0251A",
329
+ contrastText: "#FFFFFF"
330
+ },
331
+ info: {
332
+ main: "#00B8D9",
333
+ light: "#33D9FF",
334
+ dark: "#0099CC",
335
+ contrastText: "#000000"
336
+ },
337
+ warning: {
338
+ main: "#FFD930",
339
+ light: "#FFF0A0",
340
+ dark: "#CCA800",
341
+ contrastText: "#000000"
342
+ }
343
+ },
344
+ background: {
345
+ backdrop: "#000000B3",
346
+ appBar: "#000000B3",
347
+ glass: "#0000004D",
348
+ modal: "#131313",
349
+ default: "#262626",
350
+ primary: "#0E0E0E",
351
+ secondary: "#1A1A1A",
352
+ paper: "#131313",
353
+ terminal: "#000000",
354
+ grid: require_themeDefault.alpha("#00FC40", .06),
355
+ transparent: "#00000000",
356
+ scrollbar: "#B3B3B380",
357
+ scrollbarTrack: "#38383880"
358
+ },
359
+ text: {
360
+ inherit: "inherit",
361
+ initial: "#FFFFFF",
362
+ primary: "#00FC40",
363
+ secondary: "#9C9C9C",
364
+ disabled: "#363636",
365
+ error: "#D70015",
366
+ success: "#009928",
367
+ info: "#00B8D9",
368
+ warning: "#8C6D00"
369
+ },
370
+ border: {
371
+ default: "#262626",
372
+ light: require_themeDefault.alpha("#E8FFE5", .1),
373
+ primary: "#00FC40",
374
+ dark: "#006413"
375
+ },
376
+ skeleton: { highlight: require_themeDefault.alpha("#363636", .65) },
377
+ logoFilter: "brightness(0) invert(1)",
378
+ portraitBlend: "screen",
379
+ portraitOpacity: .8,
380
+ shadow,
381
+ shadows,
382
+ components: (0, _umber_style_core.asIs)({}),
383
+ defaults: (0, _umber_style_core.asIs)({})
384
+ });
385
+ /**
386
+ * The query helpers for `baseTheme`'s breakpoints, as plain functions. A theme with its own
387
+ * breakpoints has the same helpers on `theme.breakpoints`.
388
+ */
389
+ const { up, down, only, between, not, containerQueries } = breakpoints;
390
+ // src/theme/createTheme.ts
391
+ /**
392
+ * Builds a theme by deep-merging sparse `overrides` onto `base`.
393
+ *
394
+ * - Recurses only where both sides are plain objects; arrays (`shadows`,
395
+ * `fontSizes`) and functions replace wholesale.
396
+ * - `undefined` override values are ignored - a key can be added or replaced,
397
+ * never removed.
398
+ * - Neither argument is mutated; untouched branches keep referential identity.
399
+ * - `breakpoints` gets its query helpers back, built from the merged sizes.
400
+ * - The returned type keeps what the overrides add - see `ThemeMerge`.
401
+ */
402
+ const createTheme = (base, overrides) => {
403
+ const theme = require_themeDefault.deepMerge(base, overrides);
404
+ return withHelpers(theme);
405
+ };
406
+ /** A theme whose `breakpoints` carry the query helpers - added when a hand-built theme lacks them. */
407
+ const withHelpers = (theme) => theme.breakpoints && !("up" in theme.breakpoints) ? {
408
+ ...theme,
409
+ breakpoints: require_breakpoints.withBreakpointHelpers(theme.breakpoints)
410
+ } : theme;
411
+ // src/theme/defineThemes.ts
412
+ const rawPaths = (theme) => "$modes" in theme && typeof theme.$modes === "object" && theme.$modes ? Object.entries(theme.$modes).filter(([path, mode]) => (mode === "asIs" || mode === "raw") && path !== "components").map(([path]) => path) : [];
413
+ const at = (value, path) => path.split(".").reduce((from, key) => from?.[key], value);
414
+ /** The path of the first difference between two values, or `undefined` when there is none. */
415
+ const firstDifference = (a, b, path) => {
416
+ if (typeof a !== "object" || typeof b !== "object" || !a || !b) return Object.is(a, b) ? void 0 : path;
417
+ for (const key of /* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)])) {
418
+ const found = firstDifference(a[key], b[key], `${path}.${key}`);
419
+ if (found) return found;
420
+ }
421
+ };
422
+ const warnAboutRawTokens = (themes) => {
423
+ const [[firstName, base] = []] = Object.entries(themes);
424
+ if (!base) return;
425
+ for (const [name, theme] of Object.entries(themes)) for (const path of rawPaths(base)) {
426
+ const found = firstDifference(at(base, path), at(theme, path), path);
427
+ if (!found) continue;
428
+ console.warn(`[soroush] Theme "${name}" and "${firstName}" differ at ${found}: server components always render with the serverTheme you pass to configure. Keep raw tokens (breakpoints, sizes, typography, layout, transitions, defaults) the same in every theme; colours, spacing and font sizes may differ.`);
429
+ return;
430
+ }
431
+ };
432
+ /**
433
+ * Defines an app's themes: every theme in `themes` gets the one `components` object - the
434
+ * customization of the components, the same in every theme - and the types check that all themes
435
+ * have exactly the same keys, at every depth, so one theme cannot lack a color another has (the
436
+ * error names the theme and the key). The values may differ.
437
+ *
438
+ * Check `components` where it is written, with `satisfies ThemeComponents` from the React library
439
+ * (this package cannot know a framework's slots); it is kept as written, so a look such as
440
+ * `variant: 'pill'` is known to the types once the themes are registered (see `Register`).
441
+ *
442
+ * Returns new objects: neither the themes nor `components` is changed, as the styling engine
443
+ * requires a theme object not to change once it is in use.
444
+ */
445
+ const defineThemes = (themes, components = {}) => {
446
+ if (process.env.NODE_ENV !== "production") warnAboutRawTokens(themes);
447
+ return Object.fromEntries(Object.entries(themes).map(([name, theme]) => [name, {
448
+ ...theme,
449
+ components
450
+ }]));
451
+ };
452
+ exports.avatar = avatar;
453
+ exports.baseTheme = baseTheme;
454
+ exports.between = between;
455
+ exports.borderWidths = borderWidths;
456
+ exports.breakpoints = breakpoints;
457
+ exports.containerQueries = containerQueries;
458
+ exports.createTheme = createTheme;
459
+ exports.defineThemes = defineThemes;
460
+ exports.down = down;
461
+ exports.fontSizes = fontSizes;
462
+ exports.fontWeights = fontWeights;
463
+ exports.fonts = fonts;
464
+ exports.icon = icon;
465
+ exports.layout = layout;
466
+ exports.letterSpacings = letterSpacings;
467
+ exports.lineHeights = lineHeights;
468
+ exports.not = not;
469
+ exports.only = only;
470
+ exports.radii = radii;
471
+ exports.sizes = sizes;
472
+ exports.space = space;
473
+ exports.spacing = spacing;
474
+ exports.themeDefault = require_themeDefault.themeDefault;
475
+ exports.transitions = transitions;
476
+ exports.typography = typography;
477
+ exports.up = up;
478
+ exports.zOrder = zOrder;