-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: button component (css rewrite + remove button-style prop) (#…
…450) * feat: update token package * refactor: CSS rewrite * refactor: remove button-style prop from button component
- Loading branch information
1 parent
f3a052b
commit f7d4ce4
Showing
11 changed files
with
2,363 additions
and
621 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
271 changes: 111 additions & 160 deletions
271
packages/web/src/components/gcds-button/gcds-button.css
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,192 +1,143 @@ | ||
:host button, | ||
:host a { | ||
cursor: pointer; | ||
font: var(--gcds-button-font); | ||
padding: var(--gcds-button-padding); | ||
border: var(--gcds-button-border-width) solid transparent; | ||
text-decoration: none; | ||
border-radius: var(--gcds-button-border-radius); | ||
box-sizing: border-box; | ||
display: inline-block; | ||
width: var(--gcds-button-width); | ||
text-align: center; | ||
transition: all 0.15s ease-in-out; | ||
|
||
slot { | ||
display: initial; | ||
} | ||
|
||
/* Button Role Styles */ | ||
&.button--role-danger { | ||
background-color: var(--gcds-button-danger-default-background); | ||
color: var(--gcds-button-danger-default-text); | ||
@layer reset, default, roles, size, disabled, hover, focus, active, mobile; | ||
|
||
&:hover { | ||
background-color: var(--gcds-button-danger-hover-background); | ||
} | ||
@layer reset { | ||
:host { | ||
display: inline-block; | ||
|
||
&:focus { | ||
background-color: var(--gcds-button-shared-focus-background); | ||
color: var(--gcds-button-shared-focus-text); | ||
outline: var(--gcds-button-shared-focus-outline-width) solid | ||
var(--gcds-button-shared-focus-background); | ||
outline-offset: var(--gcds-button-border-width); | ||
border-color: var(--gcds-button-shared-focus-background); | ||
box-shadow: var(--gcds-button-shared-focus-box-shadow); | ||
.gcds-button { | ||
box-sizing: border-box; | ||
cursor: pointer; | ||
text-decoration: none; | ||
} | ||
|
||
&:active { | ||
background-color: var(--gcds-button-shared-active-background); | ||
border-color: var(--gcds-button-shared-active-background); | ||
slot { | ||
display: initial; | ||
} | ||
} | ||
} | ||
|
||
&.button--role-primary { | ||
background-color: var(--gcds-button-primary-default-background); | ||
color: var(--gcds-button-primary-default-text); | ||
|
||
&:hover { | ||
background-color: var(--gcds-button-primary-hover-background); | ||
} | ||
@layer default { | ||
:host .gcds-button { | ||
display: inline-block; | ||
width: var(--gcds-button-width); | ||
font: var(--gcds-button-font); | ||
text-align: center; | ||
text-wrap: balance; | ||
padding: var(--gcds-button-padding); | ||
border: var(--gcds-button-border-width) solid transparent; | ||
border-radius: var(--gcds-button-border-radius); | ||
transition: all 0.15s ease-in-out; | ||
} | ||
} | ||
|
||
&:focus { | ||
background-color: var(--gcds-button-shared-focus-background); | ||
color: var(--gcds-button-shared-focus-text); | ||
outline: var(--gcds-button-shared-focus-outline-width) solid | ||
var(--gcds-button-shared-focus-background); | ||
outline-offset: var(--gcds-button-border-width); | ||
border-color: var(--gcds-button-shared-focus-background); | ||
box-shadow: var(--gcds-button-shared-focus-box-shadow); | ||
@layer roles { | ||
:host .gcds-button { | ||
/* Button danger */ | ||
&.button--role-danger { | ||
background-color: var(--gcds-button-danger-default-background); | ||
color: var(--gcds-button-danger-default-text); | ||
} | ||
|
||
&:active { | ||
background-color: var(--gcds-button-shared-active-background); | ||
border-color: var(--gcds-button-shared-active-background); | ||
/* Button primary */ | ||
&.button--role-primary { | ||
background-color: var(--gcds-button-primary-default-background); | ||
color: var(--gcds-button-primary-default-text); | ||
} | ||
} | ||
|
||
&.button--role-secondary { | ||
background-color: var(--gcds-button-secondary-default-background); | ||
color: var(--gcds-button-secondary-default-text); | ||
border: var(--gcds-button-border-width) solid currentColor; | ||
|
||
&:hover { | ||
background-color: var(--gcds-button-secondary-hover-background); | ||
border-color: var(--gcds-button-secondary-default-text); | ||
/* Button secondary */ | ||
&.button--role-secondary { | ||
background-color: var(--gcds-button-secondary-default-background); | ||
color: var(--gcds-button-secondary-default-text); | ||
} | ||
|
||
&:focus { | ||
background-color: var(--gcds-button-shared-focus-background); | ||
color: var(--gcds-button-shared-focus-text); | ||
outline: var(--gcds-button-shared-focus-outline-width) solid | ||
var(--gcds-button-shared-focus-background); | ||
outline-offset: var(--gcds-button-border-width); | ||
border-color: var(--gcds-button-shared-focus-background); | ||
box-shadow: var(--gcds-button-shared-focus-box-shadow); | ||
|
||
&:hover { | ||
border-color: var(--gcds-button-shared-focus-background); | ||
border: var(--gcds-button-border-width) solid currentColor; | ||
} | ||
|
||
/* Button skip to content */ | ||
&.button--role-skip-to-content { | ||
position: absolute; | ||
top: var(--gcds-button-skip-top); | ||
left: 0; | ||
width: inherit; | ||
z-index: 3; | ||
|
||
&:not(:focus) { | ||
clip: rect(0, 0, 0, 0); | ||
height: 0; | ||
margin: 0; | ||
overflow: hidden; | ||
padding: 0; | ||
width: 0; | ||
} | ||
} | ||
|
||
&:active { | ||
background-color: var(--gcds-button-shared-active-background); | ||
border-color: var(--gcds-button-shared-active-background) !important; | ||
} | ||
} | ||
} | ||
|
||
&.button--text-only { | ||
background-color: var(--gcds-button-text-only-default-background); | ||
color: var(--gcds-button-text-only-default-text); | ||
|
||
&:not([aria-disabled='true']) { | ||
text-decoration: underline; | ||
text-underline-offset: 0.2em; | ||
text-decoration-color: currentColor; | ||
text-decoration-thickness: var( | ||
--gcds-button-text-only-default-decoration-thickness | ||
); | ||
} | ||
|
||
&:hover { | ||
background-color: var(--gcds-button-text-only-default-background); | ||
color: var(--gcds-button-text-only-hover-text); | ||
text-decoration-thickness: var( | ||
--gcds-button-text-only-hover-decoration-thickness | ||
); | ||
} | ||
|
||
&:focus { | ||
background-color: var(--gcds-button-shared-focus-background); | ||
color: var(--gcds-button-shared-focus-text); | ||
outline: var(--gcds-button-shared-focus-outline-width) solid | ||
var(--gcds-button-shared-focus-background); | ||
outline-offset: var(--gcds-button-border-width); | ||
border-color: var(--gcds-button-shared-focus-background); | ||
box-shadow: var(--gcds-button-shared-focus-box-shadow); | ||
text-decoration: none; | ||
} | ||
@layer size { | ||
:host .gcds-button.button--small { | ||
font: var(--gcds-button-small-font); | ||
padding: var(--gcds-button-small-padding); | ||
} | ||
} | ||
|
||
&:active { | ||
background-color: var(--gcds-button-shared-active-background); | ||
border-color: var(--gcds-button-shared-active-background); | ||
} | ||
@layer disabled { | ||
:host .gcds-button[aria-disabled='true'] { | ||
background-color: var(--gcds-button-shared-disabled-background); | ||
color: var(--gcds-button-shared-disabled-text); | ||
cursor: not-allowed; | ||
border: var(--gcds-button-border-width) solid currentColor; | ||
pointer-events: none; | ||
} | ||
} | ||
|
||
&.button--role-skip-to-content { | ||
position: absolute; | ||
top: var(--gcds-button-skip-top); | ||
left: 0; | ||
width: inherit; | ||
z-index: 3; | ||
|
||
&:not(:focus) { | ||
clip: rect(0, 0, 0, 0); | ||
height: 0; | ||
margin: 0; | ||
overflow: hidden; | ||
padding: 0; | ||
width: 0; | ||
} | ||
@layer hover { | ||
@media (hover: hover) { | ||
:host .gcds-button:hover { | ||
/* Danger button */ | ||
&.button--role-danger { | ||
background-color: var(--gcds-button-danger-hover-background); | ||
} | ||
|
||
&:focus { | ||
background-color: var(--gcds-button-shared-focus-background); | ||
color: var(--gcds-button-shared-focus-text); | ||
outline: var(--gcds-button-shared-focus-outline-width) solid | ||
var(--gcds-button-shared-focus-background); | ||
outline-offset: var(--gcds-button-border-width); | ||
border-color: var(--gcds-button-shared-focus-background); | ||
box-shadow: var(--gcds-button-shared-focus-box-shadow); | ||
text-decoration: none; | ||
} | ||
/* Primary button */ | ||
&.button--role-primary { | ||
background-color: var(--gcds-button-primary-hover-background); | ||
} | ||
|
||
&:active { | ||
background-color: var(--gcds-button-shared-active-background); | ||
border-color: var(--gcds-button-shared-active-background); | ||
/* Secondary button */ | ||
&.button--role-secondary { | ||
background-color: var(--gcds-button-secondary-hover-background); | ||
} | ||
} | ||
} | ||
} | ||
|
||
/* Shared Styles */ | ||
&[aria-disabled='true'] { | ||
background-color: var(--gcds-button-shared-disabled-background); | ||
color: var(--gcds-button-shared-disabled-text); | ||
cursor: not-allowed; | ||
border: var(--gcds-button-border-width) solid currentColor; | ||
pointer-events: none; | ||
@layer focus { | ||
:host .gcds-button:focus { | ||
background-color: var(--gcds-button-shared-focus-background); | ||
color: var(--gcds-button-shared-focus-text); | ||
outline: var(--gcds-button-shared-focus-outline-width) solid | ||
var(--gcds-button-shared-focus-background); | ||
outline-offset: var(--gcds-button-border-width); | ||
border-color: var(--gcds-button-shared-focus-background); | ||
box-shadow: var(--gcds-button-shared-focus-box-shadow); | ||
} | ||
} | ||
|
||
/* Small button styling */ | ||
&.button--small { | ||
font: var(--gcds-button-small-font); | ||
padding: var(--gcds-button-small-padding); | ||
@layer active { | ||
:host .gcds-button:active { | ||
background-color: var(--gcds-button-shared-active-background); | ||
border-color: var(--gcds-button-shared-active-background); | ||
} | ||
} | ||
|
||
@media screen and (max-width: 30rem) { | ||
:host button:not(.button--text-only), | ||
:host a:not(.button--text-only) { | ||
width: var(--gcds-button-mobile-width); | ||
margin: var(--gcds-button-mobile-margin); | ||
/* Note: mobile specific style decision */ | ||
@layer mobile { | ||
@media screen and (max-width: 30rem) { | ||
:host { | ||
display: block; | ||
|
||
.gcds-button { | ||
width: var(--gcds-button-mobile-width); | ||
margin: var(--gcds-button-mobile-margin); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.