@threadlabs/looma 0.46.5 → 0.47.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/components/ui-button/ui-button.html +32 -15
- package/components/ui-checkbox/ui-checkbox.html +20 -2
- package/components/ui-icon-button/ui-icon-button.html +35 -16
- package/components/ui-radio/ui-radio.html +23 -1
- package/components/ui-switch/ui-switch.html +22 -0
- package/dist/index.js +1 -1
- package/docs/README.md +7 -5
- package/docs/catalog.json +228 -40
- package/docs/customizer-render.mjs +3 -3
- package/docs/customizer.js +1 -7
- package/docs/theme.mjs +117 -34
- package/package.json +2 -2
- package/styles/ui-button.css +33 -16
- package/styles/ui-checkbox.css +23 -2
- package/styles/ui-icon-button.css +35 -16
- package/styles/ui-radio.css +26 -1
- package/styles/ui-switch.css +25 -0
- package/theme-system.css +2 -0
- package/tokens.css +45 -18
- package/vue/UiButton.vue +32 -21
- package/vue/UiCheckbox.vue +21 -2
- package/vue/UiIconButton.vue +35 -28
- package/vue/UiRadio.vue +24 -1
- package/vue/UiSwitch.vue +23 -0
- package/vue/chunks/UiButton.js +1 -1
- package/vue/chunks/UiCheckbox.js +1 -1
- package/vue/chunks/UiIconButton.js +1 -1
- package/vue/chunks/UiRadio.js +1 -1
- package/vue/chunks/UiSwitch.js +1 -1
- package/vue/components.css +217 -88
package/docs/customizer.js
CHANGED
|
@@ -138,7 +138,6 @@ export function connect(host) {
|
|
|
138
138
|
const muted = Boolean(origin && Object.keys(Object.values(presets)[0].values).every(key => origin.values[key] === recipe.values[key]));
|
|
139
139
|
componentRegistry.update(select, { muted });
|
|
140
140
|
}
|
|
141
|
-
componentRegistry.update(root.querySelector(`[data-action="restore-${family}"]`), { disabled: state.id === 'custom' || !state.customized });
|
|
142
141
|
}
|
|
143
142
|
for (const control of root.querySelectorAll('[data-font-picker]')) {
|
|
144
143
|
control.querySelector('option[value=custom]').textContent = recipe.values[control.dataset.fontPicker].split(',')[0].replaceAll('"', '').trim();
|
|
@@ -305,11 +304,6 @@ export function connect(host) {
|
|
|
305
304
|
}
|
|
306
305
|
case 'back': navigate(''); break;
|
|
307
306
|
case 'use-glass': show(applyRefinement(recipe, 'material', 'glass')); sayApplied('Frosted glass applied. Your colors and type are unchanged.'); break;
|
|
308
|
-
case 'restore-material': case 'restore-palette': case 'restore-status': {
|
|
309
|
-
const family = button.dataset.action.slice(8), state = refinementState(recipe, family);
|
|
310
|
-
if (state.id !== 'custom') { show(applyRefinement(recipe, family, state.id)); sayApplied(`${{ material: 'Material', palette: 'Palette', status: 'Status color' }[family]} preset restored; other theme decisions are unchanged.`); }
|
|
311
|
-
break;
|
|
312
|
-
}
|
|
313
307
|
case 'add': {
|
|
314
308
|
const option = [...root.querySelectorAll('[data-add-example] option')].find(option => option.value === selectedExample);
|
|
315
309
|
if (!option) break;
|
|
@@ -396,7 +390,7 @@ export function connect(host) {
|
|
|
396
390
|
const synchronize = () => { if (!pending && theme && JSON.stringify(recipe) !== JSON.stringify(theme.recipe)) show(theme.recipe, false); };
|
|
397
391
|
const cancel = event => { if (event.target.matches('[data-light-editor], [data-editor-kind="curve"]')) { flush(false); say('Drag cancelled; the previous value is restored.'); } };
|
|
398
392
|
const keyboard = event => {
|
|
399
|
-
if (!(event.ctrlKey || event.metaKey) || event.key.toLowerCase() !== 'z' || event.target.closest?.('input,textarea,
|
|
393
|
+
if (!(event.ctrlKey || event.metaKey) || event.key.toLowerCase() !== 'z' || event.target.closest?.('input,textarea,[contenteditable="true"]')) return;
|
|
400
394
|
event.preventDefault(); flush(); theme?.[event.shiftKey ? 'redo' : 'undo'](); show(theme?.recipe ?? recipe, false);
|
|
401
395
|
};
|
|
402
396
|
const remove = event => {
|
package/docs/theme.mjs
CHANGED
|
@@ -72,11 +72,11 @@ const fontStarting = (values, body, display) => ({
|
|
|
72
72
|
...starting({ ...values, 'body-font': googleFontStack(body), 'display-font': googleFontStack(display) }),
|
|
73
73
|
fonts: { 'body-font': body, 'display-font': display },
|
|
74
74
|
});
|
|
75
|
-
/** The documentation starts with Looma's coordinated identity;
|
|
76
|
-
export const defaultRecipe = () => ({ ...starting({ action: '#7658d6', canvas: '#fbf9f4', surface: '#
|
|
75
|
+
/** The documentation starts with Looma's coordinated identity; Minimal keeps the neutral baseline. */
|
|
76
|
+
export const defaultRecipe = () => ({ ...starting({ action: '#7658d6', canvas: '#fbf9f4', surface: '#fffdf8', text: '#2b2538', 'body-font': googleFontStack('Manrope'), 'display-font': googleFontStack('Manrope'), 'text-size': '17px', 'inner-depth': '0.7' }), fonts: { 'body-font': 'Manrope', 'display-font': 'Manrope' } });
|
|
77
77
|
export const startingPoints = {
|
|
78
78
|
looma: defaultRecipe(),
|
|
79
|
-
|
|
79
|
+
minimal: { ...starting({
|
|
80
80
|
'neutral-source': 'gray', 'neutral-strength': '0.18', 'neutral-border-contrast': '2.2', 'status-chroma': '0.1',
|
|
81
81
|
'corner-roundness': '6px', 'outer-depth': '0.2', 'inner-depth': '0', 'response-time': '100ms',
|
|
82
82
|
}), presets: { status: 'restrained' } },
|
|
@@ -129,11 +129,11 @@ export const startingPoints = {
|
|
|
129
129
|
'response-time': '180ms', 'response-curve': 'cubic-bezier(0.16,1,0.3,1)',
|
|
130
130
|
}, 'Nunito Sans', 'Lora'), presets: { status: 'semantic' } },
|
|
131
131
|
};
|
|
132
|
-
export const startingPointLabels = { looma: 'Looma',
|
|
132
|
+
export const startingPointLabels = { looma: 'Looma', minimal: 'Minimal', gold: 'Gold', bookish: 'Bookish', wiki: 'Wiki', editorial: 'Editorial', night: 'Night', garden: 'Garden' };
|
|
133
133
|
const paletteKeys = themeFields.filter(field => field.family === 'Colour').map(field => field.id);
|
|
134
134
|
// Palette choices move only the shared color seeds; size, material and motion stay independent.
|
|
135
135
|
export const themePalettes = Object.fromEntries([
|
|
136
|
-
['looma', 'Looma'], ['
|
|
136
|
+
['looma', 'Looma'], ['minimal', 'Indigo & mist'], ['gold', 'Gold'], ['bookish', 'Plum & paper'], ['wiki', 'Indigo & chalk'],
|
|
137
137
|
['editorial', 'Ink & parchment'], ['night', 'Midnight'], ['garden', 'Forest & cream'],
|
|
138
138
|
].map(([id, label]) => [id, { label, values: Object.fromEntries(paletteKeys.map(key => [key, startingPoints[id].values[key]])) }]));
|
|
139
139
|
|
|
@@ -266,8 +266,8 @@ const alphaSurface = (fill, background, alpha) => {
|
|
|
266
266
|
};
|
|
267
267
|
const luminanceContrast = (a, b) => (Math.max(a, b) + .05) / (Math.min(a, b) + .05);
|
|
268
268
|
const contrast = (a, b) => luminanceContrast(luminance(a), luminance(b));
|
|
269
|
-
// Bound
|
|
270
|
-
//
|
|
269
|
+
// Bound opaque ink against the complete sRGB gradient. Different chromatic
|
|
270
|
+
// stops can mix darker than either endpoint, so inspect the interior as well.
|
|
271
271
|
function materialLuminances(start, end) {
|
|
272
272
|
const a = rgb(start), b = rgb(end);
|
|
273
273
|
const at = t => channelLuminance(a.map((n, i) => n + (b[i] - n) * t));
|
|
@@ -282,16 +282,37 @@ function materialContrast(start, end, ink) {
|
|
|
282
282
|
const [minimum, maximum] = materialLuminances(start, end);
|
|
283
283
|
return ink < minimum ? luminanceContrast(minimum, ink) : ink > maximum ? luminanceContrast(maximum, ink) : 1;
|
|
284
284
|
}
|
|
285
|
-
|
|
285
|
+
// Darker colored paint needs more saturation to avoid a muddy shadow. Keep
|
|
286
|
+
// chroma before moving hue; a bounded hue adjustment recovers colorfulness when
|
|
287
|
+
// the requested shade otherwise loses it at the sRGB gamut boundary.
|
|
288
|
+
function chromaticRecession([l, c, h], lightness) {
|
|
289
|
+
const depth = Math.max(0, l - lightness);
|
|
290
|
+
if (c < .01) return fromLch([lightness, c * lightness / (l || 1), h]);
|
|
291
|
+
const target = c * (1 + depth * .5), minimum = c * (1 + depth * .25) - .002;
|
|
292
|
+
let best = fromLch([lightness, target, h]), bestChroma = toLch(best)[1];
|
|
293
|
+
for (let offset = 1; offset <= 12 && bestChroma < minimum; offset++) {
|
|
294
|
+
for (const direction of [-1, 1]) {
|
|
295
|
+
const candidate = fromLch([lightness, target, h + offset * direction]), chroma = toLch(candidate)[1];
|
|
296
|
+
if (chroma > bestChroma + .0005) { best = candidate; bestChroma = chroma; }
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return best;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function materialColours(fill, text, light, minimum = 4.55, minimumRange = 0) {
|
|
286
303
|
const labels = (Array.isArray(text) ? text : [text]).map(label => typeof label === 'number' ? label : luminance(label));
|
|
287
304
|
const [l, c, h] = toLch(fill), [lightness] = toLch(light);
|
|
288
|
-
//
|
|
289
|
-
//
|
|
305
|
+
// Content surfaces retain restrained lighting. Filled pigment gains chroma
|
|
306
|
+
// as it recedes, so a darker gold reads as colored material rather than brown.
|
|
290
307
|
const response = 1 - .75 * l;
|
|
291
308
|
let depth = .05 * response;
|
|
292
|
-
const shaded = amount =>
|
|
309
|
+
const shaded = amount => {
|
|
310
|
+
if (amount === 0) return fill;
|
|
311
|
+
const lightness = Math.max(0, l - amount);
|
|
312
|
+
return minimumRange ? chromaticRecession([l, c, h], lightness) : fromLch([lightness, c * lightness / (l || 1), h]);
|
|
313
|
+
};
|
|
293
314
|
while (depth > 0 && labels.some(label => luminanceContrast(luminance(shaded(depth)), label) < minimum)) depth = Math.max(0, depth - .001);
|
|
294
|
-
|
|
315
|
+
let shade = shaded(depth);
|
|
295
316
|
// Lift chroma with lightness, plus a small pigment-dependent saturation boost,
|
|
296
317
|
// so the broad reflection stays colored instead of becoming a white wash.
|
|
297
318
|
const [, tintChroma, tintHue] = toLch(mix(light, fill, .18));
|
|
@@ -309,6 +330,15 @@ function materialColours(fill, text, light, minimum = 4.55) {
|
|
|
309
330
|
};
|
|
310
331
|
while (amount > 0 && !readableReflection(amount)) amount = Math.max(0, amount - .005);
|
|
311
332
|
const reflection = mix(target, fill, amount);
|
|
333
|
+
// Bright saturated pigments have little reflection headroom in sRGB. Keep
|
|
334
|
+
// their material visible through a deeper chromatic shade rather than a
|
|
335
|
+
// white wash, bounded by the label's contrast across the complete gradient.
|
|
336
|
+
while (depth + .002 <= .16 && colourDistance(reflection, shade) < minimumRange * lightness) {
|
|
337
|
+
const candidate = shaded(depth + .002);
|
|
338
|
+
if (labels.some(label => materialContrast(reflection, candidate, label) < minimum)) break;
|
|
339
|
+
depth += .002;
|
|
340
|
+
shade = candidate;
|
|
341
|
+
}
|
|
312
342
|
// A tiny specular peak is allowed to brighten separately from the chromatic
|
|
313
343
|
// body reflection. Keep the same quantization margin as every material stop.
|
|
314
344
|
let glare = .55 * lightness;
|
|
@@ -344,16 +374,43 @@ const actionBoundary = (fill, surfaces, ink, amplitude) => {
|
|
|
344
374
|
|
|
345
375
|
// Adjust semantic ink in lightness before sacrificing its hue or chroma. Mixing
|
|
346
376
|
// amber toward black also removes its color, making a readable warning look brown.
|
|
347
|
-
function readableTone(seed, surfaces, minimum, endpoint) {
|
|
377
|
+
function readableTone(seed, surfaces, minimum, endpoint, chromatic = false) {
|
|
348
378
|
const [l, c, h] = toLch(seed), end = toLch(endpoint)[0];
|
|
349
379
|
const backgrounds = surfaces.map(surface => typeof surface === 'number' ? surface : luminance(surface));
|
|
350
380
|
for (let step = 0; step <= 256; step++) {
|
|
351
|
-
const
|
|
381
|
+
const lightness = l + (end - l) * step / 256;
|
|
382
|
+
const next = chromatic && lightness < l ? chromaticRecession([l, c, h], lightness) : fromLch([lightness, c, h]);
|
|
352
383
|
if (backgrounds.every(background => luminanceContrast(luminance(next), background) >= minimum)) return next;
|
|
353
384
|
}
|
|
354
385
|
return endpoint;
|
|
355
386
|
}
|
|
356
387
|
|
|
388
|
+
// Preserve pigment rather than mixing it toward black/white. Deep solids need
|
|
389
|
+
// a larger lift than pale fills to make hover read with the same visual weight.
|
|
390
|
+
function interactionColour(fill, label, distance, direction = toLch(fill)[0] < .5 ? 1 : -1) {
|
|
391
|
+
const [l, c, h] = toLch(fill);
|
|
392
|
+
for (const sign of [direction, -direction]) {
|
|
393
|
+
const next = fromLch([l + sign * distance, c, h]);
|
|
394
|
+
if (contrast(next, label) >= 4.55) return next;
|
|
395
|
+
}
|
|
396
|
+
return readableTone(fill, [label], 4.55, foreground(label, '#ffffff', '#000000'));
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// Calibrate translucent paint against its plate in Oklab. Raw percentages have
|
|
400
|
+
// very different perceptual weights for a dark plum, a bright gold and white ink.
|
|
401
|
+
function stateWash(pigment, plate, distance, dark) {
|
|
402
|
+
const [l, c, h] = toLch(pigment), washL = dark ? .65 : .72;
|
|
403
|
+
const wash = fromLch([washL, c * washL / Math.max(.001, l), h]);
|
|
404
|
+
let low = 0, high = 1;
|
|
405
|
+
for (let step = 0; step < 16; step++) {
|
|
406
|
+
const alpha = (low + high) / 2;
|
|
407
|
+
if (colourDistance(alphaSurface(wash, plate, alpha), plate) < distance) low = alpha; else high = alpha;
|
|
408
|
+
}
|
|
409
|
+
return wash + Math.round(high * 255).toString(16).padStart(2, '0');
|
|
410
|
+
}
|
|
411
|
+
const washSurface = (wash, surface) => alphaSurface(wash, surface, parseInt(wash.slice(7), 16) / 255);
|
|
412
|
+
|
|
413
|
+
const quietChromaScale = .74;
|
|
357
414
|
const paletteCache = new Map();
|
|
358
415
|
export function deriveTheme(input, { mode } = {}) {
|
|
359
416
|
if (mode !== undefined && !['light', 'dark'].includes(mode)) throw new Error('Unknown theme color mode.');
|
|
@@ -413,22 +470,21 @@ export function deriveTheme(input, { mode } = {}) {
|
|
|
413
470
|
tokens[`--ui-${tone}`] = fill;
|
|
414
471
|
tokens[`--ui-on-${tone}`] = onFill;
|
|
415
472
|
tokens[`--ui-${tone}-on-strong`] = onFill;
|
|
416
|
-
for (const [part, colour] of Object.entries(materialColours(fill, onFill, values['light-color']))) tokens[`--ui-${tone}-${part}`] = colour;
|
|
473
|
+
for (const [part, colour] of Object.entries(materialColours(fill, onFill, values['light-color'], 4.55, .14))) tokens[`--ui-${tone}-${part}`] = colour;
|
|
417
474
|
const stateTarget = onFill === '#000000' ? '#ffffff' : '#000000';
|
|
418
475
|
const [fillL, fillC, fillH] = toLch(fill);
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
//
|
|
427
|
-
|
|
428
|
-
const density = toLch(tokens[`--ui-${tone}-hover`])[0] / (toLch(fill)[0] || 1);
|
|
476
|
+
const hoverStep = .035 + .08 * Math.max(0, 1 - fillL / .5);
|
|
477
|
+
tokens[`--ui-${tone}-hover`] = interactionColour(fill, onFill, hoverStep);
|
|
478
|
+
const direction = onFill === '#000000' ? 1 : -1;
|
|
479
|
+
const room = direction > 0 ? 1 - fillL : fillL;
|
|
480
|
+
const activeL = Math.max(0, Math.min(1, fillL + direction * Math.max(.085, room * .26)));
|
|
481
|
+
tokens[`--ui-${tone}-active`] = readableColour(fromLch([activeL, fillC * activeL / (fillL || 1), fillH]), [onFill], 4.55, stateTarget);
|
|
482
|
+
// Move the whole painted plane by the same step. A fixed reflection hides
|
|
483
|
+
// fill changes; multiplying its density exaggerates deep pigments' response.
|
|
484
|
+
const shift = toLch(tokens[`--ui-${tone}-hover`])[0] - toLch(fill)[0];
|
|
429
485
|
for (const part of ['reflection', 'shade']) {
|
|
430
486
|
const [l, c, h] = toLch(tokens[`--ui-${tone}-${part}`]);
|
|
431
|
-
tokens[`--ui-${tone}-hover-${part}`] =
|
|
487
|
+
tokens[`--ui-${tone}-hover-${part}`] = readableTone(fromLch([l + shift, c, h]), [onFill], 4.55, stateTarget);
|
|
432
488
|
}
|
|
433
489
|
const contextual = readableColour(fill, surfaces, 4.5, ink);
|
|
434
490
|
const quiet = mix(contextual, tokens['--ui-surface-raised'], .20);
|
|
@@ -438,13 +494,34 @@ export function deriveTheme(input, { mode } = {}) {
|
|
|
438
494
|
const warmLift = dark ? Math.max(0, 1 - Math.abs(pigmentH - 70) / 35) ** 2 : 0;
|
|
439
495
|
const semantic = Object.hasOwn(statusSeeds, tone) && ['derived', 'related'].includes(values[tone + '-source']);
|
|
440
496
|
const tintScale = semantic ? .25 + 1.5 * Number(values['status-chroma']) : 1;
|
|
441
|
-
const quietC = Math.min(pigmentC, (dark ? .035 + .015 * warmLift : .02) * tintScale);
|
|
497
|
+
const quietC = Math.min(pigmentC, (dark ? .035 + .015 * warmLift : .02) * tintScale) * quietChromaScale;
|
|
442
498
|
const softL = dark ? Math.max(quietL, plateL + .07) + .04 * warmLift : Math.max(.92, plateL - .04);
|
|
443
499
|
tokens[`--ui-${tone}-soft`] = readableColour(fromLch([softL, quietC, pigmentH]), [ink], 4.5, paper);
|
|
444
500
|
}
|
|
501
|
+
const choiceFill = tokens['--ui-accent'], choiceInk = tokens['--ui-on-accent'];
|
|
502
|
+
tokens['--ui-choice-hover-surface'] = interactionColour(choiceFill, choiceInk, .04);
|
|
503
|
+
const choiceShift = toLch(tokens['--ui-choice-hover-surface'])[0] - toLch(choiceFill)[0];
|
|
504
|
+
for (const part of ['reflection', 'shade']) {
|
|
505
|
+
const [l, c, h] = toLch(tokens[`--ui-accent-${part}`]);
|
|
506
|
+
tokens[`--ui-choice-hover-${part}`] = readableTone(fromLch([l + choiceShift, c, h]), [choiceInk], 4.55, foreground(choiceInk, '#ffffff', '#000000'));
|
|
507
|
+
}
|
|
508
|
+
const materialOpacity = Number(values.finish) * Number(values['light-strength']);
|
|
509
|
+
const preliminaryMaterial = materialColours(tokens['--ui-surface-raised'], ink, values['light-color']);
|
|
510
|
+
const washPlate = alphaSurface(mix(preliminaryMaterial.reflection, preliminaryMaterial.shade, .5), tokens['--ui-surface-raised'], materialOpacity);
|
|
511
|
+
for (const tone of Object.keys(tones)) {
|
|
512
|
+
const [l, c, h] = toLch(tokens[`--ui-${tone}`]);
|
|
513
|
+
const quietPigment = fromLch([l, c * quietChromaScale, h]);
|
|
514
|
+
tokens[`--ui-${tone}-wash`] = stateWash(quietPigment, washPlate, .04, dark);
|
|
515
|
+
tokens[`--ui-${tone}-wash-hover`] = stateWash(quietPigment, washPlate, .065, dark);
|
|
516
|
+
tokens[`--ui-${tone}-ghost-hover`] = stateWash(tokens[`--ui-${tone}`], tokens['--ui-surface'], .03, dark);
|
|
517
|
+
}
|
|
518
|
+
tokens['--ui-neutral-wash-hover'] = stateWash(ink, washPlate, .025, dark);
|
|
519
|
+
tokens['--ui-neutral-ghost-hover'] = stateWash(ink, tokens['--ui-surface'], .03, dark);
|
|
520
|
+
const washSurfaces = Object.entries(tokens).filter(([name]) => /-(wash|wash-hover|ghost-hover)$/.test(name))
|
|
521
|
+
.flatMap(([, wash]) => [...surfaces, washPlate].map(surface => washSurface(wash, surface)));
|
|
445
522
|
// Quiet fills are actual alpha composites. At an extreme light/dark flip,
|
|
446
523
|
// reduce their shared tint before it would leave no readable contextual ink.
|
|
447
|
-
const quietSurfaces = strength => [...surfaces, ...surfaces.map(surface => alphaSurface(surface, ink, 1 - .1 * Number(values.translucency))), ...(dark ? [readableColour(mix(ink, tokens['--ui-surface-raised'], .22), [ink], 4.5, paper)] : []), ...Object.keys(tones).map(tone => tokens[`--ui-${tone}-soft`]), ...Object.keys(tones).flatMap(tone => surfaces.flatMap(background => [
|
|
524
|
+
const quietSurfaces = strength => [...surfaces, ...washSurfaces, ...surfaces.map(surface => alphaSurface(surface, ink, 1 - .1 * Number(values.translucency))), ...(dark ? [readableColour(mix(ink, tokens['--ui-surface-raised'], .22), [ink], 4.5, paper)] : []), ...Object.keys(tones).map(tone => tokens[`--ui-${tone}-soft`]), ...Object.keys(tones).flatMap(tone => surfaces.flatMap(background => [
|
|
448
525
|
mix(tokens[`--ui-${tone}`], background, .12 * strength),
|
|
449
526
|
...[.05, .12, .18, .19].map(alpha => alphaSurface(tokens[`--ui-${tone}`], background, alpha * strength)),
|
|
450
527
|
]))];
|
|
@@ -476,35 +553,41 @@ export function deriveTheme(input, { mode } = {}) {
|
|
|
476
553
|
const [, neutralC, neutralH] = toLch(neutralSource === 'text' || neutralSource === 'gray' ? tokens['--ui-text'] : accents[neutralSource]);
|
|
477
554
|
const neutral = fromLch([toLch(tokens['--ui-text'])[0], neutralSource === 'gray' ? 0 : Math.min(.04, neutralC), neutralH]);
|
|
478
555
|
const fillAmount = .02 + Number(values['neutral-strength']) * .16;
|
|
479
|
-
for (const [state, amount] of [['surface', fillAmount], ['
|
|
556
|
+
for (const [state, amount] of [['surface', fillAmount], ['active', fillAmount + .08]]) {
|
|
480
557
|
const tinted = mix(neutral, tokens['--ui-surface-raised'], amount * (dark ? 2.25 : 1));
|
|
481
558
|
const [l, c, h] = toLch(tinted);
|
|
482
559
|
const fill = dark ? fromLch([Math.max(l, toLch(tokens['--ui-surface-raised'])[0] + amount * 1.5), c, h]) : tinted;
|
|
483
560
|
tokens[`--ui-neutral-${state}`] = readableColour(fill, [tokens['--ui-text']], 4.5, paper);
|
|
484
561
|
}
|
|
562
|
+
tokens['--ui-neutral-hover'] = interactionColour(tokens['--ui-neutral-surface'], tokens['--ui-text'], .035, dark ? 1 : -1);
|
|
485
563
|
const borderSurfaces = [...surfaces, tokens['--ui-neutral-surface']];
|
|
486
564
|
const engagedSurfaces = [...surfaces, tokens['--ui-neutral-hover'], tokens['--ui-neutral-active']];
|
|
487
565
|
tokens['--ui-control-border'] = readableColour(mix(neutral, tokens['--ui-surface-raised'], .14), borderSurfaces, borderMinimum, ink);
|
|
488
|
-
tokens['--ui-control-border-hover'] = readableColour(tokens['--ui-control-border'], engagedSurfaces, Math.min(4.5, borderMinimum + .
|
|
566
|
+
tokens['--ui-control-border-hover'] = readableColour(tokens['--ui-control-border'], engagedSurfaces, Math.min(4.5, borderMinimum + .4), ink);
|
|
489
567
|
tokens['--ui-border'] = mix(neutral, tokens['--ui-surface-raised'], .10);
|
|
490
568
|
tokens['--ui-border-strong'] = mix(neutral, tokens['--ui-surface-raised'], .18);
|
|
491
569
|
for (const [role, fill, labels] of [
|
|
492
570
|
['surface', tokens['--ui-surface-raised'], [tokens['--ui-text'], tokens['--ui-text-secondary'], ...Object.keys(tones).map(tone => tokens[`--ui-${tone}-subtle-text`])]],
|
|
493
571
|
['neutral', tokens['--ui-neutral-surface'], tokens['--ui-text']],
|
|
494
|
-
]) for (const [part, colour] of Object.entries(materialColours(fill, labels, values['light-color']))) tokens[`--ui-${role}-${part}`] = colour;
|
|
572
|
+
]) for (const [part, colour] of Object.entries(materialColours(fill, labels, values['light-color'], 4.55, role === 'neutral' ? .14 : 0))) tokens[`--ui-${role}-${part}`] = colour;
|
|
573
|
+
const neutralShift = toLch(tokens['--ui-neutral-hover'])[0] - toLch(tokens['--ui-neutral-surface'])[0];
|
|
574
|
+
for (const part of ['reflection', 'shade']) {
|
|
575
|
+
const [l, c, h] = toLch(tokens[`--ui-neutral-${part}`]);
|
|
576
|
+
tokens[`--ui-neutral-hover-${part}`] = readableTone(fromLch([l + neutralShift, c, h]), [tokens['--ui-text']], 4.55, paper);
|
|
577
|
+
}
|
|
495
578
|
// Borders surround the finished paint, including its translucent wash and
|
|
496
579
|
// material gradient. Text readability has its own independent contrast floor.
|
|
497
|
-
const materialOpacity = Number(values.finish) * Number(values['light-strength']);
|
|
498
580
|
for (const tone of Object.keys(tones)) {
|
|
499
581
|
const pigment = tokens[`--ui-${tone}`];
|
|
500
582
|
const backgrounds = surfaces.flatMap(surface => {
|
|
501
583
|
const reflection = alphaSurface(tokens['--ui-surface-reflection'], surface, materialOpacity);
|
|
502
584
|
const shade = alphaSurface(tokens['--ui-surface-shade'], surface, materialOpacity);
|
|
503
585
|
return [surface, ...materialLuminances(reflection, shade),
|
|
586
|
+
...['wash', 'wash-hover', 'ghost-hover'].flatMap(state => materialLuminances(washSurface(tokens[`--ui-${tone}-${state}`], reflection), washSurface(tokens[`--ui-${tone}-${state}`], shade))),
|
|
504
587
|
...[.08, .12].flatMap(alpha => materialLuminances(alphaSurface(pigment, reflection, alpha * tonalOpacity), alphaSurface(pigment, shade, alpha * tonalOpacity))),
|
|
505
588
|
...[.08, .12, .18].map(alpha => alphaSurface(pigment, surface, alpha * tonalOpacity))];
|
|
506
589
|
});
|
|
507
|
-
tokens[`--ui-${tone}-outline-border`] = readableTone(pigment, backgrounds, borderMinimum, ink);
|
|
590
|
+
tokens[`--ui-${tone}-outline-border`] = readableTone(pigment, backgrounds, borderMinimum, ink, true);
|
|
508
591
|
tokens[`--ui-${tone}-subtle-text`] = readableTone(tokens[`--ui-${tone}-subtle-text`], [...readingSurfaces, ...backgrounds], 4.5, ink);
|
|
509
592
|
tokens[`--ui-${tone}-soft-border`] = alphaSurface(tokens[`--ui-${tone}-subtle-text`], tokens[`--ui-${tone}-soft`], .25);
|
|
510
593
|
}
|
|
@@ -565,7 +648,7 @@ export function themeCSS(input, systemCSS = '', { scope = 'portable' } = {}) {
|
|
|
565
648
|
const relativeLengths = new Map(themeFields.filter(field => field.property && field.type.includes('length') && recipe.values[field.id].endsWith('rem')).map(field => [field.property, recipe.values[field.id]]));
|
|
566
649
|
for (const [name, value] of Object.entries(light)) {
|
|
567
650
|
if (name === 'color-scheme') continue;
|
|
568
|
-
if (/^#[\da-f]{6}
|
|
651
|
+
if (/^#[\da-f]{6}(?:[\da-f]{2})?$/i.test(value)) palette.push(` ${name}: light-dark(${value}, ${dark[name]});`);
|
|
569
652
|
else {
|
|
570
653
|
const relative = relativeLengths.get(name);
|
|
571
654
|
const resolved = name === '--ui-tonal-opacity' ? Math.min(Number(value), Number(dark[name])) : relative ? value.replace(relative, `calc(${parseFloat(relative)} * var(--_ui-root-font-unit, 1rem))`) : value;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@threadlabs/looma",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Looma components as HTML, Vue, and plain DOM, with design tokens.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"@tiptap/pm": ">=2 <3",
|
|
123
123
|
"@tiptap/vue-3": ">=2 <3",
|
|
124
124
|
"vue": "^3.5.43",
|
|
125
|
-
"markupress": ">=0.12.0 <1",
|
|
125
|
+
"markupress": ">=0.12.0 <0.14.4 || >=0.14.5 <1",
|
|
126
126
|
"@threadlabs/markupkit": ">=0.2.0 <1",
|
|
127
127
|
"vite": ">=7.2.7 <9"
|
|
128
128
|
},
|
package/styles/ui-button.css
CHANGED
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
--_tone-highlight: var(--ui-accent-highlight, none);
|
|
25
25
|
--_tone-hover-highlight: var(--ui-accent-hover-highlight, none);
|
|
26
26
|
--_tone-outline-border: var(--ui-accent-outline-border, var(--ui-accent-subtle-text));
|
|
27
|
+
--_tone-wash: var(--ui-accent-wash);
|
|
28
|
+
--_tone-wash-hover: var(--ui-accent-wash-hover);
|
|
29
|
+
--_tone-ghost-hover: var(--ui-accent-ghost-hover);
|
|
27
30
|
--_tone-glow: var(--ui-accent-glow, 0 0 transparent);
|
|
28
31
|
--_hue: var(--ui-accent);
|
|
29
32
|
--_hue-hover: var(--ui-accent-hover);
|
|
@@ -209,19 +212,15 @@
|
|
|
209
212
|
}
|
|
210
213
|
|
|
211
214
|
:scope:where([data-component~="ui-button"])[data-appearance="outline"]:not([data-tone="neutral"]) {
|
|
212
|
-
--_outline-
|
|
213
|
-
--_outline-wash: oklch(from var(--_tone) l c h / calc(8% * var(--ui-tonal-opacity, 1)));
|
|
215
|
+
--_outline-wash: var(--_tone-wash);
|
|
214
216
|
border-color: var(--ui-button-border, var(--_tone-outline-border, var(--_tone-text)));
|
|
215
217
|
background-color: var(--ui-button-surface, transparent);
|
|
216
218
|
box-shadow: var(--ui-button-shadow, var(--ui-neutral-shadow));
|
|
217
|
-
background-image:
|
|
218
|
-
linear-gradient(var(--_outline-wash), var(--_outline-wash)),
|
|
219
|
-
var(--_outline-highlight);
|
|
219
|
+
background-image: linear-gradient(var(--_outline-wash), var(--_outline-wash));
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
:scope:where([data-component~="ui-button"])[data-appearance="outline"]:not([data-tone="neutral"]):hover:not(:disabled, [aria-disabled="true"]) {
|
|
223
|
-
--_outline-
|
|
224
|
-
--_outline-wash: oklch(from var(--_tone) l c h / calc(12% * var(--ui-tonal-opacity, 1)));
|
|
223
|
+
--_outline-wash: var(--_tone-wash-hover);
|
|
225
224
|
background-color: var(--ui-button-hover-surface, transparent);
|
|
226
225
|
border-color: var(--ui-button-hover-border, var(--_tone-outline-border));
|
|
227
226
|
}
|
|
@@ -289,6 +288,9 @@
|
|
|
289
288
|
--_tone-highlight: var(--ui-accent-secondary-highlight, none);
|
|
290
289
|
--_tone-hover-highlight: var(--ui-accent-secondary-hover-highlight, none);
|
|
291
290
|
--_tone-outline-border: var(--ui-accent-secondary-outline-border, var(--ui-accent-secondary-subtle-text));
|
|
291
|
+
--_tone-wash: var(--ui-accent-secondary-wash);
|
|
292
|
+
--_tone-wash-hover: var(--ui-accent-secondary-wash-hover);
|
|
293
|
+
--_tone-ghost-hover: var(--ui-accent-secondary-ghost-hover);
|
|
292
294
|
--_tone-glow: var(--ui-accent-secondary-glow, 0 0 transparent);
|
|
293
295
|
--_hue: var(--ui-accent-secondary);
|
|
294
296
|
--_hue-hover: var(--ui-accent-secondary-hover);
|
|
@@ -304,6 +306,9 @@
|
|
|
304
306
|
--_tone-highlight: var(--ui-accent-tertiary-highlight, none);
|
|
305
307
|
--_tone-hover-highlight: var(--ui-accent-tertiary-hover-highlight, none);
|
|
306
308
|
--_tone-outline-border: var(--ui-accent-tertiary-outline-border, var(--ui-accent-tertiary-subtle-text));
|
|
309
|
+
--_tone-wash: var(--ui-accent-tertiary-wash);
|
|
310
|
+
--_tone-wash-hover: var(--ui-accent-tertiary-wash-hover);
|
|
311
|
+
--_tone-ghost-hover: var(--ui-accent-tertiary-ghost-hover);
|
|
307
312
|
--_tone-glow: var(--ui-accent-tertiary-glow, 0 0 transparent);
|
|
308
313
|
--_hue: var(--ui-accent-tertiary);
|
|
309
314
|
--_hue-hover: var(--ui-accent-tertiary-hover);
|
|
@@ -317,8 +322,9 @@
|
|
|
317
322
|
--_tone-hover-border: var(--ui-control-border-hover, var(--ui-neutral-hover));
|
|
318
323
|
--_tone-active-border: var(--ui-control-border-hover, var(--ui-neutral-active));
|
|
319
324
|
--_tone-highlight: var(--ui-neutral-highlight, none);
|
|
320
|
-
--_tone-hover-highlight: var(--ui-neutral-highlight, var(--_tone-highlight));
|
|
325
|
+
--_tone-hover-highlight: var(--ui-neutral-hover-highlight, var(--_tone-highlight));
|
|
321
326
|
--_tone-outline-border: var(--ui-control-border);
|
|
327
|
+
--_tone-ghost-hover: var(--ui-neutral-ghost-hover);
|
|
322
328
|
--_tone-glow: var(--ui-neutral-glow, 0 0 transparent);
|
|
323
329
|
--_hue: var(--ui-text);
|
|
324
330
|
--_hue-hover: var(--ui-text);
|
|
@@ -336,15 +342,14 @@
|
|
|
336
342
|
:scope:where([data-component~="ui-button"])[data-tone="neutral"][data-appearance="outline"] {
|
|
337
343
|
border-color: var(--ui-button-border, var(--ui-control-border));
|
|
338
344
|
background-color: var(--ui-button-surface, transparent);
|
|
345
|
+
background-image: none;
|
|
339
346
|
box-shadow: var(--ui-button-shadow, var(--ui-neutral-shadow));
|
|
340
347
|
}
|
|
341
348
|
:scope:where([data-component~="ui-button"])[data-tone="neutral"][data-appearance="outline"]:hover:not(:disabled, [aria-disabled="true"]) {
|
|
342
349
|
border-color: var(--ui-button-hover-border, var(--ui-control-border-hover));
|
|
343
|
-
background-color: var(--ui-button-hover-surface,
|
|
344
|
-
--_outline-wash:
|
|
345
|
-
background-image:
|
|
346
|
-
linear-gradient(var(--_outline-wash), var(--_outline-wash)),
|
|
347
|
-
var(--ui-surface-highlight, linear-gradient(transparent, transparent));
|
|
350
|
+
background-color: var(--ui-button-hover-surface, transparent);
|
|
351
|
+
--_outline-wash: var(--ui-neutral-wash-hover);
|
|
352
|
+
background-image: linear-gradient(var(--_outline-wash), var(--_outline-wash));
|
|
348
353
|
}
|
|
349
354
|
:scope:where([data-component~="ui-button"])[data-tone="neutral"][data-appearance="outline"]:active:not(:disabled, [aria-disabled="true"]) {
|
|
350
355
|
background-image: none;
|
|
@@ -367,6 +372,9 @@
|
|
|
367
372
|
--_tone-highlight: var(--ui-danger-highlight, none);
|
|
368
373
|
--_tone-hover-highlight: var(--ui-danger-hover-highlight, none);
|
|
369
374
|
--_tone-outline-border: var(--ui-danger-outline-border, var(--ui-danger-subtle-text));
|
|
375
|
+
--_tone-wash: var(--ui-danger-wash);
|
|
376
|
+
--_tone-wash-hover: var(--ui-danger-wash-hover);
|
|
377
|
+
--_tone-ghost-hover: var(--ui-danger-ghost-hover);
|
|
370
378
|
--_tone-glow: var(--ui-danger-glow, 0 0 transparent);
|
|
371
379
|
--_hue: var(--ui-danger);
|
|
372
380
|
--_hue-hover: var(--ui-danger-hover);
|
|
@@ -382,6 +390,9 @@
|
|
|
382
390
|
--_tone-highlight: var(--ui-success-highlight, none);
|
|
383
391
|
--_tone-hover-highlight: var(--ui-success-hover-highlight, none);
|
|
384
392
|
--_tone-outline-border: var(--ui-success-outline-border, var(--ui-success-subtle-text));
|
|
393
|
+
--_tone-wash: var(--ui-success-wash);
|
|
394
|
+
--_tone-wash-hover: var(--ui-success-wash-hover);
|
|
395
|
+
--_tone-ghost-hover: var(--ui-success-ghost-hover);
|
|
385
396
|
--_tone-glow: var(--ui-success-glow, 0 0 transparent);
|
|
386
397
|
--_hue: var(--ui-success);
|
|
387
398
|
--_hue-hover: var(--ui-success-hover);
|
|
@@ -397,6 +408,9 @@
|
|
|
397
408
|
--_tone-highlight: var(--ui-warning-highlight, none);
|
|
398
409
|
--_tone-hover-highlight: var(--ui-warning-hover-highlight, none);
|
|
399
410
|
--_tone-outline-border: var(--ui-warning-outline-border, var(--ui-warning-subtle-text));
|
|
411
|
+
--_tone-wash: var(--ui-warning-wash);
|
|
412
|
+
--_tone-wash-hover: var(--ui-warning-wash-hover);
|
|
413
|
+
--_tone-ghost-hover: var(--ui-warning-ghost-hover);
|
|
400
414
|
--_tone-glow: var(--ui-warning-glow, 0 0 transparent);
|
|
401
415
|
--_hue: var(--ui-warning);
|
|
402
416
|
--_hue-hover: var(--ui-warning-hover);
|
|
@@ -412,6 +426,9 @@
|
|
|
412
426
|
--_tone-highlight: var(--ui-info-highlight, none);
|
|
413
427
|
--_tone-hover-highlight: var(--ui-info-hover-highlight, none);
|
|
414
428
|
--_tone-outline-border: var(--ui-info-outline-border, var(--ui-info-subtle-text));
|
|
429
|
+
--_tone-wash: var(--ui-info-wash);
|
|
430
|
+
--_tone-wash-hover: var(--ui-info-wash-hover);
|
|
431
|
+
--_tone-ghost-hover: var(--ui-info-ghost-hover);
|
|
415
432
|
--_tone-glow: var(--ui-info-glow, 0 0 transparent);
|
|
416
433
|
--_hue: var(--ui-info);
|
|
417
434
|
--_hue-hover: var(--ui-info-hover);
|
|
@@ -454,9 +471,9 @@
|
|
|
454
471
|
color: var(--ui-button-ghost-text, var(--_tone-text));
|
|
455
472
|
}
|
|
456
473
|
|
|
457
|
-
/*
|
|
474
|
+
/* Shared translucent paint keeps text and icon action feedback coordinated. */
|
|
458
475
|
:scope:where([data-component~="ui-button"])[data-appearance="ghost"]:hover:not(:disabled, [aria-disabled="true"]) {
|
|
459
|
-
background-color: var(--ui-button-ghost-hover-surface,
|
|
476
|
+
background-color: var(--ui-button-ghost-hover-surface, var(--_tone-ghost-hover));
|
|
460
477
|
border-color: transparent;
|
|
461
478
|
}
|
|
462
479
|
|
|
@@ -613,7 +630,7 @@
|
|
|
613
630
|
|
|
614
631
|
/* A value picker is a field, with Select's quiet edge and resting lift. */
|
|
615
632
|
|
|
616
|
-
/*
|
|
633
|
+
/* Shared translucent paint keeps text and icon action feedback coordinated. */
|
|
617
634
|
|
|
618
635
|
/* A soft halo that transitions in with the other box-shadow changes, layered on the raised shadow. */
|
|
619
636
|
|
package/styles/ui-checkbox.css
CHANGED
|
@@ -165,8 +165,26 @@
|
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
|
|
169
|
-
|
|
168
|
+
@media (hover: hover) and (forced-colors: none) {
|
|
169
|
+
:scope:where([data-component~="ui-checkbox"]):hover input:enabled {
|
|
170
|
+
--_choice-hover-wash: var(--ui-neutral-wash-hover);
|
|
171
|
+
background-image:
|
|
172
|
+
linear-gradient(var(--_choice-hover-wash), var(--_choice-hover-wash)),
|
|
173
|
+
var(--ui-surface-highlight, linear-gradient(transparent, transparent));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
:scope:where([data-component~="ui-checkbox"]):hover input:enabled:not([aria-invalid="true"]) {
|
|
177
|
+
border-color: var(--ui-control-border-hover, var(--ui-border-strong));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
:scope:where([data-component~="ui-checkbox"]):hover input:enabled:is(:checked, :indeterminate) {
|
|
181
|
+
background-color: var(--ui-choice-hover-surface);
|
|
182
|
+
background-image: var(--ui-choice-hover-highlight, none);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
:scope:where([data-component~="ui-checkbox"]):hover input:enabled:is(:checked, :indeterminate):not([aria-invalid="true"]) {
|
|
186
|
+
border-color: var(--ui-choice-hover-surface);
|
|
187
|
+
}
|
|
170
188
|
}
|
|
171
189
|
|
|
172
190
|
input:focus-visible {
|
|
@@ -229,6 +247,9 @@
|
|
|
229
247
|
@media (forced-colors: active) {
|
|
230
248
|
}
|
|
231
249
|
|
|
250
|
+
@media (hover: hover) and (forced-colors: none) {
|
|
251
|
+
}
|
|
252
|
+
|
|
232
253
|
/* A sized choice keeps its box and aligns instead: the label takes that size's field type size,
|
|
233
254
|
and the first line centres in that control height, so the label shares a row's baseline.
|
|
234
255
|
Multi-line labels and descriptions still grow downward from that first line. */
|