@fldr/ui 0.1.0 → 0.3.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.
Files changed (56) hide show
  1. package/dist/.build-complete +1 -1
  2. package/dist/chunks/{code-nj2nu6qzxhz6qnkk.js → code-hp2x28uiufmk3elz.js} +2 -4
  3. package/dist/chunks/highlighter-mouttug0tu8xg1i8.js +1364 -0
  4. package/dist/code/server.d.ts +4 -89
  5. package/dist/code/server.js +3 -136
  6. package/dist/code.d.ts +53 -70
  7. package/dist/code.js +186 -327
  8. package/dist/command-line/cli.js +0 -0
  9. package/dist/command-line/commands/add.js +0 -0
  10. package/dist/command-line/commands/ai.js +0 -0
  11. package/dist/command-line/commands/blocks.js +0 -0
  12. package/dist/command-line/commands/doc.js +0 -0
  13. package/dist/command-line/commands/init.js +0 -0
  14. package/dist/command-line/commands/ls.js +0 -0
  15. package/dist/components/code.d.ts +1 -1
  16. package/dist/components/code.js +1 -1
  17. package/dist/highlighter-BT3TakhJ.d.ts +13 -0
  18. package/dist/{index-B9niVl3r.d.ts → index-CNL6VDYZ.d.ts} +2 -4
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.js +1 -1
  21. package/dist/styles/kumo-binding.css +1 -0
  22. package/dist/styles/kumo-standalone.css +1 -1
  23. package/dist/styles/kumo.css +20 -38
  24. package/dist/styles/theme-code.css +142 -0
  25. package/dist/styles/theme-fldr.css +429 -15
  26. package/dist/theming.d.ts +71 -32
  27. package/dist/theming.js +162 -17
  28. package/package.json +2 -4
  29. package/scripts/css-build.ts +1 -0
  30. package/scripts/publish-fldr.ts +50 -8
  31. package/scripts/theme-generator/index.ts +15 -5
  32. package/dist/chunks/bash-jpzh6zbf5237424t.js +0 -3
  33. package/dist/chunks/core-n0de50o00ej2ecfe.js +0 -7177
  34. package/dist/chunks/css-j501gxq1am2gnikh.js +0 -4
  35. package/dist/chunks/diff-g2re0kj6fh27rgg5.js +0 -4
  36. package/dist/chunks/engine-javascript-e9xj8hhz9xfqhpnu.js +0 -3118
  37. package/dist/chunks/engine-oniguruma-ias56ildu01gf939.js +0 -389
  38. package/dist/chunks/github-light-hir7yctc38258pwt.js +0 -5
  39. package/dist/chunks/graphql-n9vlzkvcp2j19p7a.js +0 -16
  40. package/dist/chunks/hcl-ohpfnrffs96hzyj5.js +0 -4
  41. package/dist/chunks/html-nimj6ljkkifnc9ni.js +0 -12
  42. package/dist/chunks/javascript-b6fq9bl50fdj6813.js +0 -4
  43. package/dist/chunks/json-h2g0z143t3cs13d7.js +0 -4
  44. package/dist/chunks/jsonc-jxlzvingck161eej.js +0 -4
  45. package/dist/chunks/jsx-jp7a33937sef92sn.js +0 -4
  46. package/dist/chunks/markdown-eybeqjr58vfygtz1.js +0 -4
  47. package/dist/chunks/python-nrpnmxq4r6yp6fcd.js +0 -4
  48. package/dist/chunks/shellscript-i4m7lo8wi0f5bl8b.js +0 -4
  49. package/dist/chunks/sql-hqp2eekl7qhmxe92.js +0 -4
  50. package/dist/chunks/toml-oyqrgosuct25x413.js +0 -4
  51. package/dist/chunks/tsx-pem8x69upvmibv6l.js +0 -4
  52. package/dist/chunks/typescript-pe5y016phdwbgws7.js +0 -4
  53. package/dist/chunks/vesper-g839e590k3dxnwh3.js +0 -5
  54. package/dist/chunks/wasm-cpasy0o9lsjrm39j.js +0 -8
  55. package/dist/chunks/yaml-kzk5ddyekbyha04v.js +0 -4
  56. package/dist/types-C6in2C8V.d.ts +0 -135
package/dist/theming.js CHANGED
@@ -111,6 +111,27 @@ function generateThemeOverrideCSS(config, themeName, useNewNames = false, header
111
111
  function defineTheme(theme) {
112
112
  return theme;
113
113
  }
114
+ /**
115
+ * Build a theme on top of another one. Token groups merge, and the new
116
+ * theme's tokens win, so a variant only lists what it changes.
117
+ */
118
+ function extendTheme(base, theme) {
119
+ return {
120
+ name: theme.name,
121
+ text: {
122
+ ...base.text,
123
+ ...theme.text
124
+ },
125
+ color: {
126
+ ...base.color,
127
+ ...theme.color
128
+ },
129
+ typography: {
130
+ ...base.typography,
131
+ ...theme.typography
132
+ }
133
+ };
134
+ }
114
135
  const NAME = /^[a-z][a-z0-9-]*$/;
115
136
  const RESERVED = /* @__PURE__ */ new Set(["kumo", "fedramp"]);
116
137
  function assertKnown(group, keys, known) {
@@ -155,9 +176,29 @@ function generateThemeCSS(theme) {
155
176
  };
156
177
  return generateThemeOverrideCSS(config, name, false, `/* Kumo theme "${name}". Generated by generateThemeCSS(); edit the theme definition, not this file. */\n`);
157
178
  }
179
+ function defineDensity(density) {
180
+ return density;
181
+ }
182
+ /** Generate the CSS for a density. Load it after Kumo's styles. */
183
+ function generateDensityCSS(density) {
184
+ const { name, spacing, typography = {} } = density;
185
+ if (!NAME.test(name)) throw new Error(`Invalid density name "${name}": use lowercase letters, digits and dashes`);
186
+ assertKnown("typography", Object.keys(typography), THEME_CONFIG.typography);
187
+ const lines = [` --spacing: ${spacing};`];
188
+ for (const [key, value] of Object.entries(typography)) lines.push(` --text-${key}: ${value};`);
189
+ return [
190
+ `/* Kumo density "${name}". Generated by generateDensityCSS(). */`,
191
+ "@layer base {",
192
+ ` [data-density="${name}"] {`,
193
+ ...lines,
194
+ " }",
195
+ "}",
196
+ ""
197
+ ].join("\n");
198
+ }
158
199
  //#endregion
159
200
  //#region src/themes/fldr.ts
160
- /** fldr: graphite on warm off-white, indigo accent. */
201
+ /** fldr: graphite on warm off-white, with Kumo's blue as the accent. */
161
202
  const fldrTheme = defineTheme({
162
203
  name: "fldr",
163
204
  text: {
@@ -178,12 +219,12 @@ const fldrTheme = defineTheme({
178
219
  dark: "#9c9a94"
179
220
  },
180
221
  "kumo-brand": {
181
- light: "#5146e5",
182
- dark: "#a59ff6"
222
+ light: "oklch(48.8% 0.243 264.376)",
223
+ dark: "oklch(70.7% 0.165 254.624)"
183
224
  },
184
225
  "kumo-link": {
185
- light: "#4238c4",
186
- dark: "#a59ff6"
226
+ light: "oklch(42.4% 0.199 265.638)",
227
+ dark: "oklch(70.7% 0.165 254.624)"
187
228
  }
188
229
  },
189
230
  color: {
@@ -220,22 +261,126 @@ const fldrTheme = defineTheme({
220
261
  dark: "#2b2a28"
221
262
  },
222
263
  "kumo-focus": {
223
- light: "#5146e5",
224
- dark: "#7f76ee"
225
- },
226
- "kumo-brand": {
227
- light: "#5146e5",
228
- dark: "#6258ea"
264
+ light: "oklch(0.5772 0.2324 260)",
265
+ dark: "oklch(70.7% 0.165 254.624)"
266
+ }
267
+ }
268
+ });
269
+ /** An fldr variant that only swaps the accent hue. */
270
+ function fldrAccent(name, accent) {
271
+ return extendTheme(fldrTheme, {
272
+ name,
273
+ text: {
274
+ "kumo-brand": accent.text,
275
+ "kumo-link": accent.text
229
276
  },
230
- "kumo-brand-hover": {
231
- light: "#4238c4",
232
- dark: "#5146e5"
277
+ color: {
278
+ "kumo-brand": accent.brand,
279
+ "kumo-brand-hover": accent.hover,
280
+ "kumo-focus": accent.brand
233
281
  }
282
+ });
283
+ }
284
+ const fldrVioletTheme = fldrAccent("fldr-violet", {
285
+ brand: {
286
+ light: "oklch(54.1% 0.281 293.009)",
287
+ dark: "oklch(54.1% 0.281 293.009)"
288
+ },
289
+ hover: {
290
+ light: "oklch(49.1% 0.27 292.581)",
291
+ dark: "oklch(60.6% 0.25 292.717)"
292
+ },
293
+ text: {
294
+ light: "oklch(49.1% 0.27 292.581)",
295
+ dark: "oklch(70.2% 0.183 293.541)"
296
+ }
297
+ });
298
+ const fldrGreenTheme = fldrAccent("fldr-green", {
299
+ brand: {
300
+ light: "oklch(50.8% 0.118 165.612)",
301
+ dark: "oklch(50.8% 0.118 165.612)"
302
+ },
303
+ hover: {
304
+ light: "oklch(43.2% 0.095 166.913)",
305
+ dark: "oklch(59.6% 0.145 163.225)"
306
+ },
307
+ text: {
308
+ light: "oklch(43.2% 0.095 166.913)",
309
+ dark: "oklch(76.5% 0.177 163.223)"
310
+ }
311
+ });
312
+ const fldrOrangeTheme = fldrAccent("fldr-orange", {
313
+ brand: {
314
+ light: "oklch(55.3% 0.195 38.402)",
315
+ dark: "oklch(55.3% 0.195 38.402)"
316
+ },
317
+ hover: {
318
+ light: "oklch(47% 0.157 37.304)",
319
+ dark: "oklch(64.6% 0.222 41.116)"
320
+ },
321
+ text: {
322
+ light: "oklch(47% 0.157 37.304)",
323
+ dark: "oklch(75% 0.183 55.934)"
324
+ }
325
+ });
326
+ const fldrRoseTheme = fldrAccent("fldr-rose", {
327
+ brand: {
328
+ light: "oklch(58.6% 0.253 17.585)",
329
+ dark: "oklch(58.6% 0.253 17.585)"
330
+ },
331
+ hover: {
332
+ light: "oklch(51.4% 0.222 16.935)",
333
+ dark: "oklch(64.5% 0.246 16.439)"
334
+ },
335
+ text: {
336
+ light: "oklch(51.4% 0.222 16.935)",
337
+ dark: "oklch(71.2% 0.194 13.428)"
338
+ }
339
+ });
340
+ /** Monochrome: graphite ink instead of a hue. */
341
+ const fldrInkTheme = fldrAccent("fldr-ink", {
342
+ brand: {
343
+ light: "#191918",
344
+ dark: "#41403d"
345
+ },
346
+ hover: {
347
+ light: "#2b2a28",
348
+ dark: "#5a5955"
349
+ },
350
+ text: {
351
+ light: "#191918",
352
+ dark: "#f6f5f2"
353
+ }
354
+ });
355
+ //#endregion
356
+ //#region src/themes/density.ts
357
+ /** About 12% tighter than Kumo's default: 28px base controls, 13px body text. */
358
+ const compactDensity = defineDensity({
359
+ name: "compact",
360
+ spacing: "0.22rem",
361
+ typography: {
362
+ xs: "11px",
363
+ sm: "12px",
364
+ base: "13px",
365
+ lg: "15px"
234
366
  }
235
367
  });
236
368
  //#endregion
237
369
  //#region src/themes/index.ts
238
- /** Themes shipped as prebuilt CSS (`@fldr/ui/styles/theme-<name>.css`). */
239
- const BUILT_IN_THEMES = [fldrTheme];
370
+ /**
371
+ * Themes shipped as prebuilt CSS. All of them are written to
372
+ * `theme-fldr.css` (`@fldr/ui/styles/theme-fldr.css`), which the
373
+ * standalone and Tailwind builds already include.
374
+ */
375
+ const BUILT_IN_THEMES = [
376
+ fldrTheme,
377
+ fldrVioletTheme,
378
+ fldrGreenTheme,
379
+ fldrOrangeTheme,
380
+ fldrRoseTheme,
381
+ fldrInkTheme
382
+ ];
383
+ /** Densities shipped in `theme-fldr.css`, applied with `data-density="<name>"`. */
384
+ const BUILT_IN_DENSITIES = [compactDensity];
240
385
  //#endregion
241
- export { BUILT_IN_THEMES, defineTheme, fldrTheme, generateThemeCSS };
386
+ export { BUILT_IN_DENSITIES, BUILT_IN_THEMES, compactDensity, defineDensity, defineTheme, extendTheme, fldrGreenTheme, fldrInkTheme, fldrOrangeTheme, fldrRoseTheme, fldrTheme, fldrVioletTheme, generateDensityCSS, generateThemeCSS };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fldr/ui",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "private": false,
5
5
  "description": "fldr's design system: Cloudflare Kumo with a theme authoring API and PandaCSS preset",
6
6
  "keywords": [
@@ -459,13 +459,11 @@
459
459
  },
460
460
  "dependencies": {
461
461
  "@base-ui/react": "^1.9.0",
462
- "@shikijs/langs": "^4.0.0",
463
- "@shikijs/themes": "^4.0.0",
462
+ "@tanstack/highlight": "1.2.12",
464
463
  "cn": "0.4.0",
465
464
  "d3-geo": "^3.1.1",
466
465
  "motion": "^12.34.1",
467
466
  "react-day-picker": "^9.13.2",
468
- "shiki": "^4.0.0",
469
467
  "use-sync-external-store": "^1.6.0"
470
468
  },
471
469
  "peerDependencies": {
@@ -27,6 +27,7 @@ const cssFiles: string[] = [
27
27
  "theme-kumo.css",
28
28
  "theme-fedramp.css",
29
29
  "theme-fldr.css",
30
+ "theme-code.css",
30
31
  ];
31
32
 
32
33
  cssFiles.forEach((file) => {
@@ -11,14 +11,32 @@
11
11
  * pnpm publish:fldr 0.1.0 [--otp=123456]
12
12
  */
13
13
  import { spawnSync } from "node:child_process";
14
- import { cpSync, existsSync, mkdtempSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
14
+ import {
15
+ cpSync,
16
+ existsSync,
17
+ mkdtempSync,
18
+ readFileSync,
19
+ readdirSync,
20
+ statSync,
21
+ writeFileSync,
22
+ } from "node:fs";
15
23
  import { tmpdir } from "node:os";
16
24
  import { extname, join, resolve } from "node:path";
17
25
  import { fileURLToPath } from "node:url";
18
26
 
19
27
  const NAME = "@fldr/ui";
20
28
  const UPSTREAM_NAME = "@fldr/ui";
21
- const TEXT_EXTENSIONS = new Set([".js", ".mjs", ".cjs", ".ts", ".mts", ".json", ".md", ".css", ".txt"]);
29
+ const TEXT_EXTENSIONS = new Set([
30
+ ".js",
31
+ ".mjs",
32
+ ".cjs",
33
+ ".ts",
34
+ ".mts",
35
+ ".json",
36
+ ".md",
37
+ ".css",
38
+ ".txt",
39
+ ]);
22
40
 
23
41
  const pkgDir = resolve(fileURLToPath(import.meta.url), "../..");
24
42
  const args = process.argv.slice(2);
@@ -52,7 +70,8 @@ function rewrite(dir: string) {
52
70
  rewrite(path);
53
71
  } else if (TEXT_EXTENSIONS.has(extname(name))) {
54
72
  const text = readFileSync(path, "utf8");
55
- if (text.includes(UPSTREAM_NAME)) writeFileSync(path, text.replaceAll(UPSTREAM_NAME, NAME));
73
+ if (text.includes(UPSTREAM_NAME))
74
+ writeFileSync(path, text.replaceAll(UPSTREAM_NAME, NAME));
56
75
  }
57
76
  }
58
77
  }
@@ -63,16 +82,39 @@ const published = {
63
82
  ...rest,
64
83
  name: NAME,
65
84
  version,
66
- description: "fldr's design system: Cloudflare Kumo with a theme authoring API and PandaCSS preset",
67
- keywords: ["fldr", "kumo", "components", "design-system", "react", "ui", "pandacss"],
68
- repository: { type: "git", url: "git+https://github.com/mergd/fldr-ui.git", directory: "packages/kumo" },
85
+ description:
86
+ "fldr's design system: Cloudflare Kumo with a theme authoring API and PandaCSS preset",
87
+ keywords: [
88
+ "fldr",
89
+ "kumo",
90
+ "components",
91
+ "design-system",
92
+ "react",
93
+ "ui",
94
+ "pandacss",
95
+ ],
96
+ repository: {
97
+ type: "git",
98
+ url: "git+https://github.com/mergd/fldr-ui.git",
99
+ directory: "packages/kumo",
100
+ },
69
101
  };
70
- writeFileSync(join(stage, "package.json"), `${JSON.stringify(published, null, 2)}\n`);
102
+ writeFileSync(
103
+ join(stage, "package.json"),
104
+ `${JSON.stringify(published, null, 2)}\n`,
105
+ );
71
106
 
72
107
  console.log(`Staged ${NAME}@${version} in ${stage}`);
73
108
  const result = spawnSync(
74
109
  "pnpm",
75
- ["publish", "--access", "public", "--no-git-checks", ...(dryRun ? ["--dry-run"] : []), ...(otp ? [otp] : [])],
110
+ [
111
+ "publish",
112
+ "--access",
113
+ "public",
114
+ "--no-git-checks",
115
+ ...(dryRun ? ["--dry-run"] : []),
116
+ ...(otp ? [otp] : []),
117
+ ],
76
118
  { cwd: stage, stdio: "inherit" },
77
119
  );
78
120
  process.exit(result.status ?? 1);
@@ -19,8 +19,12 @@ import {
19
19
  getTokenRenameMap,
20
20
  } from "./generate-css.js";
21
21
  import { THEME_CONFIG, AVAILABLE_THEMES } from "./config.js";
22
- import { BUILT_IN_THEMES } from "../../src/themes/index.js";
23
- import { generateThemeCSS } from "../../src/theming/define-theme.js";
22
+ import { BUILT_IN_DENSITIES, BUILT_IN_THEMES } from "../../src/themes/index.js";
23
+ import {
24
+ generateDensityCSS,
25
+ generateThemeCSS,
26
+ } from "../../src/theming/define-theme.js";
27
+ import { generateCodeThemeCSS } from "../../src/code/theme.js";
24
28
 
25
29
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
26
30
  const STYLES_DIR = path.resolve(__dirname, "../../src/styles");
@@ -135,9 +139,15 @@ async function main() {
135
139
  useNewNames: args.useNewNames,
136
140
  });
137
141
 
138
- for (const theme of BUILT_IN_THEMES) {
139
- files.set(`theme-${theme.name}.css`, generateThemeCSS(theme));
140
- }
142
+ files.set("theme-code.css", generateCodeThemeCSS());
143
+
144
+ files.set(
145
+ "theme-fldr.css",
146
+ [
147
+ ...BUILT_IN_THEMES.map(generateThemeCSS),
148
+ ...BUILT_IN_DENSITIES.map(generateDensityCSS),
149
+ ].join("\n"),
150
+ );
141
151
 
142
152
  for (const [filename, content] of files) {
143
153
  const filepath = path.join(STYLES_DIR, filename);
@@ -1,3 +0,0 @@
1
- "use client";
2
- import shellscript_default from "./shellscript-i4m7lo8wi0f5bl8b.js";
3
- export { shellscript_default as default };