@threadlabs/looma 0.42.0 → 0.43.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/components/ui-action-bar/ui-action-bar.html +1 -7
  2. package/components/ui-affordance-scope/ui-affordance-scope.html +4 -4
  3. package/components/ui-avatar/ui-avatar.html +0 -22
  4. package/components/ui-avatar-group/ui-avatar-group.html +1 -11
  5. package/components/ui-badge/ui-badge.html +57 -78
  6. package/components/ui-button/ui-button.html +36 -81
  7. package/components/ui-callout/ui-callout.html +30 -68
  8. package/components/ui-card/ui-card.html +47 -21
  9. package/components/ui-checkbox/ui-checkbox.html +1 -15
  10. package/components/ui-cluster/ui-cluster.html +1 -7
  11. package/components/ui-combobox/ui-combobox.html +7 -70
  12. package/components/ui-container/ui-container.html +2 -12
  13. package/components/ui-context-menu/ui-context-menu.html +1 -23
  14. package/components/ui-dialog/ui-dialog.html +1 -31
  15. package/components/ui-disclosure/ui-disclosure.html +1 -15
  16. package/components/ui-editor-mention-menu/ui-editor-mention-menu.js +3 -0
  17. package/components/ui-editor-slash-menu/ui-editor-slash-menu.js +4 -0
  18. package/components/ui-editor-table-overlay/ui-editor-table-overlay.html +3 -2
  19. package/components/ui-floating-action-button/ui-floating-action-button.html +0 -14
  20. package/components/ui-form-field/ui-form-field.html +2 -32
  21. package/components/ui-grid/ui-grid.html +1 -11
  22. package/components/ui-icon/ui-icon.html +1 -12
  23. package/components/ui-icon-button/ui-icon-button.html +52 -87
  24. package/components/ui-input/ui-input.html +5 -55
  25. package/components/ui-input-group/ui-input-group.html +1 -13
  26. package/components/ui-list/ui-list.html +0 -10
  27. package/components/ui-list-item/ui-list-item.html +1 -19
  28. package/components/ui-listbox/ui-listbox.html +0 -21
  29. package/components/ui-menu/ui-menu.html +0 -22
  30. package/components/ui-menu-item/ui-menu-item.html +0 -26
  31. package/components/ui-meter/ui-meter.html +11 -6
  32. package/components/ui-nav-item/ui-nav-item.html +0 -18
  33. package/components/ui-popover/ui-popover.html +0 -30
  34. package/components/ui-radio/ui-radio.html +7 -13
  35. package/components/ui-radio-group/ui-radio-group.html +0 -5
  36. package/components/ui-reel/ui-reel.html +1 -11
  37. package/components/ui-search-result-row/ui-search-result-row.html +0 -34
  38. package/components/ui-search-shell/ui-search-shell.html +1 -43
  39. package/components/ui-select/ui-select.html +0 -42
  40. package/components/ui-separator/ui-separator.html +0 -6
  41. package/components/ui-sidebar/ui-sidebar.html +2 -24
  42. package/components/ui-site-header/ui-site-header.html +0 -25
  43. package/components/ui-skeleton/ui-skeleton.html +0 -9
  44. package/components/ui-stack/ui-stack.html +6 -11
  45. package/components/ui-swatch/ui-swatch.html +0 -5
  46. package/components/ui-switch/ui-switch.html +1 -15
  47. package/components/ui-switcher/ui-switcher.html +1 -11
  48. package/components/ui-tabs/ui-tabs.html +1 -19
  49. package/components/ui-text/ui-text.html +19 -6
  50. package/components/ui-textarea/ui-textarea.html +0 -50
  51. package/components/ui-toast/ui-toast.html +12 -27
  52. package/components/ui-toast-region/ui-toast-region.html +13 -34
  53. package/components/ui-tooltip/ui-tooltip.html +1 -43
  54. package/components/ui-top-bar/ui-top-bar.html +1 -31
  55. package/components/ui-tree/ui-tree.html +1 -16
  56. package/components/ui-tree-item/ui-tree-item.html +1 -23
  57. package/components/ui-tree-item/ui-tree-item.js +0 -1
  58. package/dist/index.js +1 -1
  59. package/docs/README.md +13 -11
  60. package/docs/card.html +2 -6
  61. package/docs/card.js +7 -37
  62. package/docs/catalog.json +821 -202
  63. package/docs/catalog.mjs +1 -1
  64. package/docs/customizer-render.mjs +27 -14
  65. package/docs/customizer.js +42 -9
  66. package/docs/documentation.css +3 -7
  67. package/docs/examples/ui-button/examples/08-loading.behavior.js +1 -1
  68. package/docs/examples/ui-checkbox/examples/02-checked-indeterminate-and-disabled.behavior.js +1 -1
  69. package/docs/examples/ui-editor-mention-menu/examples/00-preview.behavior.js +1 -0
  70. package/docs/examples/ui-editor-slash-menu/examples/00-preview.behavior.js +81 -0
  71. package/docs/examples/ui-editor-table-overlay/examples/00-preview.behavior.js +24 -0
  72. package/docs/examples/ui-search-shell/examples/00-preview.behavior.js +14 -0
  73. package/docs/examples/ui-search-shell/examples/02-label-dismissible-status-and-footer.behavior.js +7 -7
  74. package/docs/examples/ui-toast/examples/01-authored.behavior.js +2 -2
  75. package/docs/index.d.ts +1 -1
  76. package/docs/local-server.mjs +2 -5
  77. package/docs/palette.mjs +5 -4
  78. package/docs/pastoral.svg +54 -0
  79. package/docs/portrait.svg +15 -0
  80. package/docs/render.mjs +33 -3
  81. package/docs/site.mjs +22 -54
  82. package/docs/theme.mjs +97 -35
  83. package/docs/value-editors.mjs +2 -1
  84. package/package.json +2 -2
  85. package/styles/ui-action-bar.css +3 -11
  86. package/styles/ui-affordance-scope.css +4 -4
  87. package/styles/ui-avatar-group.css +3 -15
  88. package/styles/ui-avatar.css +2 -26
  89. package/styles/ui-badge.css +56 -80
  90. package/styles/ui-button.css +35 -83
  91. package/styles/ui-callout.css +32 -72
  92. package/styles/ui-card.css +42 -18
  93. package/styles/ui-checkbox.css +3 -19
  94. package/styles/ui-cluster.css +2 -10
  95. package/styles/ui-combobox.css +7 -140
  96. package/styles/ui-container.css +2 -14
  97. package/styles/ui-context-menu.css +3 -27
  98. package/styles/ui-dialog.css +5 -67
  99. package/styles/ui-disclosure.css +3 -19
  100. package/styles/ui-editor-table-overlay.css +2 -2
  101. package/styles/ui-floating-action-button.css +2 -18
  102. package/styles/ui-form-field.css +4 -36
  103. package/styles/ui-grid.css +2 -14
  104. package/styles/ui-icon-button.css +51 -89
  105. package/styles/ui-icon.css +3 -16
  106. package/styles/ui-input-group.css +2 -14
  107. package/styles/ui-input.css +6 -57
  108. package/styles/ui-list-item.css +3 -23
  109. package/styles/ui-list.css +2 -14
  110. package/styles/ui-listbox.css +2 -44
  111. package/styles/ui-menu-item.css +2 -30
  112. package/styles/ui-menu.css +2 -26
  113. package/styles/ui-meter.css +8 -4
  114. package/styles/ui-nav-item.css +2 -22
  115. package/styles/ui-popover.css +2 -34
  116. package/styles/ui-radio-group.css +1 -6
  117. package/styles/ui-radio.css +9 -17
  118. package/styles/ui-reel.css +2 -14
  119. package/styles/ui-search-result-row.css +2 -38
  120. package/styles/ui-search-shell.css +3 -47
  121. package/styles/ui-select.css +2 -46
  122. package/styles/ui-separator.css +2 -10
  123. package/styles/ui-sidebar.css +4 -28
  124. package/styles/ui-site-header.css +1 -26
  125. package/styles/ui-skeleton.css +2 -12
  126. package/styles/ui-stack.css +4 -12
  127. package/styles/ui-swatch.css +1 -6
  128. package/styles/ui-switch.css +3 -19
  129. package/styles/ui-switcher.css +2 -14
  130. package/styles/ui-tabs.css +3 -23
  131. package/styles/ui-text.css +10 -2
  132. package/styles/ui-textarea.css +2 -54
  133. package/styles/ui-toast-region.css +29 -73
  134. package/styles/ui-toast.css +24 -54
  135. package/styles/ui-tooltip.css +3 -47
  136. package/styles/ui-top-bar.css +3 -35
  137. package/styles/ui-tree-item.css +5 -51
  138. package/styles/ui-tree.css +3 -20
  139. package/theme-system.css +6 -2
  140. package/tokens.css +55 -21
  141. package/vanilla/UiBadge.d.ts +1 -1
  142. package/vanilla/UiBadge.js +1 -1
  143. package/vanilla/UiButton.d.ts +1 -1
  144. package/vanilla/UiButton.js +1 -1
  145. package/vanilla/UiCard.d.ts +1 -1
  146. package/vanilla/UiCard.js +1 -1
  147. package/vanilla/UiEditorTableOverlay.js +50 -36
  148. package/vanilla/UiIconButton.d.ts +1 -1
  149. package/vanilla/UiIconButton.js +1 -1
  150. package/vanilla/UiMeter.d.ts +1 -1
  151. package/vanilla/UiMeter.js +1 -1
  152. package/vanilla/UiStack.js +1 -1
  153. package/vanilla/UiText.d.ts +1 -1
  154. package/vanilla/UiText.js +1 -1
  155. package/vue/UiActionBar.vue +3 -9
  156. package/vue/UiAffordanceScope.vue +4 -4
  157. package/vue/UiAvatar.vue +1 -28
  158. package/vue/UiAvatarGroup.vue +1 -11
  159. package/vue/UiBadge.d.ts +2 -2
  160. package/vue/UiBadge.vue +84 -81
  161. package/vue/UiButton.d.ts +2 -2
  162. package/vue/UiButton.vue +78 -97
  163. package/vue/UiCallout.vue +30 -71
  164. package/vue/UiCard.d.ts +2 -2
  165. package/vue/UiCard.vue +77 -26
  166. package/vue/UiCheckbox.vue +1 -15
  167. package/vue/UiCluster.vue +1 -10
  168. package/vue/UiCombobox.vue +13 -72
  169. package/vue/UiContainer.vue +1 -13
  170. package/vue/UiContextMenu.vue +1 -30
  171. package/vue/UiDialog.vue +3 -33
  172. package/vue/UiDisclosure.vue +1 -15
  173. package/vue/UiEditorTableOverlay.d.ts +11 -1
  174. package/vue/UiEditorTableOverlay.vue +100 -65
  175. package/vue/UiFloatingActionButton.vue +0 -22
  176. package/vue/UiFormField.vue +6 -33
  177. package/vue/UiGrid.vue +1 -13
  178. package/vue/UiIcon.vue +1 -16
  179. package/vue/UiIconButton.d.ts +2 -2
  180. package/vue/UiIconButton.vue +103 -99
  181. package/vue/UiInput.vue +1 -54
  182. package/vue/UiInputGroup.vue +8 -20
  183. package/vue/UiList.vue +2 -12
  184. package/vue/UiListItem.vue +8 -26
  185. package/vue/UiListbox.vue +0 -23
  186. package/vue/UiMenu.vue +1 -23
  187. package/vue/UiMenuItem.vue +0 -26
  188. package/vue/UiMeter.d.ts +2 -2
  189. package/vue/UiMeter.vue +47 -12
  190. package/vue/UiNavItem.vue +3 -21
  191. package/vue/UiPopover.vue +1 -32
  192. package/vue/UiRadio.vue +1 -11
  193. package/vue/UiRadioGroup.vue +0 -11
  194. package/vue/UiReel.vue +1 -11
  195. package/vue/UiSearchResultRow.vue +0 -35
  196. package/vue/UiSearchShell.vue +1 -53
  197. package/vue/UiSelect.vue +0 -42
  198. package/vue/UiSeparator.vue +0 -7
  199. package/vue/UiSidebar.vue +3 -26
  200. package/vue/UiSiteHeader.vue +0 -24
  201. package/vue/UiSkeleton.vue +0 -9
  202. package/vue/UiStack.vue +6 -11
  203. package/vue/UiSwatch.vue +1 -6
  204. package/vue/UiSwitch.vue +1 -15
  205. package/vue/UiSwitcher.vue +1 -14
  206. package/vue/UiTabs.vue +1 -19
  207. package/vue/UiText.d.ts +2 -2
  208. package/vue/UiText.vue +29 -4
  209. package/vue/UiTextarea.vue +0 -50
  210. package/vue/UiToast.vue +26 -34
  211. package/vue/UiToastRegion.vue +26 -55
  212. package/vue/UiTooltip.vue +1 -43
  213. package/vue/UiTopBar.vue +1 -34
  214. package/vue/UiTree.vue +2 -17
  215. package/vue/UiTreeItem.vue +2 -28
  216. package/vue/chunks/UiActionBar.js +1 -1
  217. package/vue/chunks/UiAffordanceScope.js +1 -1
  218. package/vue/chunks/UiAvatar.js +1 -1
  219. package/vue/chunks/UiAvatarGroup.js +1 -1
  220. package/vue/chunks/UiBadge.js +4 -2
  221. package/vue/chunks/UiButton.js +4 -2
  222. package/vue/chunks/UiCallout.js +1 -1
  223. package/vue/chunks/UiCard.js +5 -3
  224. package/vue/chunks/UiCheckbox.js +1 -1
  225. package/vue/chunks/UiCluster.js +2 -2
  226. package/vue/chunks/UiCombobox.js +3 -3
  227. package/vue/chunks/UiContainer.js +2 -2
  228. package/vue/chunks/UiContextMenu.js +1 -1
  229. package/vue/chunks/UiDialog.js +1 -1
  230. package/vue/chunks/UiDisclosure.js +1 -1
  231. package/vue/chunks/UiEditorTableOverlay.js +41 -13
  232. package/vue/chunks/UiFloatingActionButton.js +1 -1
  233. package/vue/chunks/UiFormField.js +1 -1
  234. package/vue/chunks/UiGrid.js +2 -2
  235. package/vue/chunks/UiIcon.js +1 -1
  236. package/vue/chunks/UiIconButton.js +4 -2
  237. package/vue/chunks/UiInput.js +1 -1
  238. package/vue/chunks/UiInputGroup.js +1 -1
  239. package/vue/chunks/UiList.js +1 -1
  240. package/vue/chunks/UiListItem.js +1 -1
  241. package/vue/chunks/UiListbox.js +1 -1
  242. package/vue/chunks/UiMenu.js +1 -1
  243. package/vue/chunks/UiMenuItem.js +1 -1
  244. package/vue/chunks/UiMeter.js +4 -2
  245. package/vue/chunks/UiNavItem.js +1 -1
  246. package/vue/chunks/UiPopover.js +1 -1
  247. package/vue/chunks/UiRadio.js +1 -1
  248. package/vue/chunks/UiRadioGroup.js +1 -1
  249. package/vue/chunks/UiReel.js +2 -2
  250. package/vue/chunks/UiSearchResultRow.js +1 -1
  251. package/vue/chunks/UiSearchShell.js +1 -1
  252. package/vue/chunks/UiSelect.js +1 -1
  253. package/vue/chunks/UiSeparator.js +1 -1
  254. package/vue/chunks/UiSidebar.js +1 -1
  255. package/vue/chunks/UiSiteHeader.js +1 -1
  256. package/vue/chunks/UiSkeleton.js +1 -1
  257. package/vue/chunks/UiStack.js +3 -3
  258. package/vue/chunks/UiSwatch.js +1 -1
  259. package/vue/chunks/UiSwitch.js +1 -1
  260. package/vue/chunks/UiSwitcher.js +2 -2
  261. package/vue/chunks/UiTabs.js +1 -1
  262. package/vue/chunks/UiText.js +4 -2
  263. package/vue/chunks/UiTextarea.js +1 -1
  264. package/vue/chunks/UiToast.js +1 -1
  265. package/vue/chunks/UiToastRegion.js +1 -1
  266. package/vue/chunks/UiTooltip.js +1 -1
  267. package/vue/chunks/UiTopBar.js +1 -1
  268. package/vue/chunks/UiTree.js +1 -1
  269. package/vue/chunks/UiTreeItem.js +1 -1
  270. package/vue/components.css +633 -2068
  271. package/vue/editor/index.js +7 -1
  272. package/docs/preview.js +0 -22
package/docs/catalog.mjs CHANGED
@@ -27,7 +27,7 @@ export async function readExamples(directory, componentId) {
27
27
  if (files.includes(name + extension)) frameworks[target] = { language, code: await readFile(path.join(directory, name + extension), 'utf8') };
28
28
  }
29
29
  const behavior = files.includes(name + '.behavior.ts') ? path.join(directory, name + '.behavior.ts') : files.includes(name + '.behavior.js') ? path.join(directory, name + '.behavior.js') : undefined;
30
- return { id: `${componentId}/${name}`, name, title: fields.title ?? name, description: fields.description ?? '', markup: source.slice(meta[0].length).trim(), resizable: fields.preview === 'resizable', bindings: fields.bind ?? '', frameworks, ...(behavior ? { behavior } : {}) };
30
+ return { id: `${componentId}/${name}`, name, title: fields.title ?? name, description: fields.description ?? '', markup: source.slice(meta[0].length).trim(), resizable: fields.preview === 'resizable', ...(fields.preview === 'stretch' ? { stretch: true } : {}), bindings: fields.bind ?? '', frameworks, ...(behavior ? { behavior } : {}) };
31
31
  }));
32
32
  }
33
33
 
@@ -1,22 +1,33 @@
1
1
  import { googleFonts, systemFont } from './fonts.mjs';
2
2
  import { escapeHtml as escape } from './catalog.mjs';
3
- import { componentPath, previewPath } from './render.mjs';
3
+ import { componentPath, previewMarkup, exampleKey, exampleResources, cardDescription } from './render.mjs';
4
4
  import { valueEditor } from './value-editors.mjs';
5
5
  import { defaultRecipe, themeFields, startingPoints, startingPointLabels, startingPointFor, deriveTheme, applyRefinement, themeCSS, validateRecipe, themePalettes, materialPresets, refinementState } from './theme.mjs';
6
6
 
7
7
  export function customizerResource(site, input = defaultRecipe()) {
8
8
  const recipe = validateRecipe(input);
9
- const cardFields = ['id', 'title', 'description', 'exampleTitle', 'src', '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: component.description, exampleTitle: example.title, src: site.base + previewPath(example).slice(1), 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) })));
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) })));
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]));
14
+ let specimen = 0;
14
15
  const documentationCard = (tag, suffix, previewOnly = false) => {
15
16
  const example = examples.find(item => item.tag === tag && (!suffix || item.id.endsWith(suffix))) ?? examples.find(item => item.tag === tag);
16
- return example ? `<looma-example-card ${previewOnly ? 'preview-only' : ''} ${cardFields.filter(key => key !== 'id').map(key => `${key.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase())}="${escape(String(example[key]))}"`).join(' ')} identity="${escape(example.id)}" loading="lazy"></looma-example-card>` : '';
17
+ return example ? `<looma-example-card ${previewOnly ? 'preview-only' : ''} ${cardFields.filter(key => key !== 'id').map(key => `${key.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase())}="${escape(String(example[key]))}"`).join(' ')} identity="${escape(example.id)}">${previewMarkup(site.catalog.components.flatMap(component => component.examples).find(item => item.id === example.id), `customizer-${specimen++}-${exampleKey(example.id)}`, site.base, example.category === 'layout')}</looma-example-card>` : '';
17
18
  };
18
19
  const renderField = field => {
19
- const value = recipe.values[field.id], editor = valueEditor(field, value, { remPixels: parseFloat(recipe.values['text-size']) });
20
+ const value = recipe.values[field.id];
21
+ if (field.id === 'label-size') {
22
+ const inherited = value === 'inherit', size = inherited ? recipe.values['text-size'] : value;
23
+ return `<ui-form-field><label slot="label" for="theme-label-source">Field label size</label><span slot="help">${escape(field.description)}</span><ui-stack gap="xs"><ui-select id="theme-label-source" size="sm" data-label-size-source value="${inherited ? 'inherit' : 'custom'}"><option value="inherit">Follow body text</option><option value="custom">Set a separate size</option></ui-select><ui-number-input id="theme-label-size" size="sm" data-label-size-value label="Independent field label size" value="${escape(size)}" unit="${size.match(/[a-z]+$/i)?.[0] ?? 'px'}" min="0.1" step="1"${inherited ? ' hidden' : ''}></ui-number-input></ui-stack></ui-form-field>`;
24
+ }
25
+ if (field.type === 'optional-colour') {
26
+ const custom = value !== field.defaultValue;
27
+ const fallback = recipe.values.action;
28
+ return `<ui-form-field><label slot="label" for="theme-${field.id}-source">${escape(field.label)}</label><span slot="help">${escape(field.description)}</span><ui-stack gap="xs"><ui-select id="theme-${field.id}-source" size="sm" data-color-source="${field.id}" value="${custom ? 'custom' : 'default'}"><option value="default">Not used</option><option value="custom">Choose a color</option></ui-select><ui-color-picker id="theme-${field.id}" data-token="${field.id}" data-optional-color="${field.id}" value="${escape(custom ? value : fallback)}" label="${escape(field.label)} colour picker"${custom ? '' : ' hidden'}></ui-color-picker></ui-stack></ui-form-field>`;
29
+ }
30
+ const editor = valueEditor(field, value, { remPixels: parseFloat(recipe.values['text-size']) });
20
31
  const common = `size="sm" data-token="${field.id}" label="${escape(field.label)}"`;
21
32
  let control;
22
33
  if (field.type === 'font') {
@@ -47,33 +58,35 @@ export function customizerResource(site, input = defaultRecipe()) {
47
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>` : '';
48
59
  return choice(`id="${location}-${family}" data-refinement-preset="${family}"${muted ? ' muted' : ''}`, `${label} preset`, state.id, options, preview);
49
60
  };
50
- const paletteDetails = `<ui-grid columns="2" gap="s" style="--ui-grid-min: 8rem">${['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-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-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>`;
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>`;
51
62
  const paletteRelationships = `<ui-stack gap="s"><ui-text variant="heading" as="h3">How should the colors work together?</ui-text>${[
52
63
  ['preserve', 'Keep my colors', 'Keep the base colors as chosen. Warmth and intensity still refine the result.'],
53
64
  ['neighboring', 'Related colors', 'Tint neutral surfaces with a neighboring hue for a closely coordinated palette.'],
54
65
  ['complementary', 'Contrasting colors', 'Tint neutral surfaces toward the opposite hue for warm–cool contrast.'],
55
66
  ].map(([id,label,description]) => `<ui-button variant="card" tone="neutral" data-action="palette-relationship" data-relationship="${id}" aria-pressed="${recipe.values['palette-relationship'] === id}"><ui-stack gap="xs"><ui-text variant="label">${label}</ui-text><span class="palette-range" data-relationship-preview="${id}" aria-hidden="true"><span class="palette-canvas"></span><span class="palette-content"></span><span class="palette-action"></span></span><ui-text variant="caption">${description}</ui-text></ui-stack><span slot="action" data-relationship-selected="${id}"${recipe.values['palette-relationship'] === id ? '' : ' hidden'}><ui-icon name="check"></ui-icon></span></ui-button>`).join('')}</ui-stack>`;
56
- const sizePreview = `<ui-text variant="caption">Shared size ladder: buttons, fields and swatches align at each step.</ui-text><ui-stack>${['sm','md','lg'].map((size,index) => `<ui-stack gap="xs" data-size-sample="${size}"><ui-text variant="caption">${['Small','Medium','Large'][index]}<span data-size-readout></span></ui-text><ui-cluster><ui-button size="${size}">Action</ui-button><ui-input size="${size}" style="--ui-input-inline-size: 10ch" label="${size} size sample" value="Frodo"></ui-input><ui-color-picker size="${size}" label="${size} swatch sample"></ui-color-picker></ui-cluster></ui-stack>`).join('')}</ui-stack><div class="spacing-samples" data-spacing-samples role="img" aria-label="Spacing progression"><span></span><span></span><span></span><span></span></div>`;
67
+ const sizePreview = `<ui-stack gap="l"><ui-text size="md">Compare the same actions and fields at each size. Rhythm separates these groups and opens the lines of text; spacing adjusts the room between controls.</ui-text><ui-stack gap="xl" data-size-groups>${['sm','md','lg'].map((size,index) => `<ui-stack gap="s" data-size-sample="${size}"><ui-text weight="medium" size="md">${['Small','Medium','Large'][index]}<span data-size-readout></span></ui-text><ui-cluster data-size-actions><ui-button size="${size}" variant="solid" tone="accent">Create</ui-button><ui-button size="${size}" variant="outline" tone="accent">Save</ui-button><ui-button size="${size}" variant="outline" tone="neutral">Archive</ui-button></ui-cluster><ui-cluster><ui-input size="${size}" style="--ui-input-inline-size: 10ch" aria-label="${size} size sample" value="Frodo"></ui-input><ui-color-picker size="${size}" label="${size} swatch sample"></ui-color-picker></ui-cluster></ui-stack>`).join('')}</ui-stack><ui-card><ui-stack gap="s"><ui-text weight="medium" size="md">Grouped content</ui-text><ui-text size="md">Frodo plans the journey. Sam brings lunch. A longer paragraph makes the line rhythm visible alongside the space between groups.</ui-text></ui-stack></ui-card><div class="spacing-samples" data-spacing-samples role="img" aria-label="Spacing progression"><span></span><span></span><span></span><span></span></div></ui-stack>`;
57
68
  const fieldsFor = ids => ids.map(id => renderField(themeFields.find(field => field.id === id))).join('');
58
69
  const viewTitles = { material: 'Material & light', palette: 'Palette', typography: 'Typography', layout: 'Size & spacing', motion: 'Motion', themes: 'Starting theme', export: 'Export & save', components: 'Component library' };
59
70
  const refinement = (family, content) => `<section id="${family}" data-refinement-view="${family}" hidden tabindex="-1" aria-label="${viewTitles[family]} editor"><ui-stack gap="l"><ui-cluster><ui-button data-action="back"><ui-icon name="arrow-left"></ui-icon>Overview</ui-button><ui-text variant="heading" as="h2">${viewTitles[family]}</ui-text></ui-cluster>${content}</ui-stack></section>`;
60
71
  const editor = (family, preview, controls) => refinement(family, `<div class="refinement-layout"><div class="editor-preview" data-editor-preview="${family}">${preview}</div><ui-stack>${controls}</ui-stack></div>`);
61
- const typographyView = editor('typography', `<ui-card><ui-stack><ui-text variant="heading" as="h2">There and back again.</ui-text><ui-text>Frodo plans the journey. Sam brings lunch. Clear notes keep the Fellowship moving.</ui-text><ui-text variant="label">Memo ready</ui-text><ui-text variant="caption">Notes by Sméagol · Updated today</ui-text></ui-stack></ui-card>`, `${fieldsFor(['body-font','text-size'])}<ui-disclosure summary="Heading font"><ui-stack>${fieldsFor(['display-font'])}</ui-stack></ui-disclosure><ui-disclosure summary="Label emphasis"><ui-stack>${fieldsFor(['text-weight'])}</ui-stack></ui-disclosure>`);
72
+ const typographyView = editor('typography', `<ui-card><ui-stack><ui-text variant="heading" as="h2">There and back again.</ui-text><ui-text>Frodo plans the journey. Sam brings lunch. Clear notes keep the Fellowship moving.</ui-text><ui-form-field><label slot="label" for="type-sample-name">Memo title</label><ui-input id="type-sample-name" value="There and back again"></ui-input><span slot="help">Shown above your notes.</span></ui-form-field><ui-text variant="caption">Notes by Sméagol · Updated today</ui-text></ui-stack></ui-card>`, `${fieldsFor(['body-font','text-size','label-size'])}<ui-disclosure summary="Heading font"><ui-stack>${fieldsFor(['display-font'])}</ui-stack></ui-disclosure><ui-disclosure summary="Label emphasis"><ui-stack>${fieldsFor(['text-weight'])}</ui-stack></ui-disclosure>`);
62
73
  const layoutView = editor('layout', `<ui-stack>${sizePreview}</ui-stack>`, `${fieldsFor(['control-roominess','rhythm','spacing','corner-roundness'])}<ui-disclosure summary="Scale & edges"><ui-stack>${fieldsFor(['scale-contrast','space-curve','line-weight'])}</ui-stack></ui-disclosure>`);
63
74
  const motionView = editor('motion', `<ui-stack><ui-card><ui-stack><ui-text variant="eyebrow">Motion study</ui-text><div class="motion-track"><span data-motion-object aria-hidden="true"></span></div><ui-cluster><ui-button data-action="replay-motion"><ui-icon name="play"></ui-icon>Replay motion</ui-button><ui-text variant="caption" data-motion-readout></ui-text></ui-cluster><ui-text variant="caption" data-motion-preference></ui-text></ui-stack></ui-card></ui-stack>`, `${fieldsFor(['response-time'])}<ui-disclosure summary="Shape the curve"><ui-stack>${fieldsFor(['response-curve'])}</ui-stack></ui-disclosure><ui-text variant="caption">Replay shows the shared curve. Try the popover to feel it in a real component. System reduced-motion preferences are respected.</ui-text><ui-disclosure summary="Try a popover">${documentationCard('ui-popover', null, true)}</ui-disclosure>`);
75
+ const materialSurfaces = `<ui-grid columns="2" min="sm"><ui-card variant="elevated" data-material-standard><ui-stack gap="s"><ui-text weight="medium" size="md">Everyday surface</ui-text><ui-text variant="caption">A restrained lift for ordinary content.</ui-text><ui-button variant="outline" tone="neutral">Read memo</ui-button></ui-stack></ui-card><ui-card variant="elevated" treatment="expressive" data-material-expressive><ui-stack gap="s"><ui-text weight="medium" size="md">Expressive surface</ui-text><ui-text variant="caption">Finish, edge light, glow and the decorative rim.</ui-text><ui-button variant="solid" tone="accent">Join briefing</ui-button></ui-stack></ui-card></ui-grid><ui-cluster><ui-button id="material-popover-trigger" variant="outline" tone="accent">Open popover</ui-button><ui-popover for="material-popover-trigger"><ui-stack gap="s"><ui-text size="md">Floating material</ui-text><ui-text variant="caption">Adjust glass, separation and translucency with this open.</ui-text></ui-stack></ui-popover><ui-button id="material-dialog-trigger" variant="outline" tone="neutral">Open dialog</ui-button><ui-dialog id="material-preview-dialog" for="material-dialog-trigger" label="Surface and light"><ui-text size="md">Compare the backdrop, content plane and frame as the material changes.</ui-text><ui-button slot="actions" variant="solid" commandfor="material-preview-dialog" command="close">Done</ui-button></ui-dialog></ui-cluster>`;
64
76
  const materialSample = `<ui-card treatment="expressive"><ui-stack gap="m"><ui-text variant="heading" as="h3">Fellowship briefing</ui-text><ui-text>Readable content stays on an opaque plate while the decorative rim catches the scene.</ui-text><ui-input label="Office search" placeholder="Search the Fellowship office"></ui-input><ui-action-bar><ui-button slot="secondary" preset="standard">Keep draft</ui-button><ui-button slot="primary" preset="primary">Send briefing</ui-button></ui-action-bar></ui-stack></ui-card>`;
65
77
  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>`;
66
- const materialView = editor('material', materialSample, `<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>`);
67
- 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">The colors your theme’s light and dark palettes are built from.</ui-text>${themeFields.filter(field => field.family === 'Colour' && field.type === 'colour').map(renderField).join('')}<ui-disclosure summary="Adjust color character"><ui-stack>${themeFields.filter(field => field.family === 'Colour' && field.type !== 'colour' && field.id !== 'palette-relationship').map(renderField).join('')}</ui-stack></ui-disclosure><ui-disclosure summary="Color relationships">${paletteRelationships}</ui-disclosure></ui-stack></div>`);
78
+ 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
+ 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-disclosure summary="Status colors" 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>`);
68
81
  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('');
69
- 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-list','ui-list-item'].map(tag => `<link rel="component" href="@threadlabs/looma/components/${tag}/${tag}.html">`).join('\n');
70
- return `${links}\n<link rel="component" href="./card.html">\n<template component="looma-customizer" module="./customizer.js"><defs>
82
+ 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
+ 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>
71
84
  <state name="previews" type="list" value="${escape(JSON.stringify(initial))}"><prop type="object">${cardFields.map(name => `<prop name="${name}" required type="${name === 'resizable' ? 'boolean' : 'string'}"></prop>`).join('')}</prop></state>
72
85
  <state name="cards" type="list" value="${escape(JSON.stringify(initial))}"><prop type="object">${cardFields.map(name => `<prop name="${name}" required type="${name === 'resizable' ? 'boolean' : 'string'}"></prop>`).join('')}</prop></state>
73
86
  </defs>
74
87
  <div data-looma-customizer data-recipe="${escape(JSON.stringify(recipe))}" data-base="${escape(site.base)}" data-mode="${site.config.local ? 'local' : 'public'}" data-revision="${escape(site.config.revision ?? '')}">
75
88
  <ui-stack gap="l">
76
- <ui-text variant="caption" role="status" aria-live="polite" data-message></ui-text>
89
+ <ui-text size="md" role="status" aria-live="polite" data-message></ui-text>
77
90
  <ui-stack gap="xs"><ui-text variant="eyebrow">Theme changes</ui-text><ui-cluster><ui-button size="sm" data-action="undo" disabled>Undo</ui-button><ui-button size="sm" data-action="redo" disabled>Redo</ui-button><ui-button size="sm" data-action="reset" title="Restore this theme’s starting values">Reset</ui-button></ui-cluster></ui-stack>
78
91
  ${materialView}${paletteView}${typographyView}${layoutView}${motionView}
79
92
  ${refinement('themes', `<ui-stack>${choice('id="theme-start" data-preset', 'Starting point', startingPointFor(recipe), `<option value="custom" disabled>Your theme</option>${Object.entries(startingPointLabels).map(([id,label]) => `<option value="${id}">${label}</option>`).join('')}`)}<ui-text variant="caption">A starting theme coordinates color, typography, space, material, and motion. Refine any of them from the overview.</ui-text>${documentationCard('ui-cluster', '/99-theme-sampler', true)}</ui-stack>`)}
@@ -90,7 +103,7 @@ export function customizerResource(site, input = defaultRecipe()) {
90
103
  <section data-theme-sampler><ui-stack gap="xs"><ui-text variant="heading" as="h2">Theme sampler</ui-text>${documentationCard('ui-cluster', '/99-theme-sampler', true)}</ui-stack></section>
91
104
  <noscript>Enable JavaScript to edit the theme. The component reference and example previews remain available.</noscript>
92
105
  </div>${refinement('components', ` <section class="examples"><ui-stack><ui-form-field><label slot="label" for="example-query">Search components</label><ui-input id="example-query" type="search" data-example-query placeholder="Name, tag or purpose"></ui-input></ui-form-field><ui-text variant="caption" role="status" aria-live="polite" data-example-count></ui-text><ui-disclosure summary="Add an example"><ui-stack><ui-combobox id="example-choice" data-add-example label="Choose a component example" placeholder="Search buttons, fields, dialogs…" disclosure clearable>${options}</ui-combobox><ui-button data-action="add" disabled>Add to preview</ui-button></ui-stack></ui-disclosure>
93
- <ui-grid columns="2" min="sm"><section $each="card of $previews" $key="$card.id"><looma-example-card ${cardFields.filter(name => name !== 'id').map(name => `from:${name.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase())}="$card.${name}"`).join(' ')} from:identity="$card.id" loading="eager" removable></looma-example-card></section></ui-grid>
106
+ <ui-grid columns="2" min="sm"><section $each="card of $previews" $key="$card.id"><looma-example-card ${cardFields.filter(name => name !== 'id').map(name => `from:${name.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase())}="$card.${name}"`).join(' ')} from:identity="$card.id" removable><looma-preview-choice slot="preview" from:identity="$card.id" from:namespace="concat('selected-', $card.id)"></looma-preview-choice></looma-example-card></section></ui-grid>
94
107
  <ui-button data-action="more-examples">Show more components</ui-button></ui-stack></section>
95
108
  `)}</ui-stack></div>
96
109
  <style>
@@ -33,10 +33,12 @@ export function connect(host) {
33
33
  const fields = new Map(themeFields.map(field => [field.id, field]));
34
34
  const unitContext = () => ({ remPixels: parseFloat(view.getComputedStyle(document.documentElement).fontSize) });
35
35
  const editorFor = (field, value) => valueEditor(field, value, { remPixels: parseFloat(recipe.values['text-size']) });
36
- let boundsBase;
36
+ let boundsBase, lastLabelSize;
37
+ const optionalColors = new Map();
37
38
  const updateControl = (element, value) => {
38
39
  if (element.matches('[data-choice]')) element.dataset.selectedValue = value;
39
40
  const field = fields.get(element.dataset.token);
41
+ if (field?.type === 'optional-colour' && value === field.defaultValue) return;
40
42
  if (!field || !element.dataset.editorKind) { componentRegistry.update(element, { value }); return; }
41
43
  const editor = editorFor(field, value);
42
44
  if (element.dataset.editorKind === 'curve') {
@@ -91,6 +93,25 @@ export function connect(host) {
91
93
  };
92
94
  const paint = () => {
93
95
  const values = recipe.values;
96
+ for (const field of themeFields.filter(field => field.type === 'optional-colour')) {
97
+ const value = values[field.id], custom = value !== field.defaultValue;
98
+ if (custom) optionalColors.set(field.id, value);
99
+ const picker = root.querySelector(`[data-optional-color="${field.id}"]`);
100
+ picker.hidden = !custom;
101
+ componentRegistry.update(root.querySelector(`[data-color-source="${field.id}"]`), { value: custom ? 'custom' : 'default' });
102
+ }
103
+ for (const sample of root.querySelectorAll('[data-extra-accent]')) sample.hidden = values[sample.dataset.extraAccent] === 'none';
104
+ for (const readout of root.querySelectorAll('[data-palette-roles]')) {
105
+ const { tokens } = deriveTheme(recipe, { mode: readout.dataset.paletteRoles });
106
+ readout.textContent = `Shared border ${tokens['--ui-control-border']} · minimum ${values['neutral-border-contrast']}:1. `;
107
+ }
108
+ const followsBody = values['label-size'] === 'inherit';
109
+ if (!followsBody) lastLabelSize = values['label-size'];
110
+ const labelSize = root.querySelector('[data-label-size-value]');
111
+ labelSize.hidden = followsBody;
112
+ const labelValue = followsBody ? lastLabelSize ?? values['text-size'] : values['label-size'];
113
+ componentRegistry.update(labelSize, { value: labelValue, unit: labelValue.match(/[a-z]+$/i)?.[0] ?? 'px' });
114
+ componentRegistry.update(root.querySelector('[data-label-size-source]'), { value: followsBody ? 'inherit' : 'custom' });
94
115
  root.querySelector('[data-theme-summary]').textContent = startingPointLabels[recipe.origin ?? startingPointFor(recipe)] ?? 'Your theme';
95
116
  const summaries = {
96
117
  palette: `${themePalettes[refinementState(recipe, 'palette').id]?.label ?? 'Custom colors'} · Light & dark`,
@@ -136,7 +157,6 @@ export function connect(host) {
136
157
  const report = root.querySelector('[data-palette-adjustments]');
137
158
  report.textContent = adjustments.length ? 'Paired ranges are derived for readability. Your base colors stay editable; resolved values are shown below.' : 'Both ranges preserve your base colors with readable text and essential outlines.';
138
159
  root.querySelector('[data-palette-adjustment-details]').textContent = adjustments.length ? adjustments.map(item => `${item.mode} ${fields.get(item.id).label.toLowerCase()} ${item.requested} → ${item.resolved}`).join('; ') + '. Base colors remain editable.' : 'Both ranges preserve your base colors with readable text and essential outlines.';
139
- for (const card of root.querySelectorAll('[data-example-card]')) card.dispatchEvent(new CustomEvent('looma-theme-preview', { detail: { css } }));
140
160
  const cssControl = root.querySelector('[data-css]');
141
161
  if (cssControl.getClientRects().length) updateControl(cssControl, css);
142
162
  for (const action of ['undo','redo']) componentRegistry.update(root.querySelector(`[data-action="${action}"]`), { disabled: !theme?.[action === 'undo' ? 'canUndo' : 'canRedo'] });
@@ -221,6 +241,11 @@ export function connect(host) {
221
241
  return { ...recipe, fonts, ...(origin ? { origin } : {}), presets, values };
222
242
  };
223
243
  const input = event => {
244
+ if (event.target.matches('[data-label-size-value]')) {
245
+ try { preview(refinedRecipe({ ...recipe.values, 'label-size': String(event.detail?.value ?? event.target.value) })); }
246
+ catch (error) { say(error.message, true); }
247
+ return;
248
+ }
224
249
  if (event.target.matches('[data-example-query]')) { filterExamples(); return; }
225
250
  if (event.target.matches('[data-light-editor]')) {
226
251
  try {
@@ -294,7 +319,7 @@ export function connect(host) {
294
319
  const option = [...root.querySelectorAll('[data-add-example] option')].find(option => option.value === selectedExample);
295
320
  if (!option) break;
296
321
  const selected = JSON.parse(option.dataset.example);
297
- const card = Object.fromEntries(['id','title','description','exampleTitle','src','resizable','category','tag','nativeRoot','href','packageName'].map(key => [key, selected[key]]));
322
+ const card = Object.fromEntries(['id','title','description','exampleTitle','resizable','category','tag','nativeRoot','href','packageName'].map(key => [key, selected[key]]));
298
323
  removedExamples.delete(card.id);
299
324
  if (!host.state.cards.some(item => item.id === card.id)) host.state.cards = [card, ...host.state.cards];
300
325
  updateControl(root.querySelector('[data-example-query]'), ''); previewQuery = '';
@@ -336,10 +361,22 @@ export function connect(host) {
336
361
  };
337
362
  const change = async event => {
338
363
  const value = event.detail?.value ?? event.target.value;
339
- if (event.target.matches('[data-light-editor]') || event.target.closest?.('[data-token]')) {
364
+ if (event.target.matches('[data-light-editor], [data-label-size-value]') || event.target.closest?.('[data-token]')) {
340
365
  input(event); flush(); sayApplied('Theme remembered in this browser. Undo restores the previous decision.'); return;
341
366
  }
342
367
  flush();
368
+ if (event.target.matches('[data-color-source]')) {
369
+ const field = fields.get(event.target.dataset.colorSource);
370
+ const fallback = recipe.values.action;
371
+ show(refinedRecipe({ ...recipe.values, [field.id]: value === 'default' ? field.defaultValue : optionalColors.get(field.id) ?? fallback }));
372
+ sayApplied(`${field.label} updated and remembered in this browser.`);
373
+ return;
374
+ }
375
+ if (event.target.matches('[data-label-size-source]')) {
376
+ show(refinedRecipe({ ...recipe.values, 'label-size': value === 'inherit' ? 'inherit' : lastLabelSize ?? recipe.values['text-size'] }));
377
+ sayApplied('Field label size updated and remembered in this browser.');
378
+ return;
379
+ }
343
380
  if (event.target.matches('[data-unit-for]')) {
344
381
  const field = fields.get(event.target.dataset.unitFor);
345
382
  try {
@@ -374,9 +411,6 @@ export function connect(host) {
374
411
  if (!(event.ctrlKey || event.metaKey) || event.key.toLowerCase() !== 'z' || event.target.closest?.('input,textarea,select,[contenteditable="true"]')) return;
375
412
  event.preventDefault(); flush(); theme?.[event.shiftKey ? 'redo' : 'undo'](); show(theme?.recipe ?? recipe, false);
376
413
  };
377
- const ready = event => {
378
- if (event.data?.type === 'looma-preview-ready' && [...root.querySelectorAll('iframe')].some(frame => frame.contentWindow === event.source)) paint();
379
- };
380
414
  const remove = event => {
381
415
  const example = catalogExamples.find(card => card.id === event.detail.id);
382
416
  const chosen = host.state.cards.some(card => card.id === event.detail.id);
@@ -430,7 +464,6 @@ export function connect(host) {
430
464
  root.addEventListener('blur', blur, true);
431
465
  root.addEventListener('change', change);
432
466
  root.addEventListener('click', click);
433
- view.addEventListener('message', ready);
434
467
  view.addEventListener('popstate', renderView);
435
468
  view.addEventListener('hashchange', renderView);
436
469
  view.addEventListener('beforeunload', flush);
@@ -448,5 +481,5 @@ export function connect(host) {
448
481
  root.querySelector('[data-action="save"]').hidden = false;
449
482
  }).catch(error => { if (alive && error.name !== 'AbortError') say(error.message, true); });
450
483
  }
451
- return () => { previewObserver.disconnect(); if (layoutFrame) view.cancelAnimationFrame(layoutFrame); view.removeEventListener('resize', schedulePreviewLayout); motionPreference.removeEventListener('change', motionPreferenceChanged); root.removeEventListener('toggle', updateSizes, true); motionAnimation?.cancel(); flush(); root.removeEventListener('cancel', cancel); root.removeEventListener('keydown', keyboard); alive = false; abort.abort(); root.removeEventListener('looma-example-remove', remove); root.removeEventListener('input', input); root.removeEventListener('value-change', choose); root.removeEventListener('value-change', selectExample); root.removeEventListener('value-change', selectFont); root.removeEventListener('blur', blur, true); root.removeEventListener('change', change); root.removeEventListener('click', click); view.removeEventListener('beforeunload', flush); view.removeEventListener('message', ready); view.removeEventListener('popstate', renderView); view.removeEventListener('hashchange', renderView); view.removeEventListener(themeEvent, synchronize); };
484
+ return () => { previewObserver.disconnect(); if (layoutFrame) view.cancelAnimationFrame(layoutFrame); view.removeEventListener('resize', schedulePreviewLayout); motionPreference.removeEventListener('change', motionPreferenceChanged); root.removeEventListener('toggle', updateSizes, true); motionAnimation?.cancel(); flush(); root.removeEventListener('cancel', cancel); root.removeEventListener('keydown', keyboard); alive = false; abort.abort(); root.removeEventListener('looma-example-remove', remove); root.removeEventListener('input', input); root.removeEventListener('value-change', choose); root.removeEventListener('value-change', selectExample); root.removeEventListener('value-change', selectFont); root.removeEventListener('blur', blur, true); root.removeEventListener('change', change); root.removeEventListener('click', click); view.removeEventListener('beforeunload', flush); view.removeEventListener('popstate', renderView); view.removeEventListener('hashchange', renderView); view.removeEventListener(themeEvent, synchronize); };
452
485
  }
@@ -1,18 +1,14 @@
1
1
  :root { --markupress-header-notice-display: none; }
2
2
  :root[data-looma-documentation-theme] { --markupress-header-notice-display: inline-flex; }
3
- /* Documentation presentation owns only its native preview frame and code overflow. Controls use Looma. */
4
- [data-example-card] iframe { display: block; max-inline-size: 100%; border: 0; background: transparent; }
3
+ /* Documentation presentation owns its native example stage. Controls use Looma. */
5
4
  [data-example-card] pre { overflow: auto; }
6
5
  /* The customizer is an application page; use Markupress's public width token instead of patching its layout. */
7
6
  :root:has([data-looma-customizer]), :root:has([data-component~="looma-catalog"]) { --markupress-content-width: 110rem; }
8
- body:has([data-preview]) { background: var(--ui-surface); color: var(--ui-text); font-family: var(--ui-font-sans); font-size: var(--ui-font-size); line-height: var(--ui-line-height); }
9
- [data-preview] { display: grid; place-items: center; gap: var(--ui-space-4); min-block-size: 13rem; padding: 1.35rem; box-sizing: border-box; }
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: linear-gradient(90deg, rgb(43 37 56 / .035) 1px, transparent 1px), linear-gradient(rgb(43 37 56 / .035) 1px, transparent 1px), color-mix(in srgb, var(--ui-accent) 5%, var(--ui-surface)); background-size: 22px 22px; }
10
8
  [data-preview-layout] { justify-items: stretch; }
11
- body:has([data-preview]) { margin: 0; background: linear-gradient(90deg, rgb(43 37 56 / .035) 1px, transparent 1px), linear-gradient(rgb(43 37 56 / .035) 1px, transparent 1px), color-mix(in srgb, var(--ui-accent) 5%, var(--ui-surface)); background-size: 22px 22px; }
12
9
 
13
10
  /* These headings are authored page content projected through the example card's heading slot. */
14
11
  .looma-reference-examples { padding-block-start: var(--ui-space-5); }
15
12
  .looma-example-heading h3 { margin: 0; font-size: var(--ui-font-size-lg); line-height: var(--ui-line-height-tight); }
16
13
  .looma-example-heading p { margin: var(--ui-space-2) 0 0; font-size: var(--ui-font-size-sm); color: var(--ui-text-secondary); }
17
- html[data-preview-reference], html[data-preview-reference] body { background: var(--ui-surface); }
18
- html[data-preview-reference] [data-preview] { min-block-size: 11rem; }
14
+ [data-example-card][reference] [data-preview] { min-block-size: 11rem; background: var(--ui-surface); }
@@ -1,7 +1,7 @@
1
1
  import { componentRegistry } from "@nextwebwg/html-next/runtime";
2
2
  /** Simulates a save so the example shows the transition into and out of loading. */
3
3
  export default function saveChanges(root) {
4
- const button = root.querySelector("#docs-save-changes");
4
+ const button = root.querySelector('[data-example-id="docs-save-changes"]');
5
5
  if (!button)
6
6
  return () => { };
7
7
  let timer;
@@ -1,7 +1,7 @@
1
1
  import { componentRegistry } from "@nextwebwg/html-next/runtime";
2
2
  /** Keeps the summary checkbox in step with three independently checked items. */
3
3
  export default function connectSelection(root) {
4
- const all = root.querySelector("#docs-checkbox-all");
4
+ const all = root.querySelector('[data-example-id="docs-checkbox-all"]');
5
5
  const items = Array.from(root.querySelectorAll(".docs-checkbox-item"));
6
6
  if (!all || !items.length)
7
7
  return () => { };
@@ -0,0 +1 @@
1
+ export { openPicker as default } from "../../ui-editor-slash-menu/examples/00-preview.behavior.js";
@@ -0,0 +1,81 @@
1
+ import { componentRegistry } from "@nextwebwg/html-next/runtime";
2
+ /** The host owns keyboard selection and dismissal for editor suggestion surfaces. */
3
+ export function openPicker(root) {
4
+ const trigger = root.querySelector("[data-demo-trigger]");
5
+ const surface = root.querySelector("[data-demo-surface]");
6
+ if (!trigger || !surface)
7
+ return () => { };
8
+ let open = false, selectedIndex = 0, frame = 0;
9
+ const options = () => [...surface.querySelectorAll('[role="option"]')].filter(option => !option.hidden && option.getAttribute("aria-disabled") !== "true");
10
+ const select = (index) => {
11
+ const rows = options();
12
+ selectedIndex = rows.length ? (index + rows.length) % rows.length : 0;
13
+ componentRegistry.update(surface, { selectedIndex });
14
+ const active = rows[selectedIndex];
15
+ if (active?.id)
16
+ surface.setAttribute("aria-activedescendant", active.id);
17
+ };
18
+ const close = () => {
19
+ open = false;
20
+ cancelAnimationFrame(frame);
21
+ componentRegistry.update(surface, { open: false });
22
+ trigger.setAttribute("aria-expanded", "false");
23
+ };
24
+ const commit = () => { close(); trigger.focus(); };
25
+ const toggle = () => {
26
+ if (open) {
27
+ close();
28
+ return;
29
+ }
30
+ open = true;
31
+ selectedIndex = 0;
32
+ componentRegistry.update(surface, { open: true, selectedIndex, anchorRect: trigger.getBoundingClientRect().toJSON() });
33
+ trigger.setAttribute("aria-expanded", "true");
34
+ frame = requestAnimationFrame(() => { select(0); surface.focus(); });
35
+ };
36
+ const keyboard = (event) => {
37
+ if (!open) {
38
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
39
+ event.preventDefault();
40
+ toggle();
41
+ }
42
+ return;
43
+ }
44
+ if (event.key === "Escape") {
45
+ event.preventDefault();
46
+ commit();
47
+ }
48
+ else if (event.key === "ArrowDown" || event.key === "ArrowUp") {
49
+ event.preventDefault();
50
+ select(selectedIndex + (event.key === "ArrowDown" ? 1 : -1));
51
+ }
52
+ else if (event.key === "Enter") {
53
+ event.preventDefault();
54
+ options()[selectedIndex]?.click();
55
+ }
56
+ };
57
+ const highlight = (event) => select(event.detail.index);
58
+ const reposition = () => { if (open)
59
+ componentRegistry.update(surface, { anchorRect: trigger.getBoundingClientRect().toJSON() }); };
60
+ const view = root.ownerDocument.defaultView;
61
+ const outside = (event) => { if (open && !surface.contains(event.target) && !trigger.contains(event.target))
62
+ close(); };
63
+ trigger.addEventListener("click", toggle);
64
+ root.addEventListener("keydown", keyboard);
65
+ surface.addEventListener("select", commit);
66
+ surface.addEventListener("highlight", highlight);
67
+ view?.addEventListener("scroll", reposition, { capture: true, passive: true });
68
+ view?.addEventListener("resize", reposition);
69
+ root.ownerDocument.addEventListener("pointerdown", outside);
70
+ return () => {
71
+ cancelAnimationFrame(frame);
72
+ trigger.removeEventListener("click", toggle);
73
+ root.removeEventListener("keydown", keyboard);
74
+ surface.removeEventListener("select", commit);
75
+ surface.removeEventListener("highlight", highlight);
76
+ view?.removeEventListener("scroll", reposition, true);
77
+ view?.removeEventListener("resize", reposition);
78
+ root.ownerDocument.removeEventListener("pointerdown", outside);
79
+ };
80
+ }
81
+ export default openPicker;
@@ -0,0 +1,24 @@
1
+ import { componentRegistry } from "@nextwebwg/html-next/runtime";
2
+ /** Keep the controls aligned with the real cells at every preview width. */
3
+ export default function setup(root) {
4
+ const surface = root.querySelector("[data-demo-table-controls]");
5
+ const table = surface?.querySelector("table");
6
+ if (!surface || !table)
7
+ return () => { };
8
+ const measure = () => {
9
+ const origin = surface.getBoundingClientRect();
10
+ const rows = [...table.rows], cells = [...(rows[0]?.cells ?? [])];
11
+ if (!rows.length || !cells.length)
12
+ return;
13
+ const cell = cells[0].getBoundingClientRect();
14
+ componentRegistry.update(surface, { geometry: {
15
+ rowBoundaries: [...rows.map(row => row.getBoundingClientRect().top - origin.top), rows.at(-1).getBoundingClientRect().bottom - origin.top],
16
+ columnBoundaries: [...cells.map(cell => cell.getBoundingClientRect().left - origin.left), cells.at(-1).getBoundingClientRect().right - origin.left],
17
+ activeCell: { left: cell.left - origin.left, top: cell.top - origin.top, width: cell.width, height: cell.height, rowIndex: 0, columnIndex: 0 },
18
+ } });
19
+ };
20
+ const observer = new ResizeObserver(measure);
21
+ observer.observe(table);
22
+ measure();
23
+ return () => observer.disconnect();
24
+ }
@@ -0,0 +1,14 @@
1
+ import { componentRegistry } from "@nextwebwg/html-next/runtime";
2
+ /** Opens this specimen from its own trigger and closes it after a choice. */
3
+ export default function setup(root) {
4
+ const trigger = root.querySelector("[data-demo-trigger]");
5
+ const surface = root.querySelector("[data-demo-surface]");
6
+ if (!trigger || !surface)
7
+ return () => { };
8
+ const open = () => componentRegistry.update(surface, { open: true });
9
+ const close = () => componentRegistry.update(surface, { open: false });
10
+ trigger.addEventListener("click", open);
11
+ surface.addEventListener("select", close);
12
+ surface.addEventListener("close", close);
13
+ return () => { trigger.removeEventListener("click", open); surface.removeEventListener("select", close); surface.removeEventListener("close", close); };
14
+ }
@@ -1,13 +1,13 @@
1
1
  /** Filters the example's results as the query changes; a real application would query its index. */
2
2
  export default function filterResults(root) {
3
3
  const update = () => {
4
- const input = root.querySelector("#docs-search-input");
5
- const status = root.querySelector("#docs-search-status");
6
- const empty = root.querySelector("#docs-search-empty");
4
+ const input = root.querySelector('[data-example-id="docs-search-input"]');
5
+ const status = root.querySelector('[data-example-id="docs-search-status"]');
6
+ const empty = root.querySelector('[data-example-id="docs-search-empty"]');
7
7
  const results = [
8
- root.querySelector("#docs-result-design-tokens"),
9
- root.querySelector("#docs-result-token-overrides"),
10
- root.querySelector("#docs-result-button-variants")
8
+ root.querySelector('[data-example-id="docs-result-design-tokens"]'),
9
+ root.querySelector('[data-example-id="docs-result-token-overrides"]'),
10
+ root.querySelector('[data-example-id="docs-result-button-variants"]')
11
11
  ].filter((result) => result !== null);
12
12
  if (!input || !status || !empty || results.length === 0)
13
13
  return;
@@ -22,7 +22,7 @@ export default function filterResults(root) {
22
22
  empty.hidden = visible !== 0;
23
23
  };
24
24
  const onInput = (event) => {
25
- if (event.target?.id === "docs-search-input")
25
+ if (event.target?.dataset.exampleId === "docs-search-input")
26
26
  update();
27
27
  };
28
28
  root.addEventListener("input", onInput);
@@ -1,8 +1,8 @@
1
1
  /** Shows a hidden authored toast when the example's button is pressed; the toast hides itself when dismissed. */
2
2
  export function showToastOnClick(buttonId, toastId) {
3
3
  return (root) => {
4
- const button = root.querySelector(`#${buttonId}`);
5
- const toast = root.querySelector(`#${toastId}`);
4
+ const button = root.querySelector(`[data-example-id="${buttonId}"]`);
5
+ const toast = root.querySelector(`[data-example-id="${toastId}"]`);
6
6
  if (!button || !toast)
7
7
  return () => { };
8
8
  const show = () => {
package/docs/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export interface DocumentationGroup { id: string; label: string }
2
2
  export interface ExampleCode { language: string; code: string }
3
3
  export interface DocumentationExample {
4
4
  id: string; name: string; title: string; description: string; markup: string;
5
- resizable: boolean; frameworks: Record<string, ExampleCode>; behavior?: string; bindings?: string;
5
+ resizable: boolean; stretch?: boolean; frameworks: Record<string, ExampleCode>; behavior?: string; bindings?: string;
6
6
  }
7
7
  export interface DocumentationComponent {
8
8
  id: string; package: string; tag: string; title: string; description: string; group: string;
@@ -14,7 +14,7 @@ async function body(request) {
14
14
  catch { throw rejected('Expected a JSON theme recipe and revision.', 400); }
15
15
  }
16
16
 
17
- /** Local capabilities stay in the parent editor; opaque example frames receive only theme CSS. */
17
+ /** Serve trusted project documentation with a constrained, same-origin theme writer. */
18
18
  export async function serveLocalDocumentation({ upstream, store, base = '/', port = 0, onSaved = async () => {} }) {
19
19
  const target = new URL(upstream);
20
20
  if (target.protocol !== 'http:' || target.hostname !== '127.0.0.1') throw new Error('The documentation upstream must be a loopback MarkupKit server.');
@@ -52,10 +52,7 @@ export async function serveLocalDocumentation({ upstream, store, base = '/', por
52
52
  delete headers['x-looma-capability'];
53
53
  const proxy = proxyRequest(target.origin + request.url, { method: request.method, headers }, remote => {
54
54
  const responseHeaders = { ...remote.headers };
55
- if (url.pathname.startsWith(api + 'preview/')) {
56
- const existing = responseHeaders['content-security-policy'];
57
- responseHeaders['content-security-policy'] = [...(existing ? [existing].flat() : []), 'sandbox allow-scripts'];
58
- }
55
+
59
56
  response.writeHead(remote.statusCode, responseHeaders); remote.pipe(response);
60
57
  });
61
58
  proxy.on('error', () => { if (!response.headersSent) json(response, 502, { error: 'The documentation renderer is unavailable.' }); else response.destroy(); });
package/docs/palette.mjs CHANGED
@@ -43,10 +43,11 @@ export function paletteSeeds(values) {
43
43
  const intensity = Number(values['color-intensity']) * 2, warmth = (Number(values.warmth) - .5) * 2;
44
44
  const relationship = values['palette-relationship'];
45
45
  const brandHue = toLch(values.action)[2];
46
- return Object.fromEntries(['action', 'canvas', 'surface', 'text'].map(key => {
47
- if (intensity === 1 && warmth === 0 && relationship === 'preserve') return [key, values[key]];
48
- let [l, c, h] = toLch(values[key]);
49
- if (key !== 'action') {
46
+ return Object.fromEntries(['action', 'secondary-action', 'tertiary-action', 'canvas', 'surface', 'text'].map(key => {
47
+ const seed = values[key] === 'none' ? values.action : values[key];
48
+ if (intensity === 1 && warmth === 0 && relationship === 'preserve') return [key, seed];
49
+ let [l, c, h] = toLch(seed);
50
+ if (!['action','secondary-action','tertiary-action'].includes(key)) {
50
51
  const tint = Math.max(Math.abs(warmth), relationship === 'preserve' ? 0 : .5);
51
52
  if (tint) l = clamp(l, .08 * tint, 1 - .03 * tint);
52
53
  if (relationship !== 'preserve') { h = brandHue + (relationship === 'neighboring' ? 30 : 180); c = Math.max(c, .018); }