forked from Dogfalo/materialize
-
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #578 from gselderslaghs/buttons-scss-mixin
refactor(Buttons) implement buttons styling with mixin
- Loading branch information
Showing
3 changed files
with
179 additions
and
43 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 |
---|---|---|
@@ -0,0 +1,155 @@ | ||
@mixin btn( | ||
$height: var(--btn-height), | ||
$border-radius: var(--btn-border-radius), | ||
$padding-left: var(--btn-padding), | ||
$padding-right: var(--btn-padding), | ||
$font-size: var(--btn-font-size), | ||
) { | ||
height: $height; | ||
border-radius: $border-radius; | ||
padding-left: $padding-left; | ||
padding-right: $padding-right; | ||
font-size: $font-size; | ||
font-weight: 500; | ||
text-decoration: none; | ||
display: inline-flex; | ||
align-items: center; | ||
cursor: pointer; | ||
-webkit-tap-highlight-color: transparent; // Gets rid of tap active state | ||
white-space: nowrap; | ||
outline: 0; | ||
user-select: none; | ||
transition: background-color .2s ease-out; | ||
|
||
&:focus { | ||
background-color: var(--md-sys-color-primary-container); | ||
} | ||
} | ||
|
||
@mixin btn-filled { | ||
color: var(--md-sys-color-on-primary); | ||
background-color: var(--md-sys-color-primary); | ||
|
||
&:hover, | ||
&:focus { | ||
color: var(--md-sys-color-on-primary); | ||
} | ||
|
||
&:hover { | ||
@extend .z-depth-1; | ||
background-color: color-mix(in srgb, var(--md-sys-color-primary), var(--md-sys-color-on-primary) 16%); | ||
} | ||
|
||
&:focus { | ||
@extend .z-depth-0; | ||
background-color: color-mix(in srgb, var(--md-sys-color-primary), var(--md-sys-color-on-primary) 20%); | ||
} | ||
|
||
@include focus-visible(); | ||
} | ||
|
||
@mixin btn-tonal { | ||
color: var(--md-sys-color-on-secondary-container); | ||
background-color: var(--md-sys-color-secondary-container); | ||
|
||
&:hover, | ||
&:focus { | ||
color: var(--md-sys-color-on-secondary-container); | ||
} | ||
|
||
&:hover { | ||
@extend .z-depth-1; | ||
background-color: color-mix(in srgb, var(--md-sys-color-secondary-container), var(--md-sys-color-on-secondary-container) 16%); | ||
} | ||
|
||
&:focus { | ||
@extend .z-depth-0; | ||
background-color: color-mix(in srgb, var(--md-sys-color-secondary-container), var(--md-sys-color-on-secondary-container) 20%); | ||
} | ||
|
||
@include focus-visible(); | ||
} | ||
|
||
@mixin btn-elevated { | ||
color: var(--md-sys-color-on-secondary-container); | ||
background-color: var(--md-sys-color-secondary-container); | ||
@extend .z-depth-1; | ||
|
||
&:hover, | ||
&:focus { | ||
color: var(--md-sys-color-primary); | ||
} | ||
|
||
&:hover { | ||
@extend .z-depth-2; | ||
background-color: color-mix(in srgb, var(--md-sys-color-secondary-container), var(--md-sys-color-on-secondary-container) 16%); | ||
} | ||
|
||
&:focus { | ||
@extend .z-depth-1; | ||
background-color: color-mix(in srgb, var(--md-sys-color-secondary-container), var(--md-sys-color-primary) 20%); | ||
} | ||
|
||
@include focus-visible(); | ||
} | ||
|
||
@mixin btn-outlined { | ||
background-color: transparent; | ||
color: var(--md-sys-color-primary); | ||
border: 1px solid var(--md-sys-color-outline); | ||
|
||
&:hover, | ||
&:focus { | ||
color: var(--md-sys-color-primary); | ||
} | ||
|
||
&:hover { | ||
background-color: color-mix(in srgb, transparent, var(--md-sys-color-primary) 16%); | ||
} | ||
|
||
&:focus { | ||
background-color: color-mix(in srgb, transparent, var(--md-sys-color-primary) 20%); | ||
border: 1px solid var(--md-sys-color-primary); | ||
} | ||
|
||
@include focus-visible(); | ||
} | ||
|
||
@mixin btn-flat { | ||
@extend .z-depth-0; | ||
color: var(--md-sys-color-primary); | ||
background-color: transparent; | ||
|
||
&:hover, | ||
&:focus { | ||
color: var(--md-sys-color-primary); | ||
} | ||
|
||
&:hover { | ||
background-color: color-mix(in srgb, var(--md-sys-color-primary) 16%, transparent); | ||
} | ||
|
||
&:focus { | ||
background-color: color-mix(in srgb, transparent, var(--md-sys-color-primary) 20%); | ||
} | ||
|
||
@include focus-visible(); | ||
} | ||
|
||
@mixin btn-disabled { | ||
@extend .z-depth-0; | ||
color: color-mix(in srgb, transparent, var(--md-sys-color-on-surface) 76%); | ||
background-color: color-mix(in srgb, transparent, var(--md-sys-color-on-surface) 24%); | ||
pointer-events: none; | ||
box-shadow: none; | ||
cursor: default; | ||
} | ||
|
||
// Focus with Keyboard | ||
@mixin focus-visible { | ||
&:focus-visible { | ||
outline: 3px solid var(--md-sys-color-secondary); | ||
outline-offset: 2px; | ||
} | ||
} | ||
|
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