@threadlabs/looma 0.41.2 → 0.43.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-action-bar/ui-action-bar.html +1 -7
- package/components/ui-affordance-scope/ui-affordance-scope.html +4 -4
- package/components/ui-avatar/ui-avatar.html +0 -22
- package/components/ui-avatar-group/ui-avatar-group.html +1 -11
- package/components/ui-badge/ui-badge.html +57 -78
- package/components/ui-button/ui-button.html +66 -90
- package/components/ui-button/ui-button.js +2 -2
- package/components/ui-callout/ui-callout.html +31 -69
- package/components/ui-card/ui-card.html +47 -21
- package/components/ui-checkbox/ui-checkbox.html +2 -16
- package/components/ui-cluster/ui-cluster.html +1 -7
- package/components/ui-combobox/ui-combobox.html +7 -70
- package/components/ui-container/ui-container.html +2 -12
- package/components/ui-context-menu/ui-context-menu.html +1 -23
- package/components/ui-dialog/ui-dialog.html +9 -41
- package/components/ui-disclosure/ui-disclosure.html +1 -15
- package/components/ui-editor-mention-menu/ui-editor-mention-menu.html +1 -1
- package/components/ui-editor-mention-menu-item/ui-editor-mention-menu-item.html +1 -1
- package/components/ui-editor-table-context-menu/ui-editor-table-context-menu.html +1 -1
- package/components/ui-editor-table-overlay/ui-editor-table-overlay.html +2 -2
- package/components/ui-editor-table-toolbar/ui-editor-table-toolbar.html +2 -2
- package/components/ui-floating-action-button/ui-floating-action-button.html +0 -14
- package/components/ui-form-field/ui-form-field.html +2 -32
- package/components/ui-grid/ui-grid.html +1 -11
- package/components/ui-icon/ui-icon.html +1 -12
- package/components/ui-icon-button/ui-icon-button.html +94 -94
- package/components/ui-input/ui-input.html +5 -55
- package/components/ui-input-group/ui-input-group.html +1 -13
- package/components/ui-light-editor/ui-light-editor.html +1 -1
- package/components/ui-list/ui-list.html +0 -10
- package/components/ui-list-item/ui-list-item.html +1 -19
- package/components/ui-listbox/ui-listbox.html +0 -21
- package/components/ui-menu/ui-menu.html +8 -32
- package/components/ui-menu-item/ui-menu-item.html +1 -27
- package/components/ui-meter/ui-meter.html +11 -6
- package/components/ui-nav-item/ui-nav-item.html +0 -18
- package/components/ui-popover/ui-popover.html +9 -41
- package/components/ui-radio/ui-radio.html +58 -12
- package/components/ui-radio-group/ui-radio-group.html +0 -5
- package/components/ui-reel/ui-reel.html +1 -11
- package/components/ui-search-result-row/ui-search-result-row.html +0 -34
- package/components/ui-search-shell/ui-search-shell.html +1 -43
- package/components/ui-section/ui-section.html +1 -1
- package/components/ui-select/ui-select.html +0 -42
- package/components/ui-separator/ui-separator.html +0 -6
- package/components/ui-sidebar/ui-sidebar.html +2 -24
- package/components/ui-site-header/ui-site-header.html +0 -25
- package/components/ui-skeleton/ui-skeleton.html +0 -9
- package/components/ui-stack/ui-stack.html +6 -11
- package/components/ui-status-message/ui-status-message.html +1 -1
- package/components/ui-swatch/ui-swatch.html +0 -5
- package/components/ui-switch/ui-switch.html +6 -17
- package/components/ui-switcher/ui-switcher.html +1 -11
- package/components/ui-tabs/ui-tabs.html +4 -22
- package/components/ui-text/ui-text.html +20 -7
- package/components/ui-textarea/ui-textarea.html +0 -50
- package/components/ui-toast/ui-toast.html +12 -27
- package/components/ui-toast-region/ui-toast-region.html +13 -34
- package/components/ui-tooltip/ui-tooltip.html +9 -53
- package/components/ui-top-bar/ui-top-bar.html +1 -31
- package/components/ui-tree/ui-tree.html +1 -16
- package/components/ui-tree-item/ui-tree-item.html +1 -23
- package/components/ui-tree-item/ui-tree-item.js +0 -1
- package/dist/index.js +1 -1
- package/docs/README.md +15 -9
- package/docs/catalog.json +973 -186
- package/docs/customizer-render.mjs +25 -9
- package/docs/customizer.js +42 -2
- package/docs/fonts.mjs +1 -1
- package/docs/palette.mjs +5 -4
- package/docs/theme.mjs +214 -51
- package/docs/value-editors.mjs +2 -1
- package/package.json +2 -2
- package/styles/ui-action-bar.css +3 -11
- package/styles/ui-affordance-scope.css +4 -4
- package/styles/ui-avatar-group.css +3 -15
- package/styles/ui-avatar.css +2 -26
- package/styles/ui-badge.css +56 -80
- package/styles/ui-button.css +65 -92
- package/styles/ui-callout.css +33 -73
- package/styles/ui-card.css +42 -18
- package/styles/ui-checkbox.css +4 -20
- package/styles/ui-cluster.css +2 -10
- package/styles/ui-combobox.css +7 -140
- package/styles/ui-container.css +2 -14
- package/styles/ui-context-menu.css +3 -27
- package/styles/ui-dialog.css +22 -88
- package/styles/ui-disclosure.css +3 -19
- package/styles/ui-editor-mention-menu-item.css +1 -1
- package/styles/ui-editor-mention-menu.css +1 -1
- package/styles/ui-editor-table-context-menu.css +1 -1
- package/styles/ui-editor-table-overlay.css +2 -2
- package/styles/ui-editor-table-toolbar.css +2 -2
- package/styles/ui-floating-action-button.css +2 -18
- package/styles/ui-form-field.css +4 -36
- package/styles/ui-grid.css +2 -14
- package/styles/ui-icon-button.css +93 -96
- package/styles/ui-icon.css +3 -16
- package/styles/ui-input-group.css +2 -14
- package/styles/ui-input.css +6 -57
- package/styles/ui-light-editor.css +2 -2
- package/styles/ui-list-item.css +3 -23
- package/styles/ui-list.css +2 -14
- package/styles/ui-listbox.css +2 -44
- package/styles/ui-menu-item.css +3 -31
- package/styles/ui-menu.css +11 -37
- package/styles/ui-meter.css +8 -4
- package/styles/ui-nav-item.css +2 -22
- package/styles/ui-popover.css +12 -46
- package/styles/ui-radio-group.css +1 -6
- package/styles/ui-radio.css +68 -15
- package/styles/ui-reel.css +2 -14
- package/styles/ui-search-result-row.css +2 -38
- package/styles/ui-search-shell.css +3 -47
- package/styles/ui-section.css +1 -1
- package/styles/ui-select.css +2 -46
- package/styles/ui-separator.css +2 -10
- package/styles/ui-sidebar.css +4 -28
- package/styles/ui-site-header.css +1 -26
- package/styles/ui-skeleton.css +2 -12
- package/styles/ui-stack.css +4 -12
- package/styles/ui-status-message.css +1 -1
- package/styles/ui-swatch.css +1 -6
- package/styles/ui-switch.css +8 -21
- package/styles/ui-switcher.css +2 -14
- package/styles/ui-tabs.css +6 -26
- package/styles/ui-text.css +11 -3
- package/styles/ui-textarea.css +2 -54
- package/styles/ui-toast-region.css +29 -73
- package/styles/ui-toast.css +24 -54
- package/styles/ui-tooltip.css +12 -58
- package/styles/ui-top-bar.css +3 -35
- package/styles/ui-tree-item.css +5 -51
- package/styles/ui-tree.css +3 -20
- package/theme-system.css +16 -10
- package/tokens.css +75 -18
- package/vanilla/UiBadge.d.ts +1 -1
- package/vanilla/UiBadge.js +1 -1
- package/vanilla/UiButton.d.ts +1 -1
- package/vanilla/UiButton.js +1 -1
- package/vanilla/UiCard.d.ts +1 -1
- package/vanilla/UiCard.js +1 -1
- package/vanilla/UiIconButton.d.ts +1 -1
- package/vanilla/UiIconButton.js +1 -1
- package/vanilla/UiMeter.d.ts +1 -1
- package/vanilla/UiMeter.js +1 -1
- package/vanilla/UiStack.js +1 -1
- package/vanilla/UiText.d.ts +1 -1
- package/vanilla/UiText.js +1 -1
- package/vue/UiActionBar.vue +3 -9
- package/vue/UiAffordanceScope.vue +4 -4
- package/vue/UiAvatar.vue +1 -28
- package/vue/UiAvatarGroup.vue +1 -11
- package/vue/UiBadge.d.ts +2 -2
- package/vue/UiBadge.vue +84 -81
- package/vue/UiButton.d.ts +2 -2
- package/vue/UiButton.vue +120 -106
- package/vue/UiCallout.vue +31 -72
- package/vue/UiCard.d.ts +2 -2
- package/vue/UiCard.vue +77 -32
- package/vue/UiCheckbox.vue +2 -16
- package/vue/UiCluster.vue +1 -10
- package/vue/UiCombobox.vue +13 -72
- package/vue/UiContainer.vue +1 -13
- package/vue/UiContextMenu.vue +1 -30
- package/vue/UiDialog.vue +23 -77
- package/vue/UiDisclosure.vue +1 -15
- package/vue/UiEditorMentionMenu.vue +1 -1
- package/vue/UiEditorMentionMenuItem.vue +1 -1
- package/vue/UiEditorTableContextMenu.vue +1 -1
- package/vue/UiEditorTableOverlay.vue +2 -2
- package/vue/UiEditorTableToolbar.vue +2 -2
- package/vue/UiFloatingActionButton.vue +0 -22
- package/vue/UiFormField.vue +6 -33
- package/vue/UiGrid.vue +1 -13
- package/vue/UiIcon.vue +1 -16
- package/vue/UiIconButton.d.ts +2 -2
- package/vue/UiIconButton.vue +145 -106
- package/vue/UiInput.vue +1 -54
- package/vue/UiInputGroup.vue +8 -20
- package/vue/UiLightEditor.vue +2 -2
- package/vue/UiList.vue +2 -12
- package/vue/UiListItem.vue +8 -26
- package/vue/UiListbox.vue +0 -23
- package/vue/UiMenu.vue +12 -44
- package/vue/UiMenuItem.vue +1 -27
- package/vue/UiMeter.d.ts +2 -2
- package/vue/UiMeter.vue +47 -12
- package/vue/UiNavItem.vue +3 -21
- package/vue/UiPopover.vue +12 -53
- package/vue/UiRadio.vue +58 -12
- package/vue/UiRadioGroup.vue +0 -11
- package/vue/UiReel.vue +1 -11
- package/vue/UiSearchResultRow.vue +0 -35
- package/vue/UiSearchShell.vue +1 -53
- package/vue/UiSection.vue +1 -1
- package/vue/UiSelect.vue +0 -42
- package/vue/UiSeparator.vue +0 -7
- package/vue/UiSidebar.vue +3 -26
- package/vue/UiSiteHeader.vue +0 -24
- package/vue/UiSkeleton.vue +0 -9
- package/vue/UiStack.vue +6 -11
- package/vue/UiStatusMessage.vue +1 -1
- package/vue/UiSwatch.vue +1 -6
- package/vue/UiSwitch.vue +6 -17
- package/vue/UiSwitcher.vue +1 -14
- package/vue/UiTabs.vue +4 -22
- package/vue/UiText.d.ts +2 -2
- package/vue/UiText.vue +30 -5
- package/vue/UiTextarea.vue +0 -50
- package/vue/UiToast.vue +26 -34
- package/vue/UiToastRegion.vue +26 -55
- package/vue/UiTooltip.vue +12 -64
- package/vue/UiTopBar.vue +1 -34
- package/vue/UiTree.vue +2 -17
- package/vue/UiTreeItem.vue +2 -28
- package/vue/chunks/UiActionBar.js +1 -1
- package/vue/chunks/UiAffordanceScope.js +1 -1
- package/vue/chunks/UiAvatar.js +1 -1
- package/vue/chunks/UiAvatarGroup.js +1 -1
- package/vue/chunks/UiBadge.js +4 -2
- package/vue/chunks/UiButton.js +4 -2
- package/vue/chunks/UiCallout.js +1 -1
- package/vue/chunks/UiCard.js +5 -3
- package/vue/chunks/UiCheckbox.js +1 -1
- package/vue/chunks/UiCluster.js +2 -2
- package/vue/chunks/UiCombobox.js +3 -3
- package/vue/chunks/UiContainer.js +2 -2
- package/vue/chunks/UiContextMenu.js +1 -1
- package/vue/chunks/UiDialog.js +1 -1
- package/vue/chunks/UiDisclosure.js +1 -1
- package/vue/chunks/UiEditorMentionMenu.js +1 -1
- package/vue/chunks/UiEditorMentionMenuItem.js +1 -1
- package/vue/chunks/UiEditorTableContextMenu.js +1 -1
- package/vue/chunks/UiEditorTableOverlay.js +1 -1
- package/vue/chunks/UiEditorTableToolbar.js +1 -1
- package/vue/chunks/UiFloatingActionButton.js +1 -1
- package/vue/chunks/UiFormField.js +1 -1
- package/vue/chunks/UiGrid.js +2 -2
- package/vue/chunks/UiIcon.js +1 -1
- package/vue/chunks/UiIconButton.js +4 -2
- package/vue/chunks/UiInput.js +1 -1
- package/vue/chunks/UiInputGroup.js +1 -1
- package/vue/chunks/UiLightEditor.js +1 -1
- package/vue/chunks/UiList.js +1 -1
- package/vue/chunks/UiListItem.js +1 -1
- package/vue/chunks/UiListbox.js +1 -1
- package/vue/chunks/UiMenu.js +1 -1
- package/vue/chunks/UiMenuItem.js +1 -1
- package/vue/chunks/UiMeter.js +4 -2
- package/vue/chunks/UiNavItem.js +1 -1
- package/vue/chunks/UiPopover.js +1 -1
- package/vue/chunks/UiRadio.js +1 -1
- package/vue/chunks/UiRadioGroup.js +1 -1
- package/vue/chunks/UiReel.js +2 -2
- package/vue/chunks/UiSearchResultRow.js +1 -1
- package/vue/chunks/UiSearchShell.js +1 -1
- package/vue/chunks/UiSection.js +1 -1
- package/vue/chunks/UiSelect.js +1 -1
- package/vue/chunks/UiSeparator.js +1 -1
- package/vue/chunks/UiSidebar.js +1 -1
- package/vue/chunks/UiSiteHeader.js +1 -1
- package/vue/chunks/UiSkeleton.js +1 -1
- package/vue/chunks/UiStack.js +3 -3
- package/vue/chunks/UiStatusMessage.js +1 -1
- package/vue/chunks/UiSwatch.js +1 -1
- package/vue/chunks/UiSwitch.js +1 -1
- package/vue/chunks/UiSwitcher.js +2 -2
- package/vue/chunks/UiTabs.js +1 -1
- package/vue/chunks/UiText.js +4 -2
- package/vue/chunks/UiTextarea.js +1 -1
- package/vue/chunks/UiToast.js +1 -1
- package/vue/chunks/UiToastRegion.js +1 -1
- package/vue/chunks/UiTooltip.js +1 -1
- package/vue/chunks/UiTopBar.js +1 -1
- package/vue/chunks/UiTree.js +1 -1
- package/vue/chunks/UiTreeItem.js +1 -1
- package/vue/components.css +857 -2184
- package/vue/editor/index.js +8 -2
package/docs/theme.mjs
CHANGED
|
@@ -5,12 +5,32 @@ const bounds = {
|
|
|
5
5
|
'text-size': [14, 24], 'control-roominess': [2, 4], 'corner-roundness': [0, 32],
|
|
6
6
|
'line-weight': [.5, 3], rhythm: [.75, 1.5], spacing: [.75, 1.5], 'scale-contrast': [1, 1.5],
|
|
7
7
|
'space-curve': [.5, 2], 'text-weight': [400, 700], 'outer-depth': [0, 2], 'inner-depth': [0, 2],
|
|
8
|
-
'response-time': [0, 600],
|
|
8
|
+
'response-time': [0, 600], 'neutral-border-contrast': [1, 4.5],
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
+
const brandChoices = { primary: 'Primary accent', secondary: 'Secondary accent', tertiary: 'Tertiary accent' };
|
|
12
|
+
const statusChoices = { derived: 'Semantic hue', related: 'Harmonize with primary', ...brandChoices };
|
|
13
|
+
const neutralChoices = { text: 'Derive from text', ...brandChoices, gray: 'Untinted gray' };
|
|
14
|
+
const relationshipChoices = { preserve: 'Preserve seed hues', neighboring: 'Neighboring hues', complementary: 'Complementary hues' };
|
|
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: '#ba5b0b', info: '#0066cc' };
|
|
17
|
+
|
|
11
18
|
/** The shared authoring schema; ids remain stable in saved recipes. */
|
|
12
19
|
export const themeFields = [
|
|
13
|
-
['Colour', 'action', 'Action', '--ui-accent', 'colour', '#5b55d6', 'Primary
|
|
20
|
+
['Colour', 'action', 'Action', '--ui-accent', 'colour', '#5b55d6', 'Primary fill; readable labels and contextual action text are derived separately.'],
|
|
21
|
+
['Colour', 'secondary-action', 'Secondary accent', null, 'optional-colour', 'none', 'An optional supporting brand color for selected components. Primary actions keep the primary accent.'],
|
|
22
|
+
['Colour', 'tertiary-action', 'Tertiary accent', null, 'optional-colour', 'none', 'An optional third accent for categories, highlights and supporting content.'],
|
|
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
|
+
['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
|
+
['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', 'Perceptual saturation of derived status colors, coordinated with the primary accent. Brand mappings keep the chosen family intact.'],
|
|
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
|
+
['Colour', 'danger-source', 'Error relationship', null, 'choice', 'derived', 'Choose a semantic hue, harmonize it with primary, or use a governed brand-accent family.'],
|
|
29
|
+
['Colour', 'warning-source', 'Warning relationship', null, 'choice', 'derived', 'Choose a semantic hue, harmonize it with primary, or use a governed brand-accent family.'],
|
|
30
|
+
['Colour', 'info-source', 'Info relationship', null, 'choice', 'derived', 'Choose a semantic hue, harmonize it with primary, or use a governed brand-accent family.'],
|
|
31
|
+
['Colour', 'selection-accent', 'Selection accent', null, 'choice', 'primary', 'Choose the accent for selected rows and choices.'],
|
|
32
|
+
['Colour', 'focus-accent', 'Focus accent', null, 'choice', 'primary', 'Choose the accent for keyboard focus rings.'],
|
|
33
|
+
['Colour', 'link-accent', 'Link accent', null, 'choice', 'primary', 'Choose the accent for inline Text links and editor links.'],
|
|
14
34
|
['Colour', 'canvas', 'Canvas', '--ui-surface', 'colour', '#f6f6f8', 'The ground behind surfaces.'],
|
|
15
35
|
['Colour', 'surface', 'Surface', '--ui-surface-raised', 'colour', '#ffffff', 'Fields, cards and floating surfaces.'],
|
|
16
36
|
['Colour', 'text', 'Text', '--ui-text', 'colour', '#1a1a1a', 'Readable content; supporting text follows this and Surface.'],
|
|
@@ -20,45 +40,51 @@ export const themeFields = [
|
|
|
20
40
|
['Type', 'body-font', 'Font', '--ui-font-sans', 'font', 'system-ui, sans-serif', 'The shared interface typeface.'],
|
|
21
41
|
['Type', 'display-font', 'Heading font', '--ui-font-display', 'font', 'system-ui, sans-serif', 'The heading typeface.'],
|
|
22
42
|
['Type', 'text-size', 'Base text size', '--ui-font-size', 'positive-length', '16px', 'Sets the document root in px. Type, spacing and layout use rem relationships and scale from this base once.'],
|
|
43
|
+
['Type', 'label-size', 'Field label size', '--ui-field-label-font-size', 'inherited-length', 'inherit', 'Follows body text unless you choose a separate size for field labels. Help text keeps its supporting size.'],
|
|
23
44
|
['Type', 'text-weight', 'Emphasis weight', '--ui-font-medium', 'weight', '500', 'Control-label emphasis; body and headings keep their roles.'],
|
|
24
45
|
['Size & spacing', 'control-roominess', 'Control roominess', '--ui-control-roominess', 'positive', '2.5', 'Shared control height as a multiple of base text size; buttons, fields and swatches stay aligned.'],
|
|
25
|
-
['Size & spacing', 'rhythm', 'Rhythm', '--ui-rhythm', 'positive', '1', '
|
|
26
|
-
['Size & spacing', 'spacing', 'Spacing', '--ui-spacing', 'positive', '1', '
|
|
46
|
+
['Size & spacing', 'rhythm', 'Rhythm', '--ui-rhythm', 'positive', '1', 'Vertical breathing room: opens text lines and the gaps between stacked groups without spreading navigation or button rows.'],
|
|
47
|
+
['Size & spacing', 'spacing', 'Spacing', '--ui-spacing', 'positive', '1', 'Space between controls and around content. Changes gaps and padding independently of vertical rhythm.'],
|
|
27
48
|
['Size & spacing', 'scale-contrast', 'Size ratio', '--ui-scale-ratio', 'ratio', '1.2', 'The multiplier between small, medium and large controls. At 1 the sizes are equal; higher values separate them.'],
|
|
28
49
|
['Size & spacing', 'space-curve', 'Spacing curve', '--ui-space-curve', 'nonnegative', '1', 'Spacing growth: 1 is linear, 2 is quadratic. Independent of control sizes.'],
|
|
29
50
|
['Size & spacing', 'corner-roundness', 'Corner roundness', '--ui-radius-md', 'length', '8px', 'One corner family across controls and surfaces.'],
|
|
30
51
|
['Size & spacing', 'line-weight', 'Line weight', '--ui-border-width', 'length', '1px', 'Shared edge weight; focus stays independently visible.'],
|
|
31
52
|
['Material', 'outer-depth', 'Outer depth', '--ui-outer-depth', 'nonnegative', '0.6', 'How strongly controls and floating surfaces rise above the page.'],
|
|
32
53
|
['Material', 'inner-depth', 'Inner depth', '--ui-inner-depth', 'nonnegative', '0.3', 'How strongly fields and pressed controls sit into their surface.'],
|
|
33
|
-
['Material', 'glassiness', '
|
|
54
|
+
['Material', 'glassiness', 'Frosting', '--ui-glassiness', 'fraction', '0', 'Backdrop blur on decorative glass, from none to frosted. Content remains opaque.'],
|
|
34
55
|
['Material', 'surface-separation', 'Surface separation', '--ui-surface-separation', 'fraction', '0', 'One material offset, scaled by popup purpose and actual size: quiet tooltips through substantial dialogs.'],
|
|
35
|
-
['Material', 'translucency', '
|
|
56
|
+
['Material', 'translucency', 'Transparency', '--ui-overlay-translucency', 'fraction', '0', 'How much of the scene comes through decorative glass rims, from opaque to clear. Content remains opaque.'],
|
|
36
57
|
['Material', 'edge-light', 'Edge light', '--ui-edge-light', 'fraction', '0', 'Light caught by surface edges, independent of depth.'],
|
|
37
58
|
['Material', 'finish', 'Finish', '--ui-finish', 'fraction', '0', 'Matte through polished: how strongly the material catches a reflection.'],
|
|
38
59
|
['Material', 'glow', 'Glow', '--ui-glow', 'fraction', '0', 'Reflected light beyond a surface, from a quiet halo to a vivid bloom at the upper end.'],
|
|
60
|
+
['Material', 'light-color', 'Light color', '--ui-light-color', 'colour', '#ffffff', 'The reflected environment, independent of object pigment. Neutral white by default; reflected hues remain readable.'],
|
|
39
61
|
['Material', 'light-x', 'Light horizontal position', '--ui-light-x', 'fraction', '0.5', 'The light source from left to right, relative to each surface.'],
|
|
40
62
|
['Material', 'light-y', 'Light vertical position', '--ui-light-y', 'fraction', '0', 'The light source from top to bottom, relative to each surface.'],
|
|
41
63
|
['Material', 'light-spread', 'Light spread', '--ui-light-spread', 'fraction', '0.5', 'A concentrated spot through broad illumination.'],
|
|
42
64
|
['Material', 'light-strength', 'Light strength', '--ui-light-strength', 'fraction', '0.65', 'Shared illumination; each material and component role determines its response.'],
|
|
43
65
|
['Motion', 'response-time', 'Response time', '--ui-motion-fast', 'time', '120ms', 'Shared feedback pace; floating transitions take proportionally longer.'],
|
|
44
66
|
['Motion', 'response-curve', 'Response curve', '--ui-motion-ease', 'easing', 'cubic-bezier(0.2,0,0.2,1)', 'How movement accelerates and settles.'],
|
|
45
|
-
].map(([family, id, label, property, type, defaultValue, description]) => Object.freeze({ family, id, label, property, type, defaultValue, description, ...(type === 'choice' ? { choices:
|
|
67
|
+
].map(([family, id, label, property, type, defaultValue, description]) => Object.freeze({ family, id, label, property, type, defaultValue, description, ...(type === 'choice' ? { choices: choicesFor(id) } : {}), ...(bounds[id] ? { min: bounds[id][0], max: bounds[id][1] } : type === 'fraction' ? { min: 0, max: 1 } : {}) }));
|
|
46
68
|
|
|
47
|
-
|
|
48
|
-
const starting = values => ({ schemaVersion: 1, values: { ...
|
|
69
|
+
const baseRecipe = () => ({ schemaVersion: 1, values: Object.fromEntries(themeFields.map(field => [field.id, field.defaultValue])) });
|
|
70
|
+
const starting = values => ({ schemaVersion: 1, values: { ...baseRecipe().values, ...values } });
|
|
71
|
+
/** The documentation starts with Looma's coordinated identity; Clear keeps the neutral baseline. */
|
|
72
|
+
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' } });
|
|
49
73
|
export const startingPoints = {
|
|
50
|
-
|
|
74
|
+
looma: defaultRecipe(),
|
|
75
|
+
clear: baseRecipe(),
|
|
76
|
+
gold: { ...starting({ action: '#ffb84d', canvas: '#ffffff', surface: '#ffffff', text: '#171717', 'body-font': googleFontStack('Lato'), 'display-font': googleFontStack('Fraunces'), 'text-size': '17px', 'corner-roundness': '16px', finish: '0.55', 'light-x': '0' }), fonts: { 'body-font': 'Lato', 'display-font': 'Fraunces' } },
|
|
51
77
|
bookish: starting({ rhythm: '1.05', action: '#2e1228', canvas: '#f7f7f5', surface: '#fffefd', text: '#0d0c0c', 'body-font': 'Arial, sans-serif', 'display-font': 'Georgia, serif', 'text-weight': '400', 'control-roominess': '2.625', 'scale-contrast': '1.18', 'outer-depth': '1', 'inner-depth': '1', glassiness: '0.8', 'surface-separation': '0.65', translucency: '0.18', 'edge-light': '1', finish: '0.85', glow: '0.3', 'light-spread': '0.3', 'light-strength': '0.9', 'response-time': '150ms', 'response-curve': 'ease' }),
|
|
52
78
|
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' }),
|
|
53
79
|
editorial: starting({ rhythm: '1.3', 'text-size': '17px', spacing: '1.12', 'space-curve': '1.4', 'scale-contrast': '1.3', action: '#182c24', canvas: '#eee9dc', surface: '#fffdf5', text: '#182c24', 'corner-roundness': '0px', 'outer-depth': '0', 'inner-depth': '0', 'body-font': 'Georgia, serif', 'display-font': 'Georgia, serif', 'text-weight': '400', 'line-weight': '2px', 'response-time': '90ms', 'response-curve': 'linear' }),
|
|
54
80
|
night: starting({ rhythm: '1.05', 'display-font': 'ui-monospace, monospace', 'text-weight': '500', 'control-roominess': '2.375', spacing: '1.05', 'scale-contrast': '1.25', 'space-curve': '1', finish: '0.6', glow: '0.45', glassiness: '0.45', 'surface-separation': '0.25', 'light-x': '0.25', 'light-spread': '0.65', action: '#a7b8ff', canvas: '#11141c', surface: '#202634', text: '#edf1fb', 'corner-roundness': '12px', 'outer-depth': '1.4', 'inner-depth': '0.45', translucency: '0.2', 'edge-light': '0.65', 'response-time': '210ms', 'response-curve': 'cubic-bezier(0.2,0.8,0.2,1)' }),
|
|
55
81
|
garden: starting({ rhythm: '1.2', 'body-font': 'ui-rounded, system-ui, sans-serif', 'display-font': 'Georgia, serif', 'text-weight': '400', 'space-curve': '1.15', finish: '0.15', 'light-spread': '1', action: '#256342', canvas: '#f4edda', surface: '#fff8e7', text: '#173121', 'corner-roundness': '22px', 'outer-depth': '0.35', 'inner-depth': '0', 'edge-light': '0.2', 'control-roominess': '2.875', 'scale-contrast': '1.24', spacing: '1.05', 'response-time': '180ms', 'response-curve': 'cubic-bezier(0.16,1,0.3,1)' }),
|
|
56
82
|
};
|
|
57
|
-
export const startingPointLabels = { clear: 'Clear', bookish: 'Bookish', wiki: 'Wiki', editorial: 'Editorial', night: 'Night', garden: 'Garden' };
|
|
83
|
+
export const startingPointLabels = { looma: 'Looma', clear: 'Clear', gold: 'Gold', bookish: 'Bookish', wiki: 'Wiki', editorial: 'Editorial', night: 'Night', garden: 'Garden' };
|
|
58
84
|
const paletteKeys = themeFields.filter(field => field.family === 'Colour').map(field => field.id);
|
|
59
85
|
// Palette choices move only the shared color seeds; size, material and motion stay independent.
|
|
60
86
|
export const themePalettes = Object.fromEntries([
|
|
61
|
-
['clear', 'Indigo & mist'], ['bookish', 'Plum & paper'], ['wiki', 'Indigo & chalk'],
|
|
87
|
+
['looma', 'Looma'], ['clear', 'Indigo & mist'], ['gold', 'Gold'], ['bookish', 'Plum & paper'], ['wiki', 'Indigo & chalk'],
|
|
62
88
|
['editorial', 'Ink & parchment'], ['night', 'Midnight'], ['garden', 'Forest & cream'],
|
|
63
89
|
].map(([id, label]) => [id, { label, values: Object.fromEntries(paletteKeys.map(key => [key, startingPoints[id].values[key]])) }]));
|
|
64
90
|
|
|
@@ -124,15 +150,18 @@ export function validateRecipe(input) {
|
|
|
124
150
|
if (!input || input.schemaVersion !== 1 || !input.values || typeof input.values !== 'object' || Array.isArray(input.values)) throw new Error('Unsupported theme recipe version or values.');
|
|
125
151
|
const known = new Set(themeFields.map(field => field.id));
|
|
126
152
|
for (const key of Object.keys(input.values)) if (!known.has(key)) throw new Error(`Unknown theme decision ${key}.`);
|
|
127
|
-
const
|
|
153
|
+
const defaults = defaultRecipe();
|
|
154
|
+
const values = { ...defaults.values, ...input.values };
|
|
128
155
|
for (const field of themeFields) {
|
|
129
156
|
const value = values[field.id];
|
|
130
157
|
let valid = typeof value === 'string' && value.length > 0;
|
|
131
158
|
if (valid) switch (field.type) {
|
|
132
159
|
case 'choice': valid = Object.hasOwn(field.choices, value); break;
|
|
160
|
+
case 'optional-colour': valid = value === field.defaultValue || /^#[\da-f]{6}$/i.test(value); break;
|
|
133
161
|
case 'colour': valid = /^#[\da-f]{6}$/i.test(value); break;
|
|
134
162
|
case 'font': valid = font.test(value); break;
|
|
135
163
|
case 'length': valid = length.test(value) && Number.isFinite(parseFloat(value)); break;
|
|
164
|
+
case 'inherited-length': valid = value === 'inherit' || (length.test(value) && Number.isFinite(parseFloat(value)) && parseFloat(value) > 0); break;
|
|
136
165
|
case 'positive-length': valid = length.test(value) && Number.isFinite(parseFloat(value)) && parseFloat(value) > 0; break;
|
|
137
166
|
case 'time': valid = time.test(value) && Number.isFinite(parseFloat(value)); break;
|
|
138
167
|
case 'easing': valid = easing(value); break;
|
|
@@ -153,8 +182,10 @@ export function validateRecipe(input) {
|
|
|
153
182
|
}
|
|
154
183
|
if (input.presets !== undefined && (!input.presets || typeof input.presets !== 'object' || Array.isArray(input.presets) || Object.entries(input.presets).some(([family, id]) => !Object.hasOwn(refinementPresets(family) ?? {}, id)))) throw new Error('Unknown refinement preset.');
|
|
155
184
|
if (input.fonts !== undefined && (!input.fonts || typeof input.fonts !== 'object' || Array.isArray(input.fonts) || Object.entries(input.fonts).some(([key, family]) => !['body-font', 'display-font'].includes(key) || !Object.hasOwn(googleFonts, family) || values[key] !== googleFontStack(family)))) throw new Error('Choose a Google font with its matching font stack.');
|
|
185
|
+
const inheritedFonts = Object.fromEntries(Object.entries(defaults.fonts ?? {}).filter(([role]) => !Object.hasOwn(input.values, role)));
|
|
186
|
+
const fonts = { ...inheritedFonts, ...input.fonts };
|
|
156
187
|
if (input.origin !== undefined && !Object.hasOwn(startingPoints, input.origin)) throw new Error('Unknown theme origin.');
|
|
157
|
-
return { schemaVersion: 1, values, ...(input.fonts === undefined ? {} : { fonts
|
|
188
|
+
return { schemaVersion: 1, values, ...(input.fonts === undefined && !Object.keys(fonts).length ? {} : { fonts }), ...(input.origin === undefined ? {} : { origin: input.origin }), ...(input.presets === undefined ? {} : { presets: { ...input.presets } }) };
|
|
158
189
|
}
|
|
159
190
|
|
|
160
191
|
/** Match presets by their complete semantic recipe, including locally saved themes. */
|
|
@@ -164,15 +195,51 @@ export function startingPointFor(input) {
|
|
|
164
195
|
}
|
|
165
196
|
|
|
166
197
|
const rgb = hex => [1, 3, 5].map(i => parseInt(hex.slice(i, i + 2), 16));
|
|
167
|
-
const
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
198
|
+
const channelLuminance = channels => channels.map(n => { const s = n / 255; return s <= .04045 ? s / 12.92 : ((s + .055) / 1.055) ** 2.4; }).reduce((sum, n, i) => sum + n * [.2126, .7152, .0722][i], 0);
|
|
199
|
+
const luminance = hex => channelLuminance(rgb(hex));
|
|
200
|
+
const alphaSurface = (fill, background, alpha) => {
|
|
201
|
+
const a = rgb(fill), b = rgb(background);
|
|
202
|
+
return '#' + a.map((n, i) => Math.round(n * alpha + b[i] * (1 - alpha)).toString(16).padStart(2, '0')).join('');
|
|
203
|
+
};
|
|
204
|
+
const luminanceContrast = (a, b) => (Math.max(a, b) + .05) / (Math.min(a, b) + .05);
|
|
205
|
+
const contrast = (a, b) => luminanceContrast(luminance(a), luminance(b));
|
|
206
|
+
// Bound both material stops for opaque ink. The shade scales each sRGB channel
|
|
207
|
+
// down, so the darkest mixtures lie on its segment with the reflected light.
|
|
208
|
+
function materialLuminances(start, end) {
|
|
209
|
+
const a = rgb(start), b = rgb(end);
|
|
210
|
+
const at = t => channelLuminance(a.map((n, i) => n + (b[i] - n) * t));
|
|
211
|
+
let low = 0, high = 1;
|
|
212
|
+
for (let step = 0; step < 24; step++) {
|
|
213
|
+
const left = (2 * low + high) / 3, right = (low + 2 * high) / 3;
|
|
214
|
+
if (at(left) < at(right)) high = right; else low = left;
|
|
215
|
+
}
|
|
216
|
+
return [Math.min(at(0), at(1), at((low + high) / 2)), Math.max(at(0), at(1))];
|
|
217
|
+
}
|
|
218
|
+
function materialContrast(start, end, ink) {
|
|
219
|
+
const [minimum, maximum] = materialLuminances(start, end);
|
|
220
|
+
return ink < minimum ? luminanceContrast(minimum, ink) : ink > maximum ? luminanceContrast(maximum, ink) : 1;
|
|
221
|
+
}
|
|
222
|
+
function materialColours(fill, text, light, minimum = 4.55) {
|
|
223
|
+
const labels = (Array.isArray(text) ? text : [text]).map(label => typeof label === 'number' ? label : luminance(label));
|
|
224
|
+
const [l, c, h] = toLch(fill), [lightness] = toLch(light);
|
|
225
|
+
// Recede perceptually while retaining relative saturation and hue. Scaling
|
|
226
|
+
// L and C together scales linear RGB, keeping every shade channel <= fill.
|
|
227
|
+
let depth = .05;
|
|
228
|
+
const shaded = amount => amount === 0 ? fill : fromLch([Math.max(0, l - amount), c * Math.max(0, l - amount) / (l || 1), h]);
|
|
229
|
+
while (depth > 0 && labels.some(label => luminanceContrast(luminance(shaded(depth)), label) < minimum)) depth = Math.max(0, depth - .001);
|
|
230
|
+
const shade = shaded(depth);
|
|
231
|
+
// Environment influences reflected hue, not the pigment's saturation. Neutral
|
|
232
|
+
// light lifts lightness without the broad white mixture that washes colour out.
|
|
233
|
+
const [, tintChroma, tintHue] = toLch(mix(light, fill, .18));
|
|
234
|
+
const target = fromLch([l + (lightness - l) * .16, Math.max(c * .95, tintChroma), tintHue]);
|
|
235
|
+
let amount = 1;
|
|
236
|
+
while (amount > 0 && labels.some(label => materialContrast(mix(target, fill, amount), shade, label) < minimum)) amount = Math.max(0, amount - .005);
|
|
237
|
+
const reflection = mix(target, fill, amount);
|
|
238
|
+
// A tiny specular peak is allowed to brighten separately from the chromatic
|
|
239
|
+
// body reflection. Keep the same quantization margin as every material stop.
|
|
240
|
+
let glare = .55 * lightness;
|
|
241
|
+
while (glare > 0 && labels.some(label => luminanceContrast(luminance(alphaSurface('#ffffff', reflection, glare)), label) < minimum)) glare = Math.max(0, glare - .005);
|
|
242
|
+
return { reflection, shade, specular: alphaSurface('#ffffff', reflection, glare) };
|
|
176
243
|
}
|
|
177
244
|
const foreground = (fill, light, dark) => [light, dark, '#ffffff', '#000000'].sort((a, b) => contrast(fill, b) - contrast(fill, a))[0];
|
|
178
245
|
|
|
@@ -187,6 +254,20 @@ function readableColour(seed, surfaces, minimum, endpoint) {
|
|
|
187
254
|
}
|
|
188
255
|
|
|
189
256
|
/** Resolve editable colour seeds into a coordinated set of readable semantic roles. */
|
|
257
|
+
// Perceptual distance in Cartesian Oklab, including chroma-only separation.
|
|
258
|
+
const colourDistance = (a, b) => {
|
|
259
|
+
const [l1, c1, h1] = toLch(a), [l2, c2, h2] = toLch(b);
|
|
260
|
+
return Math.sqrt((l1 - l2) ** 2 + (c1 - c2) ** 2 + 2 * c1 * c2 * (1 - Math.cos((h1 - h2) * Math.PI / 180)));
|
|
261
|
+
};
|
|
262
|
+
const surfaceOffset = (surface, ink, distance) => mix(ink, surface, Math.min(1, distance / Math.max(.001, colourDistance(surface, ink))));
|
|
263
|
+
const actionBoundary = (fill, surfaces, ink, amplitude) => {
|
|
264
|
+
const distance = Math.min(...surfaces.map(surface => colourDistance(fill, surface)));
|
|
265
|
+
const shortfall = Math.max(0, 1 - distance / amplitude);
|
|
266
|
+
// Blend assistance in continuously. Searching for an exact distance along an
|
|
267
|
+
// ink path can jump when that path initially reduces chroma separation.
|
|
268
|
+
return mix(surfaceOffset(surfaces[1], ink, amplitude), fill, shortfall ** 2);
|
|
269
|
+
};
|
|
270
|
+
|
|
190
271
|
const paletteCache = new Map();
|
|
191
272
|
export function deriveTheme(input, { mode } = {}) {
|
|
192
273
|
if (mode !== undefined && !['light', 'dark'].includes(mode)) throw new Error('Unknown theme color mode.');
|
|
@@ -197,7 +278,7 @@ export function deriveTheme(input, { mode } = {}) {
|
|
|
197
278
|
const [min, max] = bounds[field.id]; tokens[field.property] = `clamp(${min}px, ${values[field.id]}, ${max}px)`;
|
|
198
279
|
}
|
|
199
280
|
}
|
|
200
|
-
const cacheKey = JSON.stringify([mode, ...paletteKeys.map(key => values[key])]);
|
|
281
|
+
const cacheKey = JSON.stringify([mode, ...paletteKeys.map(key => values[key]), values['light-color']]);
|
|
201
282
|
if (paletteCache.has(cacheKey)) {
|
|
202
283
|
const cached = paletteCache.get(cacheKey);
|
|
203
284
|
return { tokens: { ...tokens, ...cached.tokens }, adjustments: cached.adjustments.map(item => ({ ...item })) };
|
|
@@ -213,51 +294,133 @@ export function deriveTheme(input, { mode } = {}) {
|
|
|
213
294
|
const surface = seed => readableColour(nativeInk === ink ? seed : companionSurface(seed, mode ?? (ink === '#000000' ? 'light' : 'dark')), [ink], 7, paper);
|
|
214
295
|
tokens['--ui-surface'] = surface(seeds.canvas);
|
|
215
296
|
tokens['--ui-surface-raised'] = surface(seeds.surface);
|
|
216
|
-
|
|
297
|
+
const dark = ink === '#ffffff';
|
|
298
|
+
if (dark) {
|
|
299
|
+
// Dark plates need a positive elevation step; independently flipping near-white
|
|
300
|
+
// seeds otherwise collapses both canvas and content to almost the same black.
|
|
301
|
+
const [canvasL, canvasC, canvasH] = toLch(tokens['--ui-surface']);
|
|
302
|
+
tokens['--ui-surface'] = fromLch([Math.min(canvasL, .38), canvasC, canvasH]);
|
|
303
|
+
const [raisedL, raisedC, raisedH] = toLch(tokens['--ui-surface-raised']);
|
|
304
|
+
tokens['--ui-surface-raised'] = readableColour(fromLch([Math.max(raisedL, Math.min(canvasL, .38) + .08), raisedC, raisedH]), [ink], 7, paper);
|
|
305
|
+
tokens['--ui-surface-sunken'] = fromLch([Math.max(0, Math.min(canvasL, .38) - .035), canvasC, canvasH]);
|
|
306
|
+
} else tokens['--ui-surface-sunken'] = surface(mix(tokens['--ui-surface-raised'], tokens['--ui-surface'], .92));
|
|
217
307
|
const surfaces = ['--ui-surface', '--ui-surface-raised', '--ui-surface-sunken'].map(name => tokens[name]);
|
|
218
|
-
const
|
|
308
|
+
const accents = { primary: seeds.action, secondary: seeds['secondary-action'], tertiary: seeds['tertiary-action'] };
|
|
309
|
+
const tones = { accent: accents.primary, 'accent-secondary': accents.secondary, 'accent-tertiary': accents.tertiary };
|
|
310
|
+
const brandChroma = Math.min(.20, Math.max(.08, toLch(accents.primary)[1]));
|
|
311
|
+
for (const role of ['danger','success','warning','info']) {
|
|
312
|
+
const source = values[role + '-source'];
|
|
313
|
+
if (source === 'derived' || source === 'related') {
|
|
314
|
+
let [l, , h] = toLch(statusSeeds[role]);
|
|
315
|
+
if (source === 'related') {
|
|
316
|
+
const brandHue = toLch(accents.primary)[2];
|
|
317
|
+
const delta = ((brandHue - h + 540) % 360) - 180;
|
|
318
|
+
h += Math.max(-15, Math.min(15, delta));
|
|
319
|
+
}
|
|
320
|
+
tones[role] = fromLch([l, brandChroma * (.5 + Number(values['status-chroma'])) * (.6 + Number(values['color-intensity']) * .8), h]);
|
|
321
|
+
} else tones[role] = accents[source];
|
|
322
|
+
}
|
|
219
323
|
for (const [tone, original] of Object.entries(tones)) {
|
|
220
|
-
const
|
|
221
|
-
const
|
|
222
|
-
const fill = readableColour(seed, surfaces, 5, ink);
|
|
324
|
+
const fill = original;
|
|
325
|
+
const onFill = foreground(fill, '#ffffff', '#000000');
|
|
223
326
|
tokens[`--ui-${tone}`] = fill;
|
|
224
|
-
tokens[`--ui-on-${tone}`] =
|
|
225
|
-
tokens[`--ui-${tone}-on-strong`] =
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
tokens[`--ui-${tone}-
|
|
229
|
-
tokens[`--ui-${tone}-
|
|
327
|
+
tokens[`--ui-on-${tone}`] = onFill;
|
|
328
|
+
tokens[`--ui-${tone}-on-strong`] = onFill;
|
|
329
|
+
for (const [part, colour] of Object.entries(materialColours(fill, onFill, values['light-color']))) tokens[`--ui-${tone}-${part}`] = colour;
|
|
330
|
+
const stateTarget = onFill === '#000000' ? '#ffffff' : '#000000';
|
|
331
|
+
tokens[`--ui-${tone}-hover`] = mix(fill, stateTarget, .86);
|
|
332
|
+
tokens[`--ui-${tone}-active`] = mix(fill, stateTarget, .74);
|
|
333
|
+
const contextual = readableColour(fill, surfaces, 4.5, ink);
|
|
334
|
+
const quiet = mix(contextual, tokens['--ui-surface-raised'], .20);
|
|
335
|
+
const [quietL] = toLch(quiet);
|
|
336
|
+
const [, pigmentC, pigmentH] = toLch(fill);
|
|
337
|
+
const plateL = toLch(tokens['--ui-surface-raised'])[0];
|
|
338
|
+
const quietC = dark ? Math.min(pigmentC, .035) : Math.min(pigmentC, .02 + .03 * Math.max(0, Math.cos((pigmentH - 140) * Math.PI / 180)));
|
|
339
|
+
tokens[`--ui-${tone}-soft`] = readableColour(fromLch([dark ? Math.max(quietL, plateL + .07) : Math.max(.92, plateL - .04), quietC, pigmentH]), [ink], 4.5, paper);
|
|
230
340
|
}
|
|
231
|
-
//
|
|
232
|
-
|
|
341
|
+
// Quiet fills are actual alpha composites. At an extreme light/dark flip,
|
|
342
|
+
// reduce their shared tint before it would leave no readable contextual ink.
|
|
343
|
+
const quietSurfaces = strength => [...surfaces, ...(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 => [
|
|
344
|
+
mix(tokens[`--ui-${tone}`], background, .12 * strength),
|
|
345
|
+
...[.05, .12, .18, .19].map(alpha => alphaSurface(tokens[`--ui-${tone}`], background, alpha * strength)),
|
|
346
|
+
]))];
|
|
347
|
+
let tonalOpacity = 1;
|
|
348
|
+
while (tonalOpacity > 0 && quietSurfaces(tonalOpacity).some(background => contrast(ink, background) < 4.5)) tonalOpacity = Math.max(0, tonalOpacity - .01);
|
|
349
|
+
tokens['--ui-tonal-opacity'] = String(Number(tonalOpacity.toFixed(2)));
|
|
350
|
+
const readingSurfaces = quietSurfaces(tonalOpacity);
|
|
233
351
|
for (const tone of Object.keys(tones)) {
|
|
234
|
-
|
|
352
|
+
const [l, c, h] = toLch(tokens[`--ui-${tone}`]);
|
|
353
|
+
const foregroundSeed = fromLch([dark ? Math.max(l, .80) : Math.min(l, .50), Math.min(c, dark ? .16 : .18), h]);
|
|
354
|
+
tokens[`--ui-${tone}-subtle-text`] = readableColour(foregroundSeed, readingSurfaces, 4.5, ink);
|
|
355
|
+
tokens[`--ui-${tone}-soft-border`] = alphaSurface(tokens[`--ui-${tone}-subtle-text`], tokens[`--ui-${tone}-soft`], .25);
|
|
235
356
|
}
|
|
357
|
+
// Existing validation/editor hooks must receive a contextual text role, never
|
|
358
|
+
// a pressed fill. Preserve consumer overrides at their established boundaries.
|
|
359
|
+
tokens['--ui-field-danger'] = tokens['--ui-danger-subtle-text'];
|
|
360
|
+
for (const hook of ['code-keyword', 'link-color', 'toolbar-active-text', 'mention-color']) tokens[`--ui-editor-${hook}`] = tokens['--ui-accent-subtle-text'];
|
|
236
361
|
const textSeed = nativeInk === ink ? seeds.text : mix(seeds.text, ink, .08);
|
|
237
362
|
tokens['--ui-text'] = readableColour(textSeed, readingSurfaces, 4.5, ink);
|
|
238
363
|
tokens['--ui-text-secondary'] = readableColour(mix(tokens['--ui-text'], tokens['--ui-surface-raised'], .72), readingSurfaces, 4.5, ink);
|
|
239
364
|
tokens['--ui-text-muted'] = tokens['--ui-text-secondary'];
|
|
240
|
-
|
|
241
|
-
|
|
365
|
+
// Colored action edges keep a boundary when their pigment approaches a surface.
|
|
366
|
+
// Neutral controls use their own shared contrast decision below.
|
|
367
|
+
const separation = Math.min(...surfaces.map(surface => colourDistance(tokens['--ui-accent'], surface)));
|
|
368
|
+
const amplitude = .10 + .16 * separation / (separation + .20);
|
|
369
|
+
for (const tone of Object.keys(tones)) for (const state of ['', '-hover', '-active']) {
|
|
370
|
+
tokens[`--ui-${tone}${state}-border`] = actionBoundary(tokens[`--ui-${tone}${state}`], surfaces, ink, amplitude);
|
|
371
|
+
}
|
|
372
|
+
// Neutral pigment governs fills; a shared contrast floor governs every neutral
|
|
373
|
+
// control boundary independently of how close the brand pigment is to its canvas.
|
|
374
|
+
const neutralSource = values['neutral-source'];
|
|
375
|
+
const [, neutralC, neutralH] = toLch(neutralSource === 'text' || neutralSource === 'gray' ? tokens['--ui-text'] : accents[neutralSource]);
|
|
376
|
+
const neutral = fromLch([toLch(tokens['--ui-text'])[0], neutralSource === 'gray' ? 0 : Math.min(.04, neutralC), neutralH]);
|
|
377
|
+
const fillAmount = .02 + Number(values['neutral-strength']) * .16;
|
|
378
|
+
for (const [state, amount] of [['surface', fillAmount], ['hover', fillAmount + .04], ['active', fillAmount + .08]]) {
|
|
379
|
+
const tinted = mix(neutral, tokens['--ui-surface-raised'], amount * (dark ? 2.25 : 1));
|
|
380
|
+
const [l, c, h] = toLch(tinted);
|
|
381
|
+
const fill = dark ? fromLch([Math.max(l, toLch(tokens['--ui-surface-raised'])[0] + amount * 1.5), c, h]) : tinted;
|
|
382
|
+
tokens[`--ui-neutral-${state}`] = readableColour(fill, [tokens['--ui-text']], 4.5, paper);
|
|
383
|
+
}
|
|
384
|
+
const borderSurfaces = [...surfaces, tokens['--ui-neutral-surface']];
|
|
385
|
+
const engagedSurfaces = [...surfaces, tokens['--ui-neutral-hover'], tokens['--ui-neutral-active']];
|
|
386
|
+
const borderMinimum = Math.min(4.5, Number(values['neutral-border-contrast']) * (dark ? 1.15 : 1));
|
|
387
|
+
tokens['--ui-control-border'] = readableColour(mix(neutral, tokens['--ui-surface-raised'], .14), borderSurfaces, borderMinimum, ink);
|
|
388
|
+
tokens['--ui-control-border-hover'] = readableColour(tokens['--ui-control-border'], engagedSurfaces, Math.min(4.5, borderMinimum + .3), ink);
|
|
389
|
+
tokens['--ui-border'] = mix(neutral, tokens['--ui-surface-raised'], .10);
|
|
390
|
+
tokens['--ui-border-strong'] = mix(neutral, tokens['--ui-surface-raised'], .18);
|
|
391
|
+
for (const [role, fill, labels] of [
|
|
392
|
+
['surface', tokens['--ui-surface-raised'], [tokens['--ui-text'], tokens['--ui-text-secondary'], ...Object.keys(tones).map(tone => tokens[`--ui-${tone}-subtle-text`])]],
|
|
393
|
+
['neutral', tokens['--ui-neutral-surface'], tokens['--ui-text']],
|
|
394
|
+
]) for (const [part, colour] of Object.entries(materialColours(fill, labels, values['light-color']))) tokens[`--ui-${role}-${part}`] = colour;
|
|
395
|
+
// Knobs are painted foreground surfaces, not text. Bound them against the
|
|
396
|
+
// continuous track luminance range, not just its colored endpoints (3:1).
|
|
397
|
+
for (const [role, fill, track, trackFill] of [
|
|
398
|
+
['knob', tokens['--ui-text-secondary'], 'surface', tokens['--ui-surface-raised']],
|
|
399
|
+
['knob-on-accent', tokens['--ui-on-accent'], 'accent', tokens['--ui-accent']],
|
|
400
|
+
]) {
|
|
401
|
+
const [low, high] = materialLuminances(tokens[`--ui-${track}-reflection`], tokens[`--ui-${track}-shade`]);
|
|
402
|
+
const range = [Math.min(low, luminance(trackFill)), Math.max(high, luminance(trackFill), luminance(tokens[`--ui-${track}-specular`]))];
|
|
403
|
+
for (const [part, colour] of Object.entries(materialColours(fill, range, values['light-color'], 3.05))) tokens[`--ui-${role}-${part}`] = colour;
|
|
242
404
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
tokens['--ui-
|
|
246
|
-
tokens['--ui-
|
|
247
|
-
|
|
405
|
+
const selection = values['selection-accent'] === 'primary' ? 'accent' : 'accent-' + values['selection-accent'];
|
|
406
|
+
const link = values['link-accent'] === 'primary' ? 'accent' : 'accent-' + values['link-accent'];
|
|
407
|
+
tokens['--ui-link-color'] = tokens[`--ui-${link}-subtle-text`];
|
|
408
|
+
tokens['--ui-editor-link-color'] = tokens['--ui-link-color'];
|
|
409
|
+
// Contextual pigment keeps even deep brand colors visible over a dark plate.
|
|
410
|
+
const selectionPigment = tokens[`--ui-${selection}${dark ? '-subtle-text' : ''}`];
|
|
411
|
+
tokens['--ui-selection-surface'] = readableColour(mix(selectionPigment, tokens['--ui-surface-raised'], dark ? .22 : .1), [ink], dark ? 7 : 4.5, paper);
|
|
412
|
+
tokens['--ui-selection-text'] = readableColour(tokens[`--ui-${selection}-subtle-text`], [...surfaces, tokens['--ui-selection-surface']], dark ? 7 : 4.5, ink);
|
|
413
|
+
tokens['--ui-selection-border'] = mix(selectionPigment, tokens['--ui-surface-raised'], dark ? .44 : .2);
|
|
248
414
|
tokens['--ui-control-surface'] = tokens['--ui-surface-raised'];
|
|
249
415
|
// A hint is quieter than body copy; resolve it against its field, not every tinted content surface.
|
|
250
416
|
tokens['--ui-control-placeholder'] = readableColour(mix(tokens['--ui-text'], tokens['--ui-control-surface'], .5), [tokens['--ui-control-surface']], 4.5, ink);
|
|
251
|
-
tokens['--ui-control-border'] = readableColour(mix(tokens['--ui-text'], tokens['--ui-surface-raised'], .43), readingSurfaces, 3, ink);
|
|
252
|
-
tokens['--ui-control-border-hover'] = tokens['--ui-control-border'];
|
|
253
|
-
tokens['--ui-border-strong'] = tokens['--ui-control-border'];
|
|
254
417
|
tokens['--ui-disabled-text'] = mix(tokens['--ui-text'], tokens['--ui-surface-raised'], .45);
|
|
255
418
|
tokens['--ui-disabled-surface'] = tokens['--ui-surface-sunken'];
|
|
256
419
|
tokens['--ui-disabled-border'] = mix(tokens['--ui-text'], tokens['--ui-surface-raised'], .2);
|
|
257
|
-
tokens['--ui-focus-ring'] = readableColour(
|
|
420
|
+
tokens['--ui-focus-ring'] = readableColour(accents[values['focus-accent']], readingSurfaces, 3, ink);
|
|
258
421
|
tokens['--ui-focus-width'] = 'max(2px, calc(var(--ui-border-width) * 2))';
|
|
259
422
|
tokens['color-scheme'] = ink === '#000000' ? 'light' : 'dark';
|
|
260
|
-
for (const [id, property] of [['
|
|
423
|
+
for (const [id, property] of [['canvas', '--ui-surface'], ['surface', '--ui-surface-raised'], ['text', '--ui-text']]) {
|
|
261
424
|
if (tokens[property].toLowerCase() !== values[id].toLowerCase()) adjustments.push({ id, requested: values[id], resolved: tokens[property], reason: 'Adjusted to keep the shared palette readable.' });
|
|
262
425
|
}
|
|
263
426
|
const colors = Object.fromEntries(Object.entries(tokens).filter(([key]) => !geometry.has(key) || /^#[\da-f]{6}$/i.test(tokens[key])));
|
|
@@ -285,7 +448,7 @@ export function themeCSS(input, systemCSS = '', { scope = 'portable' } = {}) {
|
|
|
285
448
|
if (/^#[\da-f]{6}$/i.test(value)) palette.push(` ${name}: light-dark(${value}, ${dark[name]});`);
|
|
286
449
|
else {
|
|
287
450
|
const relative = relativeLengths.get(name);
|
|
288
|
-
const resolved = relative ? value.replace(relative, `calc(${parseFloat(relative)} * var(--_ui-root-font-unit, 1rem))`) : value;
|
|
451
|
+
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;
|
|
289
452
|
geometry.push(` ${name}: ${resolved};`);
|
|
290
453
|
}
|
|
291
454
|
}
|
package/docs/value-editors.mjs
CHANGED
|
@@ -4,10 +4,11 @@ const timeUnits = { ms: 1, s: 1000 };
|
|
|
4
4
|
const rounded = value => String(Number(Number(value).toFixed(6)));
|
|
5
5
|
|
|
6
6
|
export function valueEditor(field, value, { remPixels = 16 } = {}) {
|
|
7
|
+
if (field.type === 'inherited-length') return { kind: 'inherited-size', value };
|
|
7
8
|
if (field.id === 'text-size') return { kind: 'number', value, unit: 'px', min: field.min, max: field.max, step: 1 };
|
|
8
9
|
if (field.type === 'choice') return { kind: 'choice', value };
|
|
9
10
|
if (field.type === 'easing') return { kind: /^step-/.test(value) ? 'text' : 'curve', value };
|
|
10
|
-
if (['colour', 'font'].includes(field.type)) return { kind: 'text', value };
|
|
11
|
+
if (['colour', 'optional-colour', 'font'].includes(field.type)) return { kind: 'text', value };
|
|
11
12
|
if (field.type.includes('length') || field.type === 'time') {
|
|
12
13
|
const unit = value.match(/[a-z]+$/i)?.[0] ?? 'px';
|
|
13
14
|
// Convert authoring limits against the same root as the displayed quantity.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@threadlabs/looma",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.43.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.2 <1",
|
|
131
131
|
"@threadlabs/markupkit": ">=0.2.0 <1",
|
|
132
132
|
"vite": ">=7.2.7 <9"
|
|
133
133
|
},
|
package/styles/ui-action-bar.css
CHANGED
|
@@ -7,17 +7,11 @@
|
|
|
7
7
|
[data-component~="ui-action-bar"] { --html-next-scope-owner: "ui-action-bar" !important; }
|
|
8
8
|
}
|
|
9
9
|
@scope ([data-component~="ui-action-bar"]) to ([data-component], [data-slotted]) {
|
|
10
|
-
/*
|
|
11
|
-
@property --ui-action-bar-gap {
|
|
12
|
-
syntax: "*";
|
|
13
|
-
inherits: false;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/* The action row of a form or dialog. Tertiary actions (Back, Cancel, Discard) sit at the start
|
|
10
|
+
/* The action row of a form or dialog. Tertiary actions (Back, Cancel, Discard) sit at the start
|
|
17
11
|
edge; secondary actions (Save as draft, Preview) sit just before the primary one, which ends the
|
|
18
12
|
row. The bar arranges its actions and leaves their look to them. */
|
|
19
13
|
:scope:where([data-component~="ui-action-bar"]) {
|
|
20
|
-
/*
|
|
14
|
+
/* Resolve shared part values at the component root. */
|
|
21
15
|
--_ui-action-bar-gap: var(--ui-action-bar-gap);
|
|
22
16
|
|
|
23
17
|
--_gap: var(--ui-space-2);
|
|
@@ -77,9 +71,7 @@
|
|
|
77
71
|
}
|
|
78
72
|
}
|
|
79
73
|
@scope ([data-component~="ui-action-bar"]) to ([data-component]) {
|
|
80
|
-
/*
|
|
81
|
-
|
|
82
|
-
/* The action row of a form or dialog. Tertiary actions (Back, Cancel, Discard) sit at the start
|
|
74
|
+
/* The action row of a form or dialog. Tertiary actions (Back, Cancel, Discard) sit at the start
|
|
83
75
|
edge; secondary actions (Save as draft, Preview) sit just before the primary one, which ends the
|
|
84
76
|
row. The bar arranges its actions and leaves their look to them. */
|
|
85
77
|
|
|
@@ -9,17 +9,17 @@
|
|
|
9
9
|
@scope ([data-component~="ui-affordance-scope"]) to ([data-component], [data-slotted]) {
|
|
10
10
|
:scope:where([data-component~="ui-affordance-scope"]) {
|
|
11
11
|
display: contents !important;
|
|
12
|
-
--
|
|
13
|
-
--
|
|
12
|
+
--_ui-affordance-scope-engaged: 0;
|
|
13
|
+
--_ui-affordance-scope-guide: 1;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
:scope:where([data-component~="ui-affordance-scope"])[data-ui-affordance-scope-state~="engaged"] {
|
|
17
|
-
--
|
|
17
|
+
--_ui-affordance-scope-engaged: 1;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/* Published to descendants: each guide multiplies its opacity by it, so none reaches them all. */
|
|
21
21
|
:scope:where([data-component~="ui-affordance-scope"])[data-ui-affordance-scope-state~="guide=none"] {
|
|
22
|
-
--
|
|
22
|
+
--_ui-affordance-scope-guide: 0;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/* A component that sets its display still honours the hidden attribute on its root. */
|
|
@@ -7,18 +7,8 @@
|
|
|
7
7
|
[data-component~="ui-avatar-group"] { --html-next-scope-owner: "ui-avatar-group" !important; }
|
|
8
8
|
}
|
|
9
9
|
@scope ([data-component~="ui-avatar-group"]) to ([data-component], [data-slotted]) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
syntax: "*";
|
|
13
|
-
inherits: false;
|
|
14
|
-
}
|
|
15
|
-
@property --ui-avatar-group-overlap-shadow {
|
|
16
|
-
syntax: "*";
|
|
17
|
-
inherits: false;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
:scope:where([data-component~="ui-avatar-group"]) {
|
|
21
|
-
/* Hooks do not inherit, so the parts below read them from the root. */
|
|
10
|
+
:scope:where([data-component~="ui-avatar-group"]) {
|
|
11
|
+
/* Resolve shared part values at the component root. */
|
|
22
12
|
--_ui-avatar-group-overlap-shadow: var(--ui-avatar-group-overlap-shadow);
|
|
23
13
|
--_ui-avatar-group-edge-ring: var(--ui-avatar-group-edge-ring);
|
|
24
14
|
|
|
@@ -84,9 +74,7 @@
|
|
|
84
74
|
}
|
|
85
75
|
}
|
|
86
76
|
@scope ([data-component~="ui-avatar-group"]) to ([data-component]) {
|
|
87
|
-
/*
|
|
88
|
-
|
|
89
|
-
/* Overlap and the separating shadow are applied by the controller: slotted avatars are nested
|
|
77
|
+
/* Overlap and the separating shadow are applied by the controller: slotted avatars are nested
|
|
90
78
|
* component roots outside this style scope. */
|
|
91
79
|
:where([data-slotted], [data-slotted] *):is(*) {
|
|
92
80
|
margin-inline-start: -0.5rem !important;
|
package/styles/ui-avatar.css
CHANGED
|
@@ -7,29 +7,7 @@
|
|
|
7
7
|
[data-component~="ui-avatar"] { --html-next-scope-owner: "ui-avatar" !important; }
|
|
8
8
|
}
|
|
9
9
|
@scope ([data-component~="ui-avatar"]) to ([data-component], [data-slotted]) {
|
|
10
|
-
|
|
11
|
-
@property --ui-avatar-border {
|
|
12
|
-
syntax: "*";
|
|
13
|
-
inherits: false;
|
|
14
|
-
}
|
|
15
|
-
@property --ui-avatar-radius {
|
|
16
|
-
syntax: "*";
|
|
17
|
-
inherits: false;
|
|
18
|
-
}
|
|
19
|
-
@property --ui-avatar-surface {
|
|
20
|
-
syntax: "*";
|
|
21
|
-
inherits: false;
|
|
22
|
-
}
|
|
23
|
-
@property --ui-avatar-text {
|
|
24
|
-
syntax: "*";
|
|
25
|
-
inherits: false;
|
|
26
|
-
}
|
|
27
|
-
@property --ui-avatar-active-ring {
|
|
28
|
-
syntax: "*";
|
|
29
|
-
inherits: false;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
:scope:where([data-component~="ui-avatar"]) {
|
|
10
|
+
:scope:where([data-component~="ui-avatar"]) {
|
|
33
11
|
--_ui-default-icon-size: 1.25rem;
|
|
34
12
|
display: inline-grid !important;
|
|
35
13
|
place-items: center;
|
|
@@ -115,9 +93,7 @@
|
|
|
115
93
|
}
|
|
116
94
|
}
|
|
117
95
|
@scope ([data-component~="ui-avatar"]) to ([data-component]) {
|
|
118
|
-
/*
|
|
119
|
-
|
|
120
|
-
/* An outline, not a dot: the avatar clips its content to the circle, and an outline is drawn
|
|
96
|
+
/* An outline, not a dot: the avatar clips its content to the circle, and an outline is drawn
|
|
121
97
|
outside the box, so the ring survives the clip and the overlap in an Avatar Group. */
|
|
122
98
|
|
|
123
99
|
.image,
|