@threadlabs/looma 0.51.5 → 0.52.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/README.md +4 -4
- package/components/shared/overlay.js +7 -2
- package/components/ui-breadcrumb-item/ui-breadcrumb-item.html +1 -0
- package/components/ui-calendar/ui-calendar.js +11 -7
- package/components/ui-card/ui-card.html +7 -0
- package/components/ui-date-field/ui-date-field.js +0 -5
- package/components/ui-disclosure/ui-disclosure.js +19 -4
- package/components/ui-editor-link-form/ui-editor-link-form.js +5 -0
- package/components/ui-editor-mention-menu-item/ui-editor-mention-menu-item.html +2 -3
- package/components/ui-editor-table-context-menu/ui-editor-table-context-menu.html +10 -1
- package/components/ui-file-input/ui-file-input.js +0 -2
- package/components/ui-status-message/ui-status-message.html +1 -0
- package/components/ui-tabs/ui-tabs.html +1 -0
- package/components/ui-tooltip/ui-tooltip.html +11 -32
- package/dist/index.js +14 -8
- package/docs/catalog.json +592 -131
- package/editor/components.css +530 -551
- package/editor/index.js +72 -47
- package/package.json +30 -35
- package/styles/ui-action-bar.css +8 -8
- package/styles/ui-affordance-scope.css +10 -10
- package/styles/ui-avatar-group.css +11 -11
- package/styles/ui-avatar.css +14 -14
- package/styles/ui-badge.css +67 -67
- package/styles/ui-breadcrumb-item.css +10 -10
- package/styles/ui-breadcrumbs.css +8 -8
- package/styles/ui-button.css +99 -99
- package/styles/ui-calendar.css +1 -1
- package/styles/ui-callout.css +14 -14
- package/styles/ui-card-group.css +11 -11
- package/styles/ui-card.css +40 -35
- package/styles/ui-checkbox.css +28 -28
- package/styles/ui-cluster.css +30 -30
- package/styles/ui-color-picker.css +16 -16
- package/styles/ui-combobox.css +50 -50
- package/styles/ui-compact-content.css +1 -1
- package/styles/ui-compact-editor.css +1 -1
- package/styles/ui-compact-mark.css +1 -1
- package/styles/ui-compact-node.css +1 -1
- package/styles/ui-container.css +14 -14
- package/styles/ui-context-menu.css +8 -8
- package/styles/ui-cover.css +9 -9
- package/styles/ui-curve-editor.css +9 -9
- package/styles/ui-cycle-button.css +10 -10
- package/styles/ui-date-field.css +1 -1
- package/styles/ui-date-picker.css +1 -1
- package/styles/ui-date-range-picker.css +1 -1
- package/styles/ui-description-item.css +8 -8
- package/styles/ui-description-list.css +18 -18
- package/styles/ui-dialog.css +37 -37
- package/styles/ui-disclosure.css +26 -26
- package/styles/ui-editable.css +13 -13
- package/styles/ui-editor-block-actions.css +1 -1
- package/styles/ui-editor-chip-editor.css +1 -1
- package/styles/ui-editor-code-language.css +1 -1
- package/styles/ui-editor-footnote-editor.css +1 -1
- package/styles/ui-editor-formatting-tools.css +1 -1
- package/styles/ui-editor-image-toolbar.css +1 -1
- package/styles/ui-editor-insert-table-grid.css +9 -9
- package/styles/ui-editor-link-card.css +1 -1
- package/styles/ui-editor-link-form.css +1 -1
- package/styles/ui-editor-mention-menu-item.css +13 -15
- package/styles/ui-editor-mention-menu.css +12 -12
- package/styles/ui-editor-slash-menu-group.css +7 -7
- package/styles/ui-editor-slash-menu-item.css +12 -12
- package/styles/ui-editor-slash-menu.css +13 -13
- package/styles/ui-editor-surface.css +8 -8
- package/styles/ui-editor-table-context-menu.css +19 -15
- package/styles/ui-editor-table-overlay.css +15 -15
- package/styles/ui-editor-table-toolbar.css +19 -19
- package/styles/ui-editor-toolbar.css +16 -16
- package/styles/ui-editor.css +1 -1
- package/styles/ui-file-input.css +1 -1
- package/styles/ui-floating-action-button.css +14 -14
- package/styles/ui-form-field.css +9 -9
- package/styles/ui-grid.css +19 -19
- package/styles/ui-icon-button.css +73 -73
- package/styles/ui-icon.css +11 -11
- package/styles/ui-image.css +23 -23
- package/styles/ui-input-group.css +26 -26
- package/styles/ui-input.css +23 -23
- package/styles/ui-light-editor.css +15 -15
- package/styles/ui-list-item.css +25 -25
- package/styles/ui-list.css +16 -16
- package/styles/ui-listbox.css +22 -22
- package/styles/ui-menu-group.css +7 -7
- package/styles/ui-menu-item.css +20 -20
- package/styles/ui-menu.css +20 -20
- package/styles/ui-meter.css +32 -32
- package/styles/ui-nav-item.css +18 -18
- package/styles/ui-number-input.css +12 -12
- package/styles/ui-page-header.css +10 -10
- package/styles/ui-pagination.css +1 -1
- package/styles/ui-popover.css +17 -17
- package/styles/ui-radio-group.css +10 -10
- package/styles/ui-radio.css +25 -25
- package/styles/ui-reel.css +21 -21
- package/styles/ui-scroll-area.css +20 -20
- package/styles/ui-search-result-row.css +16 -16
- package/styles/ui-search-shell.css +10 -10
- package/styles/ui-section.css +18 -18
- package/styles/ui-select.css +22 -22
- package/styles/ui-separator.css +12 -12
- package/styles/ui-sidebar.css +26 -26
- package/styles/ui-site-header.css +65 -65
- package/styles/ui-skeleton.css +18 -18
- package/styles/ui-slider.css +11 -11
- package/styles/ui-spinner.css +9 -9
- package/styles/ui-stack.css +22 -22
- package/styles/ui-status-message.css +12 -12
- package/styles/ui-swatch.css +14 -14
- package/styles/ui-switch.css +23 -23
- package/styles/ui-switcher.css +20 -20
- package/styles/ui-table.css +12 -12
- package/styles/ui-tabs.css +18 -17
- package/styles/ui-text.css +40 -40
- package/styles/ui-textarea.css +21 -21
- package/styles/ui-time-field.css +1 -1
- package/styles/ui-time-picker.css +1 -1
- package/styles/ui-toast-region.css +29 -29
- package/styles/ui-toast.css +19 -19
- package/styles/ui-tooltip.css +37 -58
- package/styles/ui-top-bar.css +8 -8
- package/styles/ui-tree-item.css +112 -112
- package/styles/ui-tree.css +11 -11
- package/vanilla/UiActionBar.d.ts +1 -1
- package/vanilla/UiActionBar.js +2 -2
- package/vanilla/UiAffordanceScope.d.ts +1 -1
- package/vanilla/UiAffordanceScope.js +2 -2
- package/vanilla/UiAvatar.d.ts +1 -1
- package/vanilla/UiAvatar.js +2 -2
- package/vanilla/UiAvatarGroup.d.ts +1 -1
- package/vanilla/UiAvatarGroup.js +2 -2
- package/vanilla/UiBadge.d.ts +1 -1
- package/vanilla/UiBadge.js +2 -2
- package/vanilla/UiBreadcrumbItem.d.ts +1 -1
- package/vanilla/UiBreadcrumbItem.js +2 -2
- package/vanilla/UiBreadcrumbs.d.ts +1 -1
- package/vanilla/UiBreadcrumbs.js +2 -2
- package/vanilla/UiButton.d.ts +1 -1
- package/vanilla/UiButton.js +5 -5
- package/vanilla/UiCalendar.d.ts +1 -1
- package/vanilla/UiCalendar.js +10 -10
- package/vanilla/UiCallout.d.ts +1 -1
- package/vanilla/UiCallout.js +2 -2
- package/vanilla/UiCard.d.ts +2 -1
- package/vanilla/UiCard.js +18 -18
- package/vanilla/UiCardGroup.d.ts +1 -1
- package/vanilla/UiCardGroup.js +2 -2
- package/vanilla/UiCheckbox.d.ts +1 -1
- package/vanilla/UiCheckbox.js +2 -2
- package/vanilla/UiCluster.d.ts +1 -1
- package/vanilla/UiCluster.js +2 -2
- package/vanilla/UiColorPicker.d.ts +1 -1
- package/vanilla/UiColorPicker.js +2 -2
- package/vanilla/UiCombobox.d.ts +1 -1
- package/vanilla/UiCombobox.js +8 -8
- package/vanilla/UiCompactContent.d.ts +1 -1
- package/vanilla/UiCompactContent.js +4 -4
- package/vanilla/UiCompactEditor.d.ts +1 -1
- package/vanilla/UiCompactEditor.js +2 -2
- package/vanilla/UiCompactMark.d.ts +1 -1
- package/vanilla/UiCompactMark.js +5 -5
- package/vanilla/UiCompactNode.d.ts +1 -1
- package/vanilla/UiCompactNode.js +8 -8
- package/vanilla/UiContainer.d.ts +1 -1
- package/vanilla/UiContainer.js +2 -2
- package/vanilla/UiContextMenu.d.ts +1 -1
- package/vanilla/UiContextMenu.js +2 -2
- package/vanilla/UiCover.d.ts +1 -1
- package/vanilla/UiCover.js +2 -2
- package/vanilla/UiCurveEditor.d.ts +1 -1
- package/vanilla/UiCurveEditor.js +2 -2
- package/vanilla/UiCycleButton.d.ts +1 -1
- package/vanilla/UiCycleButton.js +2 -2
- package/vanilla/UiDateField.d.ts +1 -1
- package/vanilla/UiDateField.js +2 -2
- package/vanilla/UiDatePicker.d.ts +1 -1
- package/vanilla/UiDatePicker.js +2 -2
- package/vanilla/UiDateRangePicker.d.ts +1 -1
- package/vanilla/UiDateRangePicker.js +4 -4
- package/vanilla/UiDescriptionItem.d.ts +1 -1
- package/vanilla/UiDescriptionItem.js +2 -2
- package/vanilla/UiDescriptionList.d.ts +1 -1
- package/vanilla/UiDescriptionList.js +2 -2
- package/vanilla/UiDialog.d.ts +1 -1
- package/vanilla/UiDialog.js +2 -2
- package/vanilla/UiDisclosure.d.ts +1 -1
- package/vanilla/UiDisclosure.js +2 -2
- package/vanilla/UiEditable.d.ts +1 -1
- package/vanilla/UiEditable.js +2 -2
- package/vanilla/UiEditor.d.ts +1 -1
- package/vanilla/UiEditor.js +6 -6
- package/vanilla/UiEditorBlockActions.d.ts +1 -1
- package/vanilla/UiEditorBlockActions.js +2 -2
- package/vanilla/UiEditorChipEditor.d.ts +1 -1
- package/vanilla/UiEditorChipEditor.js +2 -2
- package/vanilla/UiEditorCodeLanguage.d.ts +1 -1
- package/vanilla/UiEditorCodeLanguage.js +4 -4
- package/vanilla/UiEditorFootnoteEditor.d.ts +1 -1
- package/vanilla/UiEditorFootnoteEditor.js +2 -2
- package/vanilla/UiEditorFormattingTools.d.ts +1 -1
- package/vanilla/UiEditorFormattingTools.js +4 -4
- package/vanilla/UiEditorImageToolbar.d.ts +1 -1
- package/vanilla/UiEditorImageToolbar.js +2 -2
- package/vanilla/UiEditorInsertTableGrid.d.ts +1 -1
- package/vanilla/UiEditorInsertTableGrid.js +4 -4
- package/vanilla/UiEditorLinkCard.d.ts +1 -1
- package/vanilla/UiEditorLinkCard.js +2 -2
- package/vanilla/UiEditorLinkForm.d.ts +1 -1
- package/vanilla/UiEditorLinkForm.js +4 -4
- package/vanilla/UiEditorMentionMenu.d.ts +1 -1
- package/vanilla/UiEditorMentionMenu.js +4 -4
- package/vanilla/UiEditorMentionMenuItem.d.ts +1 -1
- package/vanilla/UiEditorMentionMenuItem.js +2 -2
- package/vanilla/UiEditorSlashMenu.d.ts +1 -1
- package/vanilla/UiEditorSlashMenu.js +4 -4
- package/vanilla/UiEditorSlashMenuGroup.d.ts +1 -1
- package/vanilla/UiEditorSlashMenuGroup.js +2 -2
- package/vanilla/UiEditorSlashMenuItem.d.ts +1 -1
- package/vanilla/UiEditorSlashMenuItem.js +2 -2
- package/vanilla/UiEditorSurface.d.ts +1 -1
- package/vanilla/UiEditorSurface.js +2 -2
- package/vanilla/UiEditorTableContextMenu.d.ts +1 -1
- package/vanilla/UiEditorTableContextMenu.js +7 -6
- package/vanilla/UiEditorTableOverlay.d.ts +1 -1
- package/vanilla/UiEditorTableOverlay.js +5 -5
- package/vanilla/UiEditorTableToolbar.d.ts +1 -1
- package/vanilla/UiEditorTableToolbar.js +8 -8
- package/vanilla/UiEditorToolbar.d.ts +1 -1
- package/vanilla/UiEditorToolbar.js +2 -2
- package/vanilla/UiFileInput.d.ts +1 -1
- package/vanilla/UiFileInput.js +4 -4
- package/vanilla/UiFloatingActionButton.d.ts +1 -1
- package/vanilla/UiFloatingActionButton.js +2 -2
- package/vanilla/UiFormField.d.ts +1 -1
- package/vanilla/UiFormField.js +2 -2
- package/vanilla/UiGrid.d.ts +1 -1
- package/vanilla/UiGrid.js +4 -4
- package/vanilla/UiIcon.d.ts +1 -1
- package/vanilla/UiIcon.js +4 -4
- package/vanilla/UiIconButton.d.ts +1 -1
- package/vanilla/UiIconButton.js +2 -2
- package/vanilla/UiImage.d.ts +1 -1
- package/vanilla/UiImage.js +2 -2
- package/vanilla/UiInput.d.ts +1 -1
- package/vanilla/UiInput.js +2 -2
- package/vanilla/UiInputGroup.d.ts +1 -1
- package/vanilla/UiInputGroup.js +2 -2
- package/vanilla/UiLightEditor.d.ts +1 -1
- package/vanilla/UiLightEditor.js +2 -2
- package/vanilla/UiList.d.ts +1 -1
- package/vanilla/UiList.js +3 -3
- package/vanilla/UiListItem.d.ts +1 -1
- package/vanilla/UiListItem.js +2 -2
- package/vanilla/UiListbox.d.ts +1 -1
- package/vanilla/UiListbox.js +5 -5
- package/vanilla/UiMenu.d.ts +1 -1
- package/vanilla/UiMenu.js +2 -2
- package/vanilla/UiMenuGroup.d.ts +1 -1
- package/vanilla/UiMenuGroup.js +2 -2
- package/vanilla/UiMenuItem.d.ts +1 -1
- package/vanilla/UiMenuItem.js +3 -3
- package/vanilla/UiMeter.d.ts +1 -1
- package/vanilla/UiMeter.js +4 -4
- package/vanilla/UiNavItem.d.ts +1 -1
- package/vanilla/UiNavItem.js +3 -3
- package/vanilla/UiNumberInput.d.ts +1 -1
- package/vanilla/UiNumberInput.js +2 -2
- package/vanilla/UiPageHeader.d.ts +1 -1
- package/vanilla/UiPageHeader.js +2 -2
- package/vanilla/UiPagination.d.ts +1 -1
- package/vanilla/UiPagination.js +4 -4
- package/vanilla/UiPopover.d.ts +1 -1
- package/vanilla/UiPopover.js +2 -2
- package/vanilla/UiRadio.d.ts +1 -1
- package/vanilla/UiRadio.js +2 -2
- package/vanilla/UiRadioGroup.d.ts +1 -1
- package/vanilla/UiRadioGroup.js +2 -2
- package/vanilla/UiReel.d.ts +1 -1
- package/vanilla/UiReel.js +2 -2
- package/vanilla/UiScrollArea.d.ts +1 -1
- package/vanilla/UiScrollArea.js +2 -2
- package/vanilla/UiSearchResultRow.d.ts +1 -1
- package/vanilla/UiSearchResultRow.js +2 -2
- package/vanilla/UiSearchShell.d.ts +1 -1
- package/vanilla/UiSearchShell.js +2 -2
- package/vanilla/UiSection.d.ts +1 -1
- package/vanilla/UiSection.js +3 -3
- package/vanilla/UiSelect.d.ts +1 -1
- package/vanilla/UiSelect.js +2 -2
- package/vanilla/UiSeparator.d.ts +1 -1
- package/vanilla/UiSeparator.js +2 -2
- package/vanilla/UiSidebar.d.ts +1 -1
- package/vanilla/UiSidebar.js +2 -2
- package/vanilla/UiSiteHeader.d.ts +1 -1
- package/vanilla/UiSiteHeader.js +2 -2
- package/vanilla/UiSkeleton.d.ts +1 -1
- package/vanilla/UiSkeleton.js +2 -2
- package/vanilla/UiSlider.d.ts +1 -1
- package/vanilla/UiSlider.js +2 -2
- package/vanilla/UiSpinner.d.ts +1 -1
- package/vanilla/UiSpinner.js +2 -2
- package/vanilla/UiStack.d.ts +1 -1
- package/vanilla/UiStack.js +2 -2
- package/vanilla/UiStatusMessage.d.ts +1 -1
- package/vanilla/UiStatusMessage.js +2 -2
- package/vanilla/UiSwatch.d.ts +1 -1
- package/vanilla/UiSwatch.js +2 -2
- package/vanilla/UiSwitch.d.ts +1 -1
- package/vanilla/UiSwitch.js +2 -2
- package/vanilla/UiSwitcher.d.ts +1 -1
- package/vanilla/UiSwitcher.js +2 -2
- package/vanilla/UiTable.d.ts +1 -1
- package/vanilla/UiTable.js +2 -2
- package/vanilla/UiTabs.d.ts +1 -1
- package/vanilla/UiTabs.js +4 -4
- package/vanilla/UiText.d.ts +1 -1
- package/vanilla/UiText.js +13 -13
- package/vanilla/UiTextarea.d.ts +1 -1
- package/vanilla/UiTextarea.js +2 -2
- package/vanilla/UiTimeField.d.ts +1 -1
- package/vanilla/UiTimeField.js +2 -2
- package/vanilla/UiTimePicker.d.ts +1 -1
- package/vanilla/UiTimePicker.js +6 -6
- package/vanilla/UiToast.d.ts +1 -1
- package/vanilla/UiToast.js +2 -2
- package/vanilla/UiToastRegion.d.ts +1 -1
- package/vanilla/UiToastRegion.js +4 -4
- package/vanilla/UiTooltip.d.ts +1 -1
- package/vanilla/UiTooltip.js +2 -2
- package/vanilla/UiTopBar.d.ts +1 -1
- package/vanilla/UiTopBar.js +2 -2
- package/vanilla/UiTree.d.ts +1 -1
- package/vanilla/UiTree.js +2 -2
- package/vanilla/UiTreeItem.d.ts +1 -1
- package/vanilla/UiTreeItem.js +2 -2
- package/bin/looma-docs.mjs +0 -3
- package/docs/README.md +0 -323
- package/docs/card.html +0 -79
- package/docs/card.js +0 -18
- package/docs/catalog-view.js +0 -24
- package/docs/catalog-view.mjs +0 -13
- package/docs/catalog.mjs +0 -131
- package/docs/cli.mjs +0 -26
- package/docs/commands.mjs +0 -94
- package/docs/customizer-render.mjs +0 -157
- package/docs/customizer.js +0 -494
- package/docs/documentation.css +0 -14
- package/docs/example-invocations.mjs +0 -63
- package/docs/fonts.mjs +0 -73
- package/docs/framework-examples.d.mts +0 -9
- package/docs/framework-examples.mjs +0 -195
- package/docs/index.d.ts +0 -59
- package/docs/index.mjs +0 -4
- package/docs/local-server.mjs +0 -65
- package/docs/navigation.mjs +0 -26
- package/docs/palette.mjs +0 -68
- package/docs/pastoral.svg +0 -54
- package/docs/portrait.svg +0 -15
- package/docs/reference.html +0 -1
- package/docs/reference.js +0 -36
- package/docs/render.mjs +0 -97
- package/docs/site.mjs +0 -237
- package/docs/store.mjs +0 -92
- package/docs/theme-session.mjs +0 -72
- package/docs/theme.mjs +0 -669
- package/docs/value-editors.mjs +0 -37
- package/docs/workspace.mjs +0 -32
package/docs/catalog.mjs
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { readFile, readdir } from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
|
|
5
|
-
export const catalogVersion = 1;
|
|
6
|
-
export const escapeHtml = value => String(value).replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>').replaceAll('"', '"');
|
|
7
|
-
export const titleOf = tag => tag.replace(/^ui-/, '').split('-').map(word => word[0].toUpperCase() + word.slice(1)).join(' ');
|
|
8
|
-
export async function readJson(file, fallback) {
|
|
9
|
-
try { return JSON.parse(await readFile(file, 'utf8')); }
|
|
10
|
-
catch (error) { if (error.code === 'ENOENT' && fallback !== undefined) return fallback; throw error; }
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/** Authored examples are data during discovery; controllers are never evaluated. */
|
|
14
|
-
export async function readExamples(directory, componentId) {
|
|
15
|
-
let files;
|
|
16
|
-
try { files = (await readdir(directory)).sort(); } catch (error) { if (error.code === 'ENOENT') return []; throw error; }
|
|
17
|
-
return Promise.all(files.filter(file => /^[^.]+\.html$/.test(file)).map(async file => {
|
|
18
|
-
const name = file.slice(0, -5);
|
|
19
|
-
const source = await readFile(path.join(directory, file), 'utf8');
|
|
20
|
-
const meta = /^<!--\r?\n([\s\S]*?)\r?\n-->\s*/.exec(source);
|
|
21
|
-
if (!meta) throw new Error(`${path.join(directory, file)}: example requires title/description metadata.`);
|
|
22
|
-
const fields = Object.fromEntries(meta[1].split(/\r?\n/).map(line => {
|
|
23
|
-
const at = line.indexOf(':'); return at < 0 ? [] : [line.slice(0, at).trim(), line.slice(at + 1).trim()];
|
|
24
|
-
}).filter(pair => pair.length));
|
|
25
|
-
const frameworks = {};
|
|
26
|
-
for (const [target, extension, language] of [['html-next', '.snippet.html', 'html'], ['vue', '.vue', 'vue'], ['react', '.tsx', 'tsx'], ['svelte', '.svelte', 'svelte']]) {
|
|
27
|
-
if (files.includes(name + extension)) frameworks[target] = { language, code: await readFile(path.join(directory, name + extension), 'utf8') };
|
|
28
|
-
}
|
|
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', ...(fields.preview === 'stretch' ? { stretch: true } : {}), bindings: fields.bind ?? '', frameworks, ...(behavior ? { behavior } : {}) };
|
|
31
|
-
}));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async function resources(directory) {
|
|
35
|
-
const result = [];
|
|
36
|
-
for (const entry of (await readdir(directory, { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
37
|
-
if (entry.name.startsWith('.') || entry.name === 'node_modules' || entry.name === 'examples') continue;
|
|
38
|
-
const file = path.join(directory, entry.name);
|
|
39
|
-
if (entry.isDirectory()) result.push(...await resources(file));
|
|
40
|
-
else if (entry.name.endsWith('.html')) result.push(file);
|
|
41
|
-
}
|
|
42
|
-
return result;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** Discover only explicitly selected roots through HTML Next's public parser. */
|
|
46
|
-
export async function discoverComponents({ root, directory, packageName, groups = [] }) {
|
|
47
|
-
if (!packageName || !directory) throw new Error('A discovery root requires packageName and directory.');
|
|
48
|
-
const { parseComponentResource, typeScriptType, normalizeType } = await import('@nextwebwg/html-next');
|
|
49
|
-
const components = [];
|
|
50
|
-
for (const source of await resources(path.resolve(root, directory))) {
|
|
51
|
-
const html = await readFile(source, 'utf8');
|
|
52
|
-
if (!/<template\b[^>]*\bcomponent=/.test(html)) continue;
|
|
53
|
-
const parsed = parseComponentResource(html, source);
|
|
54
|
-
const metadata = await readJson(path.join(path.dirname(source), 'docs.json'), {});
|
|
55
|
-
for (const definition of parsed.definitions) {
|
|
56
|
-
const contract = definition.contract;
|
|
57
|
-
const docs = metadata.components?.[contract.tag] ?? metadata;
|
|
58
|
-
const id = `${packageName}/${contract.tag}`;
|
|
59
|
-
const properties = Object.entries(contract.props).map(([name, prop]) => ({ name, type: typeScriptType(prop.type), description: prop.description ?? '', ...(Object.hasOwn(prop, 'default') ? { default: prop.default } : {}), ...(prop.values ? { options: prop.values } : {}) }));
|
|
60
|
-
const attributes = properties.map(prop => ({ ...prop, property: prop.name, name: prop.name.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`), valueType: normalizeType(contract.props[prop.name].type) }));
|
|
61
|
-
const events = (definition.declarations ?? []).filter(item => item.kind === 'event').map(event => ({ name: event.name, detailType: event.shape ? typeScriptType(event.shape) : String(event.type), detailDocs: docs.events?.[event.name] ?? '' }));
|
|
62
|
-
const slots = (definition.slots ?? []).map(slot => ({ name: slot.name ?? 'default', description: docs.slots?.[slot.name ?? 'default'] ?? '' }));
|
|
63
|
-
const tokens = [...new Set([...definition.css.matchAll(/var\(\s*(--[\w-]+)/g)].map(match => match[1]))].sort();
|
|
64
|
-
components.push({ id, package: packageName, tag: contract.tag, title: docs.title ?? titleOf(contract.tag), description: docs.description ?? contract.summary ?? '', ...(docs.summary ? { summary: docs.summary } : {}), group: docs.group ?? 'project', ...(docs.navigationParent ? { navigationParent: docs.navigationParent } : {}), root: contract.nativeElement, source, resource: source, importSource: './' + path.relative(root, source).split(path.sep).join('/'), targets: ['html-next', 'vue', 'react', 'svelte'], attributes, properties, events, slots, designTokens: { sources: [path.relative(root, source)], component: [], shared: tokens.map(name => ({ name, fallbacks: [] })) }, examples: await readExamples(path.join(path.dirname(source), 'examples'), id) });
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
const categories = components.some(component => component.group === 'project') && !groups.some(group => group.id === 'project') ? [...groups, { id: 'project', label: 'Project components' }] : groups;
|
|
68
|
-
return { schemaVersion: catalogVersion, package: packageName, groups: categories, components };
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/** Merge deterministically, reporting both owners instead of silently shadowing resources. */
|
|
72
|
-
export function mergeCatalogs(catalogs, { categories = {} } = {}) {
|
|
73
|
-
const resourceByTag = new Map();
|
|
74
|
-
const exampleOwners = new Map();
|
|
75
|
-
const groups = new Map(); const byId = new Map(); const byTag = new Map();
|
|
76
|
-
for (const catalog of catalogs) {
|
|
77
|
-
if (catalog.schemaVersion !== catalogVersion) throw new Error(`Unsupported documentation catalog version ${catalog.schemaVersion} for ${catalog.package}.`);
|
|
78
|
-
for (const group of catalog.groups ?? []) {
|
|
79
|
-
const mapped = categories[group.id] ?? group.id;
|
|
80
|
-
if (typeof mapped !== 'string' || !/^[a-z][a-z0-9-]*$/.test(mapped)) throw new Error(`Invalid category identity ${JSON.stringify(mapped)} in ${catalog.package}.`);
|
|
81
|
-
const previous = groups.get(mapped);
|
|
82
|
-
if (previous && previous.label !== group.label && mapped === group.id) throw new Error(`Conflicting category ${mapped}: ${previous.label} and ${group.label}. Configure a category mapping explicitly.`);
|
|
83
|
-
if (!previous) groups.set(mapped, { ...group, id: mapped });
|
|
84
|
-
}
|
|
85
|
-
for (const entry of catalog.components) {
|
|
86
|
-
// HTML Next's public component-tag grammar also keeps generated filenames inside their tree.
|
|
87
|
-
if (typeof entry.tag !== 'string' || !/^[a-z][a-z0-9]*(?:-[a-z0-9]+)+$/.test(entry.tag)) throw new Error(`Invalid component tag ${JSON.stringify(entry.tag)} in ${catalog.package}.`);
|
|
88
|
-
if (typeof entry.id !== 'string' || !entry.id) throw new Error(`Missing component identity for ${entry.tag} in ${catalog.package}.`);
|
|
89
|
-
const component = { ...entry, group: categories[entry.group] ?? entry.group };
|
|
90
|
-
const previous = byTag.get(component.tag) ?? byId.get(component.id);
|
|
91
|
-
if (previous) throw new Error(`Duplicate component ${component.tag}: ${previous.id} (${previous.source ?? previous.resource}) and ${component.id} (${component.source ?? component.resource}).`);
|
|
92
|
-
byId.set(component.id, component); byTag.set(component.tag, component);
|
|
93
|
-
if (!Array.isArray(component.examples)) throw new Error(`Component ${component.id} requires an examples array.`);
|
|
94
|
-
for (const example of component.examples) {
|
|
95
|
-
if (typeof example.id !== 'string' || !example.id || typeof example.markup !== 'string') throw new Error(`Invalid example identity or markup in ${component.id}.`);
|
|
96
|
-
if (!example.id.startsWith(component.id + '/')) throw new Error(`Example ${example.id} must belong to ${component.id}.`);
|
|
97
|
-
const previous = exampleOwners.get(example.id);
|
|
98
|
-
if (previous) throw new Error(`Duplicate example ${example.id}: ${previous} and ${component.id}.`);
|
|
99
|
-
exampleOwners.set(example.id, component.id);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
for (const entry of [...catalog.resources ?? [], ...catalog.components]) {
|
|
103
|
-
const previous = resourceByTag.get(entry.tag);
|
|
104
|
-
if (previous && (previous.package !== entry.package || previous.resource !== entry.resource)) throw new Error(`Conflicting resource ${entry.tag}: ${previous.resource} and ${entry.resource}.`);
|
|
105
|
-
resourceByTag.set(entry.tag, { tag: entry.tag, package: entry.package, resource: entry.resource });
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
const ownerOf = (component, trail = []) => {
|
|
109
|
-
if (trail.includes(component.id)) throw new Error(`Compound parent cycle: ${[...trail, component.id].join(' → ')}.`);
|
|
110
|
-
if (!component.navigationParent) return component;
|
|
111
|
-
const parent = byId.get(component.navigationParent) ?? byTag.get(component.navigationParent);
|
|
112
|
-
if (!parent) throw new Error(`Missing compound parent ${component.navigationParent} for ${component.id}.`);
|
|
113
|
-
return ownerOf(parent, [...trail, component.id]);
|
|
114
|
-
};
|
|
115
|
-
for (const component of byId.values()) {
|
|
116
|
-
if (component.navigationParent) {
|
|
117
|
-
const owner = ownerOf(component);
|
|
118
|
-
component.navigationParent = owner.tag;
|
|
119
|
-
component.group = owner.group;
|
|
120
|
-
}
|
|
121
|
-
if (!groups.has(component.group)) throw new Error(`Unknown category ${component.group} for ${component.id}. Declare its category or map it to an existing one.`);
|
|
122
|
-
}
|
|
123
|
-
return { schemaVersion: catalogVersion, resources: [...resourceByTag.values()], groups: [...groups.values()], components: [...byId.values()].sort((a, b) => a.id.localeCompare(b.id)) };
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/** Read a published catalog without importing the optional documentation server. */
|
|
127
|
-
export async function readCatalog(specifier = new URL('./catalog.json', import.meta.url)) {
|
|
128
|
-
const catalog = await readJson(specifier instanceof URL ? fileURLToPath(specifier) : specifier);
|
|
129
|
-
if (catalog.schemaVersion !== catalogVersion) throw new Error(`Unsupported documentation catalog version ${catalog.schemaVersion}.`);
|
|
130
|
-
return catalog;
|
|
131
|
-
}
|
package/docs/cli.mjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { parseArgs } from 'node:util';
|
|
3
|
-
import { initializeDocumentation, buildProjectDocumentation, devProjectDocumentation, previewProjectDocumentation } from './commands.mjs';
|
|
4
|
-
|
|
5
|
-
try {
|
|
6
|
-
const { values, positionals } = parseArgs({ allowPositionals: true, options: { root: { type: 'string' }, port: { type: 'string' }, title: { type: 'string' }, help: { type: 'boolean', short: 'h' } } });
|
|
7
|
-
const [command = 'help'] = positionals;
|
|
8
|
-
if (values.help || command === 'help') {
|
|
9
|
-
console.log('looma-docs init | dev | build | preview\n\n --root <project> Project directory\n --port <number> Local server port (default 3000)\n --title <name> Documentation title for init\n\nInstall the optional documentation peers: markupress, @threadlabs/markupkit and vite.');
|
|
10
|
-
} else {
|
|
11
|
-
const options = { ...(values.root ? { root: values.root } : {}), ...(values.title ? { title: values.title } : {}) };
|
|
12
|
-
if (values.port) { const port = Number(values.port); if (!Number.isInteger(port) || port < 0 || port > 65535) throw new Error('Port must be an integer from 0 to 65535.'); options.port = port; }
|
|
13
|
-
if (command === 'init') {
|
|
14
|
-
const result = await initializeDocumentation(options);
|
|
15
|
-
console.log(`Created ${result.files.join(', ')}.\nImport ${result.applicationImport} after Looma styles in your application.\nRun looma-docs dev to weave your design system.`);
|
|
16
|
-
} else if (command === 'build') {
|
|
17
|
-
const built = await buildProjectDocumentation(options); console.log(`Built ${built.routes.length} documentation routes in ${built.outDir}.`);
|
|
18
|
-
} else if (command === 'dev' || command === 'preview') {
|
|
19
|
-
const server = await (command === 'dev' ? devProjectDocumentation : previewProjectDocumentation)(options);
|
|
20
|
-
console.log(server.url);
|
|
21
|
-
let closing = false;
|
|
22
|
-
const close = async () => { if (closing) return; closing = true; await server.close(); process.exitCode = 0; };
|
|
23
|
-
process.once('SIGINT', close); process.once('SIGTERM', close);
|
|
24
|
-
} else throw new Error(`Unknown documentation command ${command}. Use looma-docs --help.`);
|
|
25
|
-
}
|
|
26
|
-
} catch (error) { console.error(error.message); process.exitCode = 1; }
|
package/docs/commands.mjs
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { watch } from 'node:fs';
|
|
2
|
-
import { lstat, open, readFile, realpath, unlink } from 'node:fs/promises';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { buildDocumentation, tool } from './site.mjs';
|
|
6
|
-
import { createThemeStore } from './store.mjs';
|
|
7
|
-
import { serveLocalDocumentation } from './local-server.mjs';
|
|
8
|
-
import { defaultRecipe, themeCSS } from './theme.mjs';
|
|
9
|
-
|
|
10
|
-
export const configName = 'looma.docs.json';
|
|
11
|
-
export async function readConfiguration(root = process.cwd()) {
|
|
12
|
-
root = await realpath(path.resolve(root));
|
|
13
|
-
try { return { root, config: JSON.parse(await readFile(path.join(root, configName), 'utf8')) }; }
|
|
14
|
-
catch (error) { if (error.code === 'ENOENT') throw new Error(`No ${configName} in this project. Run looma-docs init first.`); throw error; }
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** Initialization creates explicit owned files, leaving the application's imports to its author. */
|
|
18
|
-
export async function initializeDocumentation({ root = process.cwd(), title = 'Your design system' } = {}) {
|
|
19
|
-
root = await realpath(path.resolve(root));
|
|
20
|
-
const config = { title, base: '/', outDir: '.looma/site', theme: { recipe: 'looma.theme.json', css: 'looma.theme.css' }, components: [] };
|
|
21
|
-
const recipe = defaultRecipe();
|
|
22
|
-
const system = await readFile(fileURLToPath(import.meta.resolve('@threadlabs/looma/theme-system.css')), 'utf8');
|
|
23
|
-
const files = new Map([[configName, JSON.stringify(config, null, 2) + '\n'], [config.theme.recipe, JSON.stringify(recipe, null, 2) + '\n'], [config.theme.css, themeCSS(recipe, system)]]);
|
|
24
|
-
for (const name of files.keys()) {
|
|
25
|
-
try { await lstat(path.join(root, name)); throw new Error(`${name} already exists. Initialization will not replace it.`); }
|
|
26
|
-
catch (error) { if (error.code !== 'ENOENT') throw error; }
|
|
27
|
-
}
|
|
28
|
-
const created = [];
|
|
29
|
-
try {
|
|
30
|
-
for (const [name, source] of files) {
|
|
31
|
-
const file = path.join(root, name); const handle = await open(file, 'wx', 0o644); created.push(file);
|
|
32
|
-
try { await handle.writeFile(source); } finally { await handle.close(); }
|
|
33
|
-
}
|
|
34
|
-
} catch (error) { await Promise.all(created.map(file => unlink(file))); throw error; }
|
|
35
|
-
return { config, files: [...files.keys()], applicationImport: './' + config.theme.css };
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async function themeConfiguration(root, config, local = false) {
|
|
39
|
-
if (!config.theme && !local) return config;
|
|
40
|
-
const store = await createThemeStore({ root, ...config.theme });
|
|
41
|
-
const current = await store.read({ includeCSS: true });
|
|
42
|
-
return { ...config, recipe: current.recipe, revision: current.revision, ...(current.css !== null ? { themeCSSContents: current.css } : {}), local };
|
|
43
|
-
}
|
|
44
|
-
export async function buildProjectDocumentation({ root = process.cwd(), config, catalog } = {}) {
|
|
45
|
-
if (!config) ({ root, config } = await readConfiguration(root));
|
|
46
|
-
return buildDocumentation({ root, config: await themeConfiguration(root, config), catalog });
|
|
47
|
-
}
|
|
48
|
-
export async function previewProjectDocumentation({ root = process.cwd(), config, port = 3000 } = {}) {
|
|
49
|
-
if (!config) ({ root, config } = await readConfiguration(root));
|
|
50
|
-
const { previewApplication } = await tool('@threadlabs/markupkit', root);
|
|
51
|
-
return previewApplication({ root, outDir: config.outDir ?? '.looma/site', base: config.base ?? '/', host: '127.0.0.1', port });
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** MarkupKit serves the build; this local-only gateway adds the constrained repository writer. */
|
|
55
|
-
export async function devProjectDocumentation({ root = process.cwd(), config, catalog, port = 3000, onError = console.error } = {}) {
|
|
56
|
-
const configured = Boolean(config);
|
|
57
|
-
if (!config) ({ root, config } = await readConfiguration(root));
|
|
58
|
-
const store = await createThemeStore({ root, ...config.theme });
|
|
59
|
-
let closed = false, dirty = true, building, timer;
|
|
60
|
-
const rebuild = () => {
|
|
61
|
-
clearTimeout(timer);
|
|
62
|
-
if (building) return building;
|
|
63
|
-
building = (async () => {
|
|
64
|
-
while (dirty && !closed) {
|
|
65
|
-
dirty = false;
|
|
66
|
-
if (!configured) {
|
|
67
|
-
const next = (await readConfiguration(root)).config;
|
|
68
|
-
if (['base', 'outDir', 'theme'].some(key => JSON.stringify(next[key]) !== JSON.stringify(config[key]))) throw new Error('The server address, output or theme-file configuration changed. Restart looma-docs dev to use it.');
|
|
69
|
-
config = next;
|
|
70
|
-
}
|
|
71
|
-
await buildDocumentation({ root, config: await themeConfiguration(root, config, true), catalog });
|
|
72
|
-
}
|
|
73
|
-
})().finally(() => { building = undefined; });
|
|
74
|
-
return building;
|
|
75
|
-
};
|
|
76
|
-
await rebuild();
|
|
77
|
-
const upstream = await previewProjectDocumentation({ root, config, port: 0 });
|
|
78
|
-
let gateway;
|
|
79
|
-
try {
|
|
80
|
-
gateway = await serveLocalDocumentation({ upstream: upstream.url, store, base: config.base ?? '/', port, onSaved: async () => { dirty = true; await rebuild(); } });
|
|
81
|
-
} catch (error) { await upstream.close(); throw error; }
|
|
82
|
-
const watcher = watch(root, { recursive: true }, (_event, filename) => {
|
|
83
|
-
if (!filename || closed) return;
|
|
84
|
-
const relative = String(filename).split(path.sep).join('/');
|
|
85
|
-
if (relative.split('/').some(part => part === 'node_modules' || part === '.git' || part === '.looma')) return;
|
|
86
|
-
const output = config.outDir ?? '.looma/site';
|
|
87
|
-
if (relative === output || relative.startsWith(output + '/')) return;
|
|
88
|
-
const inputs = [configName, config.theme?.recipe ?? 'looma.theme.json', config.theme?.css ?? 'looma.theme.css', config.content, ...(config.components ?? []).map(entry => entry.directory), ...(config.overrides ?? [])].filter(Boolean).map(value => value.replace(/^\.\//, ''));
|
|
89
|
-
if (!inputs.some(input => relative === input || relative.startsWith(input + '/'))) return;
|
|
90
|
-
dirty = true;
|
|
91
|
-
clearTimeout(timer); timer = setTimeout(() => { void rebuild().catch(onError); }, 150);
|
|
92
|
-
});
|
|
93
|
-
return { url: gateway.url, close: async () => { closed = true; clearTimeout(timer); watcher.close(); await building?.catch(() => {}); await gateway.close(); await upstream.close(); } };
|
|
94
|
-
}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { googleFonts, systemFont } from './fonts.mjs';
|
|
2
|
-
import { escapeHtml as escape } from './catalog.mjs';
|
|
3
|
-
import { componentPath, previewMarkup, exampleKey, exampleResources, cardDescription } from './render.mjs';
|
|
4
|
-
import { valueEditor } from './value-editors.mjs';
|
|
5
|
-
import { defaultRecipe, themeFields, startingPoints, startingPointLabels, startingPointFor, deriveTheme, applyRefinement, themeCSS, validateRecipe, themePalettes, materialPresets, statusPresets, refinementState } from './theme.mjs';
|
|
6
|
-
|
|
7
|
-
export function customizerResource(site, input = defaultRecipe()) {
|
|
8
|
-
const recipe = validateRecipe(input);
|
|
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.summary ?? component.description), exampleTitle: example.title, resizable: Boolean(example.resizable), category: component.group, tag: component.tag, packageName: component.package, nativeRoot: component.root ? `<${component.root}>` : '', href: site.base + componentPath(component).slice(1) })));
|
|
11
|
-
const toCard = example => Object.fromEntries(cardFields.map(key => [key, example[key]]));
|
|
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
|
-
if (!initial.length && examples.length) initial.push(toCard(examples[0]));
|
|
14
|
-
let specimen = 0;
|
|
15
|
-
const documentationCard = (tag, suffix, previewOnly = false) => {
|
|
16
|
-
const example = examples.find(item => item.tag === tag && (!suffix || item.id.endsWith(suffix))) ?? examples.find(item => item.tag === tag);
|
|
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>` : '';
|
|
18
|
-
};
|
|
19
|
-
const help = (id, label, description, inline = false) => `<span${inline ? ' class="inline-help"' : ' slot="labelAction"'}><ui-icon-button id="help-${id}" size="sm" label="About ${escape(label)}"><ui-icon name="help"></ui-icon></ui-icon-button><ui-tooltip for="help-${id}" trigger="click">${escape(description)}</ui-tooltip></span>`;
|
|
20
|
-
const shortLabels = { 'body-font':'Font', 'display-font':'Heading font', 'label-size':'Field labels', 'secondary-action':'Secondary', 'tertiary-action':'Tertiary', 'selection-accent':'Selection', 'focus-accent':'Focus', 'link-accent':'Links', 'neutral-source':'Source', 'neutral-strength':'Strength', 'neutral-border-contrast':'Border contrast', 'success-source':'Success', 'danger-source':'Error', 'warning-source':'Warning', 'info-source':'Info', 'status-chroma':'Status chroma', 'control-roominess':'Roominess', 'surface-separation':'Rim width', 'corner-roundness':'Roundness' };
|
|
21
|
-
const setting = (field, control, id = `theme-${field.id}`) => `<div class="setting${field.type.includes('colour') ? ' color-setting' : field.type === 'easing' ? ' curve-setting' : ''}"><ui-form-field><label slot="label" for="${id}">${escape(shortLabels[field.id] ?? field.label)}</label>${['action','canvas','surface','text','secondary-action','tertiary-action'].includes(field.id) ? '' : help(field.id, field.label, field.description)}${control}</ui-form-field></div>`;
|
|
22
|
-
const renderField = field => {
|
|
23
|
-
const value = recipe.values[field.id];
|
|
24
|
-
if (field.id === 'label-size') {
|
|
25
|
-
const inherited = value === 'inherit', size = inherited ? recipe.values['text-size'] : value;
|
|
26
|
-
return setting(field, `<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</option><option value="custom">Set a separate size</option></ui-select><ui-number-input compact 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>`, 'theme-label-source');
|
|
27
|
-
}
|
|
28
|
-
if (field.type === 'optional-colour') {
|
|
29
|
-
return setting(field, `<ui-color-picker id="theme-${field.id}" size="sm" clearable data-token="${field.id}" data-optional-color="${field.id}" value="${escape(value === field.defaultValue ? '' : value)}" label="${escape(field.label)} colour picker"></ui-color-picker>`);
|
|
30
|
-
}
|
|
31
|
-
const editor = valueEditor(field, value, { remPixels: parseFloat(recipe.values['text-size']) });
|
|
32
|
-
const common = `size="sm" aria-label="${escape(field.label)}" data-token="${field.id}" label="${escape(field.label)}"`;
|
|
33
|
-
let control;
|
|
34
|
-
if (field.type === 'font') {
|
|
35
|
-
const selected = field.id === 'display-font' && value === recipe.values['body-font'] ? 'inherit' : recipe.fonts?.[field.id] ?? (value === systemFont ? 'system' : 'custom');
|
|
36
|
-
control = `<ui-combobox id="theme-${field.id}" size="sm" data-font-picker="${field.id}" label-visibility="sr-only" label="${escape(field.label)}" value="${escape(selected)}" placeholder="Search Google Fonts…" disclosure><template slot="option"><span class="font-option" from:data-font-preview="$option.value">{$option.label}</span></template>${field.id === 'display-font' ? '<option value="inherit">Follow body</option>' : ''}<option value="system">System font</option><option value="custom" disabled>${escape(value.split(',')[0].replaceAll('"', '').trim())}</option>${Object.values(googleFonts).map(font => `<option value="${escape(font.family)}">${escape(font.family)}</option>`).join('')}</ui-combobox><ui-text variant="caption" data-font-status="${field.id}" role="status" hidden></ui-text>`;
|
|
37
|
-
} else if (field.type === 'choice') {
|
|
38
|
-
control = `<ui-select id="theme-${field.id}" ${common} value="${escape(value)}">${Object.entries(field.choices).map(([id,label]) => `<option value="${id}">${escape(label)}</option>`).join('')}</ui-select>`;
|
|
39
|
-
} else if (field.type === 'easing') {
|
|
40
|
-
control = `<ui-input id="theme-${field.id}" size="sm" data-token="${field.id}" aria-label="${escape(field.label)}" value="${escape(value)}"></ui-input><div data-curve-for="${field.id}"${editor.kind === 'text' ? ' hidden' : ''}><ui-curve-editor ${common} data-editor-kind="curve" value="${escape(value)}"></ui-curve-editor></div>`;
|
|
41
|
-
} else if (editor.kind === 'number' || editor.kind === 'slider') {
|
|
42
|
-
const tag = editor.kind === 'slider' ? 'ui-slider' : 'ui-number-input';
|
|
43
|
-
const numeric = `<${tag} compact id="theme-${field.id}" ${common} data-editor-kind="${editor.kind}" value="${escape(editor.value)}" unit="${editor.unit}" min="${editor.min}" max="${editor.max}" step="${editor.step}"></${tag}>`;
|
|
44
|
-
control = editor.units ? `<ui-cluster wrap="nowrap" gap="xs">${numeric}<ui-select size="sm" style="--ui-select-inline-size: auto" data-unit-for="${field.id}" aria-label="${escape(field.label)} unit" value="${editor.unit}">${[...new Set([...editor.units, editor.unit])].map(unit => `<option value="${unit}">${unit}</option>`).join('')}</ui-select></ui-cluster>` : numeric;
|
|
45
|
-
} else {
|
|
46
|
-
control = field.type === 'colour' ? `<ui-color-picker id="theme-${field.id}" data-token="${field.id}" value="${escape(value)}" size="sm" label="${escape(field.label)} colour picker"></ui-color-picker>` : `<ui-input id="theme-${field.id}" ${common} value="${escape(value)}"></ui-input>`;
|
|
47
|
-
}
|
|
48
|
-
return setting(field, control);
|
|
49
|
-
};
|
|
50
|
-
const swatches = tokens => `<span class="palette-swatches" aria-hidden="true">${['--ui-accent','--ui-neutral-surface','--ui-surface','--ui-text'].map(token => `<span style="background:${escape(tokens ? tokens[token] : `var(${token})`)}"></span>`).join('')}</span>`;
|
|
51
|
-
const choice = (attributes, label, value, options, content = '') => `<ui-combobox ${attributes} size="sm" data-choice label="${escape(label)}" value="${escape(value)}" disclosure open-on-focus>${options}${content}</ui-combobox>`;
|
|
52
|
-
const renderPreset = (family, location) => {
|
|
53
|
-
const presets = { material: materialPresets, palette: themePalettes, status: statusPresets }[family];
|
|
54
|
-
const state = refinementState(recipe, family), label = { material: 'Material preset', palette: 'Palette preset', status: 'Status color relationship' }[family];
|
|
55
|
-
const origin = startingPoints[recipe.origin ?? startingPointFor(recipe)];
|
|
56
|
-
const muted = origin && Object.keys(Object.values(presets)[0].values).every(key => origin.values[key] === recipe.values[key]);
|
|
57
|
-
const options = `<option value="custom" disabled>Your ${family}</option>${Object.entries(presets).map(([id, preset]) => `<option value="${id}">${escape(preset.label)}${state.id === id && state.customized ? ' · customized' : ''}</option>`).join('')}`;
|
|
58
|
-
const preview = family === 'palette' ? `<span slot="start" data-selected-palette>${swatches()}</span><template slot="option"><span class="palette-option">${Object.keys(presets).map(id => `<template $if="$option.value = '${id}'">${swatches(deriveTheme(applyRefinement(recipe, 'palette', id), { mode: 'light' }).tokens)}</template>`).join('')}<span>{$option.label}</span></span></template>` : '';
|
|
59
|
-
if (family === 'status') return `<ui-form-field><label slot="label" for="${location}-status">${label}</label><ui-select id="${location}-status" size="sm" data-refinement-preset="status" value="${state.id}"${muted ? ' muted' : ''}>${options}</ui-select></ui-form-field>`;
|
|
60
|
-
return choice(`id="${location}-${family}" data-refinement-preset="${family}"${muted ? ' muted' : ''}`, label, state.id, options, preview);
|
|
61
|
-
};
|
|
62
|
-
const paletteDetails = `<ui-grid columns="2" min="md" gap="s">${['light', 'dark'].map(mode => `<ui-card data-theme="${mode}" padding="sm"><ui-stack gap="s"><ui-text variant="eyebrow">${mode === 'light' ? 'Light' : 'Dark'}</ui-text><div class="palette-range" role="img" aria-label="${mode} canvas, content and action range"><span class="palette-canvas"></span><span class="palette-content"></span><span class="palette-action"></span></div><ui-text variant="heading" as="h3">Fellowship</ui-text><ui-text>There and back.</ui-text><ui-text variant="caption">Second breakfast at nine.</ui-text><ui-input size="sm" aria-label="${mode} neutral field" value="Shared neutral boundary"></ui-input><ui-action-bar><ui-button slot="tertiary" size="sm" variant="outline" tone="accent">Outline</ui-button><ui-button slot="secondary" size="sm" preset="standard">Neutral</ui-button><ui-button slot="primary" size="sm" preset="primary">Accent</ui-button></ui-action-bar><ui-cluster><ui-button size="sm" variant="outline" tone="neutral">Neutral outline</ui-button><ui-badge tone="accent-secondary" data-extra-accent="secondary-action">Secondary accent</ui-badge><ui-badge tone="accent-tertiary" data-extra-accent="tertiary-action">Tertiary accent</ui-badge></ui-cluster><ui-card tone="accent-secondary" data-extra-accent="secondary-action"><ui-stack gap="s"><ui-text weight="medium">A supporting highlight</ui-text><ui-text variant="caption">A category or feature can carry another accent while the main action stays primary.</ui-text></ui-stack></ui-card><ui-cluster>${[['success','Success','circle-check'],['danger','Error','circle-x'],['warning','Warning','triangle-alert'],['info','Info','info']].map(([tone,label,icon]) => `<ui-badge tone="${tone}"><ui-icon name="${icon}" slot="icon"></ui-icon>${label}</ui-badge>`).join('')}</ui-cluster><ui-callout tone="tip">Tips share the informational color family.</ui-callout><ui-callout tone="info">A status surface shares the Info badge’s colors.</ui-callout><ui-list><ui-list-item current><a href="#palette">Selected collection</a></ui-list-item></ui-list><ui-text><a href="#palette">Read the guide</a></ui-text><ui-text variant="caption" data-palette-roles="${mode}"></ui-text></ui-stack></ui-card>`).join('')}</ui-grid><ui-text variant="caption" data-palette-adjustments role="status" aria-live="polite"></ui-text><ui-disclosure summary="Resolved palette values"><ui-text variant="caption" data-palette-adjustment-details></ui-text></ui-disclosure>`;
|
|
63
|
-
const paletteRelationships = `<ui-stack gap="s"><ui-text variant="heading" as="h3">How should the colors work together?</ui-text>${[
|
|
64
|
-
['preserve', 'Keep my colors', 'Keep the base colors as chosen. Warmth and intensity still refine the result.'],
|
|
65
|
-
['neighboring', 'Related colors', 'Tint neutral surfaces with a neighboring hue for a closely coordinated palette.'],
|
|
66
|
-
['complementary', 'Contrasting colors', 'Tint neutral surfaces toward the opposite hue for warm–cool contrast.'],
|
|
67
|
-
].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>`;
|
|
68
|
-
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>`;
|
|
69
|
-
const fieldsFor = ids => ids.map(id => renderField(themeFields.find(field => field.id === id))).join('');
|
|
70
|
-
const viewTitles = { material: 'Material & light', palette: 'Palette', typography: 'Typography', layout: 'Size & spacing', motion: 'Motion', export: 'Export & save', components: 'Component library' };
|
|
71
|
-
const refinement = (family, content) => `<section id="${family}" data-refinement-view="${family}" hidden tabindex="-1" aria-label="${viewTitles[family]} editor"><ui-stack gap="l"><ui-text variant="heading" as="h2">${viewTitles[family]}</ui-text>${content}</ui-stack></section>`;
|
|
72
|
-
const editor = (family, preview, controls) => refinement(family, `<div class="refinement-layout"><div class="controls-panel"><ui-card padding="sm"><div class="settings-grid">${controls}</div></ui-card></div><div class="editor-preview" data-editor-preview="${family}">${preview}</div></div>`);
|
|
73
|
-
const customFontStacks = `<div class="settings-section"><ui-disclosure summary="Custom font stacks"><div class="settings-grid">${['body-font','display-font'].map(id=>`<ui-form-field><label slot="label" for="theme-${id}-custom">${id === 'body-font' ? 'Font' : 'Heading font'} stack</label><ui-input id="theme-${id}-custom" size="sm" data-token="${id}" value="${escape(recipe.values[id])}" aria-label="${id === 'body-font' ? 'Font' : 'Heading font'} stack"></ui-input></ui-form-field>`).join('')}</div></ui-disclosure></div>`;
|
|
74
|
-
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>`, `<div class="settings-section"><div class="settings-grid">${fieldsFor(['body-font','display-font'])}</div></div>${fieldsFor(['text-size','label-size','text-weight'])}${customFontStacks}`);
|
|
75
|
-
const layoutView = editor('layout', `<ui-stack>${sizePreview}</ui-stack>`, `${fieldsFor(['control-roominess','rhythm','spacing','corner-roundness'])}${fieldsFor(['scale-contrast','space-curve','line-weight'])}`);
|
|
76
|
-
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'])}<div class="settings-section"><ui-disclosure summary="Shape the curve"><ui-stack>${fieldsFor(['response-curve'])}</ui-stack></ui-disclosure></div><div class="settings-section"><ui-cluster gap="xs"><ui-text weight="medium">Motion preview</ui-text>${help('motion-preview','motion preview','Replay shows the shared curve. The popover demonstrates it in a real component. System reduced-motion preferences are respected.',true)}</ui-cluster></div><div class="settings-section"><ui-disclosure summary="Try a popover">${documentationCard('ui-popover', null, true)}</ui-disclosure></div>`);
|
|
77
|
-
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>`;
|
|
78
|
-
const materialSample = `<ui-card treatment="expressive"><ui-stack gap="m"><ui-text variant="heading" as="h3">Fellowship briefing</ui-text><ui-text>Content stays readable while the rim reveals 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>`;
|
|
79
|
-
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>`;
|
|
80
|
-
const materialView = editor('material', `<ui-stack>${materialSample}${materialSurfaces}</ui-stack>`, `<div class="settings-section">${renderPreset('material', 'refinement')}</div>${fieldsFor(['finish','translucency','glassiness'])}<div class="settings-section"><ui-cluster gap="xs"><ui-text weight="medium">Lighting</ui-text><ui-icon-button id="help-lighting" size="sm" label="About lighting"><ui-icon name="help"></ui-icon></ui-icon-button><ui-tooltip for="help-lighting" trigger="click"><span data-material-dependencies></span></ui-tooltip></ui-cluster></div><ui-stack gap="s" data-glass-hint hidden><ui-text variant="caption">No transmission to blur.</ui-text><ui-button size="sm" data-action="use-glass">Use frosted glass</ui-button></ui-stack><div class="settings-section">${lightEditor}<div class="settings-grid">${fieldsFor(['light-color','light-spread','light-strength','edge-light','glow','outer-depth','inner-depth','surface-separation'])}</div></div><div class="settings-section"><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></div>`);
|
|
81
|
-
const statusControls = ['success','danger','warning','info'].map(role => fieldsFor([role + '-source'])).join('');
|
|
82
|
-
const paletteView = refinement('palette', `<div class="refinement-layout"><div class="controls-panel"><ui-card padding="sm"><ui-stack gap="s">${renderPreset('palette', 'refinement')}<ui-cluster gap="xs"><ui-text weight="medium">Base colors</ui-text>${help('base-colors','base colors',['action','canvas','surface','text'].map(id => { const f=themeFields.find(field=>field.id===id); return f.label+': '+f.description; }).join(' '),true)}</ui-cluster><div class="color-row" data-base-colors>${fieldsFor(['action','canvas','surface','text'])}</div><ui-cluster gap="xs"><ui-text weight="medium">Supporting accents</ui-text>${help('supporting-colors','supporting accents','Optional second and third accents. Choose None inside a picker to leave it unset. Components use these only when that accent is chosen.',true)}</ui-cluster><div class="color-row" data-supporting-colors>${fieldsFor(['secondary-action','tertiary-action'])}</div><ui-text weight="medium">Use colors for</ui-text><div class="settings-grid">${fieldsFor(['selection-accent','focus-accent','link-accent'])}</div><ui-text weight="medium">Neutrals & borders</ui-text><div class="settings-grid">${fieldsFor(['neutral-source','neutral-strength','neutral-border-contrast'])}</div><ui-text weight="medium">Status colors</ui-text>${renderPreset('status', 'refinement')}<div class="settings-grid">${statusControls}${fieldsFor(['status-chroma'])}</div><ui-disclosure summary="Color character"><div class="settings-grid">${fieldsFor(['warmth','color-intensity'])}</div>${paletteRelationships}</ui-disclosure></ui-stack></ui-card></div><div class="palette-preview"><ui-stack>${paletteDetails}</ui-stack></div></div>`);
|
|
83
|
-
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('');
|
|
84
|
-
const links = ['ui-menu','ui-menu-item','ui-tooltip','ui-icon-button','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');
|
|
85
|
-
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>
|
|
86
|
-
<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>
|
|
87
|
-
<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>
|
|
88
|
-
</defs>
|
|
89
|
-
<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 ?? '')}">
|
|
90
|
-
<ui-stack gap="l">
|
|
91
|
-
<div class="summary-panel" data-customizer-summary><ui-card padding="sm"><div class="summary-toolbar"><div class="summary-theme">${choice('id="theme-start" data-preset label-visibility="sr-only"', 'Starting point', startingPointFor(recipe), `<option value="custom" disabled>Your theme</option>${Object.entries(startingPointLabels).map(([id,label]) => `<option value="${id}">${label}</option>`).join('')}`)}</div><nav aria-label="Theme controls" class="summary-sections">${[['palette','Palette'],['material','Material'],['typography','Type'],['layout','Size'],['motion','Motion']].map(([id,label]) => `<div class="summary-choice"><ui-button variant="ghost" tone="neutral" size="sm" data-action="refine-${id}" aria-label="${label}"><ui-stack gap="xs"><span class="summary-heading">${id === 'palette' ? swatches() : ''}<span>${label}</span></span><span data-summary="${id}" class="summary-value"></span></ui-stack></ui-button></div>`).join('')}</nav><div class="summary-actions"><ui-cluster gap="xs" wrap="nowrap"><ui-icon-button id="theme-undo" size="sm" data-action="undo" label="Undo" disabled><ui-icon name="undo"></ui-icon></ui-icon-button><ui-tooltip for="theme-undo">Undo</ui-tooltip><ui-icon-button id="theme-redo" size="sm" data-action="redo" label="Redo" disabled><ui-icon name="redo"></ui-icon></ui-icon-button><ui-tooltip for="theme-redo">Redo</ui-tooltip><ui-button size="sm" data-action="reset">Reset</ui-button><ui-icon-button id="theme-tools" size="sm" label="Theme tools"><ui-icon name="ellipsis"></ui-icon></ui-icon-button><ui-menu for="theme-tools" label="Theme tools"><ui-menu-item data-action="back">Overview</ui-menu-item><ui-menu-item data-action="refine-components">Components</ui-menu-item><ui-menu-item data-action="refine-export">Export & save</ui-menu-item></ui-menu></ui-cluster></div><span class="summary-active-value" data-active-summary></span><span class="summary-status" role="status" aria-live="polite" data-message></span></div></ui-card></div>
|
|
92
|
-
${materialView}${paletteView}${typographyView}${layoutView}${motionView}
|
|
93
|
-
${refinement('export', `<ui-stack><ui-cluster><ui-button data-action="css" variant="solid">Download CSS</ui-button><ui-button data-action="recipe">Download recipe</ui-button><ui-button data-action="import">Import recipe</ui-button></ui-cluster>
|
|
94
|
-
<input type="file" accept="application/json,.json" hidden data-recipe-file>
|
|
95
|
-
<ui-button data-action="save" variant="solid" hidden>Save to repository</ui-button>
|
|
96
|
-
<ui-disclosure summary="Use your theme"><ui-text>Every export includes light and dark. Leave data-theme off the page to follow system preference, or set it to light or dark on the page or a section. <a href="${escape(site.base)}design-system/">Installation and mode guidance</a></ui-text></ui-disclosure>
|
|
97
|
-
<ui-disclosure summary="Theme CSS"><ui-textarea data-css readonly rows="12" aria-label="Generated theme CSS" value="${escape(themeCSS(recipe))}"></ui-textarea></ui-disclosure></ui-stack>`)}
|
|
98
|
-
<div class="customizer-layout" data-customizer-overview>
|
|
99
|
-
<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>
|
|
100
|
-
<noscript>Enable JavaScript to edit the theme. The component reference and example previews remain available.</noscript>
|
|
101
|
-
</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>
|
|
102
|
-
<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>
|
|
103
|
-
<ui-button data-action="more-examples">Show more components</ui-button></ui-stack></section>
|
|
104
|
-
`)}</ui-stack></div>
|
|
105
|
-
<style>
|
|
106
|
-
:host { background-color: var(--ui-surface); }
|
|
107
|
-
.summary-panel { container-type: inline-size; position: sticky; inset-block-start: var(--_editor-chrome-height, 4.25rem); z-index: 3; }
|
|
108
|
-
.font-option { font-family: var(--_font-preview-family, inherit); font-weight: 400; }
|
|
109
|
-
.summary-theme { inline-size: 8rem; max-inline-size: 100%; min-inline-size: 0; }
|
|
110
|
-
.summary-toolbar { display: grid !important; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center !important; gap: var(--ui-space-2) !important; }
|
|
111
|
-
.summary-sections { display: flex !important; flex-wrap: wrap !important; gap: var(--ui-space-1) !important; }
|
|
112
|
-
.summary-heading { display: flex !important; align-items: center !important; gap: var(--ui-space-2) !important; }
|
|
113
|
-
.summary-active-value { display: none; grid-column: 1 / -1; color: var(--ui-text-secondary); font-size: var(--ui-font-size-sm); }
|
|
114
|
-
.curve-setting { grid-column: 1 / -1; }
|
|
115
|
-
.summary-status { grid-column: 1 / -1; font-size: var(--ui-font-size-md); color: var(--ui-text-secondary); }
|
|
116
|
-
.summary-status:empty { display: none; }
|
|
117
|
-
.summary-choice { flex: 0 1 auto; min-inline-size: 0; }
|
|
118
|
-
.summary-value { display: block; max-inline-size: 11rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--ui-font-size-sm); color: var(--ui-text-secondary); }
|
|
119
|
-
.controls-panel { grid-column: 2; grid-row: 1; min-inline-size: 0; }
|
|
120
|
-
.refinement-layout > .editor-preview, .refinement-layout > .palette-preview { grid-column: 1; grid-row: 1; }
|
|
121
|
-
@container (max-width: 16rem) { .summary-toolbar { grid-template-columns: minmax(0, 1fr); } .summary-actions { grid-column: 1 !important; grid-row: 2 !important; } .summary-sections { grid-row: 3 !important; } }
|
|
122
|
-
.settings-grid { display: grid !important; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr)); gap: var(--ui-space-3) !important; align-items: start !important; }
|
|
123
|
-
.settings-section { grid-column: 1 / -1; }
|
|
124
|
-
.setting { min-inline-size: 0; }
|
|
125
|
-
[data-base-colors] { display: grid !important; grid-template-columns: repeat(auto-fit, minmax(min(100%, 4.25rem), max-content)); }
|
|
126
|
-
[data-base-colors] .color-setting { inline-size: auto; }
|
|
127
|
-
.color-row { display: flex !important; flex-wrap: wrap !important; gap: var(--ui-space-4) !important; }
|
|
128
|
-
.color-setting { inline-size: 5.25rem; }
|
|
129
|
-
[data-editor-preview="material"] { padding: var(--ui-space-4) !important; background-color: var(--ui-surface); background-image: repeating-linear-gradient(0deg, transparent 0 15px, color-mix(in srgb, var(--ui-text) 24%, transparent) 14px 16px), repeating-linear-gradient(90deg, transparent 0 15px, color-mix(in srgb, var(--ui-text) 24%, transparent) 14px 16px); }
|
|
130
|
-
@media (max-width: 40rem) { .summary-toolbar { grid-template-columns: minmax(0, 1fr) auto; } .summary-sections { grid-column: 1 / -1; grid-row: 2; flex-wrap: wrap !important; } .summary-actions { grid-column: 2; grid-row: 1; } .summary-value, .summary-heading .palette-swatches { display: none; } .summary-choice { flex: 0 1 auto; } .summary-active-value { display: block; } .summary-status { font-size: var(--ui-font-size-sm); } }
|
|
131
|
-
|
|
132
|
-
[data-customizer-overview][hidden], [data-refinement-view][hidden] { display: none !important; }
|
|
133
|
-
.customizer-layout { display: grid !important; grid-template-columns: minmax(0, 1fr); gap: var(--ui-space-6) !important; align-items: start !important; }
|
|
134
|
-
aside { grid-row: 1 / span 2; position: sticky; inset-block-start: calc(var(--_editor-chrome-height, 4.25rem) + var(--_customizer-summary-height, 8rem) + var(--ui-space-2)); max-block-size: calc(100dvh - var(--_editor-chrome-height, 4.25rem) - var(--ui-space-4)); overflow: auto; padding: max(var(--ui-space-2), calc(var(--ui-focus-width) * 2)) !important; scroll-padding: max(var(--ui-space-2), calc(var(--ui-focus-width) * 2)); }
|
|
135
|
-
.examples { min-inline-size: 0; }
|
|
136
|
-
.refinement-layout { display: grid !important; grid-template-columns: minmax(0, 1.15fr) minmax(20rem, 0.85fr); gap: var(--ui-space-6) !important; align-items: start !important; }
|
|
137
|
-
[data-refinement-view] { scroll-margin-block-start: calc(var(--_editor-chrome-height, 4.25rem) + var(--_customizer-summary-height, 8rem) + var(--ui-space-2)); }
|
|
138
|
-
.palette-preview, .editor-preview { position: sticky; inset-block-start: calc(var(--_editor-chrome-height, 4.25rem) + var(--_customizer-summary-height, 8rem) + var(--ui-space-2)); max-block-size: calc(100dvh - var(--_editor-chrome-height, 4.25rem) - var(--ui-space-4)); overflow: auto; }
|
|
139
|
-
.spacing-samples { display: flex !important; align-items: center !important; gap: 0 !important; padding-block: var(--ui-space-3) !important; }
|
|
140
|
-
.spacing-samples > span { display: block !important; block-size: var(--ui-space-1); inline-size: var(--ui-space-1); border-radius: 50%; background: var(--ui-accent); }
|
|
141
|
-
.spacing-samples > span:nth-child(2) { margin-inline-start: var(--ui-space-2) !important; }
|
|
142
|
-
.spacing-samples > span:nth-child(3) { margin-inline-start: var(--ui-space-3) !important; }
|
|
143
|
-
.spacing-samples > span:nth-child(4) { margin-inline-start: var(--ui-space-4) !important; }
|
|
144
|
-
.palette-option { display: flex; align-items: center; gap: var(--ui-space-2); }
|
|
145
|
-
.palette-swatches { display: flex; gap: 0.125rem; flex: none; }
|
|
146
|
-
.palette-swatches > span { display: block; inline-size: 0.65rem; block-size: 0.65rem; border-radius: var(--ui-radius-xs); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ui-text) 12%, transparent); }
|
|
147
|
-
.palette-range { display: flex !important; min-block-size: var(--ui-control-size-sm); border: var(--ui-border-width) solid var(--ui-control-border); border-radius: var(--ui-radius-sm); overflow: hidden; }
|
|
148
|
-
.palette-range > span { flex: 1; min-inline-size: var(--ui-space-5); }
|
|
149
|
-
.palette-canvas { background: var(--_palette-canvas, var(--ui-surface)); }
|
|
150
|
-
.palette-content { background: var(--_palette-content, var(--ui-surface-raised)); }
|
|
151
|
-
.palette-action { background: var(--_palette-action, var(--ui-accent)); }
|
|
152
|
-
.motion-track { overflow: clip; display: flex; align-items: center; block-size: 5rem; padding: var(--ui-space-3); border-radius: var(--ui-radius-md); background: var(--ui-surface-muted); }
|
|
153
|
-
[data-motion-object] { display: block; inline-size: 2rem; block-size: 2rem; border-radius: var(--ui-radius-sm); background: var(--ui-accent-solid); box-shadow: var(--ui-action-shadow); }
|
|
154
|
-
@media (max-width: 64rem) { .controls-panel, .refinement-layout > .editor-preview, .refinement-layout > .palette-preview { grid-column: 1; grid-row: auto; } [data-base-colors] { gap: var(--ui-space-2) !important; } [data-base-colors] .color-setting { inline-size: auto; } .customizer-layout, .refinement-layout { grid-template-columns: minmax(0, 1fr); } aside { grid-row: auto; order: 1; position: static; max-block-size: none; } .palette-preview, .editor-preview { position: sticky; inset-block-start: calc(var(--_editor-chrome-height, 4.25rem) + var(--_customizer-summary-height, 8rem) + var(--ui-space-2)); z-index: 1; background: var(--ui-surface); max-block-size: none; overflow: visible; padding: 0 !important; } .editor-preview { position: static; } [data-theme-sampler] { order: 2; } .examples { order: 3; } }
|
|
155
|
-
@media (max-width: 64rem) { .palette-preview[data-page-flow], .editor-preview[data-page-flow] { position: static; } }
|
|
156
|
-
</style></template>`;
|
|
157
|
-
}
|