@threadlabs/looma 0.43.2 → 0.44.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-callout/ui-callout.html +4 -4
- package/components/ui-dialog/ui-dialog.html +0 -4
- package/components/ui-editor-footnote-editor/ui-editor-footnote-editor.html +4 -50
- package/components/ui-editor-footnote-editor/ui-editor-footnote-editor.js +10 -31
- package/dist/index.js +1 -1
- package/docs/README.md +19 -3
- package/docs/card.html +1 -1
- package/docs/catalog-view.js +11 -5
- package/docs/catalog-view.mjs +4 -3
- package/docs/catalog.json +73 -109
- package/docs/catalog.mjs +1 -1
- package/docs/customizer-render.mjs +9 -8
- package/docs/customizer.js +8 -8
- package/docs/documentation.css +2 -2
- package/docs/examples/ui-editor-footnote-editor/examples/01-note.behavior.js +9 -0
- package/docs/fonts.mjs +1 -1
- package/docs/index.mjs +1 -1
- package/docs/render.mjs +1 -1
- package/docs/site.mjs +14 -5
- package/docs/theme.mjs +96 -16
- package/editor/chunks/extensions.js +10 -0
- package/editor/extensions/footnote.d.ts +1 -0
- package/editor/footnote-editing.d.ts +16 -27
- package/package.json +2 -2
- package/styles/ui-callout.css +4 -4
- package/styles/ui-dialog.css +0 -8
- package/theme-dark.css +9 -9
- package/theme-high-contrast.css +4 -0
- package/theme-light.css +6 -6
- package/tokens.css +20 -18
- package/vanilla/UiEditorFootnoteEditor.d.ts +0 -5
- package/vanilla/UiEditorFootnoteEditor.js +20 -68
- package/vue/UiCallout.vue +4 -4
- package/vue/UiDialog.vue +0 -7
- package/vue/UiEditorFootnoteEditor.d.ts +11 -29
- package/vue/UiEditorFootnoteEditor.vue +21 -173
- package/vue/chunks/UiCallout.js +1 -1
- package/vue/chunks/UiDialog.js +1 -1
- package/vue/chunks/UiEditorFootnoteEditor.js +34 -226
- package/vue/chunks/UiEditorImageToolbar.js +1 -1
- package/vue/chunks/UiEditorLinkForm.js +1 -1
- package/vue/chunks/compact.js +565 -0
- package/vue/components.css +320 -327
- package/vue/editor/LoomaEditor.d.ts +2 -2
- package/vue/editor/compact/index.js +1 -562
- package/vue/editor/index.js +173 -80
- package/vue/index.js +2 -2
|
@@ -2,12 +2,12 @@ import { googleFonts, systemFont } from './fonts.mjs';
|
|
|
2
2
|
import { escapeHtml as escape } from './catalog.mjs';
|
|
3
3
|
import { componentPath, previewMarkup, exampleKey, exampleResources, cardDescription } from './render.mjs';
|
|
4
4
|
import { valueEditor } from './value-editors.mjs';
|
|
5
|
-
import { defaultRecipe, themeFields, startingPoints, startingPointLabels, startingPointFor, deriveTheme, applyRefinement, themeCSS, validateRecipe, themePalettes, materialPresets, refinementState } from './theme.mjs';
|
|
5
|
+
import { defaultRecipe, themeFields, startingPoints, startingPointLabels, startingPointFor, deriveTheme, applyRefinement, themeCSS, validateRecipe, themePalettes, materialPresets, statusPresets, refinementState } from './theme.mjs';
|
|
6
6
|
|
|
7
7
|
export function customizerResource(site, input = defaultRecipe()) {
|
|
8
8
|
const recipe = validateRecipe(input);
|
|
9
9
|
const cardFields = ['id', 'title', 'description', 'exampleTitle', 'resizable', 'category', 'tag', 'nativeRoot', 'href', 'packageName'];
|
|
10
|
-
const examples = site.catalog.components.flatMap(component => component.examples.map(example => ({ id: example.id, title: component.title, description: cardDescription(component.description), exampleTitle: example.title, resizable: Boolean(example.resizable), category: component.group, tag: component.tag, packageName: component.package, nativeRoot: component.root ? `<${component.root}>` : '', href: site.base + componentPath(component).slice(1) })));
|
|
10
|
+
const examples = site.catalog.components.flatMap(component => component.examples.map(example => ({ id: example.id, title: component.title, description: cardDescription(component.summary ?? component.description), exampleTitle: example.title, resizable: Boolean(example.resizable), category: component.group, tag: component.tag, packageName: component.package, nativeRoot: component.root ? `<${component.root}>` : '', href: site.base + componentPath(component).slice(1) })));
|
|
11
11
|
const toCard = example => Object.fromEntries(cardFields.map(key => [key, example[key]]));
|
|
12
12
|
const initial = ['ui-button', 'ui-input', 'ui-color-picker', 'ui-checkbox', 'ui-card', 'ui-switch', 'ui-text', 'ui-dialog', 'ui-popover'].map(tag => examples.find(example => example.tag === tag && (tag !== 'ui-button' || example.id.endsWith('/02-variant')) && (tag !== 'ui-text' || example.id.endsWith('/02-variants')) && (tag !== 'ui-card' || example.id.endsWith('/04-expressive-surface'))) ?? examples.find(example => example.tag === tag)).filter(Boolean).map(toCard);
|
|
13
13
|
if (!initial.length && examples.length) initial.push(toCard(examples[0]));
|
|
@@ -50,15 +50,16 @@ export function customizerResource(site, input = defaultRecipe()) {
|
|
|
50
50
|
const swatches = tokens => `<span class="palette-swatches" aria-hidden="true">${['--ui-accent','--ui-neutral-surface','--ui-surface','--ui-text'].map(token => `<span style="background:${escape(tokens ? tokens[token] : `var(${token})`)}"></span>`).join('')}</span>`;
|
|
51
51
|
const choice = (attributes, label, value, options, content = '') => `<ui-combobox ${attributes} data-choice label="${escape(label)}" value="${escape(value)}" disclosure open-on-focus>${options}${content}</ui-combobox>`;
|
|
52
52
|
const renderPreset = (family, location) => {
|
|
53
|
-
const presets =
|
|
54
|
-
const state = refinementState(recipe, family), label =
|
|
53
|
+
const presets = { material: materialPresets, palette: themePalettes, status: statusPresets }[family];
|
|
54
|
+
const state = refinementState(recipe, family), label = { material: 'Material preset', palette: 'Palette preset', status: 'Status color relationship' }[family];
|
|
55
55
|
const origin = startingPoints[recipe.origin ?? startingPointFor(recipe)];
|
|
56
|
-
const muted = origin &&
|
|
56
|
+
const muted = origin && Object.keys(Object.values(presets)[0].values).every(key => origin.values[key] === recipe.values[key]);
|
|
57
57
|
const options = `<option value="custom" disabled>Your ${family}</option>${Object.entries(presets).map(([id, preset]) => `<option value="${id}">${escape(preset.label)}${state.id === id && state.customized ? ' · customized' : ''}</option>`).join('')}`;
|
|
58
58
|
const preview = family === 'palette' ? `<span slot="start" data-selected-palette>${swatches()}</span><template slot="option"><span class="palette-option">${Object.keys(presets).map(id => `<template $if="$option.value = '${id}'">${swatches(deriveTheme(applyRefinement(recipe, 'palette', id), { mode: 'light' }).tokens)}</template>`).join('')}<span>{$option.label}</span></span></template>` : '';
|
|
59
|
-
return
|
|
59
|
+
if (family === 'status') return `<ui-form-field><label slot="label" for="${location}-status">${label}</label><ui-select id="${location}-status" size="sm" data-refinement-preset="status" value="${state.id}"${muted ? ' muted' : ''}>${options}</ui-select></ui-form-field>`;
|
|
60
|
+
return choice(`id="${location}-${family}" data-refinement-preset="${family}"${muted ? ' muted' : ''}`, label, state.id, options, preview);
|
|
60
61
|
};
|
|
61
|
-
const paletteDetails = `<ui-grid columns="2" min="md" gap="s">${['light', 'dark'].map(mode => `<ui-card data-theme="${mode}" padding="sm"><ui-stack gap="s"><ui-text variant="eyebrow">${mode === 'light' ? 'Light' : 'Dark'}</ui-text><div class="palette-range" role="img" aria-label="${mode} canvas, content and action range"><span class="palette-canvas"></span><span class="palette-content"></span><span class="palette-action"></span></div><ui-text variant="heading" as="h3">Fellowship</ui-text><ui-text>There and back.</ui-text><ui-text variant="caption">Second breakfast at nine.</ui-text><ui-input size="sm" aria-label="${mode} neutral field" value="Shared neutral boundary"></ui-input><ui-action-bar><ui-button slot="tertiary" size="sm" variant="outline" tone="accent">Outline</ui-button><ui-button slot="secondary" size="sm" preset="standard">Neutral</ui-button><ui-button slot="primary" size="sm" preset="primary">Accent</ui-button></ui-action-bar><ui-cluster><ui-button size="sm" variant="outline" tone="neutral">Neutral outline</ui-button><ui-badge tone="accent-secondary" data-extra-accent="secondary-action">Secondary accent</ui-badge><ui-badge tone="accent-tertiary" data-extra-accent="tertiary-action">Tertiary accent</ui-badge></ui-cluster><ui-card tone="accent-secondary" data-extra-accent="secondary-action"><ui-stack gap="s"><ui-text weight="medium">A supporting highlight</ui-text><ui-text variant="caption">A category or feature can carry another accent while the main action stays primary.</ui-text></ui-stack></ui-card><ui-cluster>${[['success','Success','circle-check'],['danger','Error','circle-x'],['warning','Warning','triangle-alert'],['info','Info','info']].map(([tone,label,icon]) => `<ui-badge tone="${tone}"><ui-icon name="${icon}" slot="icon"></ui-icon>${label}</ui-badge>`).join('')}</ui-cluster><ui-callout tone="info">A status surface shares the Info badge’s colors.</ui-callout><ui-list><ui-list-item current><a href="#palette">Selected collection</a></ui-list-item></ui-list><ui-text><a href="#palette">Read the guide</a></ui-text><ui-text variant="caption" data-palette-roles="${mode}"></ui-text></ui-stack></ui-card>`).join('')}</ui-grid><ui-text variant="caption" data-palette-adjustments role="status" aria-live="polite"></ui-text><ui-disclosure summary="Resolved palette values"><ui-text variant="caption" data-palette-adjustment-details></ui-text></ui-disclosure>`;
|
|
62
|
+
const paletteDetails = `<ui-grid columns="2" min="md" gap="s">${['light', 'dark'].map(mode => `<ui-card data-theme="${mode}" padding="sm"><ui-stack gap="s"><ui-text variant="eyebrow">${mode === 'light' ? 'Light' : 'Dark'}</ui-text><div class="palette-range" role="img" aria-label="${mode} canvas, content and action range"><span class="palette-canvas"></span><span class="palette-content"></span><span class="palette-action"></span></div><ui-text variant="heading" as="h3">Fellowship</ui-text><ui-text>There and back.</ui-text><ui-text variant="caption">Second breakfast at nine.</ui-text><ui-input size="sm" aria-label="${mode} neutral field" value="Shared neutral boundary"></ui-input><ui-action-bar><ui-button slot="tertiary" size="sm" variant="outline" tone="accent">Outline</ui-button><ui-button slot="secondary" size="sm" preset="standard">Neutral</ui-button><ui-button slot="primary" size="sm" preset="primary">Accent</ui-button></ui-action-bar><ui-cluster><ui-button size="sm" variant="outline" tone="neutral">Neutral outline</ui-button><ui-badge tone="accent-secondary" data-extra-accent="secondary-action">Secondary accent</ui-badge><ui-badge tone="accent-tertiary" data-extra-accent="tertiary-action">Tertiary accent</ui-badge></ui-cluster><ui-card tone="accent-secondary" data-extra-accent="secondary-action"><ui-stack gap="s"><ui-text weight="medium">A supporting highlight</ui-text><ui-text variant="caption">A category or feature can carry another accent while the main action stays primary.</ui-text></ui-stack></ui-card><ui-cluster>${[['success','Success','circle-check'],['danger','Error','circle-x'],['warning','Warning','triangle-alert'],['info','Info','info']].map(([tone,label,icon]) => `<ui-badge tone="${tone}"><ui-icon name="${icon}" slot="icon"></ui-icon>${label}</ui-badge>`).join('')}</ui-cluster><ui-callout tone="tip">Tips share the informational color family.</ui-callout><ui-callout tone="info">A status surface shares the Info badge’s colors.</ui-callout><ui-list><ui-list-item current><a href="#palette">Selected collection</a></ui-list-item></ui-list><ui-text><a href="#palette">Read the guide</a></ui-text><ui-text variant="caption" data-palette-roles="${mode}"></ui-text></ui-stack></ui-card>`).join('')}</ui-grid><ui-text variant="caption" data-palette-adjustments role="status" aria-live="polite"></ui-text><ui-disclosure summary="Resolved palette values"><ui-text variant="caption" data-palette-adjustment-details></ui-text></ui-disclosure>`;
|
|
62
63
|
const paletteRelationships = `<ui-stack gap="s"><ui-text variant="heading" as="h3">How should the colors work together?</ui-text>${[
|
|
63
64
|
['preserve', 'Keep my colors', 'Keep the base colors as chosen. Warmth and intensity still refine the result.'],
|
|
64
65
|
['neighboring', 'Related colors', 'Tint neutral surfaces with a neighboring hue for a closely coordinated palette.'],
|
|
@@ -77,7 +78,7 @@ export function customizerResource(site, input = defaultRecipe()) {
|
|
|
77
78
|
const lightEditor = `<ui-light-editor data-light-editor x="${recipe.values['light-x']}" y="${recipe.values['light-y']}" label="Theme light position"><ui-stack gap="s"><ui-text variant="heading">Move the light</ui-text><ui-button preset="primary">Material response</ui-button></ui-stack></ui-light-editor>`;
|
|
78
79
|
const materialView = editor('material', `<ui-stack>${materialSample}${materialSurfaces}</ui-stack>`, `<ui-cluster>${renderPreset('material', 'refinement')}<ui-button data-action="restore-material">Reset material</ui-button></ui-cluster>${fieldsFor(['finish','translucency','glassiness'])}<ui-text variant="caption" data-material-dependencies role="status"></ui-text><ui-stack gap="s" data-glass-hint hidden><ui-text variant="caption">Frosting needs some transparency to reveal the scene behind the decorative rim.</ui-text><ui-button size="sm" data-action="use-glass">Use frosted glass</ui-button></ui-stack><ui-disclosure summary="Advanced material" data-advanced="material"><ui-stack>${lightEditor}${fieldsFor(['light-color','light-spread','light-strength','edge-light','glow','outer-depth','inner-depth','surface-separation'])}</ui-stack></ui-disclosure><ui-disclosure summary="Try floating surfaces"><ui-stack>${documentationCard('ui-card','/04-expressive-surface')}${documentationCard('ui-tooltip')}${documentationCard('ui-popover')}${documentationCard('ui-dialog')}</ui-stack></ui-disclosure>`);
|
|
79
80
|
const statusControls = ['success','danger','warning','info'].map(role => fieldsFor([role + '-source'])).join('');
|
|
80
|
-
const paletteView = refinement('palette', `<ui-cluster>${renderPreset('palette', 'refinement')}<ui-button data-action="restore-palette">Reset palette</ui-button></ui-cluster><div class="refinement-layout"><div class="palette-preview"><ui-stack>${paletteDetails}</ui-stack></div><ui-stack><ui-text variant="heading" as="h3">Base colors</ui-text><ui-text variant="caption">Primary is the main voice. Add supporting accents where they help; status colors keep their own meanings.</ui-text>${fieldsFor(['action','canvas','surface','text'])}<ui-disclosure summary="Supporting accents"><ui-stack>${fieldsFor(['secondary-action','tertiary-action'])}</ui-stack></ui-disclosure><ui-disclosure summary="Neutrals & shared borders" data-advanced="neutrals"><ui-stack>${fieldsFor(['neutral-source','neutral-strength','neutral-border-contrast'])}<ui-text variant="caption">Neutral solid and outline buttons and form fields use this same border. Raising the minimum changes the whole family.</ui-text></ui-stack></ui-disclosure><ui-
|
|
81
|
+
const paletteView = refinement('palette', `<ui-cluster>${renderPreset('palette', 'refinement')}<ui-button data-action="restore-palette">Reset palette</ui-button></ui-cluster><div class="refinement-layout"><div class="palette-preview"><ui-stack>${paletteDetails}</ui-stack></div><ui-stack><ui-text variant="heading" as="h3">Base colors</ui-text><ui-text variant="caption">Primary is the main voice. Add supporting accents where they help; status colors keep their own meanings.</ui-text>${fieldsFor(['action','canvas','surface','text'])}<ui-disclosure summary="Supporting accents"><ui-stack>${fieldsFor(['secondary-action','tertiary-action'])}</ui-stack></ui-disclosure><ui-disclosure summary="Neutrals & shared borders" data-advanced="neutrals"><ui-stack>${fieldsFor(['neutral-source','neutral-strength','neutral-border-contrast'])}<ui-text variant="caption">Neutral solid and outline buttons and form fields use this same border. Raising the minimum changes the whole family.</ui-text></ui-stack></ui-disclosure><ui-text variant="heading" as="h3">Status colors</ui-text><ui-cluster align="end">${renderPreset('status', 'refinement')}<ui-button size="sm" data-action="restore-status">Reset status colors</ui-button></ui-cluster><ui-text variant="caption">Keep semantic hues, use less color, or let the primary accent carry every status while icons and labels distinguish meanings. Info and Tip share one family.</ui-text><ui-disclosure summary="Advanced status relationships" data-advanced="status"><ui-stack>${statusControls}${fieldsFor(['status-chroma'])}<ui-text variant="caption">Keep semantic hues, harmonize them with your brand, or use an accent family. Looma derives readable fills and text; labels and icons keep states identifiable when colors are shared. Supporting accents follow primary until enabled.</ui-text></ui-stack></ui-disclosure><ui-disclosure summary="Accent assignments" data-advanced="assignments"><ui-stack>${fieldsFor(['selection-accent','focus-accent','link-accent'])}</ui-stack></ui-disclosure><ui-disclosure summary="Adjust color character"><ui-stack>${fieldsFor(['warmth','color-intensity'])}</ui-stack></ui-disclosure><ui-disclosure summary="Color relationships">${paletteRelationships}</ui-disclosure></ui-stack></div>`);
|
|
81
82
|
const options = site.catalog.groups.map(group => `<optgroup label="${escape(group.label)}">${examples.filter(example => example.category === group.id).map(example => `<option value="${escape(example.id)}" data-description="${escape(example.category + ' · ' + example.tag)}" data-example="${escape(JSON.stringify(example))}" data-search="${escape(`${example.title} ${example.tag} ${example.description} ${example.exampleTitle}`.toLocaleLowerCase())}">${escape(example.title)} · ${escape(example.exampleTitle)}</option>`).join('')}</optgroup>`).join('');
|
|
82
83
|
const links = ['ui-action-bar','ui-stack','ui-grid','ui-cluster','ui-form-field','ui-input','ui-select','ui-color-picker','ui-button','ui-disclosure','ui-textarea','ui-number-input','ui-slider','ui-curve-editor','ui-card','ui-text','ui-light-editor','ui-combobox','ui-checkbox','ui-badge','ui-icon','ui-callout','ui-popover','ui-dialog','ui-list','ui-list-item'].map(tag => `<link rel="component" href="@threadlabs/looma/components/${tag}/${tag}.html">`).join('\n');
|
|
83
84
|
return `${links}\n${exampleResources(site.catalog.components.flatMap(component => component.examples), site.catalog)}\n<link rel="component" href="./card.html">\n<link rel="component" href="./preview-choice.html">\n<template component="looma-customizer" module="./customizer.js"><defs>
|
package/docs/customizer.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { googleFontStack, systemFont, loadGoogleFonts } from './fonts.mjs';
|
|
2
2
|
import { documentationTheme, themeEvent } from './theme-session.mjs';
|
|
3
3
|
import { componentRegistry } from '@nextwebwg/html-next/runtime';
|
|
4
|
-
import { startingPoints, startingPointFor, startingPointLabels, themeCSS, validateRecipe, themeFields, themePalettes, materialPresets, applyRefinement, refinementState, deriveTheme } from './theme.mjs';
|
|
4
|
+
import { startingPoints, startingPointFor, startingPointLabels, themeCSS, validateRecipe, themeFields, themePalettes, materialPresets, statusPresets, applyRefinement, refinementState, deriveTheme } from './theme.mjs';
|
|
5
5
|
|
|
6
6
|
import { valueEditor, editorValue, convertValueUnit } from './value-editors.mjs';
|
|
7
7
|
|
|
@@ -133,8 +133,8 @@ export function connect(host) {
|
|
|
133
133
|
if (field?.type.includes('length') && field.id !== 'text-size') updateControl(control, recipe.values[field.id]);
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
-
for (const family of ['material','palette']) {
|
|
137
|
-
const state = refinementState(recipe, family), presets =
|
|
136
|
+
for (const family of ['material','palette','status']) {
|
|
137
|
+
const state = refinementState(recipe, family), presets = { material: materialPresets, palette: themePalettes, status: statusPresets }[family];
|
|
138
138
|
for (const select of root.querySelectorAll(`[data-refinement-preset="${family}"]`)) {
|
|
139
139
|
for (const option of select.querySelectorAll('option')) if (presets[option.value]) {
|
|
140
140
|
const label = presets[option.value].label + (state.id === option.value && state.customized ? ' · customized' : '');
|
|
@@ -142,7 +142,7 @@ export function connect(host) {
|
|
|
142
142
|
}
|
|
143
143
|
updateControl(select, state.id);
|
|
144
144
|
const origin = startingPoints[recipe.origin ?? startingPointFor(recipe)];
|
|
145
|
-
const muted = Boolean(origin &&
|
|
145
|
+
const muted = Boolean(origin && Object.keys(Object.values(presets)[0].values).every(key => origin.values[key] === recipe.values[key]));
|
|
146
146
|
componentRegistry.update(select, { muted });
|
|
147
147
|
}
|
|
148
148
|
componentRegistry.update(root.querySelector(`[data-action="restore-${family}"]`), { disabled: state.id === 'custom' || !state.customized });
|
|
@@ -231,7 +231,7 @@ export function connect(host) {
|
|
|
231
231
|
const refinedRecipe = values => {
|
|
232
232
|
if (recipe.values['display-font'] === recipe.values['body-font'] && values['display-font'] === recipe.values['display-font']) values = { ...values, 'display-font': values['body-font'] };
|
|
233
233
|
const presets = { ...recipe.presets };
|
|
234
|
-
for (const family of ['material', 'palette']) {
|
|
234
|
+
for (const family of ['material', 'palette', 'status']) {
|
|
235
235
|
const state = refinementState(recipe, family);
|
|
236
236
|
if (!presets[family] && state.id !== 'custom') presets[family] = state.id;
|
|
237
237
|
}
|
|
@@ -310,9 +310,9 @@ export function connect(host) {
|
|
|
310
310
|
}
|
|
311
311
|
case 'back': navigate(''); break;
|
|
312
312
|
case 'use-glass': show(applyRefinement(recipe, 'material', 'glass')); sayApplied('Frosted glass applied. Your colors and type are unchanged.'); break;
|
|
313
|
-
case 'restore-material': case 'restore-palette': {
|
|
313
|
+
case 'restore-material': case 'restore-palette': case 'restore-status': {
|
|
314
314
|
const family = button.dataset.action.slice(8), state = refinementState(recipe, family);
|
|
315
|
-
if (state.id !== 'custom') { show(applyRefinement(recipe, family, state.id)); sayApplied(`${
|
|
315
|
+
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.`); }
|
|
316
316
|
break;
|
|
317
317
|
}
|
|
318
318
|
case 'add': {
|
|
@@ -390,7 +390,7 @@ export function connect(host) {
|
|
|
390
390
|
if (event.target.matches('[data-refinement-preset]')) {
|
|
391
391
|
const family = event.target.dataset.refinementPreset;
|
|
392
392
|
show(applyRefinement(recipe, family, value));
|
|
393
|
-
sayApplied(`${
|
|
393
|
+
sayApplied(`${{ material: 'Material', palette: 'Coordinated palette', status: 'Status color relationship' }[family]} preset applied and remembered in both modes.`);
|
|
394
394
|
}
|
|
395
395
|
if (event.target.matches('[data-preset]')) { show({ ...structuredClone(startingPoints[value]), origin: value }); sayApplied('Starting point applied throughout the documentation and remembered in this browser.'); }
|
|
396
396
|
if (event.target === file && file.files[0]) {
|
package/docs/documentation.css
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
[data-example-card] pre { overflow: auto; }
|
|
5
5
|
/* The customizer is an application page; use Markupress's public width token instead of patching its layout. */
|
|
6
6
|
:root:has([data-looma-customizer]), :root:has([data-component~="looma-catalog"]) { --markupress-content-width: 110rem; }
|
|
7
|
-
[data-preview] { display: grid; place-items: center; gap: var(--ui-space-4); min-inline-size: 0; min-block-size: 13rem; padding: var(--ui-space-4); box-sizing: border-box; color: var(--ui-text); font-family: var(--ui-font-sans); font-size: var(--ui-font-size); line-height: var(--ui-line-height); background:
|
|
7
|
+
[data-preview] { display: grid; place-items: center; gap: var(--ui-space-4); min-inline-size: 0; min-block-size: 13rem; padding: var(--ui-space-4); box-sizing: border-box; color: var(--ui-text); font-family: var(--ui-font-sans); font-size: var(--ui-font-size); line-height: var(--ui-line-height); background: var(--ui-surface-raised); }
|
|
8
8
|
[data-preview-layout] { justify-items: stretch; }
|
|
9
9
|
|
|
10
10
|
/* These headings are authored page content projected through the example card's heading slot. */
|
|
11
11
|
.looma-reference-examples { padding-block-start: var(--ui-space-5); }
|
|
12
12
|
.looma-example-heading h3 { margin: 0; font-size: var(--ui-font-size-lg); line-height: var(--ui-line-height-tight); }
|
|
13
13
|
.looma-example-heading p { margin: var(--ui-space-2) 0 0; font-size: var(--ui-font-size-sm); color: var(--ui-text-secondary); }
|
|
14
|
-
[data-example-card][reference] [data-preview] { min-block-size: 11rem; background: var(--ui-surface); }
|
|
14
|
+
[data-example-card][reference] [data-preview] { min-block-size: 11rem; background: var(--ui-surface-raised); }
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { componentRegistry } from "@nextwebwg/html-next/runtime";
|
|
2
|
+
export default function setupExample(root) {
|
|
3
|
+
const popover = root.querySelector('[data-note-popover]');
|
|
4
|
+
const editor = root.querySelector('[data-note-editor]');
|
|
5
|
+
const done = () => { if (popover)
|
|
6
|
+
componentRegistry.update(popover, { open: false }); };
|
|
7
|
+
editor?.addEventListener("done", done);
|
|
8
|
+
return () => editor?.removeEventListener("done", done);
|
|
9
|
+
}
|
package/docs/fonts.mjs
CHANGED
|
@@ -5,7 +5,7 @@ export const googleFonts = Object.fromEntries([
|
|
|
5
5
|
['DM Sans', 'sans-serif'], ['Manrope', 'sans-serif'], ['Work Sans', 'sans-serif'],
|
|
6
6
|
['IBM Plex Sans', 'sans-serif'], ['Public Sans', 'sans-serif'], ['Atkinson Hyperlegible', 'sans-serif'],
|
|
7
7
|
['Outfit', 'sans-serif'], ['Fraunces', 'serif'], ['Merriweather', 'serif'], ['Lora', 'serif'],
|
|
8
|
-
['Source Serif 4', 'serif'], ['Libre Baskerville', 'serif'], ['Crimson Pro', 'serif'],
|
|
8
|
+
['Source Serif 4', 'serif'], ['Newsreader', 'serif'], ['Libre Baskerville', 'serif'], ['Crimson Pro', 'serif'],
|
|
9
9
|
['EB Garamond', 'serif'], ['Playfair Display', 'serif'], ['Roboto Mono', 'monospace'],
|
|
10
10
|
['IBM Plex Mono', 'monospace'], ['JetBrains Mono', 'monospace'], ['Fira Code', 'monospace'],
|
|
11
11
|
].map(([family, category]) => [family, { family, category, weights: ['Lato', 'Atkinson Hyperlegible', 'Libre Baskerville'].includes(family) ? '400;700' : '400;500;600;700' }]));
|
package/docs/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { readCatalog, discoverComponents, mergeCatalogs } from './catalog.mjs';
|
|
2
2
|
export { prepareDocumentation, documentationOptions, documentationPlugin, buildDocumentation } from './site.mjs';
|
|
3
|
-
export { defaultRecipe, startingPoints, themeFields, validateRecipe, deriveTheme, themeCSS, materialPresets, applyRefinement, refinementState } from './theme.mjs';
|
|
3
|
+
export { defaultRecipe, startingPoints, themeFields, validateRecipe, deriveTheme, themeCSS, materialPresets, statusPresets, applyRefinement, refinementState } from './theme.mjs';
|
|
4
4
|
export { initializeDocumentation, buildProjectDocumentation, devProjectDocumentation, previewProjectDocumentation, readConfiguration } from './commands.mjs';
|
package/docs/render.mjs
CHANGED
|
@@ -101,7 +101,7 @@ export function exampleCodes(example, component, components) {
|
|
|
101
101
|
|
|
102
102
|
/** The same card invocation is embedded in reference pages and rendered by the customizer. */
|
|
103
103
|
export function cardMarkup(example, base = '/', component = {}, { reference = false, code: exampleCode = '' } = {}) {
|
|
104
|
-
return `<looma-example-card identity="${escape(example.id)}"${reference ? ' reference' : ''} title="${escape(component.title ?? example.title)}" description="${escape(reference ? example.description : cardDescription(component.description ?? example.description))}" example-title="${escape(example.title)}" category="${escape(component.group ?? 'forms')}" tag="${escape(component.tag ?? '')}" package-name="${escape(component.package ?? '')}" native-root="${escape(component.root ? `<${component.root}>` : '')}" href="${component.tag ? base + componentPath(component).slice(1) : ''}"${example.resizable ? ' resizable' : ''}>${previewMarkup(example, `${reference ? 'reference' : 'catalog'}-${exampleKey(example.id)}`, base, component.group === 'layout')}${reference ? `<div slot="heading" class="looma-example-heading"><h3 id="example-${exampleKey(example.id)}">${escape(example.title)}</h3><p>${escape(example.description)}</p></div>` : ''}${exampleCode}</looma-example-card>`;
|
|
104
|
+
return `<looma-example-card identity="${escape(example.id)}"${reference ? ' reference' : ''} title="${escape(component.title ?? example.title)}" description="${escape(reference ? example.description : cardDescription(component.summary ?? component.description ?? example.description))}" example-title="${escape(example.title)}" category="${escape(component.group ?? 'forms')}" tag="${escape(component.tag ?? '')}" package-name="${escape(component.package ?? '')}" native-root="${escape(component.root ? `<${component.root}>` : '')}" href="${component.tag ? base + componentPath(component).slice(1) : ''}"${example.resizable ? ' resizable' : ''}>${previewMarkup(example, `${reference ? 'reference' : 'catalog'}-${exampleKey(example.id)}`, base, component.group === 'layout')}${reference ? `<div slot="heading" class="looma-example-heading"><h3 id="example-${exampleKey(example.id)}">${escape(example.title)}</h3><p>${escape(example.description)}</p></div>` : ''}${exampleCode}</looma-example-card>`;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
export function referencePage(component, catalog, cardResource, base) {
|
package/docs/site.mjs
CHANGED
|
@@ -83,7 +83,8 @@ export async function prepareDocumentation({ root, config = {}, catalog }) {
|
|
|
83
83
|
const card = path.join(generated, 'card.html');
|
|
84
84
|
await cp(own('card.html'), card);
|
|
85
85
|
await cp(own('card.js'), path.join(generated, 'card.js'));
|
|
86
|
-
|
|
86
|
+
const catalogGroups = combined.groups.filter(group => combined.components.some(component => component.group === group.id && !component.navigationParent));
|
|
87
|
+
await writeFile(path.join(generated, 'catalog-view.html'), catalogResource(catalogGroups, base));
|
|
87
88
|
await cp(own('catalog-view.js'), path.join(generated, 'catalog-view.js'));
|
|
88
89
|
for (const file of ['reference.html', 'reference.js']) await cp(own(file), path.join(generated, file));
|
|
89
90
|
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));
|
|
@@ -112,12 +113,20 @@ export async function prepareDocumentation({ root, config = {}, catalog }) {
|
|
|
112
113
|
examples.push({ ...example, file, component: component.id, path: base + componentPath(component).slice(1) });
|
|
113
114
|
}
|
|
114
115
|
}
|
|
115
|
-
const gallery =
|
|
116
|
+
const gallery = selected => catalogGroups.filter(group => !selected || group.id === selected).map(group => {
|
|
116
117
|
const components = combined.components.filter(c => c.group === group.id && !c.navigationParent);
|
|
117
118
|
// A standalone opening tag makes this a Markdown HTML block, keeping native card wrappers inside Grid.
|
|
118
|
-
return components.length ? `<section data-catalog-group="${escapeHtml(group.id)}">\n\n
|
|
119
|
+
return components.length ? `<section data-catalog-group="${escapeHtml(group.id)}" aria-label="${escapeHtml(group.label)} components">\n\n${selected ? '' : `## ${escapeHtml(group.label)}\n\n`}<ui-grid columns="3" min="sm">\n${components.map(component => `<div data-category="${escapeHtml(component.group)}" data-catalog-search="${escapeHtml(`${component.tag} ${component.title} ${component.summary ?? ''} ${component.description}`)}">${cardMarkup(component.examples[0], base, component)}</div>`).join('\n')}\n</ui-grid>\n\n</section>` : '';
|
|
119
120
|
}).join('\n\n');
|
|
120
|
-
|
|
121
|
+
const writeCatalog = async (file, title, selected = '') => {
|
|
122
|
+
const total = combined.components.filter(component => !component.navigationParent && (!selected || component.group === selected)).length;
|
|
123
|
+
await write(file, `---\ntitle: ${JSON.stringify(title)}\noutline: false\n${selected ? 'navigation: overview\norder: 0\n' : ''}---\n\n# ${escapeHtml(title)}\n\nExplore the live examples that also power your theme customizer.\n\n<link rel="component" href="${relativeHref(file, card)}">\n${exampleResources(combined.components.filter(component => !component.navigationParent && (!selected || component.group === selected)).map(component => component.examples[0]), combined)}\n<link rel="component" href="@threadlabs/looma/components/ui-grid/ui-grid.html">\n<link rel="component" href="${relativeHref(file, path.join(generated, 'catalog-view.html'))}">\n\n<looma-catalog category="${escapeHtml(selected)}" total="${total}">\n\n${gallery(selected)}\n\n</looma-catalog>\n`);
|
|
124
|
+
};
|
|
125
|
+
await writeCatalog(path.join(content, 'components/index.md'), 'Components');
|
|
126
|
+
for (const group of catalogGroups) {
|
|
127
|
+
await writeCatalog(path.join(content, 'components', groupDirectories.get(group.id), `00.${group.id}.md`), group.label, group.id);
|
|
128
|
+
generatedReferences.add(`components/${group.id}.md`);
|
|
129
|
+
}
|
|
121
130
|
await write(path.join(content, 'index.md'), `---\ntitle: ${JSON.stringify(config.title ?? 'Your design system')}\n---\n\n# ${config.title ?? 'Your design system'}\n\nWeave your design system from Looma and your own HTML Next components.\n\n[Explore components](/components/) · [Customize your theme](/customize/)\n`);
|
|
122
131
|
if (combined.components.some(component => component.group === 'editor')) await write(path.join(content, 'editor.md'), `---\ntitle: Editor\nsidebar: false\n---\n\n# Editor\n\nWriting tools and editor components, separate from the general component reference.\n\n${combined.components.filter(component => component.group === 'editor' && !component.navigationParent).map(component => `- [${component.title}](${componentPath(component)})`).join('\n')}\n`);
|
|
123
132
|
await write(path.join(content, 'design-system.md'), await readFile(own('README.md'), 'utf8'));
|
|
@@ -174,7 +183,7 @@ export function documentationPlugin(site) {
|
|
|
174
183
|
export async function documentationOptions(site) {
|
|
175
184
|
const { siteOptions } = await tool('markupress', site.root);
|
|
176
185
|
const styles = ['tokens.css', 'theme-light.css', 'theme-dark.css', 'theme-system.css'].map(file => fileURLToPath(import.meta.resolve(`@threadlabs/looma/${file}`)));
|
|
177
|
-
const options = siteOptions({ root: site.root, contentDir: path.relative(site.root, site.content), title: site.config.title ?? 'Your design system', headerNotice: 'Custom theme', base: site.base, outDir: site.config.outDir ?? 'site', ...(site.config.origin ? { origin: site.config.origin } : {}), ...(site.config.logo ? { logo: site.config.logo } : {}), ...(site.config.nav ? { nav: site.config.nav } : {}) }, { plugins: [documentationPlugin(site)], css: styles, redirects: site.redirects });
|
|
186
|
+
const options = siteOptions({ root: site.root, contentDir: path.relative(site.root, site.content), title: site.config.title ?? 'Your design system', headerNotice: 'Custom theme', sidebarNavigation: 'sections', base: site.base, outDir: site.config.outDir ?? 'site', ...(site.config.origin ? { origin: site.config.origin } : {}), ...(site.config.logo ? { logo: site.config.logo } : {}), ...(site.config.nav ? { nav: site.config.nav } : {}) }, { plugins: [documentationPlugin(site)], css: styles, redirects: site.redirects });
|
|
178
187
|
const savedTheme = path.join(site.generated, 'saved-theme.css');
|
|
179
188
|
const recipe = site.config.recipe ?? defaultRecipe();
|
|
180
189
|
const overrides = await Promise.all((site.config.overrides ?? []).map(file => readFile(path.resolve(site.root, file), 'utf8')));
|
package/docs/theme.mjs
CHANGED
|
@@ -13,7 +13,7 @@ const statusChoices = { derived: 'Semantic hue', related: 'Harmonize with primar
|
|
|
13
13
|
const neutralChoices = { text: 'Derive from text', ...brandChoices, gray: 'Untinted gray' };
|
|
14
14
|
const relationshipChoices = { preserve: 'Preserve seed hues', neighboring: 'Neighboring hues', complementary: 'Complementary hues' };
|
|
15
15
|
const choicesFor = id => id === 'neutral-source' ? neutralChoices : id.endsWith('-source') ? statusChoices : id.endsWith('-accent') ? brandChoices : relationshipChoices;
|
|
16
|
-
const statusSeeds = { danger: '#c92d1e', success: '#007a33', warning: '#
|
|
16
|
+
const statusSeeds = { danger: '#c92d1e', success: '#007a33', warning: '#b27522', info: '#0066cc' };
|
|
17
17
|
|
|
18
18
|
/** The shared authoring schema; ids remain stable in saved recipes. */
|
|
19
19
|
export const themeFields = [
|
|
@@ -23,7 +23,7 @@ export const themeFields = [
|
|
|
23
23
|
['Colour', 'neutral-source', 'Neutral relationship', null, 'choice', 'text', 'Derive restrained neutrals from text, an accent family or an untinted gray. Shared border contrast and readable labels stay governed.'],
|
|
24
24
|
['Colour', 'neutral-strength', 'Neutral fill strength', null, 'fraction', '0.25', 'How much neutral pigment appears in quiet filled controls. Borders remain shared with fields.'],
|
|
25
25
|
['Colour', 'neutral-border-contrast', 'Neutral border contrast', null, 'ratio', '2', 'Minimum border-to-surface contrast for neutral buttons and form fields. 2:1 is the balanced default; raise it for stronger boundaries.'],
|
|
26
|
-
['Colour', 'status-chroma', 'Derived status saturation', null, 'fraction', '0.5', '
|
|
26
|
+
['Colour', 'status-chroma', 'Derived status saturation', null, 'fraction', '0.5', 'Coordinate derived status pigment, text and quiet tints with the primary accent. Brand mappings keep the chosen family intact.'],
|
|
27
27
|
['Colour', 'success-source', 'Success relationship', null, 'choice', 'derived', 'Choose a semantic hue, harmonize it with primary, or use a governed brand-accent family.'],
|
|
28
28
|
['Colour', 'danger-source', 'Error relationship', null, 'choice', 'derived', 'Choose a semantic hue, harmonize it with primary, or use a governed brand-accent family.'],
|
|
29
29
|
['Colour', 'warning-source', 'Warning relationship', null, 'choice', 'derived', 'Choose a semantic hue, harmonize it with primary, or use a governed brand-accent family.'],
|
|
@@ -68,17 +68,66 @@ export const themeFields = [
|
|
|
68
68
|
|
|
69
69
|
const baseRecipe = () => ({ schemaVersion: 1, values: Object.fromEntries(themeFields.map(field => [field.id, field.defaultValue])) });
|
|
70
70
|
const starting = values => ({ schemaVersion: 1, values: { ...baseRecipe().values, ...values } });
|
|
71
|
+
const fontStarting = (values, body, display) => ({
|
|
72
|
+
...starting({ ...values, 'body-font': googleFontStack(body), 'display-font': googleFontStack(display) }),
|
|
73
|
+
fonts: { 'body-font': body, 'display-font': display },
|
|
74
|
+
});
|
|
71
75
|
/** The documentation starts with Looma's coordinated identity; Clear keeps the neutral baseline. */
|
|
72
76
|
export const defaultRecipe = () => ({ ...starting({ action: '#7658d6', canvas: '#fbf9f4', surface: '#ffffff', text: '#2b2538', 'body-font': googleFontStack('Manrope'), 'display-font': googleFontStack('Manrope'), 'text-size': '17px' }), fonts: { 'body-font': 'Manrope', 'display-font': 'Manrope' } });
|
|
73
77
|
export const startingPoints = {
|
|
74
78
|
looma: defaultRecipe(),
|
|
75
|
-
clear:
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
clear: { ...starting({
|
|
80
|
+
'neutral-source': 'gray', 'neutral-strength': '0.18', 'neutral-border-contrast': '2.2', 'status-chroma': '0.1',
|
|
81
|
+
'corner-roundness': '6px', 'outer-depth': '0.2', 'inner-depth': '0', 'response-time': '100ms',
|
|
82
|
+
}), presets: { status: 'restrained' } },
|
|
83
|
+
gold: { ...fontStarting({
|
|
84
|
+
action: '#ffb84d', 'secondary-action': '#704d7b', canvas: '#ffffff', surface: '#ffffff', text: '#171717',
|
|
85
|
+
'neutral-source': 'primary', 'neutral-strength': '0.18', 'neutral-border-contrast': '2.1',
|
|
86
|
+
'info-source': 'secondary', 'status-chroma': '0.25', 'selection-accent': 'secondary', 'link-accent': 'secondary',
|
|
87
|
+
'text-size': '17px', 'label-size': '16px', 'corner-roundness': '16px', finish: '0.55', 'light-x': '0',
|
|
88
|
+
}, 'Lato', 'Fraunces'), presets: { status: 'semantic' } },
|
|
89
|
+
bookish: { ...fontStarting({
|
|
90
|
+
action: '#2e1228', 'secondary-action': '#fc5b69', 'tertiary-action': '#896853',
|
|
91
|
+
canvas: '#f7f7f5', surface: '#fffefd', text: '#0d0c0c',
|
|
92
|
+
'neutral-source': 'primary', 'neutral-strength': '0.18', 'neutral-border-contrast': '2.1',
|
|
93
|
+
'info-source': 'primary', 'success-source': 'primary', 'status-chroma': '0.1', 'focus-accent': 'secondary',
|
|
94
|
+
rhythm: '1.05', 'text-weight': '400', 'control-roominess': '2.625', 'scale-contrast': '1.18', 'corner-roundness': '6px',
|
|
95
|
+
'outer-depth': '1', 'inner-depth': '1', glassiness: '0.8', 'surface-separation': '0.65', translucency: '0.18',
|
|
96
|
+
'edge-light': '1', finish: '0.85', glow: '0.3', 'light-spread': '0.3', 'light-strength': '0.9',
|
|
97
|
+
'response-time': '150ms', 'response-curve': 'ease',
|
|
98
|
+
}, 'Open Sans', 'Newsreader'), presets: { status: 'restrained' } },
|
|
78
99
|
wiki: starting({ rhythm: '0.95', 'text-weight': '400', 'space-curve': '0.8', action: '#4f46e5', canvas: '#ffffff', surface: '#ffffff', text: '#1a1a1a', 'control-roominess': '2.125', spacing: '0.95', 'scale-contrast': '1.15', 'corner-roundness': '6px', 'outer-depth': '0.35', 'inner-depth': '0', 'response-time': '110ms' }),
|
|
79
|
-
editorial: starting({
|
|
80
|
-
|
|
81
|
-
|
|
100
|
+
editorial: { ...starting({
|
|
101
|
+
action: '#182c24', 'secondary-action': '#9d4f38', 'tertiary-action': '#92743d',
|
|
102
|
+
canvas: '#eee9dc', surface: '#fffdf5', text: '#182c24',
|
|
103
|
+
'neutral-source': 'primary', 'neutral-strength': '0.12', 'neutral-border-contrast': '2.4',
|
|
104
|
+
'success-source': 'primary', 'info-source': 'primary', 'warning-source': 'primary', 'danger-source': 'primary',
|
|
105
|
+
'link-accent': 'secondary', 'focus-accent': 'secondary',
|
|
106
|
+
rhythm: '1.3', 'text-size': '17px', 'label-size': '16px', spacing: '1.12', 'space-curve': '1.4', 'scale-contrast': '1.3',
|
|
107
|
+
'body-font': 'Georgia, serif', 'display-font': 'Georgia, serif', 'text-weight': '400',
|
|
108
|
+
'corner-roundness': '0px', 'outer-depth': '0', 'inner-depth': '0', 'line-weight': '2px',
|
|
109
|
+
'response-time': '90ms', 'response-curve': 'linear',
|
|
110
|
+
}), presets: { status: 'primary' } },
|
|
111
|
+
night: { ...fontStarting({
|
|
112
|
+
action: '#a7b8ff', 'secondary-action': '#68bfc2', 'tertiary-action': '#d0a56b',
|
|
113
|
+
canvas: '#11141c', surface: '#202634', text: '#edf1fb',
|
|
114
|
+
'neutral-source': 'primary', 'neutral-strength': '0.3', 'neutral-border-contrast': '2.2',
|
|
115
|
+
'success-source': 'secondary', 'info-source': 'primary', 'warning-source': 'tertiary', 'status-chroma': '0.3',
|
|
116
|
+
'selection-accent': 'secondary', 'link-accent': 'secondary',
|
|
117
|
+
rhythm: '1.05', 'text-weight': '500', 'control-roominess': '2.375', spacing: '1.05', 'scale-contrast': '1.25',
|
|
118
|
+
'corner-roundness': '12px', finish: '0.6', glow: '0.45', glassiness: '0.45', 'surface-separation': '0.25',
|
|
119
|
+
'light-x': '0.25', 'light-spread': '0.65', 'outer-depth': '1.4', 'inner-depth': '0.45', translucency: '0.2', 'edge-light': '0.65',
|
|
120
|
+
'response-time': '210ms', 'response-curve': 'cubic-bezier(0.2,0.8,0.2,1)',
|
|
121
|
+
}, 'IBM Plex Sans', 'IBM Plex Mono'), presets: { status: 'semantic' } },
|
|
122
|
+
garden: { ...fontStarting({
|
|
123
|
+
action: '#256342', 'secondary-action': '#b9684b', 'tertiary-action': '#b9973e',
|
|
124
|
+
canvas: '#f4edda', surface: '#fff8e7', text: '#173121',
|
|
125
|
+
'neutral-source': 'primary', 'neutral-strength': '0.2', 'neutral-border-contrast': '2',
|
|
126
|
+
'success-source': 'primary', 'info-source': 'primary', 'warning-source': 'tertiary', 'status-chroma': '0.2', 'focus-accent': 'secondary',
|
|
127
|
+
rhythm: '1.2', 'text-weight': '400', 'space-curve': '1.15', 'control-roominess': '2.875', 'scale-contrast': '1.24', spacing: '1.05',
|
|
128
|
+
'corner-roundness': '22px', finish: '0.15', 'light-spread': '1', 'outer-depth': '0.35', 'inner-depth': '0', 'edge-light': '0.2',
|
|
129
|
+
'response-time': '180ms', 'response-curve': 'cubic-bezier(0.16,1,0.3,1)',
|
|
130
|
+
}, 'Nunito Sans', 'Lora'), presets: { status: 'semantic' } },
|
|
82
131
|
};
|
|
83
132
|
export const startingPointLabels = { looma: 'Looma', clear: 'Clear', gold: 'Gold', bookish: 'Bookish', wiki: 'Wiki', editorial: 'Editorial', night: 'Night', garden: 'Garden' };
|
|
84
133
|
const paletteKeys = themeFields.filter(field => field.family === 'Colour').map(field => field.id);
|
|
@@ -97,7 +146,21 @@ export const materialPresets = {
|
|
|
97
146
|
polished: material('Polished', { 'outer-depth': '1', 'inner-depth': '1', 'edge-light': '1', finish: '0.85', glow: '0.3', 'light-spread': '0.3', 'light-strength': '0.9' }),
|
|
98
147
|
glass: material('Frosted glass', startingPoints.bookish.values),
|
|
99
148
|
};
|
|
100
|
-
const
|
|
149
|
+
const status = (label, source, chroma) => ({ label, values: {
|
|
150
|
+
...Object.fromEntries(Object.keys(statusSeeds).map(role => [role + '-source', source])), 'status-chroma': chroma,
|
|
151
|
+
} });
|
|
152
|
+
export const statusPresets = {
|
|
153
|
+
semantic: status('Semantic colors', 'derived', '0.5'),
|
|
154
|
+
restrained: status('Less color', 'derived', '0.1'),
|
|
155
|
+
primary: status('Primary + icons', 'primary', '0.5'),
|
|
156
|
+
};
|
|
157
|
+
const refinementPresets = family => {
|
|
158
|
+
switch (family) {
|
|
159
|
+
case 'material': return materialPresets;
|
|
160
|
+
case 'palette': return themePalettes;
|
|
161
|
+
case 'status': return statusPresets;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
101
164
|
|
|
102
165
|
/** Preset provenance is optional recipe data, never a second source of theme values. */
|
|
103
166
|
export function refinementState(input, family) {
|
|
@@ -268,6 +331,17 @@ const actionBoundary = (fill, surfaces, ink, amplitude) => {
|
|
|
268
331
|
return mix(surfaceOffset(surfaces[1], ink, amplitude), fill, shortfall ** 2);
|
|
269
332
|
};
|
|
270
333
|
|
|
334
|
+
// Adjust semantic ink in lightness before sacrificing its hue or chroma. Mixing
|
|
335
|
+
// amber toward black also removes its color, making a readable warning look brown.
|
|
336
|
+
function readableTone(seed, surfaces, minimum, endpoint) {
|
|
337
|
+
const [l, c, h] = toLch(seed), end = toLch(endpoint)[0];
|
|
338
|
+
for (let step = 0; step <= 256; step++) {
|
|
339
|
+
const next = fromLch([l + (end - l) * step / 256, c, h]);
|
|
340
|
+
if (surfaces.every(surface => contrast(next, surface) >= minimum)) return next;
|
|
341
|
+
}
|
|
342
|
+
return endpoint;
|
|
343
|
+
}
|
|
344
|
+
|
|
271
345
|
const paletteCache = new Map();
|
|
272
346
|
export function deriveTheme(input, { mode } = {}) {
|
|
273
347
|
if (mode !== undefined && !['light', 'dark'].includes(mode)) throw new Error('Unknown theme color mode.');
|
|
@@ -308,16 +382,17 @@ export function deriveTheme(input, { mode } = {}) {
|
|
|
308
382
|
const accents = { primary: seeds.action, secondary: seeds['secondary-action'], tertiary: seeds['tertiary-action'] };
|
|
309
383
|
const tones = { accent: accents.primary, 'accent-secondary': accents.secondary, 'accent-tertiary': accents.tertiary };
|
|
310
384
|
const brandChroma = Math.min(.20, Math.max(.08, toLch(accents.primary)[1]));
|
|
311
|
-
for (const role of
|
|
385
|
+
for (const role of Object.keys(statusSeeds)) {
|
|
312
386
|
const source = values[role + '-source'];
|
|
313
387
|
if (source === 'derived' || source === 'related') {
|
|
314
|
-
let [l, , h] = toLch(statusSeeds[role]);
|
|
388
|
+
let [l, c, h] = toLch(statusSeeds[role]);
|
|
315
389
|
if (source === 'related') {
|
|
316
390
|
const brandHue = toLch(accents.primary)[2];
|
|
317
391
|
const delta = ((brandHue - h + 540) % 360) - 180;
|
|
318
392
|
h += Math.max(-15, Math.min(15, delta));
|
|
319
393
|
}
|
|
320
|
-
|
|
394
|
+
// Preserve each semantic anchor's balance; brand pigment bounds its intensity.
|
|
395
|
+
tones[role] = fromLch([l, Math.min(c, brandChroma * .7) * (.5 + Number(values['status-chroma'])) * (.6 + Number(values['color-intensity']) * .8), h]);
|
|
321
396
|
} else tones[role] = accents[source];
|
|
322
397
|
}
|
|
323
398
|
for (const [tone, original] of Object.entries(tones)) {
|
|
@@ -335,8 +410,12 @@ export function deriveTheme(input, { mode } = {}) {
|
|
|
335
410
|
const [quietL] = toLch(quiet);
|
|
336
411
|
const [, pigmentC, pigmentH] = toLch(fill);
|
|
337
412
|
const plateL = toLch(tokens['--ui-surface-raised'])[0];
|
|
338
|
-
const
|
|
339
|
-
|
|
413
|
+
const warmLift = dark ? Math.max(0, 1 - Math.abs(pigmentH - 70) / 35) ** 2 : 0;
|
|
414
|
+
const semantic = Object.hasOwn(statusSeeds, tone) && ['derived', 'related'].includes(values[tone + '-source']);
|
|
415
|
+
const tintScale = semantic ? .25 + 1.5 * Number(values['status-chroma']) : 1;
|
|
416
|
+
const quietC = Math.min(pigmentC, (dark ? .035 + .015 * warmLift : .02) * tintScale);
|
|
417
|
+
const softL = dark ? Math.max(quietL, plateL + .07) + .04 * warmLift : Math.max(.92, plateL - .04);
|
|
418
|
+
tokens[`--ui-${tone}-soft`] = readableColour(fromLch([softL, quietC, pigmentH]), [ink], 4.5, paper);
|
|
340
419
|
}
|
|
341
420
|
// Quiet fills are actual alpha composites. At an extreme light/dark flip,
|
|
342
421
|
// reduce their shared tint before it would leave no readable contextual ink.
|
|
@@ -350,8 +429,9 @@ export function deriveTheme(input, { mode } = {}) {
|
|
|
350
429
|
const readingSurfaces = quietSurfaces(tonalOpacity);
|
|
351
430
|
for (const tone of Object.keys(tones)) {
|
|
352
431
|
const [l, c, h] = toLch(tokens[`--ui-${tone}`]);
|
|
353
|
-
const
|
|
354
|
-
|
|
432
|
+
const semantic = Object.hasOwn(statusSeeds, tone) && ['derived', 'related'].includes(values[tone + '-source']);
|
|
433
|
+
const foregroundSeed = fromLch([dark ? Math.max(l, .80) : semantic ? l : Math.min(l, .50), Math.min(c, semantic ? .12 : dark ? .16 : .18), h]);
|
|
434
|
+
tokens[`--ui-${tone}-subtle-text`] = (semantic ? readableTone : readableColour)(foregroundSeed, readingSurfaces, 4.5, ink);
|
|
355
435
|
tokens[`--ui-${tone}-soft-border`] = alphaSurface(tokens[`--ui-${tone}-subtle-text`], tokens[`--ui-${tone}-soft`], .25);
|
|
356
436
|
}
|
|
357
437
|
// Existing validation/editor hooks must receive a contextual text role, never
|
|
@@ -479,6 +479,7 @@ var LoomaFigcaption = Node$1.create({
|
|
|
479
479
|
var labelFrom = (href, prefix) => href?.startsWith(`#${prefix}`) ? href.slice(prefix.length + 1) : null;
|
|
480
480
|
/** A footnote label as Looma Markdown reads it in `[^label]`: no whitespace and no `]`. */
|
|
481
481
|
var LOOMA_FOOTNOTE_LABEL = /^[^\s\]]+$/;
|
|
482
|
+
var LOOMA_FOOTNOTE_INSERTED = "loomaFootnoteInserted";
|
|
482
483
|
var REFERENCE = "loomaFootnoteReference";
|
|
483
484
|
var NOTES = "loomaFootnotes";
|
|
484
485
|
var NOTE = "loomaFootnote";
|
|
@@ -814,7 +815,16 @@ var LoomaFootnotes = Node$1.create({
|
|
|
814
815
|
const { $from, $to } = state.selection;
|
|
815
816
|
if (!isLabel(name) || !$from.parent.canReplaceWith($from.index(), $to.index(), state.schema.nodes[REFERENCE])) return false;
|
|
816
817
|
if (!dispatch) return true;
|
|
818
|
+
const position = tr.selection.from;
|
|
817
819
|
tr.replaceSelectionWith(state.schema.nodes[REFERENCE].create({ label: name }));
|
|
820
|
+
let occurrence = 0;
|
|
821
|
+
tr.doc.descendants((node, offset) => {
|
|
822
|
+
if (offset <= position && node.type.name === REFERENCE && node.attrs.label === name) occurrence++;
|
|
823
|
+
});
|
|
824
|
+
tr.setMeta(LOOMA_FOOTNOTE_INSERTED, {
|
|
825
|
+
label: name,
|
|
826
|
+
occurrence
|
|
827
|
+
});
|
|
818
828
|
if (!findLoomaFootnote(tr.doc, name)) {
|
|
819
829
|
const note = state.schema.nodes[NOTE].create({ label: name }, state.schema.nodes.paragraph.create());
|
|
820
830
|
if (tr.doc.lastChild?.type.name === NOTES) tr.insert(tr.doc.content.size - 1, note);
|
|
@@ -2,6 +2,7 @@ import { Node } from "@tiptap/core";
|
|
|
2
2
|
import { type Node as ProseMirrorNode } from "@tiptap/pm/model";
|
|
3
3
|
/** A footnote label as Looma Markdown reads it in `[^label]`: no whitespace and no `]`. */
|
|
4
4
|
export declare const LOOMA_FOOTNOTE_LABEL: RegExp;
|
|
5
|
+
export declare const LOOMA_FOOTNOTE_INSERTED = "loomaFootnoteInserted";
|
|
5
6
|
/**
|
|
6
7
|
* The first note for `label` in `doc` and its position.
|
|
7
8
|
* @failure Returns null when no note has that label.
|
|
@@ -1,46 +1,35 @@
|
|
|
1
|
-
import type { Editor } from "@tiptap/core";
|
|
2
|
-
/** The
|
|
1
|
+
import type { AnyExtension, Editor, JSONContent } from "@tiptap/core";
|
|
2
|
+
/** The floating editor's structured note content; numbering belongs to the document. */
|
|
3
3
|
export interface LoomaFootnoteEditingState {
|
|
4
4
|
readonly open: boolean;
|
|
5
|
-
readonly
|
|
6
|
-
/** The note's text, its blocks on separate lines. */
|
|
7
|
-
readonly note: string;
|
|
8
|
-
/** Whether `note` can be edited as text: the note is one paragraph of unformatted text. */
|
|
9
|
-
readonly editable: boolean;
|
|
10
|
-
/** Why the last label offered was not used, or empty. */
|
|
11
|
-
readonly error: string;
|
|
5
|
+
readonly note: JSONContent;
|
|
12
6
|
}
|
|
13
7
|
export declare const LOOMA_FOOTNOTE_EDITING_IDLE: LoomaFootnoteEditingState;
|
|
14
8
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* @ownership The host owns presentation: the popover, its anchor, and focus. This owns which footnote
|
|
19
|
-
* is edited and the document changes it makes.
|
|
20
|
-
* @failure A change after the footnote was deleted closes the editor and writes nothing. A label with
|
|
21
|
-
* a space or `]`, or one another footnote uses, is not applied; `error` says why.
|
|
9
|
+
* Edits one note without exposing its internal Markdown identity to the writer.
|
|
10
|
+
* @ownership The host owns action bar, popover, anchor and focus; this owns document updates.
|
|
11
|
+
* @failure Deleting the reference closes the editor. Invalid structured content never replaces a note.
|
|
22
12
|
*/
|
|
23
13
|
export interface LoomaFootnoteEditing {
|
|
24
14
|
readonly state: LoomaFootnoteEditingState;
|
|
25
|
-
/** The
|
|
15
|
+
/** The reference used to anchor the floating actions or editor. */
|
|
26
16
|
readonly element: HTMLElement | null;
|
|
27
|
-
/** Calls `listener` after every state change; returns the unsubscribe function. */
|
|
28
17
|
subscribe(listener: () => void): () => void;
|
|
29
|
-
/**
|
|
30
|
-
* Opens on the reference at `position`.
|
|
31
|
-
* @failure Returns false, and stays as it was, when the editor is read-only or no reference is there.
|
|
32
|
-
*/
|
|
18
|
+
/** Opens on an editable footnote reference; returns false when the reference or note is absent. */
|
|
33
19
|
open(position: number): boolean;
|
|
34
|
-
/** Replaces the
|
|
35
|
-
setNote(note:
|
|
36
|
-
|
|
37
|
-
/** Closes the editor and moves the caret to the end of the note. */
|
|
20
|
+
/** Replaces note content using the parent schema, preserving blocks, marks and attributes. */
|
|
21
|
+
setNote(note: JSONContent): void;
|
|
22
|
+
/** Closes the floating surface and moves the document caret to the note. */
|
|
38
23
|
goToNote(): void;
|
|
39
24
|
close(): void;
|
|
40
25
|
}
|
|
41
26
|
export interface LoomaFootnoteEditingOptions {
|
|
42
27
|
editor: Editor;
|
|
43
|
-
/** Read on each opening, so a host can change it while the editor runs. */
|
|
44
28
|
isEditable: () => boolean;
|
|
45
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Reuses the parent content schema in a short-form field, including global attributes.
|
|
32
|
+
* Document-wide normalizers and node-view callbacks stay with the parent editor.
|
|
33
|
+
*/
|
|
34
|
+
export declare function footnoteContentExtensions(editor: Editor): AnyExtension[];
|
|
46
35
|
export declare function createFootnoteEditing(options: LoomaFootnoteEditingOptions): LoomaFootnoteEditing;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@threadlabs/looma",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.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.10.
|
|
130
|
+
"markupress": ">=0.10.3 <1",
|
|
131
131
|
"@threadlabs/markupkit": ">=0.2.0 <1",
|
|
132
132
|
"vite": ">=7.2.7 <9"
|
|
133
133
|
},
|
package/styles/ui-callout.css
CHANGED
|
@@ -83,10 +83,10 @@
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
:scope:where([data-component~="ui-callout"])[data-ui-callout-state~="tone=tip"] {
|
|
86
|
-
--_callout-border: var(--ui-
|
|
87
|
-
--_callout-surface: var(--ui-
|
|
88
|
-
--_callout-tone-text: var(--ui-
|
|
89
|
-
--_callout-icon: var(--ui-
|
|
86
|
+
--_callout-border: var(--ui-info-soft-border);
|
|
87
|
+
--_callout-surface: var(--ui-info-soft);
|
|
88
|
+
--_callout-tone-text: var(--ui-info-subtle-text);
|
|
89
|
+
--_callout-icon: var(--ui-info-subtle-text);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
:scope:where([data-component~="ui-callout"])[data-ui-callout-state~="tone=important"] {
|