-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui-kit/icon-button): new component (#588)
- Loading branch information
Showing
3 changed files
with
110 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
:root { | ||
/* Dragged state layer opacity */ | ||
--md-sys-state-dragged-state-layer-opacity: 0.1599999964237213; | ||
--md-sys-state-dragged-state-layer-opacity: 0.2; | ||
/* Pressed state layer opacity */ | ||
--md-sys-state-pressed-state-layer-opacity: 0.11999999731779099; | ||
--md-sys-state-pressed-state-layer-opacity: 0.15; | ||
/* Focus state layer opacity */ | ||
--md-sys-state-focus-state-layer-opacity: 0.11999999731779099; | ||
--md-sys-state-focus-state-layer-opacity: 0.15; | ||
/* Hover state layer opacity */ | ||
--md-sys-state-hover-state-layer-opacity: 0.07999999821186066; | ||
--md-sys-state-hover-state-layer-opacity: 0.09; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import {AlwatrDummyElement, css, customElement, html, property} from '@alwatr/element'; | ||
|
||
import '@alwatr/icon'; | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'alwatr-standard-icon-button': AlwatrStandardIconButton; | ||
} | ||
} | ||
|
||
/** | ||
* Alwatr standard icon button element. | ||
*/ | ||
@customElement('alwatr-standard-icon-button') | ||
export class AlwatrStandardIconButton extends AlwatrDummyElement { | ||
static override styles = css` | ||
:host { | ||
position: relative; | ||
display: inline-flex; | ||
user-select: none; | ||
align-items: center; | ||
justify-content: center; | ||
vertical-align: middle; | ||
flex-grow: 0; | ||
flex-shrink: 0; | ||
flex-basis: auto; | ||
cursor: pointer; | ||
color: var(--md-sys-color-on-surface-variant); | ||
background-color: transparent; | ||
width: var(--md-sys-spacing-track-5); | ||
height: var(--md-sys-spacing-track-5); | ||
border-radius: 50%; | ||
outline: 0; | ||
overflow: hidden; | ||
overflow: clip; | ||
z-index: var(--md-sys-zindex-default); | ||
-webkit-tap-highlight-color: transparent; | ||
} | ||
:host::before { | ||
content: ''; | ||
position: absolute; | ||
z-index: var(--md-sys-zindex-below); | ||
left: 0; | ||
right: 0; | ||
top: 0; | ||
bottom: 0; | ||
inset: 0; | ||
opacity: 0; | ||
transition: opacity var(--md-sys-motion-duration-small-out) var(--md-sys-motion-easing-linear); | ||
background-color: var(--md-sys-color-on-surface-variant); | ||
} | ||
:host(:hover)::before { | ||
opacity: var(--md-sys-state-hover-state-layer-opacity); | ||
transition-duration: var(--md-sys-motion-duration-small-in); | ||
} | ||
:host(:active)::before { | ||
opacity: var(--md-sys-state-pressed-state-layer-opacity); | ||
transition-duration: 0ms; | ||
} | ||
:host(:focus)::before { | ||
opacity: var(--md-sys-state-focus-state-layer-opacity); | ||
transition-duration: var(--md-sys-motion-duration-small-in); | ||
} | ||
alwatr-icon { | ||
width: var(--md-sys-spacing-track-3); | ||
height: var(--md-sys-spacing-track-3); | ||
} | ||
`; | ||
|
||
@property() icon?: string; | ||
|
||
override render(): unknown { | ||
return html`<alwatr-icon .name=${this.icon}></alwatr-icon>`; | ||
} | ||
} |