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 {
77 AbstractController ,
88 AbstractControllerHost
99} from './abstract-controller.js' ;
10+ import { formatSlot } from '../ui/controls.js' ;
1011import { SlotValue } from '../types.js' ;
1112
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-
1813export class SlotsController extends AbstractController < SlotValue > {
1914 enabled : boolean ;
2015
@@ -40,7 +35,7 @@ export class SlotsController extends AbstractController<SlotValue> {
4035 . map ( ( slot ) => {
4136 return {
4237 ...slot ,
43- content : getSlotContent ( slot . name )
38+ content : formatSlot ( slot . name )
4439 } ;
4540 } ) as SlotValue [ ] ;
4641 }
Original file line number Diff line number Diff line change @@ -21,7 +21,6 @@ export type Knob<T extends Knobable = unknown> = T & {
2121 custom ?: boolean ;
2222 options ?: string [ ] ;
2323 knobType : string ;
24- content ?: string ;
2524} ;
2625
2726export type PropertyKnob = Knob < ClassField > ;
Original file line number Diff line number Diff line change @@ -8,6 +8,12 @@ import {
88
99type InputRenderer = ( item : Knobable , id : string ) => TemplateResult ;
1010
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+
1117export const cssPropRenderer : InputRenderer = (
1218 knob : Knobable ,
1319 id : string
@@ -90,9 +96,9 @@ export const renderKnobs = (
9096 renderer : InputRenderer
9197) : TemplateResult => {
9298 const rows = items . map ( ( item : Knobable ) => {
93- const { name, content } = item as PropertyKnob ;
99+ const { name } = item as PropertyKnob ;
94100 const id = `${ type } -${ name || 'default' } ` ;
95- const label = type === 'slot' ? content : name ;
101+ const label = type === 'slot' ? formatSlot ( name ) : name ;
96102 return html `
97103 < tr >
98104 < td >
You can’t perform that action at this time.
0 commit comments