Skip to content

Commit

Permalink
fix(select): change slot names to kebab-case
Browse files Browse the repository at this point in the history
BREAKING CHANGE: replace `leadingicon` and `trailingicon` slot names with `leading-icon` and `trailing-icon`

PiperOrigin-RevId: 563583658
  • Loading branch information
AndrewJakubowicz authored and copybara-github committed Sep 7, 2023
1 parent f019ac3 commit 059dad5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions select/demo/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const collection =
new Knob('menuFixed', {ui: boolInput(), defaultValue: false}),

new Knob('md-select Slots', {ui: title()}),
new Knob('slot=leadingicon', {ui: textInput(), defaultValue: ''}),
new Knob('slot=trailingicon', {ui: textInput(), defaultValue: ''}),
new Knob('slot=leading-icon', {ui: textInput(), defaultValue: ''}),
new Knob('slot=trailing-icon', {ui: textInput(), defaultValue: ''}),
]);

collection.addStories(...materialInitsToStoryInits(stories));
Expand Down
14 changes: 7 additions & 7 deletions select/demo/stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export interface StoryKnobs {
menuFixed: boolean;

'md-select Slots': void;
'slot=leadingicon': string;
'slot=trailingicon': string;
'slot=leading-icon': string;
'slot=trailing-icon': string;
}

const outlined: MaterialStoryInit<StoryKnobs> = {
Expand All @@ -44,8 +44,8 @@ const outlined: MaterialStoryInit<StoryKnobs> = {
.menuFixed=${knobs.menuFixed}
.typeaheadDelay=${knobs.typeaheadDelay}
.error=${knobs.error}>
${renderIcon(knobs['slot=leadingicon'], 'leadingicon')}
${renderIcon(knobs['slot=trailingicon'], 'trailingicon')}
${renderIcon(knobs['slot=leading-icon'], 'leading-icon')}
${renderIcon(knobs['slot=trailing-icon'], 'trailing-icon')}
${renderItems()}
</md-outlined-select>
`;
Expand All @@ -66,15 +66,15 @@ const filled: MaterialStoryInit<StoryKnobs> = {
.menuFixed=${knobs.menuFixed}
.typeaheadDelay=${knobs.typeaheadDelay}
.error=${knobs.error}>
${renderIcon(knobs['slot=leadingicon'], 'leadingicon')}
${renderIcon(knobs['slot=trailingicon'], 'trailingicon')}
${renderIcon(knobs['slot=leading-icon'], 'leading-icon')}
${renderIcon(knobs['slot=trailing-icon'], 'trailing-icon')}
${renderItems()}
</md-filled-select>
`;
}
};

function renderIcon(iconName: string, slot: 'leadingicon'|'trailingicon') {
function renderIcon(iconName: string, slot: 'leading-icon'|'trailing-icon') {
return iconName ?
html`<md-icon slot=${slot}><span>${iconName}</span></md-icon>` :
nothing;
Expand Down
6 changes: 3 additions & 3 deletions select/internal/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export abstract class Select extends LitElement {
@state() private open = false;
@query('md-menu') private readonly menu!: Menu|null;
@query('#label') private readonly labelEl!: HTMLElement;
@queryAssignedElements({slot: 'leadingicon', flatten: true})
@queryAssignedElements({slot: 'leading-icon', flatten: true})
private readonly leadingIcons!: Element[];

/**
Expand Down Expand Up @@ -229,15 +229,15 @@ export abstract class Select extends LitElement {
private renderLeadingIcon() {
return html`
<span class="icon leading" slot="start">
<slot name="leadingicon" @slotchange=${this.handleIconChange}></slot>
<slot name="leading-icon" @slotchange=${this.handleIconChange}></slot>
</span>
`;
}

private renderTrailingIcon() {
return html`
<span class="icon trailing" slot="end">
<slot name="trailingicon" @slotchange=${this.handleIconChange}>
<slot name="trailing-icon" @slotchange=${this.handleIconChange}>
<svg height="5" viewBox="7 10 10 5" focusable="false">
<polygon class="down" stroke="none" fill-rule="evenodd" points="7 10 12 15 17 10"></polygon>
<polygon class="up" stroke="none" fill-rule="evenodd" points="7 15 12 10 17 15"></polygon>
Expand Down

0 comments on commit 059dad5

Please sign in to comment.