@pure-ds/storybook 0.1.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/.storybook/addons/description/preview.js +15 -0
- package/.storybook/addons/description/register.js +60 -0
- package/.storybook/addons/html-preview/Panel.jsx +327 -0
- package/.storybook/addons/html-preview/constants.js +6 -0
- package/.storybook/addons/html-preview/preview.js +178 -0
- package/.storybook/addons/html-preview/register.js +16 -0
- package/.storybook/addons/pds-configurator/SearchTool.js +44 -0
- package/.storybook/addons/pds-configurator/Tool.js +30 -0
- package/.storybook/addons/pds-configurator/constants.js +9 -0
- package/.storybook/addons/pds-configurator/preview.js +159 -0
- package/.storybook/addons/pds-configurator/register.js +24 -0
- package/.storybook/docs.css +35 -0
- package/.storybook/htmlPreview.css +103 -0
- package/.storybook/htmlPreview.js +271 -0
- package/.storybook/main.js +160 -0
- package/.storybook/preview-body.html +48 -0
- package/.storybook/preview-head.html +11 -0
- package/.storybook/preview.js +1563 -0
- package/README.md +266 -0
- package/bin/index.js +40 -0
- package/dist/pds-reference.json +2101 -0
- package/package.json +45 -0
- package/pds.config.js +6 -0
- package/public/assets/css/app.css +1216 -0
- package/public/assets/data/auto-design-advanced.json +704 -0
- package/public/assets/data/auto-design-simple.json +123 -0
- package/public/assets/img/icon-512x512.png +0 -0
- package/public/assets/img/logo-trans.png +0 -0
- package/public/assets/img/logo.png +0 -0
- package/public/assets/js/app.js +15088 -0
- package/public/assets/js/app.js.map +7 -0
- package/public/assets/js/lit.js +1176 -0
- package/public/assets/js/lit.js.map +7 -0
- package/public/assets/js/pds.js +9801 -0
- package/public/assets/js/pds.js.map +7 -0
- package/public/assets/pds/components/pds-calendar.js +837 -0
- package/public/assets/pds/components/pds-drawer.js +857 -0
- package/public/assets/pds/components/pds-icon.js +338 -0
- package/public/assets/pds/components/pds-jsonform.js +1775 -0
- package/public/assets/pds/components/pds-richtext.js +1035 -0
- package/public/assets/pds/components/pds-scrollrow.js +331 -0
- package/public/assets/pds/components/pds-splitpanel.js +401 -0
- package/public/assets/pds/components/pds-tabstrip.js +251 -0
- package/public/assets/pds/components/pds-toaster.js +446 -0
- package/public/assets/pds/components/pds-upload.js +657 -0
- package/public/assets/pds/custom-elements.json +2003 -0
- package/public/assets/pds/icons/pds-icons.svg +498 -0
- package/public/assets/pds/pds-css-complete.json +1861 -0
- package/public/assets/pds/pds-runtime-config.json +11 -0
- package/public/assets/pds/pds.css-data.json +2152 -0
- package/public/assets/pds/styles/pds-components.css +1944 -0
- package/public/assets/pds/styles/pds-components.css.js +3895 -0
- package/public/assets/pds/styles/pds-primitives.css +352 -0
- package/public/assets/pds/styles/pds-primitives.css.js +711 -0
- package/public/assets/pds/styles/pds-styles.css +3761 -0
- package/public/assets/pds/styles/pds-styles.css.js +7529 -0
- package/public/assets/pds/styles/pds-tokens.css +699 -0
- package/public/assets/pds/styles/pds-tokens.css.js +1405 -0
- package/public/assets/pds/styles/pds-utilities.css +763 -0
- package/public/assets/pds/styles/pds-utilities.css.js +1533 -0
- package/public/assets/pds/vscode-custom-data.json +824 -0
- package/scripts/build-pds-reference.mjs +807 -0
- package/scripts/generate-stories.js +542 -0
- package/scripts/package-build.js +86 -0
- package/src/js/app.js +17 -0
- package/src/js/common/ask.js +208 -0
- package/src/js/common/common.js +20 -0
- package/src/js/common/font-loader.js +200 -0
- package/src/js/common/msg.js +90 -0
- package/src/js/lit.js +40 -0
- package/src/js/pds-core/pds-config.js +1162 -0
- package/src/js/pds-core/pds-enhancer-metadata.js +75 -0
- package/src/js/pds-core/pds-enhancers.js +357 -0
- package/src/js/pds-core/pds-enums.js +86 -0
- package/src/js/pds-core/pds-generator.js +5317 -0
- package/src/js/pds-core/pds-ontology.js +256 -0
- package/src/js/pds-core/pds-paths.js +109 -0
- package/src/js/pds-core/pds-query.js +571 -0
- package/src/js/pds-core/pds-registry.js +129 -0
- package/src/js/pds-core/pds.d.ts +129 -0
- package/src/js/pds.d.ts +408 -0
- package/src/js/pds.js +1579 -0
- package/src/pds-core/pds-api.js +105 -0
- package/stories/GettingStarted.md +96 -0
- package/stories/GettingStarted.stories.js +144 -0
- package/stories/WhatIsPDS.md +194 -0
- package/stories/WhatIsPDS.stories.js +144 -0
- package/stories/components/PdsCalendar.stories.js +263 -0
- package/stories/components/PdsDrawer.stories.js +623 -0
- package/stories/components/PdsIcon.stories.js +78 -0
- package/stories/components/PdsJsonform.stories.js +1444 -0
- package/stories/components/PdsRichtext.stories.js +367 -0
- package/stories/components/PdsScrollrow.stories.js +140 -0
- package/stories/components/PdsSplitpanel.stories.js +502 -0
- package/stories/components/PdsTabstrip.stories.js +442 -0
- package/stories/components/PdsToaster.stories.js +186 -0
- package/stories/components/PdsUpload.stories.js +66 -0
- package/stories/enhancements/Dropdowns.stories.js +185 -0
- package/stories/enhancements/InteractiveStates.stories.js +625 -0
- package/stories/enhancements/MeshGradients.stories.js +320 -0
- package/stories/enhancements/OpenGroups.stories.js +227 -0
- package/stories/enhancements/RangeSliders.stories.js +232 -0
- package/stories/enhancements/RequiredFields.stories.js +189 -0
- package/stories/enhancements/Toggles.stories.js +167 -0
- package/stories/foundations/Colors.stories.js +283 -0
- package/stories/foundations/Icons.stories.js +305 -0
- package/stories/foundations/SmartSurfaces.stories.js +367 -0
- package/stories/foundations/Spacing.stories.js +175 -0
- package/stories/foundations/Typography.stories.js +960 -0
- package/stories/foundations/ZIndex.stories.js +325 -0
- package/stories/patterns/BorderEffects.stories.js +72 -0
- package/stories/patterns/Layout.stories.js +99 -0
- package/stories/patterns/Utilities.stories.js +107 -0
- package/stories/primitives/Accordion.stories.js +359 -0
- package/stories/primitives/Alerts.stories.js +64 -0
- package/stories/primitives/Badges.stories.js +183 -0
- package/stories/primitives/Buttons.stories.js +229 -0
- package/stories/primitives/Cards.stories.js +353 -0
- package/stories/primitives/FormGroups.stories.js +569 -0
- package/stories/primitives/Forms.stories.js +131 -0
- package/stories/primitives/Media.stories.js +203 -0
- package/stories/primitives/Tables.stories.js +232 -0
- package/stories/reference/ReferenceCatalog.stories.js +28 -0
- package/stories/reference/reference-catalog.js +413 -0
- package/stories/reference/reference-docs.js +302 -0
- package/stories/reference/reference-helpers.js +310 -0
- package/stories/utilities/GridSystem.stories.js +208 -0
- package/stories/utils/PdsAsk.stories.js +420 -0
- package/stories/utils/toast-utils.js +148 -0
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
import { LitElement, html, nothing } from 'lit';
|
|
2
|
+
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
|
3
|
+
import {
|
|
4
|
+
renderMarkdown,
|
|
5
|
+
renderCode,
|
|
6
|
+
renderDefault,
|
|
7
|
+
formatTimestamp,
|
|
8
|
+
formatDemoHtml,
|
|
9
|
+
highlightDemoHtml,
|
|
10
|
+
renderChipList,
|
|
11
|
+
renderTable,
|
|
12
|
+
navigateToStory
|
|
13
|
+
} from './reference-helpers.js';
|
|
14
|
+
|
|
15
|
+
export class PdsReferenceCatalog extends LitElement {
|
|
16
|
+
static properties = {
|
|
17
|
+
data: { type: Object },
|
|
18
|
+
view: { state: true }
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
constructor() {
|
|
22
|
+
super();
|
|
23
|
+
this.data = null;
|
|
24
|
+
this.view = 'ref-components';
|
|
25
|
+
this.__buttonRefreshScheduled = false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
createRenderRoot() {
|
|
29
|
+
return this; // Light DOM to inherit design system utilities.
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
onTabChange(event) {
|
|
33
|
+
if (!event?.detail?.newTab) return;
|
|
34
|
+
this.view = event.detail.newTab;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
render() {
|
|
38
|
+
if (!this.data) {
|
|
39
|
+
return html`
|
|
40
|
+
<article class="card surface-base flex flex-col gap-sm items-center text-center">
|
|
41
|
+
<p class="text-muted">
|
|
42
|
+
Reference data is missing. Run <code>npm run build-reference</code> before launching Storybook.
|
|
43
|
+
</p>
|
|
44
|
+
</article>
|
|
45
|
+
`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const componentTotal = Object.keys(this.data.components || {}).length;
|
|
49
|
+
const tokenGroups = Object.keys(this.data.tokens || {}).length;
|
|
50
|
+
|
|
51
|
+
return html`
|
|
52
|
+
<section class="card surface-elevated flex flex-col gap-xl">
|
|
53
|
+
<header class="flex flex-wrap items-start justify-between gap-md">
|
|
54
|
+
<div class="flex flex-col gap-xs">
|
|
55
|
+
<h1 style="margin: 0;">PDS Reference</h1>
|
|
56
|
+
<p class="text-muted" style="margin: 0; max-width: 60ch;">
|
|
57
|
+
Living metadata for components, primitives, tokens, and enhancements sourced from the manifest, ontology, and Storybook docs.
|
|
58
|
+
</p>
|
|
59
|
+
</div>
|
|
60
|
+
<div class="flex flex-wrap gap-sm items-center">
|
|
61
|
+
<span class="badge">Components ${componentTotal}</span>
|
|
62
|
+
<span class="badge">Token Groups ${tokenGroups}</span>
|
|
63
|
+
<span class="badge">Generated ${formatTimestamp(this.data.generatedAt)}</span>
|
|
64
|
+
</div>
|
|
65
|
+
</header>
|
|
66
|
+
|
|
67
|
+
<pds-tabstrip label="PDS reference views" selected=${this.view} @tabchange=${this.onTabChange}>
|
|
68
|
+
<pds-tabpanel id="ref-components" label="Components">
|
|
69
|
+
<div class="flex flex-col gap-lg" style="margin-top: var(--spacing-3);">
|
|
70
|
+
${this.renderComponentsView()}
|
|
71
|
+
</div>
|
|
72
|
+
</pds-tabpanel>
|
|
73
|
+
<pds-tabpanel id="ref-primitives" label="Primitives">
|
|
74
|
+
<div class="flex flex-col gap-lg" style="margin-top: var(--spacing-3);">
|
|
75
|
+
${this.renderPrimitivesView()}
|
|
76
|
+
</div>
|
|
77
|
+
</pds-tabpanel>
|
|
78
|
+
<pds-tabpanel id="ref-tokens" label="Tokens">
|
|
79
|
+
<div class="flex flex-col gap-lg" style="margin-top: var(--spacing-3);">
|
|
80
|
+
${this.renderTokensView()}
|
|
81
|
+
</div>
|
|
82
|
+
</pds-tabpanel>
|
|
83
|
+
<pds-tabpanel id="ref-enhancements" label="Enhancements">
|
|
84
|
+
<div class="flex flex-col gap-lg" style="margin-top: var(--spacing-3);">
|
|
85
|
+
${this.renderEnhancementsView()}
|
|
86
|
+
</div>
|
|
87
|
+
</pds-tabpanel>
|
|
88
|
+
</pds-tabstrip>
|
|
89
|
+
</section>
|
|
90
|
+
`;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
renderComponentsView() {
|
|
94
|
+
const components = Object.values(this.data.components || {}).sort((a, b) => a.displayName.localeCompare(b.displayName));
|
|
95
|
+
if (!components.length) {
|
|
96
|
+
return html`<article class="card surface-base flex flex-col gap-sm"><p class="text-muted" style="margin: 0;">No component metadata was generated.</p></article>`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return html`
|
|
100
|
+
<section class="card surface-base flex flex-col gap-md">
|
|
101
|
+
<div class="flex items-center justify-end">
|
|
102
|
+
<span class="badge">${components.length} components</span>
|
|
103
|
+
</div>
|
|
104
|
+
<section class="accordion" aria-label="Component reference list">
|
|
105
|
+
${components.map((component, index) => this.renderComponentAccordionItem(component, index === 0))}
|
|
106
|
+
</section>
|
|
107
|
+
</section>
|
|
108
|
+
`;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
renderComponentAccordionItem(component, open = false) {
|
|
112
|
+
const summaryId = `component-${component.tag}`;
|
|
113
|
+
return html`
|
|
114
|
+
<details ?open=${open}>
|
|
115
|
+
<summary id=${summaryId}>
|
|
116
|
+
<div class="flex items-center justify-between gap-sm">
|
|
117
|
+
<span class="flex items-center gap-sm">
|
|
118
|
+
<code><${component.tag}></code>
|
|
119
|
+
</span>
|
|
120
|
+
<span class="flex items-center gap-xs">
|
|
121
|
+
${component.stories?.length ? html`<span class="badge">${component.stories.length} stories</span>` : nothing}
|
|
122
|
+
</span>
|
|
123
|
+
</div>
|
|
124
|
+
</summary>
|
|
125
|
+
<div role="region" aria-labelledby=${summaryId} class="flex flex-col gap-lg" style="padding: var(--spacing-4) 0;">
|
|
126
|
+
${this.renderComponentDetail(component)}
|
|
127
|
+
</div>
|
|
128
|
+
</details>
|
|
129
|
+
`;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
renderComponentDetail(component) {
|
|
133
|
+
if (!component) {
|
|
134
|
+
return html`<p class="text-muted" style="margin: 0;">Select a component to inspect its API.</p>`;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return html`
|
|
138
|
+
<section class="card surface-base flex flex-col gap-sm">
|
|
139
|
+
${component.ontology?.id ? html`<div class="flex flex-wrap gap-xs"><span class="badge">${component.ontology.id}</span></div>` : nothing}
|
|
140
|
+
<h2 style="margin: 0;"><code>${component.tag}</code></h2>
|
|
141
|
+
${component.docsDescription ? html`<div>${renderMarkdown(component.docsDescription)}</div>` : nothing}
|
|
142
|
+
</section>
|
|
143
|
+
|
|
144
|
+
${component.description ? html`
|
|
145
|
+
<section class="card surface-base flex flex-col gap-sm">
|
|
146
|
+
<h3 style="margin: 0;">Manifest Notes</h3>
|
|
147
|
+
<pre class="surface-subtle radius-lg text-sm overflow-auto" style="margin: 0; padding: var(--spacing-3);">${component.description}</pre>
|
|
148
|
+
</section>
|
|
149
|
+
` : nothing}
|
|
150
|
+
|
|
151
|
+
${component.notes?.length ? html`
|
|
152
|
+
<section class="card surface-base flex flex-col gap-xs">
|
|
153
|
+
<h3 style="margin: 0;">Implementation Notes</h3>
|
|
154
|
+
${component.notes.map((note) => html`<p class="text-muted" style="margin: 0;">${note}</p>`)}
|
|
155
|
+
</section>
|
|
156
|
+
` : nothing}
|
|
157
|
+
|
|
158
|
+
${component.ontology ? html`
|
|
159
|
+
<section class="card surface-base flex flex-col gap-sm">
|
|
160
|
+
<h3 style="margin: 0;">Ontology</h3>
|
|
161
|
+
<div class="flex flex-wrap gap-xs items-center">
|
|
162
|
+
<span class="badge">${component.ontology.id}</span>
|
|
163
|
+
${component.ontology.name ? html`<span class="badge">${component.ontology.name}</span>` : nothing}
|
|
164
|
+
</div>
|
|
165
|
+
${component.ontology.selectors?.length ? html`
|
|
166
|
+
<div class="flex flex-col gap-xs">
|
|
167
|
+
<span class="text-muted text-sm">Selectors</span>
|
|
168
|
+
${renderChipList(component.ontology.selectors)}
|
|
169
|
+
</div>
|
|
170
|
+
` : nothing}
|
|
171
|
+
</section>
|
|
172
|
+
` : nothing}
|
|
173
|
+
|
|
174
|
+
${component.stories?.length ? html`
|
|
175
|
+
<section class="card surface-base flex flex-col gap-md">
|
|
176
|
+
<h3 style="margin: 0;">Storybook Coverage</h3>
|
|
177
|
+
<div class="grid grid-auto-md gap-md">
|
|
178
|
+
${component.stories.map((story) => html`
|
|
179
|
+
<div class="card surface-elevated flex flex-col gap-xs">
|
|
180
|
+
<a
|
|
181
|
+
href="/?path=/story/${story.id}"
|
|
182
|
+
@click=${(event) => this.handleStoryNavigation(event, story.id)}
|
|
183
|
+
>${story.name}</a>
|
|
184
|
+
<div class="flex flex-wrap gap-sm text-muted text-sm">
|
|
185
|
+
<span>${story.id}</span>
|
|
186
|
+
</div>
|
|
187
|
+
${story.description ? html`<p class="text-muted" style="margin: 0;">${story.description}</p>` : nothing}
|
|
188
|
+
${story.tags?.length ? renderChipList(story.tags) : nothing}
|
|
189
|
+
</div>
|
|
190
|
+
`)}
|
|
191
|
+
</div>
|
|
192
|
+
</section>
|
|
193
|
+
` : nothing}
|
|
194
|
+
|
|
195
|
+
${this.renderTableSection('Attributes', component.attributes, [
|
|
196
|
+
{ key: 'name', label: 'Attribute', render: (value) => renderCode(value) },
|
|
197
|
+
{ key: 'description', label: 'Description' },
|
|
198
|
+
{ key: 'type', label: 'Type', render: (value) => renderCode(value) },
|
|
199
|
+
{ key: 'default', label: 'Default', render: (value) => renderDefault(value) }
|
|
200
|
+
])}
|
|
201
|
+
|
|
202
|
+
${this.renderTableSection('Properties', component.properties, [
|
|
203
|
+
{ key: 'name', label: 'Property', render: (value) => renderCode(value) },
|
|
204
|
+
{ key: 'type', label: 'Type', render: (value) => renderCode(value) },
|
|
205
|
+
{ key: 'description', label: 'Description' },
|
|
206
|
+
{ key: 'default', label: 'Default', render: (value) => renderDefault(value) }
|
|
207
|
+
])}
|
|
208
|
+
|
|
209
|
+
${this.renderTableSection('Events', component.events, [
|
|
210
|
+
{ key: 'name', label: 'Event', render: (value) => renderCode(value) },
|
|
211
|
+
{ key: 'type', label: 'Type', render: (value) => renderCode(value) },
|
|
212
|
+
{ key: 'description', label: 'Description' }
|
|
213
|
+
])}
|
|
214
|
+
|
|
215
|
+
${this.renderTableSection('Methods', component.methods, [
|
|
216
|
+
{ key: 'name', label: 'Method', render: (value) => renderCode(value) },
|
|
217
|
+
{ key: 'description', label: 'Description' },
|
|
218
|
+
{
|
|
219
|
+
key: 'parameters',
|
|
220
|
+
label: 'Parameters',
|
|
221
|
+
render: (value) => {
|
|
222
|
+
if (!value || !value.length) return html`<span class="text-muted">—</span>`;
|
|
223
|
+
return html`
|
|
224
|
+
<ul class="flex flex-col gap-xs" style="list-style: none; margin: 0; padding: 0;">
|
|
225
|
+
${value.map((param) => html`
|
|
226
|
+
<li class="flex flex-wrap gap-xs items-baseline">
|
|
227
|
+
<code>${param.name}${param.type ? `: ${param.type}` : ''}</code>
|
|
228
|
+
${param.description ? html`<span class="text-muted text-sm">- ${param.description}</span>` : nothing}
|
|
229
|
+
</li>
|
|
230
|
+
`)}
|
|
231
|
+
</ul>
|
|
232
|
+
`;
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
{ key: 'return', label: 'Returns', render: (value) => renderCode(value) }
|
|
236
|
+
])}
|
|
237
|
+
|
|
238
|
+
${this.renderTableSection('Slots', component.slots, [
|
|
239
|
+
{ key: 'name', label: 'Slot' },
|
|
240
|
+
{ key: 'description', label: 'Description' }
|
|
241
|
+
])}
|
|
242
|
+
|
|
243
|
+
${this.renderTableSection('CSS Parts', component.cssParts, [
|
|
244
|
+
{ key: 'name', label: 'CSS Part' },
|
|
245
|
+
{ key: 'description', label: 'Description' }
|
|
246
|
+
])}
|
|
247
|
+
`;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
handleStoryNavigation(event, storyId) {
|
|
251
|
+
event?.preventDefault?.();
|
|
252
|
+
event?.stopPropagation?.();
|
|
253
|
+
navigateToStory(storyId, 'story');
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
renderTableSection(title, items, columns) {
|
|
257
|
+
if (!items || !items.length) return nothing;
|
|
258
|
+
return html`
|
|
259
|
+
<section class="card surface-base flex flex-col gap-sm">
|
|
260
|
+
<h3 style="margin: 0;">${title}</h3>
|
|
261
|
+
${renderTable(items, columns)}
|
|
262
|
+
</section>
|
|
263
|
+
`;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
renderPrimitivesView() {
|
|
267
|
+
const primitives = this.data.primitives || {};
|
|
268
|
+
const primitiveCards = (primitives.primitives || []).map((primitive) => html`
|
|
269
|
+
<article class="card surface-base flex flex-col gap-sm">
|
|
270
|
+
<div class="flex items-center gap-sm flex-wrap">
|
|
271
|
+
<h3 style="margin: 0;">${primitive.name}</h3>
|
|
272
|
+
<span class="badge">${primitive.id}</span>
|
|
273
|
+
</div>
|
|
274
|
+
${primitive.selectors?.length ? html`
|
|
275
|
+
<div class="flex flex-col gap-xs">
|
|
276
|
+
<span class="text-muted text-sm">Selectors</span>
|
|
277
|
+
${renderChipList(primitive.selectors)}
|
|
278
|
+
</div>
|
|
279
|
+
` : nothing}
|
|
280
|
+
</article>
|
|
281
|
+
`);
|
|
282
|
+
|
|
283
|
+
const layoutCards = (primitives.layoutPatterns || []).map((pattern) => html`
|
|
284
|
+
<article class="card surface-base flex flex-col gap-sm">
|
|
285
|
+
<div class="flex items-center gap-sm flex-wrap">
|
|
286
|
+
<h3 style="margin: 0;">${pattern.name}</h3>
|
|
287
|
+
<span class="badge">${pattern.id}</span>
|
|
288
|
+
</div>
|
|
289
|
+
${pattern.description ? html`<p class="text-muted" style="margin: 0;">${pattern.description}</p>` : nothing}
|
|
290
|
+
${pattern.selectors?.length ? html`
|
|
291
|
+
<div class="flex flex-col gap-xs">
|
|
292
|
+
<span class="text-muted text-sm">Selectors</span>
|
|
293
|
+
${renderChipList(pattern.selectors)}
|
|
294
|
+
</div>
|
|
295
|
+
` : nothing}
|
|
296
|
+
</article>
|
|
297
|
+
`);
|
|
298
|
+
|
|
299
|
+
const utilities = primitives.utilities || [];
|
|
300
|
+
|
|
301
|
+
return html`
|
|
302
|
+
<div class="grid grid-auto-md gap-lg">
|
|
303
|
+
${primitiveCards.length ? primitiveCards : html`
|
|
304
|
+
<article class="card surface-base flex flex-col gap-sm">
|
|
305
|
+
<p class="text-muted" style="margin: 0;">No primitives registered in the ontology.</p>
|
|
306
|
+
</article>
|
|
307
|
+
`}
|
|
308
|
+
</div>
|
|
309
|
+
|
|
310
|
+
${layoutCards.length ? html`
|
|
311
|
+
<section class="card surface-base flex flex-col gap-md">
|
|
312
|
+
<h3 style="margin: 0;">Layout Patterns</h3>
|
|
313
|
+
<div class="grid grid-auto-md gap-md">${layoutCards}</div>
|
|
314
|
+
</section>
|
|
315
|
+
` : nothing}
|
|
316
|
+
|
|
317
|
+
${utilities.length ? html`
|
|
318
|
+
<section class="card surface-base flex flex-col gap-sm">
|
|
319
|
+
<h3 style="margin: 0;">Utility Classes</h3>
|
|
320
|
+
<pre class="surface-subtle radius-lg text-sm overflow-auto" style="margin: 0; padding: var(--spacing-3);">${utilities.join('\n')}</pre>
|
|
321
|
+
</section>
|
|
322
|
+
` : nothing}
|
|
323
|
+
`;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
renderTokensView() {
|
|
327
|
+
const tokenGroups = Object.entries(this.data.tokens || {});
|
|
328
|
+
if (!tokenGroups.length) {
|
|
329
|
+
return html`<article class="card surface-base flex flex-col gap-sm"><p class="text-muted" style="margin: 0;">No token metadata was generated.</p></article>`;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
return html`
|
|
333
|
+
<div class="grid grid-auto-md gap-lg">
|
|
334
|
+
${tokenGroups.map(([group, values]) => html`
|
|
335
|
+
<article class="card surface-base flex flex-col gap-sm">
|
|
336
|
+
<h3 style="margin: 0;">${group}</h3>
|
|
337
|
+
${Array.isArray(values)
|
|
338
|
+
? renderChipList(values)
|
|
339
|
+
: html`<pre class="surface-subtle radius-lg text-sm overflow-auto" style="margin: 0; padding: var(--spacing-3);">${JSON.stringify(values, null, 2)}</pre>`}
|
|
340
|
+
</article>
|
|
341
|
+
`)}
|
|
342
|
+
</div>
|
|
343
|
+
`;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
renderEnhancementsView() {
|
|
347
|
+
const enhancements = this.data.enhancements || [];
|
|
348
|
+
if (!enhancements.length) {
|
|
349
|
+
return html`<article class="card surface-base flex flex-col gap-sm"><p class="text-muted" style="margin: 0;">No progressive enhancements registered.</p></article>`;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
return html`
|
|
353
|
+
<div class="flex flex-col gap-md">
|
|
354
|
+
${enhancements.map((enhancement) => this.renderEnhancementCard(enhancement))}
|
|
355
|
+
</div>
|
|
356
|
+
`;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
renderEnhancementCard(enhancement) {
|
|
360
|
+
if (!enhancement) return nothing;
|
|
361
|
+
const { selector, description, demoHtml, source } = enhancement;
|
|
362
|
+
const safeSelector = selector || '(unknown selector)';
|
|
363
|
+
const demoMarkup = typeof demoHtml === 'string' ? demoHtml.trim() : '';
|
|
364
|
+
const formattedDemoHtml = demoMarkup ? formatDemoHtml(demoMarkup) : '';
|
|
365
|
+
const highlightedDemoHtml = formattedDemoHtml ? highlightDemoHtml(formattedDemoHtml) : '';
|
|
366
|
+
const hasDetails = Boolean(description || demoMarkup);
|
|
367
|
+
|
|
368
|
+
if (demoMarkup) {
|
|
369
|
+
this.scheduleButtonWorkingRefresh();
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
return html`
|
|
373
|
+
<article class="card surface-base flex flex-col gap-sm">
|
|
374
|
+
<div class="flex flex-wrap items-center justify-between gap-sm">
|
|
375
|
+
<h3 style="margin: 0;"><code>${safeSelector}</code></h3>
|
|
376
|
+
${source ? html`<span class="badge text-sm">${source}</span>` : nothing}
|
|
377
|
+
</div>
|
|
378
|
+
${description ? html`<p class="text-muted" style="margin: 0;">${description}</p>` : nothing}
|
|
379
|
+
${demoMarkup ? html`
|
|
380
|
+
<div class="flex flex-col gap-xs">
|
|
381
|
+
<span class="text-muted text-sm">Demo</span>
|
|
382
|
+
<div class="surface-subtle radius-lg pds-ref-demo" style="padding: var(--spacing-3);">
|
|
383
|
+
${unsafeHTML(demoMarkup)}
|
|
384
|
+
</div>
|
|
385
|
+
${highlightedDemoHtml ? html`
|
|
386
|
+
<pre class="html-source-pre radius-lg text-sm overflow-auto" style="margin: 0;"><code class="html-source-code">${unsafeHTML(highlightedDemoHtml)}</code></pre>
|
|
387
|
+
` : nothing}
|
|
388
|
+
</div>
|
|
389
|
+
` : nothing}
|
|
390
|
+
${!hasDetails ? html`<p class="text-muted text-sm" style="margin: 0;">Documentation pending.</p>` : nothing}
|
|
391
|
+
</article>
|
|
392
|
+
`;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
scheduleButtonWorkingRefresh() {
|
|
396
|
+
if (this.__buttonRefreshScheduled) return;
|
|
397
|
+
this.__buttonRefreshScheduled = true;
|
|
398
|
+
requestAnimationFrame(() => {
|
|
399
|
+
this.__buttonRefreshScheduled = false;
|
|
400
|
+
const workingTargets = this.querySelectorAll('.pds-ref-demo button.btn-working, .pds-ref-demo a.btn-working');
|
|
401
|
+
workingTargets.forEach((target) => {
|
|
402
|
+
if (!target.classList.contains('btn-working')) {
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
target.classList.remove('btn-working');
|
|
406
|
+
void target.offsetWidth; // Force reflow so the re-add triggers MutationObserver
|
|
407
|
+
target.classList.add('btn-working');
|
|
408
|
+
});
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
customElements.define('pds-reference-catalog', PdsReferenceCatalog);
|