Skip to content

Commit c70a11c

Browse files
committed
Refactor and fix hiding knobs panel
1 parent cc08a48 commit c70a11c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/api-viewer-demo-layout.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ export class ApiViewerDemoLayout extends LitElement {
127127
this.props
128128
].map(arr => arr.length === 0);
129129

130-
const noKnobs = noProps && noCustomKnobs && noSlots;
131130
const id = this.vid as number;
132131
const slots = this.processedSlots;
132+
const hideSlots = noSlots || hasTemplate(id, this.tag, SLOT);
133133

134134
return html`
135135
<div part="demo-output" @rendered="${this._onRendered}">
@@ -153,10 +153,10 @@ export class ApiViewerDemoLayout extends LitElement {
153153
heading="Knobs"
154154
slot="tab"
155155
part="tab"
156-
?hidden="${noKnobs}"
156+
?hidden="${noProps && noCustomKnobs && hideSlots}"
157157
></api-viewer-tab>
158158
<api-viewer-panel slot="panel" part="tab-panel">
159-
<div part="knobs" ?hidden="${noKnobs}">
159+
<div part="knobs">
160160
<section part="knobs-column" @change="${this._onPropChanged}">
161161
${renderKnobs(this.props, 'Properties', 'prop', propRenderer)}
162162
${renderKnobs(
@@ -167,7 +167,7 @@ export class ApiViewerDemoLayout extends LitElement {
167167
)}
168168
</section>
169169
<section
170-
?hidden="${noSlots || hasTemplate(id, this.tag, SLOT)}"
170+
?hidden="${hideSlots}"
171171
part="knobs-column"
172172
@change="${this._onSlotChanged}"
173173
>

src/lib/knobs.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export const renderKnobs = (
115115
});
116116

117117
return html`
118-
<h3 part="knobs-header">${header}</h3>
118+
<h3 part="knobs-header" ?hidden="${items.length === 0}">${header}</h3>
119119
<table>
120120
${rows}
121121
</table>

0 commit comments

Comments
 (0)