Skip to content

Commit cc08a48

Browse files
committed
Refactor and simplify prop renderer
1 parent 2e0308d commit cc08a48

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

src/lib/knobs.ts

+2-13
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export const cssPropRenderer: InputRenderer = (knob: Knob, id: string) => {
4242

4343
export const propRenderer: InputRenderer = (knob: Knob, id: string) => {
4444
const { name, type, value, options } = knob as PropertyInfo;
45-
const inputType = getInputType(type);
4645
let input;
4746
if (type === 'select' && Array.isArray(options)) {
4847
input = html`
@@ -54,16 +53,6 @@ export const propRenderer: InputRenderer = (knob: Knob, id: string) => {
5453
)}
5554
</select>
5655
`;
57-
} else if (value === undefined) {
58-
input = html`
59-
<input
60-
id="${id}"
61-
type="${inputType}"
62-
data-name="${name}"
63-
data-type="${type}"
64-
part="input"
65-
/>
66-
`;
6756
} else if (normalizeType(type) === 'boolean') {
6857
input = html`
6958
<input
@@ -79,8 +68,8 @@ export const propRenderer: InputRenderer = (knob: Knob, id: string) => {
7968
input = html`
8069
<input
8170
id="${id}"
82-
type="${inputType}"
83-
.value="${String(value)}"
71+
type="${getInputType(type)}"
72+
.value="${value == null ? '' : String(value)}"
8473
data-name="${name}"
8574
data-type="${type}"
8675
part="input"

0 commit comments

Comments
 (0)