Skip to content

Commit

Permalink
fix(iconbutton): rename selectedIcon slot to selected
Browse files Browse the repository at this point in the history
BREAKING CHANGE: change `slot="selectedIcon"` to `slot="selected"` for toggle icon buttons.

PiperOrigin-RevId: 561740365
  • Loading branch information
asyncLiz authored and copybara-github committed Aug 31, 2023
1 parent 17ddcd3 commit 9647f5e
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion catalog/eleventy-helpers/shortcodes/playground-example.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function playgroundExample(eleventyConfig) {
<summary>
<md-outlined-icon-button toggle tabindex="-1" aria-hidden="true">
<md-icon aria-hidden="true">expand_more</md-icon>
<md-icon aria-hidden="true" slot="selectedIcon">expand_less</md-icon>
<md-icon aria-hidden="true" slot="selected">expand_less</md-icon>
</md-outlined-icon-button>
Expand interactive demo.
</summary>
Expand Down
2 changes: 1 addition & 1 deletion catalog/src/components/top-app-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {materialDesign} from '../svg/material-design-logo.js';
@input=${this.onMenuIconToggle}
>
<span><md-icon>menu</md-icon></span>
<span slot="selectedIcon"><md-icon>menu_open</md-icon></span>
<span slot="selected"><md-icon>menu_open</md-icon></span>
</md-icon-button>
<md-icon-button href="/" class="home-button">
${materialDesign}
Expand Down
2 changes: 1 addition & 1 deletion docs/components/figures/iconbutton/buttons.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<md-icon>favorite</md-icon>
</md-icon-button>
<md-icon-button toggle selected>
<md-icon slot="selectedIcon" class="filled">bookmark</md-icon>
<md-icon slot="selected" class="filled">bookmark</md-icon>
<md-icon class="filled">bookmark</md-icon>
</md-icon-button>
</div>
Expand Down
16 changes: 8 additions & 8 deletions docs/components/figures/iconbutton/usage-toggle.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,37 @@
<div style="display:flex;gap:8px;">
<md-icon-button toggle>
<md-icon>close</md-icon>
<md-icon slot="selectedIcon">check</md-icon>
<md-icon slot="selected">check</md-icon>
</md-icon-button>
<md-filled-icon-button toggle>
<md-icon>close</md-icon>
<md-icon slot="selectedIcon">check</md-icon>
<md-icon slot="selected">check</md-icon>
</md-filled-icon-button>
<md-filled-tonal-icon-button toggle>
<md-icon>close</md-icon>
<md-icon slot="selectedIcon">check</md-icon>
<md-icon slot="selected">check</md-icon>
</md-filled-tonal-icon-button>
<md-outlined-icon-button toggle>
<md-icon>close</md-icon>
<md-icon slot="selectedIcon">check</md-icon>
<md-icon slot="selected">check</md-icon>
</md-outlined-icon-button>
</div>
<div style="display:flex;gap:8px;">
<md-icon-button toggle selected>
<md-icon>close</md-icon>
<md-icon slot="selectedIcon">check</md-icon>
<md-icon slot="selected">check</md-icon>
</md-icon-button>
<md-filled-icon-button toggle selected>
<md-icon>close</md-icon>
<md-icon slot="selectedIcon">check</md-icon>
<md-icon slot="selected">check</md-icon>
</md-filled-icon-button>
<md-filled-tonal-icon-button toggle selected>
<md-icon>close</md-icon>
<md-icon slot="selectedIcon">check</md-icon>
<md-icon slot="selected">check</md-icon>
</md-filled-tonal-icon-button>
<md-outlined-icon-button toggle selected>
<md-icon>close</md-icon>
<md-icon slot="selectedIcon">check</md-icon>
<md-icon slot="selected">check</md-icon>
</md-outlined-icon-button>
</div>
</figure>
Expand Down
18 changes: 9 additions & 9 deletions docs/components/icon-button.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,37 +131,37 @@ adding or removing something from favorites.
<div>
<md-icon-button toggle>
<md-icon>close</md-icon>
<md-icon slot="selectedIcon">check</md-icon>
<md-icon slot="selected">check</md-icon>
</md-icon-button>
<md-filled-icon-button toggle>
<md-icon>close</md-icon>
<md-icon slot="selectedIcon">check</md-icon>
<md-icon slot="selected">check</md-icon>
</md-filled-icon-button>
<md-filled-tonal-icon-button toggle>
<md-icon>close</md-icon>
<md-icon slot="selectedIcon">check</md-icon>
<md-icon slot="selected">check</md-icon>
</md-filled-tonal-icon-button>
<md-outlined-icon-button toggle>
<md-icon>close</md-icon>
<md-icon slot="selectedIcon">check</md-icon>
<md-icon slot="selected">check</md-icon>
</md-outlined-icon-button>
</div>
<div>
<md-icon-button toggle selected>
<md-icon>close</md-icon>
<md-icon slot="selectedIcon">check</md-icon>
<md-icon slot="selected">check</md-icon>
</md-icon-button>
<md-filled-icon-button toggle selected>
<md-icon>close</md-icon>
<md-icon slot="selectedIcon">check</md-icon>
<md-icon slot="selected">check</md-icon>
</md-filled-icon-button>
<md-filled-tonal-icon-button toggle selected>
<md-icon>close</md-icon>
<md-icon slot="selectedIcon">check</md-icon>
<md-icon slot="selected">check</md-icon>
</md-filled-tonal-icon-button>
<md-outlined-icon-button toggle selected>
<md-icon>close</md-icon>
<md-icon slot="selectedIcon">check</md-icon>
<md-icon slot="selected">check</md-icon>
</md-outlined-icon-button>
</div>
```
Expand All @@ -188,7 +188,7 @@ descriptive label when selected.
aria-label="Unselected"
aria-label-selected="Selected">
<md-icon>close</md-icon>
<md-icon slot="selectedIcon">check</md-icon>
<md-icon slot="selected">check</md-icon>
</md-icon-button>
```

Expand Down
2 changes: 1 addition & 1 deletion docs/components/text-field.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ icon), or to express errors.
<md-outlined-text-field label="Password" type="password">
<md-icon-button toggle slot="trailingicon">
<md-icon>visibility</md-icon>
<md-icon slot="selectedIcon">visibility_off</md-icon>
<md-icon slot="selected">visibility_off</md-icon>
</md-icon-button>
</md-outlined-text-field>

Expand Down
8 changes: 4 additions & 4 deletions iconbutton/demo/stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const toggles: MaterialStoryInit<StoryKnobs> = {
?disabled=${disabled}
>
<md-icon>${icon}</md-icon>
<md-icon slot="selectedIcon">${selectedIcon}</md-icon>
<md-icon slot="selected">${selectedIcon}</md-icon>
</md-icon-button>
<md-outlined-icon-button
Expand All @@ -93,7 +93,7 @@ const toggles: MaterialStoryInit<StoryKnobs> = {
?disabled=${disabled}
>
<md-icon>${icon}</md-icon>
<md-icon slot="selectedIcon">${selectedIcon}</md-icon>
<md-icon slot="selected">${selectedIcon}</md-icon>
</md-outlined-icon-button>
<md-filled-icon-button
Expand All @@ -102,7 +102,7 @@ const toggles: MaterialStoryInit<StoryKnobs> = {
?disabled=${disabled}
>
<md-icon>${icon}</md-icon>
<md-icon slot="selectedIcon">${selectedIcon}</md-icon>
<md-icon slot="selected">${selectedIcon}</md-icon>
</md-filled-icon-button>
<md-filled-tonal-icon-button
Expand All @@ -111,7 +111,7 @@ const toggles: MaterialStoryInit<StoryKnobs> = {
?disabled=${disabled}
>
<md-icon>${icon}</md-icon>
<md-icon slot="selectedIcon">${selectedIcon}</md-icon>
<md-icon slot="selected">${selectedIcon}</md-icon>
</md-filled-tonal-icon-button>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions iconbutton/internal/icon-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export class IconButton extends LitElement implements FormSubmitter {

/**
* Sets the selected state. When false, displays the default icon. When true,
* displays the `selectedIcon`, or the default icon If no `selectedIcon` is
* provided.
* displays the selected icon, or the default icon If no `slot="selected"`
* icon is provided.
*/
@property({type: Boolean, reflect: true}) selected = false;

Expand Down Expand Up @@ -169,7 +169,7 @@ export class IconButton extends LitElement implements FormSubmitter {

private renderSelectedIcon() {
// Use default slot as fallback to not require specifying multiple icons
return html`<span class="icon icon--selected"><slot name="selectedIcon"><slot></slot></slot></span>`;
return html`<span class="icon icon--selected"><slot name="selected"><slot></slot></slot></span>`;
}

private renderTouchTarget() {
Expand Down
2 changes: 1 addition & 1 deletion progress/demo/stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ const components: MaterialStoryInit<StoryKnobs> = {
@change=${toggleIndeterminate}
>
<md-icon>play_arrow</md-icon>
<md-icon slot="selectedIcon">pause</md-icon>
<md-icon slot="selected">pause</md-icon>
</md-icon-button>
</div>
</div>
Expand Down

0 comments on commit 9647f5e

Please sign in to comment.