Skip to content

Commit

Permalink
feat(button): add label slot
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 515467458
  • Loading branch information
dfreedm authored and copybara-github committed Mar 10, 2023
1 parent b794990 commit 24298e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 2 additions & 6 deletions button/lib/_shared.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
@use '../../sass/color';
@use '../../sass/dom';
@use '../../sass/resolvers';
@use '../../sass/shape';
@use '../../sass/typography';
// go/keep-sorted end

Expand Down Expand Up @@ -43,12 +44,7 @@

@include focus-ring.theme(
(
shape: (
var(--_container-shape-start-start),
var(--_container-shape-start-end),
var(--_container-shape-end-end),
var(--_container-shape-end-start),
),
shape: shape.corners-to-shape-token('--_container-shape'),
)
);
}
Expand Down
7 changes: 6 additions & 1 deletion button/lib/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ export abstract class Button extends LitElement implements ButtonState {
*/
@property({type: Boolean, attribute: 'trailingicon'}) trailingIcon = false;

// TODO(b/272598771): remove label property
/**
* The button's visible label.
*
* @deprecated Set text as content of the button instead.
*/
@property({type: String}) label = '';

Expand Down Expand Up @@ -160,7 +163,9 @@ export abstract class Button extends LitElement implements ButtonState {
}

protected renderLabel(): TemplateResult {
return html`<span class="md3-button__label">${this.label}</span>`;
// TODO(b/272598771): remove the ternary when label property is removed
return html`<span class="md3-button__label">${
this.label ? this.label : html`<slot></slot>`}</span>`;
}

protected renderLeadingIcon(): TemplateResult|string {
Expand Down

0 comments on commit 24298e6

Please sign in to comment.