@gryt/theme 0.4.0 → 0.6.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 G(r) {
1
+ function N(r) {
2
2
  return r <= 0.04045 ? r / 12.92 : ((r + 0.055) / 1.055) ** 2.4;
3
3
  }
4
4
  function v(r) {
@@ -15,12 +15,12 @@ function x(r) {
15
15
  parseInt(t.slice(4, 6), 16) / 255
16
16
  ];
17
17
  }
18
- function N([r, a, t]) {
18
+ function I([r, a, t]) {
19
19
  const e = (o) => Math.round(L(o) * 255).toString(16).padStart(2, "0");
20
20
  return `#${e(r)}${e(a)}${e(t)}`;
21
21
  }
22
22
  function S(r) {
23
- const [a, t, e] = x(r).map(G), o = Math.cbrt(
23
+ const [a, t, e] = x(r).map(N), 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 S(r) {
35
35
  }
36
36
  function y({ 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, f = (r - 0.0894841775 * e - 1.291485548 * o) ** 3;
38
- return N([
38
+ return I([
39
39
  v(L(4.0767416621 * c - 3.3077115913 * n + 0.2309699292 * f)),
40
40
  v(L(-1.2684380046 * c + 2.6097574011 * n - 0.3413193965 * f)),
41
41
  v(L(-0.0041960863 * c - 0.7034186147 * n + 1.707614701 * f))
@@ -75,7 +75,7 @@ const W = [
75
75
  0,
76
76
  8e-3
77
77
  ];
78
- function I(r) {
78
+ function U(r) {
79
79
  const a = {
80
80
  0: r.bg,
81
81
  1: r.surface,
@@ -98,7 +98,7 @@ function w(r, a) {
98
98
  i > m ? c = Math.max(c, m < 1 ? (i - m) / (1 - m) : 0) : i < m && (c = Math.max(c, m > 0 ? (m - i) / m : 0));
99
99
  }
100
100
  if (c < 1e-6) return "transparent";
101
- const n = N(
101
+ const n = I(
102
102
  o.map((u, i) => L(t[i] + (u - t[i]) / c))
103
103
  ), [f, d, g] = x(n).map((u) => Math.round(u * 255));
104
104
  return `rgb(${f} ${d} ${g} / ${(c * 100).toFixed(1)}%)`;
@@ -131,7 +131,7 @@ const q = [
131
131
  0.012,
132
132
  0.014
133
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) {
134
+ function C(r) {
135
135
  const a = {
136
136
  0: r.bg,
137
137
  1: r.surface,
@@ -150,12 +150,12 @@ function b(r) {
150
150
  );
151
151
  return o.push(r), o.push(y({ l: Math.max(0, a - 0.07), c: t, h: e })), o.push(y({ l: 0.46, c: 0.15, h: e })), o.push(y({ l: 0.33, c: 0.1, h: e })), o;
152
152
  }
153
- function E(r) {
154
- const [a, t, e] = x(r).map(G);
153
+ function G(r) {
154
+ const [a, t, e] = x(r).map(N);
155
155
  return 0.2126 * a + 0.7152 * t + 0.0722 * e;
156
156
  }
157
- function oe(r, a) {
158
- const t = E(r), e = E(a);
157
+ function se(r, a) {
158
+ const t = G(r), e = G(a);
159
159
  return (Math.max(t, e) + 0.05) / (Math.min(t, e) + 0.05);
160
160
  }
161
161
  const s = {
@@ -197,7 +197,7 @@ const s = {
197
197
  muted: "#5b5d65",
198
198
  text: "#1f2129"
199
199
  }, _ = {
200
- neutral: I({
200
+ neutral: U({
201
201
  bg: s.color.bg,
202
202
  surface: s.color.surface,
203
203
  surfaceRaised: s.color.surfaceRaised,
@@ -213,25 +213,25 @@ const s = {
213
213
  success: h(s.color.success, s.color.success),
214
214
  danger: h(s.color.danger, s.color.dangerLight),
215
215
  warning: h(s.color.warning, s.color.warning)
216
- }, T = {
217
- neutral: U(l),
216
+ }, A = {
217
+ neutral: C(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
- }, C = T.neutral[3], se = {
223
+ }, O = A.neutral[3], fe = {
224
224
  neutral: w(_.neutral, s.color.bg),
225
225
  accent: w(_.accent, s.color.bg)
226
- }, fe = {
227
- neutral: w(T.neutral, l.bg),
228
- accent: w(T.accent, l.bg)
226
+ }, de = {
227
+ neutral: w(A.neutral, l.bg),
228
+ accent: w(A.accent, l.bg)
229
229
  };
230
- function de(r = {}) {
230
+ function ue(r = {}) {
231
231
  const a = r.appearance === "light", e = { ...a ? {
232
232
  ...s.color,
233
233
  ...l,
234
- surfaceHover: C
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 de(r = {}) {
240
240
  muted: e.muted,
241
241
  text: e.text
242
242
  }, n = a ? {
243
- neutral: U(c),
243
+ neutral: C(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: I(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 R = [
322
322
  "onAccent",
323
323
  "onSecondary",
324
324
  "onDanger"
325
- ], O = [
325
+ ], j = [
326
326
  "bg",
327
327
  "surface",
328
328
  "surfaceRaised",
@@ -362,14 +362,14 @@ const p = {
362
362
  bg: l.bg,
363
363
  surface: l.surface,
364
364
  surfaceRaised: l.surfaceRaised,
365
- surfaceHover: C,
365
+ surfaceHover: O,
366
366
  border: l.border,
367
367
  muted: l.muted,
368
368
  text: l.text
369
369
  },
370
370
  radius: { ...s.radius }
371
371
  };
372
- function j(r) {
372
+ function D(r) {
373
373
  return {
374
374
  ...r.name === void 0 ? {} : { name: r.name },
375
375
  hue: { ...r.hue },
@@ -382,7 +382,7 @@ function j(r) {
382
382
  function Z(r, a) {
383
383
  return a === "light" && r.lightHue !== null ? r.lightHue : r.hue;
384
384
  }
385
- function ue(r, a) {
385
+ function ge(r, a) {
386
386
  return {
387
387
  appearance: a,
388
388
  color: { ...Z(r, a), ...r[a] },
@@ -413,12 +413,12 @@ const H = {
413
413
  function z(r) {
414
414
  return ee.test(r.trim());
415
415
  }
416
- function D(r) {
416
+ function E(r) {
417
417
  const a = r.trim().toLowerCase();
418
418
  return a.length === 4 ? `#${a[1]}${a[1]}${a[2]}${a[2]}${a[3]}${a[3]}` : a;
419
419
  }
420
- function ge(r, a) {
421
- const t = new URLSearchParams(), e = (c) => D(c).slice(1), o = $(r.name ?? "");
420
+ function ie(r, a) {
421
+ const t = new URLSearchParams(), e = (c) => E(c).slice(1), o = $(r.name ?? "");
422
422
  o !== "" && t.set("name", o);
423
423
  for (const c of R)
424
424
  r.hue[c] !== p.hue[c] && t.set(H[c], e(r.hue[c]));
@@ -427,14 +427,14 @@ function ge(r, a) {
427
427
  t.set(`lh-${H[c]}`, e(r.lightHue[c]));
428
428
  for (const c of ["dark", "light"]) {
429
429
  const n = c === "dark" ? "d" : "l";
430
- for (const f of O)
430
+ for (const f of j)
431
431
  r[c][f] !== p[c][f] && t.set(`${n}-${Y[f]}`, e(r[c][f]));
432
432
  }
433
433
  for (const c of M)
434
434
  r.radius[c] !== p.radius[c] && t.set(`r-${c}`, String(r.radius[c]));
435
435
  return a === "light" && t.set("mode", "light"), t;
436
436
  }
437
- function ie(r) {
437
+ function le(r) {
438
438
  const a = r.trim();
439
439
  if (a === "") return null;
440
440
  if (a.startsWith("{")) return ae(a);
@@ -442,13 +442,13 @@ function ie(r) {
442
442
  return re(new URLSearchParams(t));
443
443
  }
444
444
  function re(r) {
445
- const a = j(p);
445
+ const a = D(p);
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 f = n.startsWith("#") ? n : `#${n}`;
451
- return z(f) ? (t = !0, D(f)) : null;
451
+ return z(f) ? (t = !0, E(f)) : null;
452
452
  }, o = $(r.get("name") ?? "");
453
453
  o !== "" && (a.name = o, t = !0);
454
454
  for (const c of R) {
@@ -465,7 +465,7 @@ function re(r) {
465
465
  }
466
466
  for (const c of ["dark", "light"]) {
467
467
  const n = c === "dark" ? "d" : "l";
468
- for (const f of O) {
468
+ for (const f of j) {
469
469
  const d = e(`${n}-${Y[f]}`);
470
470
  d !== null && (a[c][f] = d);
471
471
  }
@@ -487,12 +487,12 @@ function ae(r) {
487
487
  return null;
488
488
  }
489
489
  if (typeof a != "object" || a === null) return null;
490
- const t = a, e = j(p);
490
+ const t = a, e = D(p);
491
491
  let o = !1;
492
492
  const c = (n, f) => {
493
493
  if (!(typeof n != "object" || n === null))
494
494
  for (const [d, g] of Object.entries(n))
495
- typeof g == "string" && z(g) && d in f && (f[d] = D(g), o = !0);
495
+ typeof g == "string" && z(g) && d in f && (f[d] = E(g), o = !0);
496
496
  };
497
497
  if (typeof t.name == "string") {
498
498
  const n = $(t.name);
@@ -511,7 +511,7 @@ function ae(r) {
511
511
  }
512
512
  return o ? { theme: e, appearance: "dark" } : null;
513
513
  }
514
- const k = { sm: 8, md: 12, lg: 20, xl: 28, full: 999 }, A = { 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 }, P = { sm: 2, md: 4, lg: 6, xl: 8, full: 4 }, ne = [
514
+ const k = { sm: 8, md: 12, lg: 20, xl: 28, full: 999 }, T = { 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 }, 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",
@@ -520,6 +520,19 @@ const k = { sm: 8, md: 12, lg: 20, xl: 28, full: 999 }, A = { sm: 6, md: 8, lg:
520
520
  source: "github.com/Gryt-chat/code-theme",
521
521
  theme: p
522
522
  },
523
+ {
524
+ /* Credits to Carlo, who made this in the generator and sent the link.
525
+ Same colours as above — the only change is the radius, and the one that
526
+ matters is `full`: it drops 999 to 8, so the controls that were pills
527
+ (buttons, the search field, badges) become rectangles with the same
528
+ corner as everything else. */
529
+ id: "gryt-rounded",
530
+ name: "Gryt Rounded",
531
+ note: "The shipped palette, every corner at eight pixels. Made by Carlo.",
532
+ group: "Gryt",
533
+ source: "Carlo",
534
+ theme: { ...D(p), name: "Gryt Rounded", radius: ne }
535
+ },
523
536
  {
524
537
  id: "ember",
525
538
  name: "Ember",
@@ -601,7 +614,7 @@ const k = { sm: 8, md: 12, lg: 20, xl: 28, full: 999 }, A = { sm: 6, md: 8, lg:
601
614
  muted: "#5b5b63",
602
615
  text: "#17171a"
603
616
  },
604
- radius: A
617
+ radius: T
605
618
  }
606
619
  },
607
620
  {
@@ -702,7 +715,7 @@ const k = { sm: 8, md: 12, lg: 20, xl: 28, full: 999 }, A = { sm: 6, md: 8, lg:
702
715
  muted: "#6c664b",
703
716
  text: "#1f1f1f"
704
717
  },
705
- radius: A
718
+ radius: T
706
719
  }
707
720
  },
708
721
  {
@@ -760,7 +773,7 @@ const k = { sm: 8, md: 12, lg: 20, xl: 28, full: 999 }, A = { sm: 6, md: 8, lg:
760
773
  muted: "#4c566a",
761
774
  text: "#2e3440"
762
775
  },
763
- radius: A
776
+ radius: T
764
777
  }
765
778
  },
766
779
  {
@@ -1038,9 +1051,9 @@ const k = { sm: 8, md: 12, lg: 20, xl: 28, full: 999 }, A = { sm: 6, md: 8, lg:
1038
1051
  radius: P
1039
1052
  }
1040
1053
  }
1041
- ], le = new Map(
1042
- ne.map((r) => [r.id, r])
1043
- ), he = [
1054
+ ], he = new Map(
1055
+ oe.map((r) => [r.id, r])
1056
+ ), be = [
1044
1057
  0,
1045
1058
  0.1217,
1046
1059
  0.3812,
@@ -1068,7 +1081,7 @@ const k = { sm: 8, md: 12, lg: 20, xl: 28, full: 999 }, A = { sm: 6, md: 8, lg:
1068
1081
  1.0004,
1069
1082
  1.0001,
1070
1083
  1
1071
- ], be = [
1084
+ ], ye = [
1072
1085
  0,
1073
1086
  0.0496,
1074
1087
  0.1585,
@@ -1096,11 +1109,19 @@ const k = { sm: 8, md: 12, lg: 20, xl: 28, full: 999 }, A = { sm: 6, md: 8, lg:
1096
1109
  0.9981,
1097
1110
  0.9986,
1098
1111
  1
1099
- ], ye = {
1112
+ ], me = {
1100
1113
  /** Most interactions. */
1101
1114
  spring: 500,
1102
1115
  /** Drawer, where the travel is the width of a panel. */
1103
1116
  springSoft: 700,
1117
+ /**
1118
+ * For something that travels further than its own width.
1119
+ *
1120
+ * A bottom sheet comes up from off the screen and covers most of it, which is
1121
+ * a longer journey than a drawer's. Reusing `springSoft` there meant the same
1122
+ * time over more distance, and it read as a snap.
1123
+ */
1124
+ springSlow: 900,
1104
1125
  /** Colour changes, which should not feel sprung. */
1105
1126
  fast: 150,
1106
1127
  /**
@@ -1110,7 +1131,7 @@ const k = { sm: 8, md: 12, lg: 20, xl: 28, full: 999 }, A = { sm: 6, md: 8, lg:
1110
1131
  * that a second pass starts before you wonder whether it has stopped.
1111
1132
  */
1112
1133
  sweep: 1400
1113
- }, me = {
1134
+ }, pe = {
1114
1135
  button: { hover: 1.03, press: 0.96 },
1115
1136
  iconButton: { hover: 1.06, press: 0.94 },
1116
1137
  checkbox: { hover: 1.08, press: 0.92 },
@@ -1119,8 +1140,8 @@ const k = { sm: 8, md: 12, lg: 20, xl: 28, full: 999 }, A = { sm: 6, md: 8, lg:
1119
1140
  toggle: { hover: 1.06, press: 0.94 },
1120
1141
  toast: { hover: 1.04, press: 0.96 },
1121
1142
  sliderThumb: { hover: 1.12, press: 0.94 }
1122
- }, pe = 64;
1123
- function Le(r, a) {
1143
+ }, Le = 64;
1144
+ function xe(r, a) {
1124
1145
  if (r.length === 0) return a;
1125
1146
  if (a <= 0) return r[0];
1126
1147
  if (a >= 1) return r[r.length - 1];
@@ -1129,42 +1150,42 @@ function Le(r, a) {
1129
1150
  }
1130
1151
  export {
1131
1152
  R as GRYT_HUE_KEYS,
1132
- O as GRYT_NEUTRAL_KEYS,
1153
+ j as GRYT_NEUTRAL_KEYS,
1133
1154
  M as GRYT_RADIUS_KEYS,
1134
1155
  V as GRYT_THEME_NAME_MAX,
1135
1156
  w as alphaScale,
1136
- j as cloneGrytTheme,
1137
- oe as contrast,
1138
- de as createGrytTheme,
1139
- ie as decodeGrytTheme,
1140
- ge as encodeGrytTheme,
1141
- se as grytAlphaScales,
1142
- fe as grytAlphaScalesLight,
1143
- pe as grytDrawerBleed,
1144
- ye as grytDurations,
1157
+ D as cloneGrytTheme,
1158
+ se as contrast,
1159
+ ue as createGrytTheme,
1160
+ le as decodeGrytTheme,
1161
+ ie as encodeGrytTheme,
1162
+ fe as grytAlphaScales,
1163
+ de as grytAlphaScalesLight,
1164
+ Le as grytDrawerBleed,
1165
+ me as grytDurations,
1145
1166
  l as grytLightTokens,
1146
- ne as grytPresets,
1147
- le as grytPresetsById,
1148
- me as grytScaleSteps,
1167
+ oe as grytPresets,
1168
+ he as grytPresetsById,
1169
+ pe as grytScaleSteps,
1149
1170
  _ as grytScales,
1150
- T as grytScalesLight,
1171
+ A as grytScalesLight,
1151
1172
  p as grytTheme,
1152
1173
  Z as grytThemeHues,
1153
- ue as grytThemeToOptions,
1174
+ ge as grytThemeToOptions,
1154
1175
  s as grytTokens,
1155
1176
  S as hexToOklch,
1156
1177
  x as hexToRgb,
1157
1178
  h as hueScale,
1158
1179
  b as hueScaleLight,
1159
1180
  z as isHexColor,
1160
- I as neutralScale,
1161
- U as neutralScaleLight,
1162
- D as normalizeHexColor,
1181
+ U as neutralScale,
1182
+ C as neutralScaleLight,
1183
+ E as normalizeHexColor,
1163
1184
  $ as normalizeThemeName,
1164
1185
  y as oklchToHex,
1165
- N as rgbToHex,
1166
- Le as sampleCurve,
1167
- he as springSamples,
1168
- be as springTightSamples
1186
+ I as rgbToHex,
1187
+ xe as sampleCurve,
1188
+ be as springSamples,
1189
+ ye as springTightSamples
1169
1190
  };
1170
1191
  //# sourceMappingURL=index.js.map