Skip to content

Commit 1078235

Browse files
committed
feat(tools): more knobs wip
1 parent 65cb9f9 commit 1078235

File tree

3 files changed

+16
-29
lines changed

3 files changed

+16
-29
lines changed

tools/pfe-tools/dev-server/plugins/templates/index.html

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,7 @@
105105
<li>
106106
<details {{ 'open' if demo.primaryElementName == primary }}>
107107
<summary>{{ first.title }}</summary>
108-
<ul>
109-
<li>
110-
<a href="/components/{{ primary.replace('pf-', '') }}/demo/knobs/">Knobs</a>
111-
</li>{% for d in group %}
108+
<ul>{% for d in group %}
112109
<li>
113110
<a href="{{ d.permalink | replace(demoURLPrefix, '/') }}">{{ d.title }}</a>
114111
</li>{% endfor %}
@@ -128,6 +125,7 @@
128125
<script type="module">
129126
import '@patternfly/pfe-tools/elements/pft-element-knobs.ts';
130127
// TODO: discriminate
128+
import '@patternfly/elements/pf-tooltip/pf-tooltip.js';
131129
import '@patternfly/elements/pf-select/pf-select.js';
132130
import '@patternfly/elements/pf-switch/pf-switch.js';
133131
import '@patternfly/elements/pf-text-input/pf-text-input.js';
@@ -154,8 +152,7 @@ <h2 slot="header">{{ first.title }}</h2>
154152
<a href="{{ first.permalink | replace(demoURLPrefix, '/') }}">
155153
<img src="/elements/{{ primary }}/docs/screenshot.png" alt="{{ primary }}">
156154
</a>
157-
<ul>
158-
<li><a href="/components/{{ primary.replace('pf-', '') }}/demo/knobs/">Knobs</a></li>{% for d in group %}{% if not loop.first %}
155+
<ul>{% for d in group %}{% if not loop.first %}
159156
<li>
160157
<a href="{{ d.permalink | replace(demoURLPrefix, '/') }}">{{ d.title }}</a>
161158
</li>{% endif %}{% endfor %}

tools/pfe-tools/dev-server/plugins/templates/knobs.html

Lines changed: 0 additions & 17 deletions
This file was deleted.

tools/pfe-tools/elements/pft-element-knobs.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,17 @@ export class PftElementKnobs<T extends HTMLElement> extends LitElement {
5858
padding: 1em;
5959
}
6060
61+
section,
6162
dl#slot-descriptions {
6263
display: grid;
6364
gap: 8px;
6465
grid-template-columns: max-content auto;
6566
& dd {
6667
margin-inline-start: 0;
6768
}
69+
& > h2 {
70+
grid-column: -1/1;
71+
}
6872
}
6973
7074
pf-text-area {
@@ -157,23 +161,26 @@ export class PftElementKnobs<T extends HTMLElement> extends LitElement {
157161
element?.getAttribute(attribute.name)
158162
?? attribute.default?.replace(QUOTE_RE, '$1');
159163
return html`
160-
<h3><code>${attribute.name}</code></h3>
161-
<zero-md><script type="text/markdown">${attribute.summary ?? ''}</script></zero-md>
162-
<zero-md><script type="text/markdown">${attribute.description ?? ''}</script></zero-md>
164+
<pf-tooltip>
165+
<label for="${knobId}"><code>${attribute.name}</code></label>${[attribute.summary, attribute.description].filter(Boolean).map(x => html`
166+
<zero-md slot="content">
167+
<template>
168+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@5/github-markdown-dark.min.css">
169+
</template>
170+
<script type="text/markdown">${x}</script>
171+
</zero-md>`)}
172+
</pf-tooltip>
163173
${isBoolean ? html`
164-
<label for="${knobId}">Present</label>
165174
<pf-switch id="${knobId}"
166175
?checked="${attribute.default === 'true'}"
167176
data-attribute="${attribute.name}"></pf-switch>` : isEnum ? html`
168177
<pf-select id="${knobId}"
169178
placeholder="Select a value"
170-
aria-label="Value"
171179
data-attribute="${attribute.name}"
172180
value="${ifDefined(attributeValue)}">${values!.map(x => html`
173181
<pf-option>${x.trim().replace(QUOTE_RE, '$1')}</pf-option>`)}
174182
</pf-select>` : html`
175183
<pf-text-input id="${knobId}"
176-
aria-label="Value"
177184
value="${ifDefined(attributeValue)}"
178185
type="${ifDefined(isNumber ? 'number' : undefined)}"
179186
helper-text="${ifDefined(attribute.type?.text)}"

0 commit comments

Comments
 (0)