Skip to content

Commit

Permalink
feat(all): expose focus-ring parts
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 548873009
  • Loading branch information
asyncLiz authored and copybara-github committed Jul 18, 2023
1 parent fd28dd1 commit 243e231
Show file tree
Hide file tree
Showing 15 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion button/lib/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export abstract class Button extends LitElement {
}

private renderFocusRing() {
return html`<md-focus-ring></md-focus-ring>`;
return html`<md-focus-ring part="focus-ring"></md-focus-ring>`;
}

private renderLabel() {
Expand Down
2 changes: 1 addition & 1 deletion checkbox/lib/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export class Checkbox extends LitElement {
<div class="container ${containerClasses}">
<div class="outline"></div>
<div class="background"></div>
<md-focus-ring for="input"></md-focus-ring>
<md-focus-ring part="focus-ring" for="input"></md-focus-ring>
<md-ripple for="input" ?disabled=${this.disabled}></md-ripple>
<svg class="icon" viewBox="0 0 18 18">
<rect class="mark short" />
Expand Down
2 changes: 1 addition & 1 deletion chips/lib/chip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export abstract class Chip extends LitElement {
<div class="container ${classMap(this.getContainerClasses())}"
role=${this.containerRole || nothing}>
${this.renderOutline()}
<md-focus-ring for=${this.primaryId}></md-focus-ring>
<md-focus-ring part="focus-ring" for=${this.primaryId}></md-focus-ring>
<md-ripple for=${this.primaryId}
?disabled=${this.rippleDisabled}></md-ripple>
${this.renderActions()}
Expand Down
2 changes: 1 addition & 1 deletion chips/lib/trailing-icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function renderRemoveButton(
tabindex=${!tabbable ? -1 : nothing}
@click=${handleRemoveClick}
>
<md-focus-ring></md-focus-ring>
<md-focus-ring part="trailing-focus-ring"></md-focus-ring>
<md-ripple></md-ripple>
<svg class="trailing icon" viewBox="0 96 960 960">
<path d="m249 849-42-42 231-231-231-231 42-42 231 231 231-231 42 42-231 231 231 231-42 42-231-231-231 231Z" />
Expand Down
2 changes: 1 addition & 1 deletion fab/lib/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export abstract class SharedFab extends LitElement {
aria-label=${ariaLabel || nothing}
>
<md-elevation></md-elevation>
<md-focus-ring></md-focus-ring>
<md-focus-ring part="focus-ring"></md-focus-ring>
<md-ripple class="ripple"></md-ripple>
${this.renderTouchTarget()}
${this.renderIcon()}
Expand Down
2 changes: 1 addition & 1 deletion iconbutton/lib/icon-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export class IconButton extends LitElement {
}

private renderFocusRing() {
return html`<md-focus-ring for=${
return html`<md-focus-ring part="focus-ring" for=${
this.href ? 'link' : 'button'}></md-focus-ring>`;
}

Expand Down
2 changes: 1 addition & 1 deletion labs/navigationtab/lib/navigation-tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class NavigationTab extends LitElement implements NavigationTabState {
tabindex="${this.active ? 0 : -1}"
@click="${this.handleClick}"
>
<md-focus-ring inward></md-focus-ring>
<md-focus-ring part="focus-ring" inward></md-focus-ring>
<md-ripple ?disabled="${
this.disabled}" class="md3-navigation-tab__ripple"></md-ripple>
<span aria-hidden="true" class="md3-navigation-tab__icon-content"
Expand Down
2 changes: 1 addition & 1 deletion labs/segmentedbutton/lib/segmented-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class SegmentedButton extends LitElement {
@click="${this.handleClick}"
class="md3-segmented-button ${classMap(this.getRenderClasses())}"
>
<md-focus-ring class="md3-segmented-button__focus-ring"></md-focus-ring>
<md-focus-ring class="md3-segmented-button__focus-ring" part="focus-ring"></md-focus-ring>
<md-ripple ?disabled="${
this.disabled}" class="md3-segmented-button__ripple"></md-ripple>
${this.renderOutline()}
Expand Down
2 changes: 1 addition & 1 deletion list/lib/listitem/list-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export class ListItemEl extends LitElement implements ListItem {
* Handles rendering of the focus ring.
*/
protected renderFocusRing(): TemplateResult|typeof nothing {
return html`<md-focus-ring class="focus-ring" for="item" inward></md-focus-ring>`;
return html`<md-focus-ring class="focus-ring" part="focus-ring" for="item" inward></md-focus-ring>`;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion menu/lib/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export abstract class Menu extends LitElement {
* Renders the focus ring component.
*/
private renderFocusRing() {
return html`<md-focus-ring for="list"></md-focus-ring>`;
return html`<md-focus-ring part="focus-ring" for="list"></md-focus-ring>`;
}

private getSurfaceClasses() {
Expand Down
4 changes: 2 additions & 2 deletions radio/lib/radio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class Radio extends LitElement {
/** @nocollapse */
static formAssociated = true;

// Unique maskId is required because of a Safari bug that fail to persist
// Unique maskId is required because of a Safari bug that fail to persist
// reference to the mask. This should be removed once the bug is fixed.
private readonly maskId = `cutout${++maskId}`;

Expand Down Expand Up @@ -125,7 +125,7 @@ export class Radio extends LitElement {
return html`
<div class=${classMap(classes)}>
<md-ripple for="input" ?disabled=${this.disabled}></md-ripple>
<md-focus-ring for="input"></md-focus-ring>
<md-focus-ring part="focus-ring" for="input"></md-focus-ring>
<svg class="icon" viewBox="0 0 20 20">
<mask id="${this.maskId}">
<rect width="100%" height="100%" fill="white" />
Expand Down
1 change: 1 addition & 0 deletions select/lib/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ export abstract class Select extends LitElement {
type="listbox"
stay-open-on-focusout
part="menu"
exportparts="focus-ring: menu-focus-ring"
.anchor=${this.field}
.open=${this.open}
.quick=${this.quick}
Expand Down
2 changes: 1 addition & 1 deletion slider/lib/slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ export class Slider extends LitElement {
})}">
<div class="handleNub"><md-elevation></md-elevation></div>
${when(this.labeled, () => this.renderLabel(label))}
<md-focus-ring for=${name}></md-focus-ring>
<md-focus-ring part="focus-ring" for=${name}></md-focus-ring>
<md-ripple for=${name} class=${name} ?disabled=${
this.disabled}></md-ripple>
</div>`;
Expand Down
2 changes: 1 addition & 1 deletion switch/lib/switch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class Switch extends LitElement {
?disabled=${this.disabled}
@click=${this.handleClick}
>
<md-focus-ring></md-focus-ring>
<md-focus-ring part="focus-ring"></md-focus-ring>
<span class="track">
${this.renderHandle()}
</span>
Expand Down
2 changes: 1 addition & 1 deletion tabs/lib/tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class Tab extends LitElement {
?disabled=${this.disabled}
aria-label=${ariaLabel || nothing}
>
<md-focus-ring inward></md-focus-ring>
<md-focus-ring part="focus-ring" inward></md-focus-ring>
<md-elevation></md-elevation>
<md-ripple ?disabled=${this.disabled}></md-ripple>
<span class="touch"></span>
Expand Down

0 comments on commit 243e231

Please sign in to comment.