@gryt/theme 0.7.0 → 0.8.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/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- function P(r) {
1
+ function _(r) {
2
2
  return r <= 0.04045 ? r / 12.92 : ((r + 0.055) / 1.055) ** 2.4;
3
3
  }
4
4
  function A(r) {
@@ -15,12 +15,12 @@ function H(r) {
15
15
  parseInt(t.slice(4, 6), 16) / 255
16
16
  ];
17
17
  }
18
- function _([r, a, t]) {
18
+ function N([r, a, t]) {
19
19
  const e = (o) => Math.round(x(o) * 255).toString(16).padStart(2, "0");
20
20
  return `#${e(r)}${e(a)}${e(t)}`;
21
21
  }
22
22
  function R(r) {
23
- const [a, t, e] = H(r).map(P), o = Math.cbrt(
23
+ const [a, t, e] = H(r).map(_), o = Math.cbrt(
24
24
  0.4122214708 * a + 0.5363325363 * t + 0.0514459929 * e
25
25
  ), c = Math.cbrt(
26
26
  0.2119034982 * a + 0.6806995451 * t + 0.1073969566 * e
@@ -35,7 +35,7 @@ function R(r) {
35
35
  }
36
36
  function m({ l: r, c: a, h: t }) {
37
37
  const e = a * Math.cos(t * Math.PI / 180), o = a * Math.sin(t * Math.PI / 180), c = (r + 0.3963377774 * e + 0.2158037573 * o) ** 3, n = (r - 0.1055613458 * e - 0.0638541728 * o) ** 3, d = (r - 0.0894841775 * e - 1.291485548 * o) ** 3;
38
- return _([
38
+ return N([
39
39
  A(x(4.0767416621 * c - 3.3077115913 * n + 0.2309699292 * d)),
40
40
  A(x(-1.2684380046 * c + 2.6097574011 * n - 0.3413193965 * d)),
41
41
  A(x(-0.0041960863 * c - 0.7034186147 * n + 1.707614701 * d))
@@ -48,7 +48,7 @@ function h(r, a) {
48
48
  const o = R(a).l, c = Math.min(0.95, Math.max(0.84, o + 0.04)), n = Math.min(0.98, Math.max(c + 0.06, 0.93));
49
49
  return e.push(m({ l: c, c: 0.11, h: t })), e.push(m({ l: n, c: 0.055, h: t })), e;
50
50
  }
51
- const W = [
51
+ const q = [
52
52
  0.187,
53
53
  0.231,
54
54
  0.245,
@@ -61,7 +61,7 @@ const W = [
61
61
  0.57,
62
62
  0.627,
63
63
  0.908
64
- ], q = [
64
+ ], K = [
65
65
  0.011,
66
66
  0.014,
67
67
  0.016,
@@ -75,7 +75,7 @@ const W = [
75
75
  0,
76
76
  8e-3
77
77
  ];
78
- function N(r) {
78
+ function U(r) {
79
79
  const a = {
80
80
  0: r.bg,
81
81
  1: r.surface,
@@ -84,8 +84,8 @@ function N(r) {
84
84
  10: r.muted,
85
85
  11: r.text
86
86
  }, t = R(r.border).h;
87
- return W.map(
88
- (e, o) => a[o] ?? m({ l: e, c: q[o], h: t })
87
+ return q.map(
88
+ (e, o) => a[o] ?? m({ l: e, c: K[o], h: t })
89
89
  );
90
90
  }
91
91
  function S(r, a) {
@@ -98,13 +98,13 @@ function S(r, a) {
98
98
  i > p ? c = Math.max(c, p < 1 ? (i - p) / (1 - p) : 0) : i < p && (c = Math.max(c, p > 0 ? (p - i) / p : 0));
99
99
  }
100
100
  if (c < 1e-6) return "transparent";
101
- const n = _(
101
+ const n = N(
102
102
  o.map((u, i) => x(t[i] + (u - t[i]) / c))
103
103
  ), [d, f, g] = H(n).map((u) => Math.round(u * 255));
104
104
  return `rgb(${d} ${f} ${g} / ${(c * 100).toFixed(1)}%)`;
105
105
  });
106
106
  }
107
- const K = [
107
+ const J = [
108
108
  0.962,
109
109
  1,
110
110
  0.978,
@@ -117,7 +117,7 @@ const K = [
117
117
  0.61,
118
118
  0.48,
119
119
  0.25
120
- ], J = [
120
+ ], X = [
121
121
  6e-3,
122
122
  0,
123
123
  4e-3,
@@ -130,8 +130,8 @@ const K = [
130
130
  0.014,
131
131
  0.012,
132
132
  0.014
133
- ], X = [0.975, 0.955, 0.93, 0.905, 0.878, 0.845, 0.795, 0.72], Q = [0.012, 0.024, 0.038, 0.05, 0.062, 0.074, 0.09, 0.11];
134
- function U(r) {
133
+ ], Q = [0.975, 0.955, 0.93, 0.905, 0.878, 0.845, 0.795, 0.72], V = [0.012, 0.024, 0.038, 0.05, 0.062, 0.074, 0.09, 0.11];
134
+ function F(r) {
135
135
  const a = {
136
136
  0: r.bg,
137
137
  1: r.surface,
@@ -140,18 +140,18 @@ function U(r) {
140
140
  10: r.muted,
141
141
  11: r.text
142
142
  }, t = R(r.border).h;
143
- return K.map(
144
- (e, o) => a[o] ?? m({ l: e, c: J[o], h: t })
143
+ return J.map(
144
+ (e, o) => a[o] ?? m({ l: e, c: X[o], h: t })
145
145
  );
146
146
  }
147
147
  function b(r) {
148
- const { l: a, c: t, h: e } = R(r), o = X.map(
149
- (c, n) => m({ l: c, c: Q[n], h: e })
148
+ const { l: a, c: t, h: e } = R(r), o = Q.map(
149
+ (c, n) => m({ l: c, c: V[n], h: e })
150
150
  );
151
151
  return o.push(r), o.push(m({ l: Math.max(0, a - 0.07), c: t, h: e })), o.push(m({ l: 0.46, c: 0.15, h: e })), o.push(m({ l: 0.33, c: 0.1, h: e })), o;
152
152
  }
153
153
  function E(r) {
154
- const [a, t, e] = H(r).map(P);
154
+ const [a, t, e] = H(r).map(_);
155
155
  return 0.2126 * a + 0.7152 * t + 0.0722 * e;
156
156
  }
157
157
  function se(r, a) {
@@ -197,7 +197,7 @@ const s = {
197
197
  muted: "#5b5d65",
198
198
  text: "#1f2129"
199
199
  }, C = {
200
- neutral: N({
200
+ neutral: U({
201
201
  bg: s.color.bg,
202
202
  surface: s.color.surface,
203
203
  surfaceRaised: s.color.surfaceRaised,
@@ -214,13 +214,13 @@ const s = {
214
214
  danger: h(s.color.danger, s.color.dangerLight),
215
215
  warning: h(s.color.warning, s.color.warning)
216
216
  }, T = {
217
- neutral: U(l),
217
+ neutral: F(l),
218
218
  accent: b(s.color.accent),
219
219
  secondary: b(s.color.secondary),
220
220
  success: b(s.color.success),
221
221
  danger: b(s.color.danger),
222
222
  warning: b(s.color.warning)
223
- }, F = T.neutral[3], de = {
223
+ }, O = T.neutral[3], de = {
224
224
  neutral: S(C.neutral, s.color.bg),
225
225
  accent: S(C.accent, s.color.bg)
226
226
  }, fe = {
@@ -231,7 +231,7 @@ function ue(r = {}) {
231
231
  const a = r.appearance === "light", e = { ...a ? {
232
232
  ...s.color,
233
233
  ...l,
234
- surfaceHover: F
234
+ surfaceHover: O
235
235
  } : s.color, ...r.color }, o = { ...s.radius, ...r.radius }, c = {
236
236
  bg: e.bg,
237
237
  surface: e.surface,
@@ -240,14 +240,14 @@ function ue(r = {}) {
240
240
  muted: e.muted,
241
241
  text: e.text
242
242
  }, n = a ? {
243
- neutral: U(c),
243
+ neutral: F(c),
244
244
  accent: b(e.accent),
245
245
  secondary: b(e.secondary),
246
246
  success: b(e.success),
247
247
  danger: b(e.danger),
248
248
  warning: b(e.warning)
249
249
  } : {
250
- neutral: N(c),
250
+ neutral: U(c),
251
251
  accent: h(e.accent, e.accentLight),
252
252
  secondary: h(e.secondary, e.secondaryLight),
253
253
  success: h(e.success, e.success),
@@ -322,7 +322,7 @@ const v = [
322
322
  "onAccent",
323
323
  "onSecondary",
324
324
  "onDanger"
325
- ], O = [
325
+ ], B = [
326
326
  "bg",
327
327
  "surface",
328
328
  "surfaceRaised",
@@ -330,9 +330,9 @@ const v = [
330
330
  "border",
331
331
  "muted",
332
332
  "text"
333
- ], D = ["sm", "md", "lg", "xl", "full"], V = 60;
333
+ ], D = ["sm", "md", "lg", "xl", "full"], Z = 60;
334
334
  function M(r) {
335
- return r.replace(/\s+/g, " ").trim().slice(0, V);
335
+ return r.replace(/\s+/g, " ").trim().slice(0, Z);
336
336
  }
337
337
  const L = {
338
338
  hue: {
@@ -362,7 +362,7 @@ const L = {
362
362
  bg: l.bg,
363
363
  surface: l.surface,
364
364
  surfaceRaised: l.surfaceRaised,
365
- surfaceHover: F,
365
+ surfaceHover: O,
366
366
  border: l.border,
367
367
  muted: l.muted,
368
368
  text: l.text
@@ -379,13 +379,13 @@ function G(r) {
379
379
  radius: { ...r.radius }
380
380
  };
381
381
  }
382
- function Z(r, a) {
382
+ function ee(r, a) {
383
383
  return a === "light" && r.lightHue !== null ? r.lightHue : r.hue;
384
384
  }
385
385
  function ge(r, a) {
386
386
  return {
387
387
  appearance: a,
388
- color: { ...Z(r, a), ...r[a] },
388
+ color: { ...ee(r, a), ...r[a] },
389
389
  radius: { ...r.radius }
390
390
  };
391
391
  }
@@ -401,7 +401,7 @@ const w = {
401
401
  onAccent: "on-accent",
402
402
  onSecondary: "on-secondary",
403
403
  onDanger: "on-danger"
404
- }, B = {
404
+ }, j = {
405
405
  bg: "bg",
406
406
  surface: "surface",
407
407
  surfaceRaised: "raised",
@@ -409,9 +409,9 @@ const w = {
409
409
  border: "border",
410
410
  muted: "muted",
411
411
  text: "text"
412
- }, ee = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
413
- function j(r) {
414
- return ee.test(r.trim());
412
+ }, re = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
413
+ function W(r) {
414
+ return re.test(r.trim());
415
415
  }
416
416
  function $(r) {
417
417
  const a = r.trim().toLowerCase();
@@ -427,8 +427,8 @@ function ie(r, a) {
427
427
  t.set(`lh-${w[c]}`, e(r.lightHue[c]));
428
428
  for (const c of ["dark", "light"]) {
429
429
  const n = c === "dark" ? "d" : "l";
430
- for (const d of O)
431
- r[c][d] !== L[c][d] && t.set(`${n}-${B[d]}`, e(r[c][d]));
430
+ for (const d of B)
431
+ r[c][d] !== L[c][d] && t.set(`${n}-${j[d]}`, e(r[c][d]));
432
432
  }
433
433
  for (const c of D)
434
434
  r.radius[c] !== L.radius[c] && t.set(`r-${c}`, String(r.radius[c]));
@@ -437,18 +437,18 @@ function ie(r, a) {
437
437
  function le(r) {
438
438
  const a = r.trim();
439
439
  if (a === "") return null;
440
- if (a.startsWith("{")) return ae(a);
440
+ if (a.startsWith("{")) return ce(a);
441
441
  const t = a.includes("?") ? a.slice(a.indexOf("?") + 1) : a;
442
- return re(new URLSearchParams(t));
442
+ return ae(new URLSearchParams(t));
443
443
  }
444
- function re(r) {
444
+ function ae(r) {
445
445
  const a = G(L);
446
446
  let t = !1;
447
447
  const e = (c) => {
448
448
  const n = r.get(c);
449
449
  if (n === null) return null;
450
450
  const d = n.startsWith("#") ? n : `#${n}`;
451
- return j(d) ? (t = !0, $(d)) : null;
451
+ return W(d) ? (t = !0, $(d)) : null;
452
452
  }, o = M(r.get("name") ?? "");
453
453
  o !== "" && (a.name = o, t = !0);
454
454
  for (const c of v) {
@@ -465,8 +465,8 @@ function re(r) {
465
465
  }
466
466
  for (const c of ["dark", "light"]) {
467
467
  const n = c === "dark" ? "d" : "l";
468
- for (const d of O) {
469
- const f = e(`${n}-${B[d]}`);
468
+ for (const d of B) {
469
+ const f = e(`${n}-${j[d]}`);
470
470
  f !== null && (a[c][d] = f);
471
471
  }
472
472
  }
@@ -479,7 +479,7 @@ function re(r) {
479
479
  appearance: r.get("mode") === "light" ? "light" : "dark"
480
480
  } : null;
481
481
  }
482
- function ae(r) {
482
+ function ce(r) {
483
483
  let a;
484
484
  try {
485
485
  a = JSON.parse(r);
@@ -492,7 +492,7 @@ function ae(r) {
492
492
  const c = (n, d) => {
493
493
  if (!(typeof n != "object" || n === null))
494
494
  for (const [f, g] of Object.entries(n))
495
- typeof g == "string" && j(g) && f in d && (d[f] = $(g), o = !0);
495
+ typeof g == "string" && W(g) && f in d && (d[f] = $(g), o = !0);
496
496
  };
497
497
  if (typeof t.name == "string") {
498
498
  const n = M(t.name);
@@ -511,7 +511,7 @@ function ae(r) {
511
511
  }
512
512
  return o ? { theme: e, appearance: "dark" } : null;
513
513
  }
514
- const y = { sm: 8, md: 12, lg: 20, xl: 28, full: 999 }, k = { sm: 6, md: 8, lg: 14, xl: 18, full: 999 }, ce = { sm: 4, md: 6, lg: 10, xl: 14, full: 6 }, te = { sm: 6, md: 8, lg: 10, xl: 14, full: 10 }, I = { sm: 2, md: 4, lg: 6, xl: 8, full: 4 }, ne = { sm: 8, md: 8, lg: 8, xl: 8, full: 8 }, oe = [
514
+ const y = { sm: 8, md: 12, lg: 20, xl: 28, full: 999 }, k = { sm: 6, md: 8, lg: 14, xl: 18, full: 999 }, I = { sm: 4, md: 6, lg: 10, xl: 14, full: 6 }, te = { sm: 6, md: 8, lg: 10, xl: 14, full: 10 }, P = { sm: 2, md: 4, lg: 6, xl: 8, full: 4 }, ne = { sm: 8, md: 8, lg: 8, xl: 8, full: 8 }, oe = [
515
515
  {
516
516
  id: "gryt",
517
517
  name: "Gryt",
@@ -900,6 +900,74 @@ const y = { sm: 8, md: 12, lg: 20, xl: 28, full: 999 }, k = { sm: 6, md: 8, lg:
900
900
  radius: y
901
901
  }
902
902
  },
903
+ {
904
+ /* Four photographs: snow-loaded spruces through a gym window, a dark room
905
+ lit by white strips, a white can on black rubber, grey sweatpants.
906
+
907
+ Paper is already near-monochrome, so this earns its place by being cold
908
+ rather than neutral. Every grey carries the blue that overcast snow
909
+ light has — Paper's are hueless, and side by side the difference is the
910
+ whole theme.
911
+
912
+ The accent is the white can on the black floor, which is why this is the
913
+ only Gryt preset with a split `lightHue`. A near-white accent is the
914
+ point in the dark half and invisible in the light one, so light gets the
915
+ colour of a wet window frame instead and keeps the same job. */
916
+ id: "winter-arc",
917
+ name: "Winter Arc",
918
+ note: "Cold monochrome. A near-white accent in the dark, snow-light greys.",
919
+ group: "Gryt",
920
+ theme: {
921
+ name: "Winter Arc",
922
+ hue: {
923
+ accent: "#dce6ec",
924
+ accentLight: "#f0f6f9",
925
+ secondary: "#7d95a3",
926
+ secondaryLight: "#9db1bc",
927
+ success: "#7fa88d",
928
+ danger: "#c2686b",
929
+ dangerLight: "#d68b8d",
930
+ warning: "#b9a068",
931
+ onAccent: "#0b0d0f",
932
+ onSecondary: "#0b1114",
933
+ onDanger: "#1b0c0d"
934
+ },
935
+ lightHue: {
936
+ accent: "#2b3a44",
937
+ accentLight: "#43596a",
938
+ secondary: "#55707f",
939
+ secondaryLight: "#6f8b9a",
940
+ success: "#4a7059",
941
+ danger: "#a4494c",
942
+ dangerLight: "#b96b6e",
943
+ warning: "#856c33",
944
+ onAccent: "#eef3f6",
945
+ onSecondary: "#eef3f6",
946
+ onDanger: "#fdf2f2"
947
+ },
948
+ dark: {
949
+ bg: "#0b0d0f",
950
+ surface: "#111417",
951
+ surfaceRaised: "#171b1f",
952
+ surfaceHover: "#1f252a",
953
+ border: "#2a3238",
954
+ muted: "#8b979f",
955
+ text: "#eef3f6"
956
+ },
957
+ light: {
958
+ bg: "#eaeef1",
959
+ surface: "#ffffff",
960
+ surfaceRaised: "#f4f7f9",
961
+ surfaceHover: "#dde4e9",
962
+ border: "#c6d0d7",
963
+ muted: "#55626b",
964
+ text: "#0f1417"
965
+ },
966
+ /* Hard corners on purpose. The reference is window mullions, plate
967
+ edges and rubber floor tiles, and Paper already has the soft set. */
968
+ radius: I
969
+ }
970
+ },
903
971
  {
904
972
  id: "signal",
905
973
  name: "Signal",
@@ -939,7 +1007,7 @@ const y = { sm: 8, md: 12, lg: 20, xl: 28, full: 999 }, k = { sm: 6, md: 8, lg:
939
1007
  muted: "#3d3d3d",
940
1008
  text: "#000000"
941
1009
  },
942
- radius: I
1010
+ radius: P
943
1011
  }
944
1012
  },
945
1013
  {
@@ -1175,7 +1243,7 @@ const y = { sm: 8, md: 12, lg: 20, xl: 28, full: 999 }, k = { sm: 6, md: 8, lg:
1175
1243
  muted: "#59636e",
1176
1244
  text: "#1f2328"
1177
1245
  },
1178
- radius: ce
1246
+ radius: I
1179
1247
  }
1180
1248
  },
1181
1249
  {
@@ -1331,7 +1399,7 @@ const y = { sm: 8, md: 12, lg: 20, xl: 28, full: 999 }, k = { sm: 6, md: 8, lg:
1331
1399
  muted: "#586e75",
1332
1400
  text: "#073642"
1333
1401
  },
1334
- radius: I
1402
+ radius: P
1335
1403
  }
1336
1404
  }
1337
1405
  ], he = new Map(
@@ -1433,9 +1501,9 @@ function xe(r, a) {
1433
1501
  }
1434
1502
  export {
1435
1503
  v as GRYT_HUE_KEYS,
1436
- O as GRYT_NEUTRAL_KEYS,
1504
+ B as GRYT_NEUTRAL_KEYS,
1437
1505
  D as GRYT_RADIUS_KEYS,
1438
- V as GRYT_THEME_NAME_MAX,
1506
+ Z as GRYT_THEME_NAME_MAX,
1439
1507
  S as alphaScale,
1440
1508
  G as cloneGrytTheme,
1441
1509
  se as contrast,
@@ -1453,20 +1521,20 @@ export {
1453
1521
  C as grytScales,
1454
1522
  T as grytScalesLight,
1455
1523
  L as grytTheme,
1456
- Z as grytThemeHues,
1524
+ ee as grytThemeHues,
1457
1525
  ge as grytThemeToOptions,
1458
1526
  s as grytTokens,
1459
1527
  R as hexToOklch,
1460
1528
  H as hexToRgb,
1461
1529
  h as hueScale,
1462
1530
  b as hueScaleLight,
1463
- j as isHexColor,
1464
- N as neutralScale,
1465
- U as neutralScaleLight,
1531
+ W as isHexColor,
1532
+ U as neutralScale,
1533
+ F as neutralScaleLight,
1466
1534
  $ as normalizeHexColor,
1467
1535
  M as normalizeThemeName,
1468
1536
  m as oklchToHex,
1469
- _ as rgbToHex,
1537
+ N as rgbToHex,
1470
1538
  xe as sampleCurve,
1471
1539
  be as springSamples,
1472
1540
  ye as springTightSamples