File tree Expand file tree Collapse file tree 4 files changed +16
-10
lines changed Expand file tree Collapse file tree 4 files changed +16
-10
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @api-viewer/demo ' : patch
3
+ ' api-viewer-element ' : patch
4
+ ---
5
+
6
+ Update slot knobs to render name properly
Original file line number Diff line number Diff line change @@ -7,14 +7,9 @@ import {
7
7
AbstractController ,
8
8
AbstractControllerHost
9
9
} from './abstract-controller.js' ;
10
+ import { formatSlot } from '../ui/controls.js' ;
10
11
import { SlotValue } from '../types.js' ;
11
12
12
- const capitalize = ( name : string ) : string =>
13
- name [ 0 ] . toUpperCase ( ) + name . slice ( 1 ) ;
14
-
15
- const getSlotContent = ( name : string ) : string =>
16
- capitalize ( name === '' ? 'content' : name ) ;
17
-
18
13
export class SlotsController extends AbstractController < SlotValue > {
19
14
enabled : boolean ;
20
15
@@ -40,7 +35,7 @@ export class SlotsController extends AbstractController<SlotValue> {
40
35
. map ( ( slot ) => {
41
36
return {
42
37
...slot ,
43
- content : getSlotContent ( slot . name )
38
+ content : formatSlot ( slot . name )
44
39
} ;
45
40
} ) as SlotValue [ ] ;
46
41
}
Original file line number Diff line number Diff line change @@ -21,7 +21,6 @@ export type Knob<T extends Knobable = unknown> = T & {
21
21
custom ?: boolean ;
22
22
options ?: string [ ] ;
23
23
knobType : string ;
24
- content ?: string ;
25
24
} ;
26
25
27
26
export type PropertyKnob = Knob < ClassField > ;
Original file line number Diff line number Diff line change @@ -8,6 +8,12 @@ import {
8
8
9
9
type InputRenderer = ( item : Knobable , id : string ) => TemplateResult ;
10
10
11
+ const capitalize = ( name : string ) : string =>
12
+ name [ 0 ] . toUpperCase ( ) + name . slice ( 1 ) ;
13
+
14
+ export const formatSlot = ( name : string ) : string =>
15
+ capitalize ( name === '' ? 'content' : name ) ;
16
+
11
17
export const cssPropRenderer : InputRenderer = (
12
18
knob : Knobable ,
13
19
id : string
@@ -90,9 +96,9 @@ export const renderKnobs = (
90
96
renderer : InputRenderer
91
97
) : TemplateResult => {
92
98
const rows = items . map ( ( item : Knobable ) => {
93
- const { name, content } = item as PropertyKnob ;
99
+ const { name } = item as PropertyKnob ;
94
100
const id = `${ type } -${ name || 'default' } ` ;
95
- const label = type === 'slot' ? content : name ;
101
+ const label = type === 'slot' ? formatSlot ( name ) : name ;
96
102
return html `
97
103
< tr >
98
104
< td >
You can’t perform that action at this time.
0 commit comments