@threadlabs/looma 0.35.1 → 0.36.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/components/ui-button/ui-button.html +11 -4
- package/components/ui-color-picker/ui-color-picker.html +1 -1
- package/components/ui-combobox/ui-combobox.html +1 -1
- package/components/ui-curve-editor/ui-curve-editor.html +1 -0
- package/components/ui-curve-editor/ui-curve-editor.js +15 -6
- package/components/ui-input/ui-input.html +4 -1
- package/components/ui-light-editor/ui-light-editor.html +143 -19
- package/components/ui-light-editor/ui-light-editor.js +26 -9
- package/components/ui-select/ui-select.html +10 -6
- package/dist/index.js +1 -1
- package/docs/README.md +33 -7
- package/docs/card.js +1 -0
- package/docs/catalog.json +37 -3
- package/docs/customizer-render.mjs +26 -8
- package/docs/customizer.js +122 -18
- package/docs/fonts.mjs +45 -0
- package/docs/index.d.ts +2 -2
- package/docs/palette.mjs +67 -0
- package/docs/site.mjs +1 -1
- package/docs/theme-session.mjs +28 -9
- package/docs/theme.mjs +67 -27
- package/docs/value-editors.mjs +6 -4
- package/package.json +2 -2
- package/styles/ui-button.css +11 -4
- package/styles/ui-color-picker.css +1 -1
- package/styles/ui-combobox.css +2 -2
- package/styles/ui-input.css +4 -1
- package/styles/ui-light-editor.css +111 -16
- package/styles/ui-select.css +10 -6
- package/theme-system.css +14 -2
- package/tokens.css +10 -0
- package/vanilla/UiCurveEditor.d.ts +1 -0
- package/vanilla/UiCurveEditor.js +1 -1
- package/vanilla/UiLightEditor.d.ts +1 -0
- package/vanilla/UiLightEditor.js +2 -2
- package/vue/UiButton.vue +4 -2
- package/vue/UiColorPicker.vue +1 -1
- package/vue/UiCombobox.vue +2 -2
- package/vue/UiCurveEditor.d.ts +6 -0
- package/vue/UiCurveEditor.vue +2 -0
- package/vue/UiInput.vue +4 -1
- package/vue/UiLightEditor.d.ts +8 -0
- package/vue/UiLightEditor.vue +22 -3
- package/vue/UiSelect.vue +1 -1
- package/vue/chunks/UiButton.js +1 -1
- package/vue/chunks/UiColorPicker.js +1 -1
- package/vue/chunks/UiCombobox.js +1 -1
- package/vue/chunks/UiCurveEditor.js +5 -3
- package/vue/chunks/UiInput.js +1 -1
- package/vue/chunks/UiLightEditor.js +16 -6
- package/vue/chunks/UiSelect.js +1 -1
- package/vue/components.css +41 -14
package/docs/fonts.mjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** A focused searchable Google Fonts collection; system fonts never require a request. */
|
|
2
|
+
export const googleFonts = Object.fromEntries([
|
|
3
|
+
['Inter', 'sans-serif'], ['Roboto', 'sans-serif'], ['Open Sans', 'sans-serif'],
|
|
4
|
+
['Source Sans 3', 'sans-serif'], ['Lato', 'sans-serif'], ['Nunito Sans', 'sans-serif'],
|
|
5
|
+
['DM Sans', 'sans-serif'], ['Manrope', 'sans-serif'], ['Work Sans', 'sans-serif'],
|
|
6
|
+
['IBM Plex Sans', 'sans-serif'], ['Public Sans', 'sans-serif'], ['Atkinson Hyperlegible', 'sans-serif'],
|
|
7
|
+
['Outfit', 'sans-serif'], ['Merriweather', 'serif'], ['Lora', 'serif'],
|
|
8
|
+
['Source Serif 4', 'serif'], ['Libre Baskerville', 'serif'], ['Crimson Pro', 'serif'],
|
|
9
|
+
['EB Garamond', 'serif'], ['Playfair Display', 'serif'], ['Roboto Mono', 'monospace'],
|
|
10
|
+
['IBM Plex Mono', 'monospace'], ['JetBrains Mono', 'monospace'], ['Fira Code', 'monospace'],
|
|
11
|
+
].map(([family, category]) => [family, { family, category, weights: ['Lato', 'Atkinson Hyperlegible', 'Libre Baskerville'].includes(family) ? '400;700' : '400;500;600;700' }]));
|
|
12
|
+
|
|
13
|
+
export const systemFont = 'system-ui, sans-serif';
|
|
14
|
+
export const googleFontStack = family => `"${family}", ${googleFonts[family].category}`;
|
|
15
|
+
export function googleFontURL(fonts = {}) {
|
|
16
|
+
const families = [...new Set(Object.values(fonts))].sort();
|
|
17
|
+
if (!families.length) return '';
|
|
18
|
+
return 'https://fonts.googleapis.com/css2?' + families.map(family => {
|
|
19
|
+
if (!Object.hasOwn(googleFonts, family)) throw new Error('Choose a supported Google font.');
|
|
20
|
+
return 'family=' + encodeURIComponent(family).replaceAll('%20', '+') + ':wght@' + googleFonts[family].weights;
|
|
21
|
+
}).join('&') + '&display=swap';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Load and confirm actual faces before reporting a selected font as ready. */
|
|
25
|
+
const fontLoads = new WeakMap();
|
|
26
|
+
export async function loadGoogleFonts(document, fonts) {
|
|
27
|
+
const url = googleFontURL(fonts);
|
|
28
|
+
let link = document.head.querySelector('link[data-looma-google-fonts]');
|
|
29
|
+
if (!url) { fontLoads.get(link)?.cancel(); link?.remove(); return; }
|
|
30
|
+
if (link?.href !== url) {
|
|
31
|
+
fontLoads.get(link)?.cancel(); link?.remove(); link = document.createElement('link');
|
|
32
|
+
link.rel = 'stylesheet'; link.dataset.loomaGoogleFonts = '';
|
|
33
|
+
let cancel;
|
|
34
|
+
const loaded = new Promise((resolve, reject) => {
|
|
35
|
+
cancel = () => resolve(false);
|
|
36
|
+
link.onload = () => resolve(true); link.onerror = () => reject(new Error('The Google font could not load. Check your connection or select the system font.'));
|
|
37
|
+
});
|
|
38
|
+
fontLoads.set(link, { loaded, cancel }); link.href = url; document.head.append(link);
|
|
39
|
+
}
|
|
40
|
+
if (await fontLoads.get(link)?.loaded === false) return;
|
|
41
|
+
for (const family of new Set(Object.values(fonts))) {
|
|
42
|
+
const faces = await document.fonts.load(`400 16px "${family}"`);
|
|
43
|
+
if (!faces.length) throw new Error(`${family} is unavailable; the fallback is currently displayed.`);
|
|
44
|
+
}
|
|
45
|
+
}
|
package/docs/index.d.ts
CHANGED
|
@@ -17,8 +17,8 @@ export interface DocumentationCatalog {
|
|
|
17
17
|
resources?: { tag: string; package: string; resource: string }[]; components: DocumentationComponent[];
|
|
18
18
|
}
|
|
19
19
|
export interface DiscoveryRoot { directory: string; packageName: string; groups?: DocumentationGroup[] }
|
|
20
|
-
export interface ThemeRecipe { schemaVersion: 1; values: Record<string, string>; presets?: Partial<Record<'material' | 'palette', string>> }
|
|
21
|
-
export interface ThemeField { family: string; id: string; label: string; property: string; type: string; defaultValue: string; description: string; min?: number; max?: number }
|
|
20
|
+
export interface ThemeRecipe { schemaVersion: 1; values: Record<string, string>; origin?: string; fonts?: Partial<Record<'body-font' | 'display-font', string>>; presets?: Partial<Record<'material' | 'palette', string>> }
|
|
21
|
+
export interface ThemeField { family: string; id: string; label: string; property: string | null; type: string; defaultValue: string; description: string; min?: number; max?: number; choices?: Record<string, string> }
|
|
22
22
|
export interface DocumentationConfiguration {
|
|
23
23
|
title?: string; base?: string; origin?: string; outDir?: string; content?: string;
|
|
24
24
|
logo?: string | { light: string; dark?: string }; nav?: { label: string; href: string }[];
|
package/docs/palette.mjs
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Perceptual palette operations use Oklab/OKLCH; output remains portable sRGB hex.
|
|
2
|
+
const linear = value => value <= .04045 ? value / 12.92 : ((value + .055) / 1.055) ** 2.4;
|
|
3
|
+
const encoded = value => value <= .0031308 ? value * 12.92 : 1.055 * value ** (1 / 2.4) - .055;
|
|
4
|
+
const clamp = (value, min = 0, max = 1) => Math.max(min, Math.min(max, value));
|
|
5
|
+
export function toLch(hex) {
|
|
6
|
+
const [r, g, b] = [1, 3, 5].map(i => linear(parseInt(hex.slice(i, i + 2), 16) / 255));
|
|
7
|
+
const l = Math.cbrt(.4122214708 * r + .5363325363 * g + .0514459929 * b);
|
|
8
|
+
const m = Math.cbrt(.2119034982 * r + .6806995451 * g + .1073969566 * b);
|
|
9
|
+
const s = Math.cbrt(.0883024619 * r + .2817188376 * g + .6299787005 * b);
|
|
10
|
+
const a = 1.9779984951 * l - 2.428592205 * m + .4505937099 * s;
|
|
11
|
+
const bb = .0259040371 * l + .7827717662 * m - .808675766 * s;
|
|
12
|
+
return [.2104542553 * l + .793617785 * m - .0040720468 * s, Math.hypot(a, bb), (Math.atan2(bb, a) * 180 / Math.PI + 360) % 360];
|
|
13
|
+
}
|
|
14
|
+
const channels = ([lightness, chroma, hue]) => {
|
|
15
|
+
const a = chroma * Math.cos(hue * Math.PI / 180), b = chroma * Math.sin(hue * Math.PI / 180);
|
|
16
|
+
const l = (lightness + .3963377774 * a + .2158037573 * b) ** 3;
|
|
17
|
+
const m = (lightness - .1055613458 * a - .0638541728 * b) ** 3;
|
|
18
|
+
const s = (lightness - .0894841775 * a - 1.291485548 * b) ** 3;
|
|
19
|
+
return [4.0767416621 * l - 3.3077115913 * m + .2309699292 * s, -1.2684380046 * l + 2.6097574011 * m - .3413193965 * s, -.0041960863 * l - .7034186147 * m + 1.707614701 * s];
|
|
20
|
+
};
|
|
21
|
+
export function fromLch([lightness, chroma, hue]) {
|
|
22
|
+
lightness = clamp(lightness); chroma = Math.max(0, chroma);
|
|
23
|
+
let rgb = channels([lightness, chroma, hue]);
|
|
24
|
+
if (rgb.some(n => n < -.000001 || n > 1.000001)) {
|
|
25
|
+
// Reduce chroma at fixed hue/lightness instead of clipping individual channels.
|
|
26
|
+
let low = 0, high = chroma;
|
|
27
|
+
for (let i = 0; i < 18; i++) {
|
|
28
|
+
const middle = (low + high) / 2;
|
|
29
|
+
if (channels([lightness, middle, hue]).every(n => n >= 0 && n <= 1)) low = middle;
|
|
30
|
+
else high = middle;
|
|
31
|
+
}
|
|
32
|
+
rgb = channels([lightness, low, hue]);
|
|
33
|
+
}
|
|
34
|
+
return '#' + rgb.map(n => Math.round(clamp(encoded(n)) * 255).toString(16).padStart(2, '0')).join('');
|
|
35
|
+
}
|
|
36
|
+
export function mixColour(a, b, weight) {
|
|
37
|
+
// Cartesian Oklab mixing avoids a hue discontinuity around 0/360 degrees.
|
|
38
|
+
const cartesian = hex => { const [l, c, h] = toLch(hex); return [l, c * Math.cos(h * Math.PI / 180), c * Math.sin(h * Math.PI / 180)]; };
|
|
39
|
+
const first = cartesian(a), second = cartesian(b), mixed = first.map((n, i) => n * weight + second[i] * (1 - weight));
|
|
40
|
+
return fromLch([mixed[0], Math.hypot(mixed[1], mixed[2]), Math.atan2(mixed[2], mixed[1]) * 180 / Math.PI]);
|
|
41
|
+
}
|
|
42
|
+
export function paletteSeeds(values) {
|
|
43
|
+
const intensity = Number(values['color-intensity']) * 2, warmth = (Number(values.warmth) - .5) * 2;
|
|
44
|
+
const relationship = values['palette-relationship'];
|
|
45
|
+
const brandHue = toLch(values.action)[2];
|
|
46
|
+
return Object.fromEntries(['action', 'canvas', 'surface', 'text'].map(key => {
|
|
47
|
+
if (intensity === 1 && warmth === 0 && relationship === 'preserve') return [key, values[key]];
|
|
48
|
+
let [l, c, h] = toLch(values[key]);
|
|
49
|
+
if (key !== 'action') {
|
|
50
|
+
const tint = Math.max(Math.abs(warmth), relationship === 'preserve' ? 0 : .5);
|
|
51
|
+
if (tint) l = clamp(l, .08 * tint, 1 - .03 * tint);
|
|
52
|
+
if (relationship !== 'preserve') { h = brandHue + (relationship === 'neighboring' ? 30 : 180); c = Math.max(c, .018); }
|
|
53
|
+
if (warmth !== 0) {
|
|
54
|
+
const target = warmth > 0 ? 85 : 255;
|
|
55
|
+
const delta = ((target - h + 540) % 360) - 180;
|
|
56
|
+
h += delta * Math.abs(warmth); c = Math.max(c, .035 * Math.abs(warmth));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return [key, fromLch([l, c * intensity, h])];
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function companionSurface(seed, mode) {
|
|
64
|
+
const [l, c, h] = toLch(seed);
|
|
65
|
+
// Retain hue and restrained colorfulness; convert the tonal role, not the identity.
|
|
66
|
+
return fromLch([mode === 'dark' ? .16 + (1 - l) * .12 : .94 + (1 - l) * .045, Math.min(c, .045), h]);
|
|
67
|
+
}
|
package/docs/site.mjs
CHANGED
|
@@ -86,7 +86,7 @@ export async function prepareDocumentation({ root, config = {}, catalog }) {
|
|
|
86
86
|
await cp(own('catalog-view.js'), path.join(generated, 'catalog-view.js'));
|
|
87
87
|
await cp(own('preview.js'), path.join(generated, 'preview.js'));
|
|
88
88
|
for (const file of ['reference.html', 'reference.js']) await cp(own(file), path.join(generated, file));
|
|
89
|
-
for (const file of ['customizer.js', 'theme.mjs', 'theme-session.mjs', 'value-editors.mjs']) await cp(own(file), path.join(generated, file));
|
|
89
|
+
for (const file of ['customizer.js', 'theme.mjs', 'theme-session.mjs', 'value-editors.mjs', 'palette.mjs', 'fonts.mjs']) await cp(own(file), path.join(generated, file));
|
|
90
90
|
const write = async (file, source) => { await mkdir(path.dirname(file), { recursive: true }); await writeFile(file, source); };
|
|
91
91
|
const examples = [];
|
|
92
92
|
// HTMLKit route groups retain their labels/order in navigation without changing public URLs.
|
package/docs/theme-session.mjs
CHANGED
|
@@ -4,10 +4,11 @@ const identity = Symbol.for('looma.documentation.theme');
|
|
|
4
4
|
export const themeEvent = 'looma-documentation-theme';
|
|
5
5
|
|
|
6
6
|
/** Browser choices belong to one documentation base; repository writes stay explicit. */
|
|
7
|
-
export function createThemeSession(view, { base, baseline, systemCSS }) {
|
|
7
|
+
export function createThemeSession(view, { base, baseline, systemCSS, historyLimit = 100 }) {
|
|
8
8
|
const key = `looma:documentation-theme:v1:${base}`;
|
|
9
9
|
let original = validateRecipe(baseline);
|
|
10
|
-
let selected;
|
|
10
|
+
let selected, draft, comparison;
|
|
11
|
+
const past = [], future = [];
|
|
11
12
|
let portableCSS = '';
|
|
12
13
|
let storageAvailable = true;
|
|
13
14
|
const style = view.document.createElement('style');
|
|
@@ -16,29 +17,47 @@ export function createThemeSession(view, { base, baseline, systemCSS }) {
|
|
|
16
17
|
const read = value => { try { return value ? validateRecipe(JSON.parse(value)) : undefined; } catch { return undefined; } };
|
|
17
18
|
try { selected = read(view.localStorage.getItem(key)); } catch { storageAvailable = false; }
|
|
18
19
|
const paint = () => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
const displayed = comparison ?? draft ?? selected;
|
|
21
|
+
portableCSS = displayed ? themeCSS(displayed, systemCSS) : '';
|
|
22
|
+
view.document.documentElement.toggleAttribute('data-looma-documentation-theme', Boolean(displayed));
|
|
23
|
+
style.textContent = displayed ? themeCSS(displayed, systemCSS, { scope: 'documentation' }) : '';
|
|
22
24
|
view.dispatchEvent(new view.CustomEvent(themeEvent, { detail: { css: portableCSS } }));
|
|
23
25
|
};
|
|
24
26
|
const persist = () => {
|
|
25
27
|
try { if (selected) view.localStorage.setItem(key, JSON.stringify(selected)); else view.localStorage.removeItem(key); storageAvailable = true; } catch { storageAvailable = false; }
|
|
26
28
|
paint();
|
|
27
29
|
};
|
|
30
|
+
const remember = () => {
|
|
31
|
+
past.push(structuredClone(selected));
|
|
32
|
+
if (past.length > historyLimit) past.shift();
|
|
33
|
+
future.length = 0;
|
|
34
|
+
};
|
|
28
35
|
const session = {
|
|
29
|
-
get recipe() { return structuredClone(selected ?? original); },
|
|
36
|
+
get recipe() { return structuredClone(draft ?? selected ?? original); },
|
|
30
37
|
get hasOverride() { return selected !== undefined; },
|
|
31
38
|
get storageAvailable() { return storageAvailable; },
|
|
32
39
|
get css() { return portableCSS; },
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
get canUndo() { return past.length > 0; },
|
|
41
|
+
get canRedo() { return future.length > 0; },
|
|
42
|
+
preview(recipe) { draft = validateRecipe(recipe); paint(); },
|
|
43
|
+
commit() { if (draft) session.apply(draft); },
|
|
44
|
+
cancel() { draft = undefined; paint(); },
|
|
45
|
+
compare(recipe) { comparison = recipe === undefined ? undefined : validateRecipe(recipe); paint(); },
|
|
46
|
+
undo() { if (!past.length) return; future.push(structuredClone(selected)); selected = past.pop(); draft = comparison = undefined; persist(); },
|
|
47
|
+
redo() { if (!future.length) return; past.push(structuredClone(selected)); selected = future.pop(); draft = comparison = undefined; persist(); },
|
|
48
|
+
apply(recipe) {
|
|
49
|
+
const next = validateRecipe(recipe);
|
|
50
|
+
if (JSON.stringify(next) !== JSON.stringify(selected)) remember();
|
|
51
|
+
selected = next; draft = comparison = undefined; persist();
|
|
52
|
+
},
|
|
53
|
+
reset() { if (selected !== undefined) remember(); selected = draft = comparison = undefined; persist(); return structuredClone(original); },
|
|
35
54
|
baseline(recipe) { original = validateRecipe(recipe); },
|
|
36
55
|
};
|
|
37
56
|
view.addEventListener('storage', event => {
|
|
38
57
|
if (event.key !== key && event.key !== null) return;
|
|
39
58
|
const next = read(event.newValue);
|
|
40
59
|
if (event.newValue !== null && !next) return;
|
|
41
|
-
selected = next; paint();
|
|
60
|
+
selected = next; draft = comparison = undefined; past.length = future.length = 0; paint();
|
|
42
61
|
});
|
|
43
62
|
paint();
|
|
44
63
|
return session;
|
package/docs/theme.mjs
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { googleFonts, googleFontStack, googleFontURL } from './fonts.mjs';
|
|
2
|
+
import { mixColour as mix, paletteSeeds, companionSurface, toLch, fromLch } from './palette.mjs';
|
|
3
|
+
|
|
1
4
|
const bounds = {
|
|
2
|
-
'text-size': [14, 24], 'control-
|
|
3
|
-
'line-weight': [.5, 3],
|
|
5
|
+
'text-size': [14, 24], 'control-roominess': [2, 4], 'corner-roundness': [0, 32],
|
|
6
|
+
'line-weight': [.5, 3], spacing: [.75, 1.5], 'scale-contrast': [1, 1.5],
|
|
4
7
|
'space-curve': [.5, 2], 'text-weight': [400, 700], 'outer-depth': [0, 2], 'inner-depth': [0, 2],
|
|
5
8
|
'response-time': [0, 600],
|
|
6
9
|
};
|
|
@@ -11,13 +14,16 @@ export const themeFields = [
|
|
|
11
14
|
['Colour', 'canvas', 'Canvas', '--ui-surface', 'colour', '#f6f6f8', 'The ground behind surfaces.'],
|
|
12
15
|
['Colour', 'surface', 'Surface', '--ui-surface-raised', 'colour', '#ffffff', 'Fields, cards and floating surfaces.'],
|
|
13
16
|
['Colour', 'text', 'Text', '--ui-text', 'colour', '#1a1a1a', 'Readable content; supporting text follows this and Surface.'],
|
|
17
|
+
['Colour', 'warmth', 'Surface warmth', null, 'fraction', '0.5', '0% cool, 50% original, 100% warm paper and ink; your brand hue stays independent.'],
|
|
18
|
+
['Colour', 'color-intensity', 'Color intensity', null, 'fraction', '0.5', '0% quiet, 50% original, 100% vivid, coordinated across surfaces, actions and status colors.'],
|
|
19
|
+
['Colour', 'palette-relationship', 'Palette relationship', null, 'choice', 'preserve', 'Keep seed hues, or relate quiet surfaces to the brand through neighboring or complementary hues.'],
|
|
14
20
|
['Type', 'body-font', 'Body font', '--ui-font-sans', 'font', 'system-ui, sans-serif', 'The shared interface typeface.'],
|
|
15
21
|
['Type', 'display-font', 'Display font', '--ui-font-display', 'font', 'system-ui, sans-serif', 'The heading typeface.'],
|
|
16
|
-
['Type', 'text-size', 'Text size', '--ui-font-size', 'positive-length', '
|
|
22
|
+
['Type', 'text-size', 'Text size', '--ui-font-size', 'positive-length', '1rem', 'Base type and choice-mark size. Accepts native CSS lengths, such as 1rem.'],
|
|
17
23
|
['Type', 'text-weight', 'Emphasis weight', '--ui-font-medium', 'weight', '500', 'Control-label emphasis; body and headings keep their roles.'],
|
|
18
|
-
['Size & spacing', 'control-
|
|
19
|
-
['Size & spacing', '
|
|
20
|
-
['Size & spacing', 'scale-contrast', 'Size ratio', '--ui-scale-ratio', 'ratio', '1.2', 'The multiplier between small, medium and large controls.'],
|
|
24
|
+
['Size & spacing', 'control-roominess', 'Control roominess', '--ui-control-roominess', 'positive', '2.5', 'Shared control height as a multiple of base text size; buttons, fields and swatches stay aligned.'],
|
|
25
|
+
['Size & spacing', 'spacing', 'Spacing', '--ui-spacing', 'positive', '1', 'More or less breathing room throughout the interface.'],
|
|
26
|
+
['Size & spacing', 'scale-contrast', 'Size ratio', '--ui-scale-ratio', 'ratio', '1.2', 'The multiplier between small, medium and large controls. At 1 the sizes are equal; higher values separate them.'],
|
|
21
27
|
['Size & spacing', 'space-curve', 'Spacing curve', '--ui-space-curve', 'nonnegative', '1', 'Spacing growth: 1 is linear, 2 is quadratic. Independent of control sizes.'],
|
|
22
28
|
['Size & spacing', 'corner-roundness', 'Corner roundness', '--ui-radius-md', 'length', '8px', 'One corner family across controls and surfaces.'],
|
|
23
29
|
['Size & spacing', 'line-weight', 'Line weight', '--ui-border-width', 'length', '1px', 'Shared edge weight; focus stays independently visible.'],
|
|
@@ -35,20 +41,20 @@ export const themeFields = [
|
|
|
35
41
|
['Material', 'light-strength', 'Light strength', '--ui-light-strength', 'fraction', '0.65', 'Shared illumination; each material and component role determines its response.'],
|
|
36
42
|
['Motion', 'response-time', 'Response time', '--ui-motion-fast', 'time', '120ms', 'Shared feedback pace; floating transitions take proportionally longer.'],
|
|
37
43
|
['Motion', 'response-curve', 'Response curve', '--ui-motion-ease', 'easing', 'cubic-bezier(0.2,0,0.2,1)', 'How movement accelerates and settles.'],
|
|
38
|
-
].map(([family, id, label, property, type, defaultValue, description]) => Object.freeze({ family, id, label, property, type, defaultValue, description, ...(bounds[id] ? { min: bounds[id][0], max: bounds[id][1] } : type === 'fraction' ? { min: 0, max: 1 } : {}) }));
|
|
44
|
+
].map(([family, id, label, property, type, defaultValue, description]) => Object.freeze({ family, id, label, property, type, defaultValue, description, ...(type === 'choice' ? { choices: { preserve: 'Preserve seed hues', neighboring: 'Neighboring hues', complementary: 'Complementary hues' } } : {}), ...(bounds[id] ? { min: bounds[id][0], max: bounds[id][1] } : type === 'fraction' ? { min: 0, max: 1 } : {}) }));
|
|
39
45
|
|
|
40
46
|
export const defaultRecipe = () => ({ schemaVersion: 1, values: Object.fromEntries(themeFields.map(field => [field.id, field.defaultValue])) });
|
|
41
47
|
const starting = values => ({ schemaVersion: 1, values: { ...defaultRecipe().values, ...values } });
|
|
42
48
|
export const startingPoints = {
|
|
43
49
|
clear: defaultRecipe(),
|
|
44
|
-
bookish: starting({ action: '#2e1228', canvas: '#f7f7f5', surface: '#fffefd', text: '#0d0c0c', 'body-font': 'Arial, sans-serif', 'display-font': 'Georgia, serif', 'text-weight': '400', 'control-
|
|
45
|
-
wiki: starting({ action: '#4f46e5', canvas: '#ffffff', surface: '#ffffff', text: '#1a1a1a', 'control-
|
|
50
|
+
bookish: starting({ action: '#2e1228', canvas: '#f7f7f5', surface: '#fffefd', text: '#0d0c0c', 'body-font': 'Arial, sans-serif', 'display-font': 'Georgia, serif', 'text-weight': '400', 'control-roominess': '2.625', 'scale-contrast': '1.18', 'outer-depth': '1', 'inner-depth': '1', glassiness: '0.8', 'surface-separation': '0.65', translucency: '0.18', 'edge-light': '1', finish: '0.85', glow: '0.3', 'light-spread': '0.3', 'light-strength': '0.9', 'response-time': '150ms', 'response-curve': 'ease' }),
|
|
51
|
+
wiki: starting({ action: '#4f46e5', canvas: '#ffffff', surface: '#ffffff', text: '#1a1a1a', 'control-roominess': '2.125', spacing: '0.85', 'scale-contrast': '1.15', 'corner-roundness': '6px', 'outer-depth': '0.35', 'inner-depth': '0', 'response-time': '110ms' }),
|
|
46
52
|
editorial: starting({ action: '#182c24', canvas: '#eee9dc', surface: '#fffdf5', text: '#182c24', 'corner-roundness': '0px', 'outer-depth': '0', 'inner-depth': '0', 'body-font': 'Georgia, serif', 'display-font': 'Georgia, serif', 'text-weight': '400', 'line-weight': '2px', 'response-time': '90ms', 'response-curve': 'linear' }),
|
|
47
53
|
night: starting({ action: '#a7b8ff', canvas: '#11141c', surface: '#202634', text: '#edf1fb', 'corner-roundness': '12px', 'outer-depth': '1.4', 'inner-depth': '0.45', translucency: '0.2', 'edge-light': '0.65', 'response-time': '210ms', 'response-curve': 'cubic-bezier(0.2,0.8,0.2,1)' }),
|
|
48
|
-
garden: starting({ action: '#256342', canvas: '#eef5e7', surface: '#fcfff6', text: '#173121', 'corner-roundness': '22px', 'outer-depth': '0.35', 'inner-depth': '0', 'edge-light': '0.2', 'control-
|
|
54
|
+
garden: starting({ action: '#256342', canvas: '#eef5e7', surface: '#fcfff6', text: '#173121', 'corner-roundness': '22px', 'outer-depth': '0.35', 'inner-depth': '0', 'edge-light': '0.2', 'control-roominess': '2.875', 'scale-contrast': '1.24', spacing: '1.05', 'response-time': '180ms', 'response-curve': 'cubic-bezier(0.16,1,0.3,1)' }),
|
|
49
55
|
};
|
|
50
56
|
export const startingPointLabels = { clear: 'Clear', bookish: 'Bookish', wiki: 'Wiki', editorial: 'Editorial', night: 'Night', garden: 'Garden' };
|
|
51
|
-
const paletteKeys =
|
|
57
|
+
const paletteKeys = themeFields.filter(field => field.family === 'Colour').map(field => field.id);
|
|
52
58
|
// Palette choices move only the shared color seeds; size, material and motion stay independent.
|
|
53
59
|
export const themePalettes = Object.fromEntries([
|
|
54
60
|
['clear', 'Indigo & mist'], ['bookish', 'Plum & paper'], ['wiki', 'Indigo & chalk'],
|
|
@@ -88,6 +94,24 @@ export function paletteFor(input) {
|
|
|
88
94
|
return Object.entries(themePalettes).find(([, palette]) => paletteKeys.every(key => values[key].toLowerCase() === palette.values[key].toLowerCase()))?.[0] ?? 'custom';
|
|
89
95
|
}
|
|
90
96
|
|
|
97
|
+
export const themeVariations = { warmer: 'Warmer', quieter: 'Quieter', expressive: 'More expressive', compact: 'More compact' };
|
|
98
|
+
/** Nearby choices reuse the same bounded semantics; locks protect whole decision families. */
|
|
99
|
+
export function nearbyVariation(input, kind, locks = []) {
|
|
100
|
+
const recipe = validateRecipe(input);
|
|
101
|
+
if (!Object.hasOwn(themeVariations, kind)) throw new Error('Unknown theme variation.');
|
|
102
|
+
const deltas = {
|
|
103
|
+
warmer: { warmth: .15 }, quieter: { 'color-intensity': -.12, glow: -.1, 'outer-depth': -.15 },
|
|
104
|
+
expressive: { finish: .15, 'edge-light': .15, glow: .1 }, compact: { 'control-roominess': -.15, spacing: -.1 },
|
|
105
|
+
}[kind];
|
|
106
|
+
const values = { ...recipe.values };
|
|
107
|
+
for (const [id, delta] of Object.entries(deltas)) {
|
|
108
|
+
const field = themeFields.find(item => item.id === id);
|
|
109
|
+
const family = field.family === 'Colour' ? 'palette' : field.family === 'Material' ? 'material' : 'type';
|
|
110
|
+
if (!locks.includes(family)) values[id] = String(Number(Math.max(field.min, Math.min(field.max, Number(values[id]) + delta)).toFixed(3)));
|
|
111
|
+
}
|
|
112
|
+
return validateRecipe({ ...recipe, values });
|
|
113
|
+
}
|
|
114
|
+
|
|
91
115
|
const scalar = /^[+]?(?:\d+(?:\.\d*)?|\.\d+)$/;
|
|
92
116
|
const length = /^(?:0|[+]?(?:\d+(?:\.\d*)?|\.\d+)(?:px|rem|em|ex|ch|cap|ic|lh|rlh|vw|vh|vi|vb|vmin|vmax|svw|svh|lvw|lvh|dvw|dvh|cm|mm|Q|in|pt|pc))$/;
|
|
93
117
|
const font = /^(?:"[^"\\;{}<>@\x00-\x1f]+"|'[^'\\;{}<>@\x00-\x1f]+'|[\p{L}_-][\p{L}\p{N}_ -]*)(?:\s*,\s*(?:"[^"\\;{}<>@\x00-\x1f]+"|'[^'\\;{}<>@\x00-\x1f]+'|[\p{L}_-][\p{L}\p{N}_ -]*))*$/u;
|
|
@@ -122,6 +146,7 @@ export function validateRecipe(input) {
|
|
|
122
146
|
const value = values[field.id];
|
|
123
147
|
let valid = typeof value === 'string' && value.length > 0;
|
|
124
148
|
if (valid) switch (field.type) {
|
|
149
|
+
case 'choice': valid = Object.hasOwn(field.choices, value); break;
|
|
125
150
|
case 'colour': valid = /^#[\da-f]{6}$/i.test(value); break;
|
|
126
151
|
case 'font': valid = font.test(value); break;
|
|
127
152
|
case 'length': valid = length.test(value) && Number.isFinite(parseFloat(value)); break;
|
|
@@ -143,7 +168,9 @@ export function validateRecipe(input) {
|
|
|
143
168
|
}
|
|
144
169
|
}
|
|
145
170
|
if (input.presets !== undefined && (!input.presets || typeof input.presets !== 'object' || Array.isArray(input.presets) || Object.entries(input.presets).some(([family, id]) => !Object.hasOwn(refinementPresets(family) ?? {}, id)))) throw new Error('Unknown refinement preset.');
|
|
146
|
-
|
|
171
|
+
if (input.fonts !== undefined && (!input.fonts || typeof input.fonts !== 'object' || Array.isArray(input.fonts) || Object.entries(input.fonts).some(([key, family]) => !['body-font', 'display-font'].includes(key) || !Object.hasOwn(googleFonts, family) || values[key] !== googleFontStack(family)))) throw new Error('Choose a Google font with its matching font stack.');
|
|
172
|
+
if (input.origin !== undefined && !Object.hasOwn(startingPoints, input.origin)) throw new Error('Unknown theme origin.');
|
|
173
|
+
return { schemaVersion: 1, values, ...(input.fonts === undefined ? {} : { fonts: { ...input.fonts } }), ...(input.origin === undefined ? {} : { origin: input.origin }), ...(input.presets === undefined ? {} : { presets: { ...input.presets } }) };
|
|
147
174
|
}
|
|
148
175
|
|
|
149
176
|
/** Match presets by their complete semantic recipe, including locally saved themes. */
|
|
@@ -153,7 +180,6 @@ export function startingPointFor(input) {
|
|
|
153
180
|
}
|
|
154
181
|
|
|
155
182
|
const rgb = hex => [1, 3, 5].map(i => parseInt(hex.slice(i, i + 2), 16));
|
|
156
|
-
const mix = (a, b, weight) => '#' + rgb(a).map((n, i) => Math.round(n * weight + rgb(b)[i] * (1 - weight)).toString(16).padStart(2, '0')).join('');
|
|
157
183
|
const luminance = hex => rgb(hex).map(n => { const s = n / 255; return s <= .04045 ? s / 12.92 : ((s + .055) / 1.055) ** 2.4; }).reduce((sum, n, i) => sum + n * [.2126, .7152, .0722][i], 0);
|
|
158
184
|
const contrast = (a, b) => (Math.max(luminance(a), luminance(b)) + .05) / (Math.min(luminance(a), luminance(b)) + .05);
|
|
159
185
|
// The brightest reflection stop is itself readable. Interpolating it over a readable
|
|
@@ -177,29 +203,38 @@ function readableColour(seed, surfaces, minimum, endpoint) {
|
|
|
177
203
|
}
|
|
178
204
|
|
|
179
205
|
/** Resolve editable colour seeds into a coordinated set of readable semantic roles. */
|
|
206
|
+
const paletteCache = new Map();
|
|
180
207
|
export function deriveTheme(input, { mode } = {}) {
|
|
181
208
|
if (mode !== undefined && !['light', 'dark'].includes(mode)) throw new Error('Unknown theme color mode.');
|
|
182
209
|
const { values } = validateRecipe(input);
|
|
183
|
-
const tokens = Object.fromEntries(themeFields.map(field => [field.property, values[field.id]]));
|
|
210
|
+
const tokens = Object.fromEntries(themeFields.filter(field => field.property).map(field => [field.property, values[field.id]]));
|
|
184
211
|
for (const field of themeFields.filter(field => field.type.includes('length') && Object.hasOwn(bounds, field.id))) {
|
|
185
212
|
if (boundedNumber(field, values[field.id]) === undefined) {
|
|
186
|
-
const [min, max] = bounds[field.id]; tokens[field.property] = `clamp(${min}
|
|
213
|
+
const [min, max] = bounds[field.id]; tokens[field.property] = `clamp(${min / 16}rem, ${values[field.id]}, ${max / 16}rem)`;
|
|
187
214
|
}
|
|
188
215
|
}
|
|
216
|
+
const cacheKey = JSON.stringify([mode, ...paletteKeys.map(key => values[key])]);
|
|
217
|
+
if (paletteCache.has(cacheKey)) {
|
|
218
|
+
const cached = paletteCache.get(cacheKey);
|
|
219
|
+
return { tokens: { ...tokens, ...cached.tokens }, adjustments: cached.adjustments.map(item => ({ ...item })) };
|
|
220
|
+
}
|
|
221
|
+
const geometry = new Set(Object.keys(tokens));
|
|
222
|
+
const seeds = paletteSeeds(values);
|
|
189
223
|
const adjustments = [];
|
|
190
|
-
const nativeInk = foreground(
|
|
224
|
+
const nativeInk = foreground(seeds.canvas, '#ffffff', '#000000');
|
|
191
225
|
const ink = mode === 'light' ? '#000000' : mode === 'dark' ? '#ffffff' : nativeInk;
|
|
192
226
|
const paper = ink === '#000000' ? '#ffffff' : '#000000';
|
|
193
227
|
// Preserve the requested palette in its native mode. The companion keeps a restrained
|
|
194
228
|
// tint of the same surface seeds; contrast resolution below governs all usable roles.
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
tokens['--ui-surface'] = surface(
|
|
198
|
-
tokens['--ui-surface-raised'] = surface(values.surface);
|
|
229
|
+
const surface = seed => readableColour(nativeInk === ink ? seed : companionSurface(seed, mode ?? (ink === '#000000' ? 'light' : 'dark')), [ink], 7, paper);
|
|
230
|
+
tokens['--ui-surface'] = surface(seeds.canvas);
|
|
231
|
+
tokens['--ui-surface-raised'] = surface(seeds.surface);
|
|
199
232
|
tokens['--ui-surface-sunken'] = surface(mix(tokens['--ui-surface-raised'], tokens['--ui-surface'], .92));
|
|
200
233
|
const surfaces = ['--ui-surface', '--ui-surface-raised', '--ui-surface-sunken'].map(name => tokens[name]);
|
|
201
|
-
const tones = { accent:
|
|
202
|
-
for (const [tone,
|
|
234
|
+
const tones = { accent: seeds.action, danger: '#c92d1e', success: '#007a33', warning: '#ba5b0b', info: '#0066cc' };
|
|
235
|
+
for (const [tone, original] of Object.entries(tones)) {
|
|
236
|
+
const [l, c, h] = toLch(original);
|
|
237
|
+
const seed = tone === 'accent' ? original : fromLch([l, c * (.6 + Number(values['color-intensity']) * .8), h]);
|
|
203
238
|
const fill = readableColour(seed, surfaces, 5, ink);
|
|
204
239
|
tokens[`--ui-${tone}`] = fill;
|
|
205
240
|
tokens[`--ui-on-${tone}`] = foreground(fill, '#ffffff', '#000000');
|
|
@@ -214,7 +249,7 @@ export function deriveTheme(input, { mode } = {}) {
|
|
|
214
249
|
for (const tone of Object.keys(tones)) {
|
|
215
250
|
tokens[`--ui-${tone}-subtle-text`] = readableColour(tokens[`--ui-${tone}`], readingSurfaces, 4.5, ink);
|
|
216
251
|
}
|
|
217
|
-
const textSeed = nativeInk === ink ?
|
|
252
|
+
const textSeed = nativeInk === ink ? seeds.text : mix(seeds.text, ink, .08);
|
|
218
253
|
tokens['--ui-text'] = readableColour(textSeed, readingSurfaces, 4.5, ink);
|
|
219
254
|
tokens['--ui-text-secondary'] = readableColour(mix(tokens['--ui-text'], tokens['--ui-surface-raised'], .72), readingSurfaces, 4.5, ink);
|
|
220
255
|
tokens['--ui-text-muted'] = tokens['--ui-text-secondary'];
|
|
@@ -232,16 +267,19 @@ export function deriveTheme(input, { mode } = {}) {
|
|
|
232
267
|
tokens['--ui-control-border'] = readableColour(mix(tokens['--ui-text'], tokens['--ui-surface-raised'], .43), readingSurfaces, 3, ink);
|
|
233
268
|
tokens['--ui-control-border-hover'] = tokens['--ui-control-border'];
|
|
234
269
|
tokens['--ui-border-strong'] = tokens['--ui-control-border'];
|
|
235
|
-
tokens['--ui-disabled-text'] = tokens['--ui-text-
|
|
270
|
+
tokens['--ui-disabled-text'] = mix(tokens['--ui-text'], tokens['--ui-surface-raised'], .45);
|
|
236
271
|
tokens['--ui-disabled-surface'] = tokens['--ui-surface-sunken'];
|
|
237
|
-
tokens['--ui-disabled-border'] = tokens['--ui-
|
|
272
|
+
tokens['--ui-disabled-border'] = mix(tokens['--ui-text'], tokens['--ui-surface-raised'], .2);
|
|
238
273
|
tokens['--ui-focus-ring'] = readableColour(tokens['--ui-accent'], readingSurfaces, 3, ink);
|
|
239
274
|
tokens['--ui-focus-width'] = 'max(2px, calc(var(--ui-border-width) * 2))';
|
|
240
275
|
tokens['color-scheme'] = ink === '#000000' ? 'light' : 'dark';
|
|
241
276
|
for (const [id, property] of [['action', '--ui-accent'], ['canvas', '--ui-surface'], ['surface', '--ui-surface-raised'], ['text', '--ui-text']]) {
|
|
242
277
|
if (tokens[property].toLowerCase() !== values[id].toLowerCase()) adjustments.push({ id, requested: values[id], resolved: tokens[property], reason: 'Adjusted to keep the shared palette readable.' });
|
|
243
278
|
}
|
|
244
|
-
|
|
279
|
+
const colors = Object.fromEntries(Object.entries(tokens).filter(([key]) => !geometry.has(key) || /^#[\da-f]{6}$/i.test(tokens[key])));
|
|
280
|
+
paletteCache.set(cacheKey, { tokens: colors, adjustments });
|
|
281
|
+
if (paletteCache.size > 16) paletteCache.delete(paletteCache.keys().next().value);
|
|
282
|
+
return { tokens, adjustments: adjustments.map(item => ({ ...item })) };
|
|
245
283
|
}
|
|
246
284
|
|
|
247
285
|
/** Shared public seeds; combine with theme-system.css for a standalone exported theme. */
|
|
@@ -251,6 +289,8 @@ export function themeCSS(input, systemCSS = '', { scope = 'portable' } = {}) {
|
|
|
251
289
|
const selector = scope === 'documentation'
|
|
252
290
|
? ':root[data-looma-documentation-theme], :root[data-looma-documentation-theme] [data-theme], :root[data-looma-documentation-theme] [data-contrast]'
|
|
253
291
|
: ':root, [data-theme], [data-contrast]';
|
|
292
|
+
const fontURL = googleFontURL(validateRecipe(input).fonts);
|
|
293
|
+
const imports = fontURL ? `@import url("${fontURL}");\n` : '';
|
|
254
294
|
const light = deriveTheme(input, { mode: 'light' }).tokens;
|
|
255
295
|
const dark = deriveTheme(input, { mode: 'dark' }).tokens;
|
|
256
296
|
const palette = [], geometry = [];
|
|
@@ -269,5 +309,5 @@ export function themeCSS(input, systemCSS = '', { scope = 'portable' } = {}) {
|
|
|
269
309
|
// Resolve colors at their point of use, so a nearer mode boundary wins independently
|
|
270
310
|
// of the selector specificity needed to restore an early documentation theme.
|
|
271
311
|
// Keep the first comment stable: the local writer recognizes its generated files by this marker.
|
|
272
|
-
return `/* Looma shared semantic theme. */\n/* Always includes light and dark.\n Set data-theme="light" or "dark" on any element to fix that subtree's mode.\n Leave the root attribute unset to follow the system; a switch can set/remove it. */\n${systemCSS}\n${geometrySelector} {\n${geometry.join('\n')}\n}\n${selector} {\n${palette.join('\n')}\n}\n${chevrons}\n:root:not([data-theme]) { color-scheme: light dark; }\n[data-theme="light"] { color-scheme: light; }\n[data-theme="dark"] { color-scheme: dark; }\n@media (prefers-reduced-motion: reduce) {\n ${selector} { --ui-motion-fast: 0ms; --ui-motion-base: 0ms; --ui-motion-press: 0ms; --ui-press-scale: 1; }\n}\n@media (prefers-reduced-transparency: reduce), (forced-colors: active) {\n ${selector} { --ui-finish: 0; --ui-glow: 0; }\n}\n`;
|
|
312
|
+
return `/* Looma shared semantic theme. */\n/* Always includes light and dark.\n Set data-theme="light" or "dark" on any element to fix that subtree's mode.\n Leave the root attribute unset to follow the system; a switch can set/remove it. */\n${imports}${systemCSS}\n${geometrySelector} {\n${geometry.join('\n')}\n}\n${selector} {\n${palette.join('\n')}\n}\n${chevrons}\n:root:not([data-theme]) { color-scheme: light dark; }\n[data-theme="light"] { color-scheme: light; }\n[data-theme="dark"] { color-scheme: dark; }\n@media (prefers-reduced-motion: reduce) {\n ${selector} { --ui-motion-fast: 0ms; --ui-motion-base: 0ms; --ui-motion-press: 0ms; --ui-press-scale: 1; }\n}\n@media (prefers-reduced-transparency: reduce), (forced-colors: active) {\n ${selector} { --ui-finish: 0; --ui-glow: 0; }\n}\n`;
|
|
273
313
|
}
|
package/docs/value-editors.mjs
CHANGED
|
@@ -3,26 +3,28 @@ const lengthUnits = { px: 1, rem: 16, em: 16, cm: 96 / 2.54, mm: 96 / 25.4, Q: 9
|
|
|
3
3
|
const timeUnits = { ms: 1, s: 1000 };
|
|
4
4
|
const rounded = value => String(Number(Number(value).toFixed(6)));
|
|
5
5
|
|
|
6
|
-
export function valueEditor(field, value
|
|
6
|
+
export function valueEditor(field, value) {
|
|
7
|
+
if (field.type === 'choice') return { kind: 'choice', value };
|
|
7
8
|
if (field.type === 'easing') return { kind: /^step-/.test(value) ? 'text' : 'curve', value };
|
|
8
9
|
if (['colour', 'font'].includes(field.type)) return { kind: 'text', value };
|
|
9
10
|
if (field.type.includes('length') || field.type === 'time') {
|
|
10
11
|
const unit = value.match(/[a-z]+$/i)?.[0] ?? 'px';
|
|
11
|
-
|
|
12
|
+
// Relative limits stay root-scaled when the user enlarges their default font.
|
|
13
|
+
const units = field.type === 'time' ? timeUnits : lengthUnits;
|
|
12
14
|
const factor = units[unit];
|
|
13
15
|
return { kind: 'number', value: value === '0' ? '0px' : value, unit,
|
|
14
16
|
min: factor ? field.min / factor : .001, max: factor ? field.max / factor : 1000000,
|
|
15
17
|
step: (field.type === 'time' ? 10 : field.id === 'line-weight' ? .25 : 1) / (factor ?? 1),
|
|
16
18
|
units: field.type === 'time' ? ['ms', 's'] : ['px', 'rem'], convertible: Boolean(factor) };
|
|
17
19
|
}
|
|
18
|
-
const scale = field.type === 'fraction' || field.id === '
|
|
20
|
+
const scale = field.type === 'fraction' || field.id === 'spacing' ? 100 : 1;
|
|
19
21
|
return { kind: field.type === 'weight' ? 'number' : 'slider', value: field.type === 'weight' ? value : Number(value) * scale,
|
|
20
22
|
min: field.min * scale, max: field.max * scale, step: field.type === 'weight' ? 50 : scale === 100 ? 1 : .01,
|
|
21
23
|
unit: scale === 100 ? '%' : '', scale };
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
export function editorValue(field, value) {
|
|
25
|
-
return field.type === 'fraction' || field.id === '
|
|
27
|
+
return field.type === 'fraction' || field.id === 'spacing' ? rounded(Number(value) / 100) : String(value);
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
export function convertValueUnit(value, nextUnit, { remPixels = 16 } = {}) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@threadlabs/looma",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Looma components as HTML, Vue, and plain DOM, with design tokens.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
"@tiptap/pm": ">=2 <3",
|
|
128
128
|
"@tiptap/vue-3": ">=2 <3",
|
|
129
129
|
"vue": "^3.5.43",
|
|
130
|
-
"markupress": "^0.8.
|
|
130
|
+
"markupress": "^0.8.6",
|
|
131
131
|
"@nextwebwg/htmlkit": "1.0.0-alpha.69",
|
|
132
132
|
"vite": "^8.3.4"
|
|
133
133
|
},
|
package/styles/ui-button.css
CHANGED
|
@@ -145,7 +145,9 @@
|
|
|
145
145
|
line-height: var(--ui-line-height-tight);
|
|
146
146
|
padding: var(--ui-control-inset-block-md, var(--ui-space-2)) var(--ui-action-inset-md, var(--ui-space-3)) !important;
|
|
147
147
|
background-image: var(--ui-surface-highlight, none);
|
|
148
|
-
box-shadow:
|
|
148
|
+
box-shadow:
|
|
149
|
+
var(--ui-button-shadow, var(--ui-action-shadow, var(--_ui-action-shadow))),
|
|
150
|
+
var(--_tone-glow);
|
|
149
151
|
cursor: pointer;
|
|
150
152
|
transition:
|
|
151
153
|
scale var(--ui-motion-press, var(--ui-motion-fast)) var(--ui-motion-ease),
|
|
@@ -278,7 +280,9 @@
|
|
|
278
280
|
background-color: var(--_tone);
|
|
279
281
|
color: var(--_on-tone);
|
|
280
282
|
background-image: var(--_tone-highlight);
|
|
281
|
-
box-shadow:
|
|
283
|
+
box-shadow:
|
|
284
|
+
var(--ui-button-solid-shadow, var(--ui-action-shadow, var(--_ui-action-shadow))),
|
|
285
|
+
var(--_tone-glow);
|
|
282
286
|
}
|
|
283
287
|
|
|
284
288
|
:is(:scope:where([data-component~="ui-button"])[data-appearance="solid"], :scope:where([data-component~="ui-button"])[data-appearance="danger"]):hover:not(:disabled, [aria-disabled="true"]) {
|
|
@@ -448,8 +452,11 @@
|
|
|
448
452
|
|
|
449
453
|
/* The size states outrank :host, so sm is named too, or a small button would stay small. */
|
|
450
454
|
@media (pointer: coarse) {
|
|
451
|
-
:scope:where([data-component~="ui-button"])
|
|
452
|
-
min-block-size: var(--ui-control-min-block-size);
|
|
455
|
+
:scope:where([data-component~="ui-button"]) {
|
|
456
|
+
min-block-size: max(var(--ui-control-size-md), var(--ui-control-min-block-size));
|
|
457
|
+
}
|
|
458
|
+
:scope:where([data-component~="ui-button"])[data-ui-button-state~="size=sm"] {
|
|
459
|
+
min-block-size: max(var(--ui-control-size-sm), var(--ui-control-min-block-size));
|
|
453
460
|
}
|
|
454
461
|
}
|
|
455
462
|
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
--_size: max(var(--ui-control-size-md), var(--ui-control-min-block-size));
|
|
110
110
|
}
|
|
111
111
|
:scope:where([data-component~="ui-color-picker"])[data-ui-color-picker-state~="size=sm"] {
|
|
112
|
-
--_size: var(--ui-control-min-block-size);
|
|
112
|
+
--_size: max(var(--ui-control-size-sm), var(--ui-control-min-block-size));
|
|
113
113
|
--_font: var(--ui-font-size-md);
|
|
114
114
|
}
|
|
115
115
|
}
|
package/styles/ui-combobox.css
CHANGED
|
@@ -320,7 +320,7 @@
|
|
|
320
320
|
/* Under touch a small field is still a touch-sized target, as a small button is, and keeps
|
|
321
321
|
body-size text: below 16px, iOS zooms the page into the focused field. */
|
|
322
322
|
:scope:where([data-component~="ui-combobox"])[data-ui-combobox-state~="size=sm"] {
|
|
323
|
-
--_row: var(--ui-control-min-block-size);
|
|
323
|
+
--_row: max(var(--ui-control-size-sm), var(--ui-control-min-block-size));
|
|
324
324
|
}
|
|
325
325
|
:scope:where([data-component~="ui-combobox"])[data-ui-combobox-state~="size=sm"] input {
|
|
326
326
|
font-size: inherit;
|
|
@@ -732,7 +732,7 @@
|
|
|
732
732
|
/* Under touch a small field is still a touch-sized target, as a small button is, and keeps
|
|
733
733
|
body-size text: below 16px, iOS zooms the page into the focused field. */
|
|
734
734
|
:where([data-component~="ui-combobox"])[data-ui-combobox-state~="size=sm"]:where(:scope, :not([data-component], [data-slotted]:not([data-slotted~="ui-combobox"]))) {
|
|
735
|
-
--_row: var(--ui-control-min-block-size);
|
|
735
|
+
--_row: max(var(--ui-control-size-sm), var(--ui-control-min-block-size));
|
|
736
736
|
}
|
|
737
737
|
:where([data-component~="ui-combobox"])[data-ui-combobox-state~="size=sm"] input:where(:scope, :not([data-component], [data-slotted]:not([data-slotted~="ui-combobox"]))) {
|
|
738
738
|
font-size: inherit;
|
package/styles/ui-input.css
CHANGED
|
@@ -117,7 +117,10 @@
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
:scope:where([data-component~="ui-input"])[data-ui-input-state~="size=sm"] {
|
|
120
|
-
min-block-size: var(
|
|
120
|
+
min-block-size: var(
|
|
121
|
+
--ui-input-min-block-size,
|
|
122
|
+
var(--_ui-default-input-min-block-size, max(var(--ui-control-size-sm), var(--ui-control-min-block-size)))
|
|
123
|
+
);
|
|
121
124
|
}
|
|
122
125
|
}
|
|
123
126
|
|