@birdycom/omniaui 0.16.0 → 0.16.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/bin/lib/webicons.mjs +120 -0
- package/bin/omniaui.mjs +10 -1
- package/dist/components.css +55 -13
- package/dist/components.min.css +1 -1
- package/dist/oc-theme.css +1 -1
- package/dist/parts/app-mode-badge.css +5 -0
- package/dist/parts/media-live-frame.css +35 -5
- package/dist/parts/site-base.css +14 -7
- package/manifest.json +8 -0
- package/package.json +2 -2
- package/snippets/webicon.html +11 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// File: packages/ui/bin/lib/webicons.mjs
|
|
2
|
+
// `omniaui webicons`: a small JSON file with only the webicons an app uses, read from the Iconify sets installed in
|
|
3
|
+
// node_modules (@iconify-json/<set>/icons.json). Nothing is fetched. The app imports the file and passes it to
|
|
4
|
+
// addWebicons() (React / Vue); Blade reads it through config('omniacss.webicons.files').
|
|
5
|
+
// Map: names (arguments and/or --scan of the source) -> resolve per set (aliases) -> write --out (or print) -> report
|
|
6
|
+
|
|
7
|
+
import fs from "node:fs/promises";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import { createRequire } from "node:module";
|
|
10
|
+
import { cwd } from "./project.mjs";
|
|
11
|
+
|
|
12
|
+
/** The webicon sets (Iconify prefixes). */
|
|
13
|
+
export const WEBICON_SETS = ["mdi", "mdi-light", "material-symbols", "svg-spinners", "flag", "vscode-icons"];
|
|
14
|
+
const NAME = new RegExp(`(?<![\\w-])(${WEBICON_SETS.join("|")}):([a-z0-9]+(?:-[a-z0-9]+)*)`, "g");
|
|
15
|
+
const SCAN_EXT = new Set([".js", ".jsx", ".ts", ".tsx", ".vue", ".svelte", ".astro", ".php", ".html", ".md", ".mdx", ".json"]);
|
|
16
|
+
const SKIP_DIR = new Set(["node_modules", "vendor", "dist", "build", ".git", ".next", ".nuxt", "storage", "coverage"]);
|
|
17
|
+
|
|
18
|
+
/** Every webicon name in the files under `dir`. */
|
|
19
|
+
export async function scanNames(dir, skip = new Set()) {
|
|
20
|
+
const found = new Set();
|
|
21
|
+
async function walk(d) {
|
|
22
|
+
for (const entry of await fs.readdir(d, { withFileTypes: true })) {
|
|
23
|
+
const full = path.join(d, entry.name);
|
|
24
|
+
if (entry.isDirectory()) {
|
|
25
|
+
if (!SKIP_DIR.has(entry.name) && !entry.name.startsWith(".")) await walk(full);
|
|
26
|
+
} else if (SCAN_EXT.has(path.extname(entry.name)) && !skip.has(path.resolve(full))) {
|
|
27
|
+
for (const m of (await fs.readFile(full, "utf8")).matchAll(NAME)) found.add(`${m[1]}:${m[2]}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
await walk(dir);
|
|
32
|
+
return [...found].sort();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** One icon of an Iconify JSON set with its aliases resolved, or null. */
|
|
36
|
+
export function resolveIcon(set, name) {
|
|
37
|
+
let extra = {};
|
|
38
|
+
let rotate = 0;
|
|
39
|
+
let hFlip = false;
|
|
40
|
+
let vFlip = false;
|
|
41
|
+
for (let n = name, depth = 0; depth < 6; depth++) {
|
|
42
|
+
const icon = set.icons[n];
|
|
43
|
+
if (icon) {
|
|
44
|
+
const out = { ...icon, ...extra, body: icon.body };
|
|
45
|
+
out.width ??= set.width ?? 16;
|
|
46
|
+
out.height ??= set.height ?? 16;
|
|
47
|
+
if (set.left && out.left == null) out.left = set.left;
|
|
48
|
+
if (set.top && out.top == null) out.top = set.top;
|
|
49
|
+
const r = ((icon.rotate ?? 0) + rotate) % 4;
|
|
50
|
+
const h = !!icon.hFlip !== hFlip;
|
|
51
|
+
const v = !!icon.vFlip !== vFlip;
|
|
52
|
+
delete out.rotate; delete out.hFlip; delete out.vFlip;
|
|
53
|
+
if (r) out.rotate = r;
|
|
54
|
+
if (h) out.hFlip = true;
|
|
55
|
+
if (v) out.vFlip = true;
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
const alias = set.aliases?.[n];
|
|
59
|
+
if (!alias) return null;
|
|
60
|
+
const { parent, rotate: ar = 0, hFlip: ah = false, vFlip: av = false, ...rest } = alias;
|
|
61
|
+
extra = { ...rest, ...extra };
|
|
62
|
+
rotate += ar;
|
|
63
|
+
hFlip = hFlip !== ah;
|
|
64
|
+
vFlip = vFlip !== av;
|
|
65
|
+
n = parent;
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** { icons: { "mdi:home": {...} }, missing: [names], noSet: [prefixes] } for the given names. */
|
|
71
|
+
export async function buildSubset(names, from = cwd) {
|
|
72
|
+
const require = createRequire(path.join(from, "package.json"));
|
|
73
|
+
const sets = new Map();
|
|
74
|
+
const icons = {};
|
|
75
|
+
const missing = [];
|
|
76
|
+
const noSet = new Set();
|
|
77
|
+
for (const full of [...new Set(names)].sort()) {
|
|
78
|
+
const i = full.indexOf(":");
|
|
79
|
+
const prefix = full.slice(0, i);
|
|
80
|
+
if (i < 1) { missing.push(full); continue; }
|
|
81
|
+
if (!sets.has(prefix)) {
|
|
82
|
+
try {
|
|
83
|
+
sets.set(prefix, JSON.parse(await fs.readFile(require.resolve(`@iconify-json/${prefix}/icons.json`), "utf8")));
|
|
84
|
+
} catch {
|
|
85
|
+
sets.set(prefix, null);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const set = sets.get(prefix);
|
|
89
|
+
if (!set) { noSet.add(prefix); missing.push(full); continue; }
|
|
90
|
+
const icon = resolveIcon(set, full.slice(i + 1));
|
|
91
|
+
if (icon) icons[full] = icon;
|
|
92
|
+
else missing.push(full);
|
|
93
|
+
}
|
|
94
|
+
return { icons, missing, noSet: [...noSet] };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** `omniaui webicons [name...] [--scan <dir>] [--out <file>]` */
|
|
98
|
+
export async function cmdWebicons(names, values) {
|
|
99
|
+
const out = values.out ?? values.to;
|
|
100
|
+
const list = [...names];
|
|
101
|
+
if (values.scan) {
|
|
102
|
+
const skip = new Set(out ? [path.resolve(cwd, out)] : []);
|
|
103
|
+
list.push(...(await scanNames(path.resolve(cwd, values.scan), skip)));
|
|
104
|
+
}
|
|
105
|
+
if (!list.length) throw new Error('name the icons ("mdi:home flag:nl-4x3") or scan the source with --scan src');
|
|
106
|
+
const { icons, missing, noSet } = await buildSubset(list);
|
|
107
|
+
const json = JSON.stringify(icons, null, 1) + "\n";
|
|
108
|
+
if (out && !values["dry-run"]) {
|
|
109
|
+
await fs.mkdir(path.dirname(path.resolve(cwd, out)), { recursive: true });
|
|
110
|
+
await fs.writeFile(path.resolve(cwd, out), json);
|
|
111
|
+
} else if (!out) {
|
|
112
|
+
process.stdout.write(json);
|
|
113
|
+
}
|
|
114
|
+
const log = out ? console.log : console.error;
|
|
115
|
+
if (out) log(`omniaui: ${Object.keys(icons).length} webicons -> ${out} (${(json.length / 1024).toFixed(1)} KB)`);
|
|
116
|
+
for (const p of noSet) log(WEBICON_SETS.includes(p) ? ` set ${p} is not installed: npm i -D @iconify-json/${p}` : ` ${p}: not a webicon set (${WEBICON_SETS.join(", ")})`);
|
|
117
|
+
const unknown = missing.filter((m) => !noSet.includes(m.slice(0, m.indexOf(":"))));
|
|
118
|
+
if (unknown.length) log(` not found: ${unknown.join(", ")}`);
|
|
119
|
+
if (out) log(` React/Vue: import icons from "./${path.basename(out)}"; addWebicons(icons)`);
|
|
120
|
+
}
|
package/bin/omniaui.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// File: packages/ui/bin/omniaui.mjs
|
|
3
3
|
// OmniaUI CLI — copy components and blocks into your project (css | vue | react | blade), list the registry.
|
|
4
|
-
// Map: args -> commands (add | list | copy-js | help | version) -> lib/add.mjs (lib/catalog.mjs, lib/project.mjs),
|
|
4
|
+
// Map: args -> commands (add | list | copy-js | webicons | help | version) -> lib/add.mjs (lib/catalog.mjs, lib/project.mjs),
|
|
5
|
+
// lib/copy-js.mjs, lib/webicons.mjs
|
|
5
6
|
// Author: Serge Cools | Framework: OmniaUI (on OmniaCSS)
|
|
6
7
|
//
|
|
7
8
|
// These commands used to be "omniacss add/list" (moved here in October 2026). The CSS build stays in
|
|
@@ -10,6 +11,7 @@
|
|
|
10
11
|
import { parseArgs } from "node:util";
|
|
11
12
|
import { cmdAdd, cmdList } from "./lib/add.mjs";
|
|
12
13
|
import { cmdCopyJs } from "./lib/copy-js.mjs";
|
|
14
|
+
import { cmdWebicons } from "./lib/webicons.mjs";
|
|
13
15
|
import { readJson } from "./lib/project.mjs";
|
|
14
16
|
|
|
15
17
|
const HELP = `
|
|
@@ -21,6 +23,10 @@ OmniaUI CLI
|
|
|
21
23
|
omniaui list [blocks|components] [-f vue] show what can be added in a flavour
|
|
22
24
|
omniaui copy-js [name...] [--to public/js] copy the scripts (data table, carousel, barcode; Pro: spotlight, ecosystem map,
|
|
23
25
|
infinite carousel, barcode maker …) as oc-<name>.js, which start on their own from a script tag
|
|
26
|
+
omniaui webicons [name...] [--scan src] [--out src/webicons.json]
|
|
27
|
+
a small JSON file with only the webicons you use (mdi:, mdi-light:, material-symbols:,
|
|
28
|
+
svg-spinners:, flag:, vscode-icons:), read from @iconify-json/<set> in node_modules;
|
|
29
|
+
no network. React/Vue: addWebicons(json). Blade: config omniacss.webicons.files
|
|
24
30
|
|
|
25
31
|
Options:
|
|
26
32
|
-f, --framework <fw> css | vue | react | blade (default: "framework" in omnia.config.json, else detected
|
|
@@ -44,6 +50,8 @@ async function main() {
|
|
|
44
50
|
allowPositionals: true,
|
|
45
51
|
options: {
|
|
46
52
|
to: { type: "string" },
|
|
53
|
+
out: { type: "string", short: "o" },
|
|
54
|
+
scan: { type: "string" },
|
|
47
55
|
dir: { type: "string" },
|
|
48
56
|
framework: { type: "string", short: "f" },
|
|
49
57
|
kind: { type: "string", short: "k" },
|
|
@@ -64,6 +72,7 @@ async function main() {
|
|
|
64
72
|
case "add": return cmdAdd(rest, values);
|
|
65
73
|
case "list": return cmdList(rest[0], values);
|
|
66
74
|
case "copy-js": return cmdCopyJs(rest, values);
|
|
75
|
+
case "webicons": return cmdWebicons(rest, values);
|
|
67
76
|
default: console.log(HELP);
|
|
68
77
|
}
|
|
69
78
|
}
|
package/dist/components.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* File: oc-theme.css — generated from tokens/semantic.json by @birdycom/omniacss 0.16.
|
|
1
|
+
/* File: oc-theme.css — generated from tokens/semantic.json by @birdycom/omniacss 0.16.1. Do not edit. */
|
|
2
2
|
/* Semantic theme tokens: every color is light-dark() of an Omnia palette token (oc-colors.css). */
|
|
3
3
|
/* Same source as the desktop export: npx omniacss tokens --format json|dtcg|python */
|
|
4
4
|
:root {
|
|
@@ -6779,6 +6779,7 @@ input.oc-input[type="month"] { inline-size: auto; min-inline-size: 11rem; }
|
|
|
6779
6779
|
.oc-card.oc-card--accent {
|
|
6780
6780
|
--oc-card-tone: var(--oc-primary);
|
|
6781
6781
|
overflow: clip;
|
|
6782
|
+
padding: 0; /* the band runs to the border; the content keeps its own padding (.oc-card-content) */
|
|
6782
6783
|
border: 2px solid var(--oc-card-tone);
|
|
6783
6784
|
box-shadow: none;
|
|
6784
6785
|
}
|
|
@@ -6789,11 +6790,15 @@ input.oc-input[type="month"] { inline-size: auto; min-inline-size: 11rem; }
|
|
|
6789
6790
|
.oc-card--accent[data-tone="destructive"] { --oc-card-tone: var(--oc-destructive); }
|
|
6790
6791
|
.oc-card--accent[data-tone="test"] { --oc-card-tone: var(--oc-mode-test); }
|
|
6791
6792
|
.oc-card--accent[data-tone="live"] { --oc-card-tone: var(--oc-mode-live); }
|
|
6793
|
+
/* A fixed minimum height (--oc-card-band-min-h), so the band of two cards side by side is equally high with or without a
|
|
6794
|
+
status, and does not jump when the status comes or goes. */
|
|
6792
6795
|
.oc-card-band {
|
|
6793
6796
|
display: flex;
|
|
6794
6797
|
flex-wrap: wrap;
|
|
6795
6798
|
align-items: center;
|
|
6799
|
+
align-content: center;
|
|
6796
6800
|
gap: 0.5rem 0.75rem;
|
|
6801
|
+
min-block-size: var(--oc-card-band-min-h, 4.25rem);
|
|
6797
6802
|
padding: 0.75rem 1rem;
|
|
6798
6803
|
background: color-mix(in oklab, var(--oc-card-tone, var(--oc-primary)) 14%, var(--oc-card));
|
|
6799
6804
|
border-block-end: 1px solid color-mix(in oklab, var(--oc-card-tone, var(--oc-primary)) 50%, transparent);
|
|
@@ -11855,10 +11860,11 @@ a.oc-attachment-image:hover > :is(img, .oc-media-art) { filter: brightness(1.05)
|
|
|
11855
11860
|
(a preview; give the box an aria-label or a caption so the preview still has a name). */
|
|
11856
11861
|
.oc-live-frame > [inert] { pointer-events: none; user-select: none; }
|
|
11857
11862
|
|
|
11858
|
-
/* Device: the page in a phone or a
|
|
11859
|
-
the border of a content-box frame, so the page keeps its exact ratio, and overflow: hidden gives the screen
|
|
11860
|
-
inner corners. Phone: 390 x 844 by default in the wrappers, at most --oc-live-phone-max wide.
|
|
11861
|
-
.
|
|
11863
|
+
/* Device: the page in a phone, a television or a laptop: a dark bezel with rounded corners around the scaled page. The
|
|
11864
|
+
bezel is the border of a content-box frame, so the page keeps its exact ratio, and overflow: hidden gives the screen
|
|
11865
|
+
its inner corners. Phone: 390 x 844 by default in the wrappers, at most --oc-live-phone-max wide. Laptop: 1440 x 900
|
|
11866
|
+
by default, see below. Color: --oc-live-bezel. */
|
|
11867
|
+
.oc-live-frame:is(.oc-live-frame--phone, .oc-live-frame--tv, .oc-live-frame--laptop) {
|
|
11862
11868
|
--oc-live-bezel: var(--color-duskblue-90);
|
|
11863
11869
|
box-sizing: content-box;
|
|
11864
11870
|
border: var(--oc-live-bezel-size) solid var(--oc-live-bezel);
|
|
@@ -11876,8 +11882,37 @@ a.oc-attachment-image:hover > :is(img, .oc-media-art) { filter: brightness(1.05)
|
|
|
11876
11882
|
inline-size: calc(100% - 2 * var(--oc-live-bezel-size));
|
|
11877
11883
|
border-radius: 0.625rem;
|
|
11878
11884
|
}
|
|
11885
|
+
/* Laptop: a thin bezel, square inner corners, and a base under the screen that is a little wider than it (with the notch
|
|
11886
|
+
to open the lid). The base is the ::after of the frame, drawn below it, so this frame does not clip (overflow:
|
|
11887
|
+
visible); the page clips itself. The frame leaves room at both sides and under it for the base, so it never overflows
|
|
11888
|
+
its column. Tokens: --oc-live-base (color), --oc-live-base-h (height), --oc-live-base-over (how far it sticks out). */
|
|
11889
|
+
.oc-live-frame--laptop {
|
|
11890
|
+
--oc-live-bezel-size: 0.375rem;
|
|
11891
|
+
--oc-live-base: var(--color-gray-30);
|
|
11892
|
+
--oc-live-base-h: 0.75rem;
|
|
11893
|
+
--oc-live-base-over: 4%;
|
|
11894
|
+
inline-size: calc(100% - 2 * var(--oc-live-bezel-size) - 2 * var(--oc-live-base-over));
|
|
11895
|
+
margin-inline: auto;
|
|
11896
|
+
margin-block-end: var(--oc-live-base-h);
|
|
11897
|
+
overflow: visible;
|
|
11898
|
+
border-radius: var(--oc-live-bezel-size) var(--oc-live-bezel-size) 0 0;
|
|
11899
|
+
}
|
|
11900
|
+
.oc-live-frame--laptop > :is(iframe, video, img, object, .oc-live-frame__content) { overflow: hidden; }
|
|
11901
|
+
.oc-live-frame--laptop::after {
|
|
11902
|
+
content: "";
|
|
11903
|
+
position: absolute;
|
|
11904
|
+
inset-inline: calc(-1 * (var(--oc-live-bezel-size) + var(--oc-live-base-over)));
|
|
11905
|
+
inset-block-start: calc(100% + var(--oc-live-bezel-size));
|
|
11906
|
+
block-size: var(--oc-live-base-h);
|
|
11907
|
+
border-radius: 0 0 50% 50% / 0 0 100% 100%;
|
|
11908
|
+
background:
|
|
11909
|
+
linear-gradient(to right, transparent 42%, oklch(from var(--oc-live-base) calc(l - 0.14) c h) 42% 58%, transparent 58%) top / 100% 40% no-repeat,
|
|
11910
|
+
linear-gradient(oklch(from var(--oc-live-base) calc(l + 0.08) c h), oklch(from var(--oc-live-base) calc(l - 0.12) c h));
|
|
11911
|
+
box-shadow: 0 6px 14px -4px oklch(from var(--color-black-60) l c h / 0.3);
|
|
11912
|
+
}
|
|
11879
11913
|
@media (forced-colors: active) {
|
|
11880
|
-
.oc-live-frame:is(.oc-live-frame--phone, .oc-live-frame--tv) { border-color: CanvasText; }
|
|
11914
|
+
.oc-live-frame:is(.oc-live-frame--phone, .oc-live-frame--tv, .oc-live-frame--laptop) { border-color: CanvasText; }
|
|
11915
|
+
.oc-live-frame--laptop::after { background: CanvasText; }
|
|
11881
11916
|
}
|
|
11882
11917
|
|
|
11883
11918
|
/* parts/media-logo.css */
|
|
@@ -12888,16 +12923,23 @@ a.oc-message__quote:focus-visible { outline: 2px solid var(--oc-ring); outline-o
|
|
|
12888
12923
|
}
|
|
12889
12924
|
.oc-skip-link:focus { translate: none; }
|
|
12890
12925
|
|
|
12891
|
-
/* Inline icon: 1.25em (1.1em in a button), never squeezed in a flex row.
|
|
12926
|
+
/* Inline icon: 1.25em (1.1em in a button), never squeezed in a flex row. Sizes --xs … --xl are fixed (0.875, 1, 1.25,
|
|
12927
|
+
1.5, 2rem). --oc-icon-ratio (width / height, set by Webicon for a 4:3 flag) keeps a wide icon in its own ratio. */
|
|
12892
12928
|
.oc-icon {
|
|
12893
|
-
|
|
12894
|
-
|
|
12929
|
+
--oc-icon-size: 1.25em;
|
|
12930
|
+
inline-size: calc(var(--oc-icon-size) * var(--oc-icon-ratio, 1));
|
|
12931
|
+
block-size: var(--oc-icon-size);
|
|
12895
12932
|
flex-shrink: 0;
|
|
12896
12933
|
}
|
|
12897
|
-
.oc-btn > .oc-icon {
|
|
12898
|
-
|
|
12899
|
-
|
|
12900
|
-
}
|
|
12934
|
+
:where(.oc-btn) > .oc-icon { --oc-icon-size: 1.1em; }
|
|
12935
|
+
.oc-icon--xs { --oc-icon-size: 0.875rem; }
|
|
12936
|
+
.oc-icon--sm { --oc-icon-size: 1rem; }
|
|
12937
|
+
.oc-icon--md { --oc-icon-size: 1.25rem; }
|
|
12938
|
+
.oc-icon--lg { --oc-icon-size: 1.5rem; }
|
|
12939
|
+
.oc-icon--xl { --oc-icon-size: 2rem; }
|
|
12940
|
+
/* A webicon drawn as inline SVG (Webicon / OcWebicon / <x-oc::webicon>: svg[data-webicon]) sits in a line of text like
|
|
12941
|
+
the Iconify element did, also where a reset makes every svg a block. Any component rule still wins (no specificity). */
|
|
12942
|
+
:where(svg[data-webicon]) { display: inline-block; vertical-align: -0.125em; }
|
|
12901
12943
|
|
|
12902
12944
|
/* parts/site-brand-mark.css */
|
|
12903
12945
|
/* File: packages/ui/src/parts/site-brand-mark.css */
|