Skip to content

Commit

Permalink
feat(switch): add touch target configs
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 556012902
  • Loading branch information
asyncLiz authored and Copybara-Service committed Aug 11, 2023
1 parent b8d0828 commit 8bad07b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion switch/internal/_switch.scss
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@
-webkit-tap-highlight-color: transparent;
}

:host([touch-target='wrapper']) {
margin: max(0px, (48px - var(--_track-height)) / 2) 0px;
}

md-focus-ring {
@include focus-ring.theme(
(
Expand Down Expand Up @@ -125,7 +129,11 @@
.touch {
position: absolute;
height: 48px;
width: 48px;
width: 100%;
}

:host([touch-target='none']) .touch {
display: none;
}

// Disabled
Expand Down
2 changes: 1 addition & 1 deletion switch/internal/switch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ export class Switch extends LitElement {
'with-icon': this.icons || (this.showOnlySelectedIcon && this.selected),
};
return html`
${this.renderTouchTarget()}
<span class="handle-container">
<md-ripple for="switch" ?disabled="${this.disabled}"></md-ripple>
<span class="handle ${classMap(classes)}">
${this.shouldShowIcons() ? this.renderIcons() : html``}
</span>
${this.renderTouchTarget()}
</span>
`;
}
Expand Down

0 comments on commit 8bad07b

Please sign in to comment.