Files
webawesome/src/components/button/button.css
Cory LaViska b96c3f318b Simplify native styles (#993)
* move print styles

* begin native styles split

* unsplit button styles 😓

* unsplit callout; remove .wa-callout

* merge forms

* remove unused

* remove unused

* unsplit checkbox

* remove old astro config

* remove overflow

* unsplit slider

* fix tooltip position in RTL

* unsplit radio

* move required light DOM styles to <wa-page>

* remove unused file

* remove unused import

* remove

* goodbye

* fix examples

* unsplit dialog

* unsplit select

* remove select

* unsplit input

* unsplit details

* update

* update comment

* update textarea

* combine native docs; improvements

* update

* reorg and fix headings

* fix details summary padding; fixes #684

* update

* fix native details summary padding; fixes #684

* #684

* remove passthrough style nonsense

* it's CSS not JS

* fix details in sidebar

* add spacing in native buttons for icons

* whitespace

* update docs

* remove button group util

* remove shadow folder, add component folder

* layerize

* default border radius

* remove color contrast script from dist

* add term

* layerize themes + color folders

* reorder

* remove radio button; #504

* remove visual tests

* remove visual tests

* remove unused stylesheet

* make search smarter

* add radio styles

* Fix filled textareas

* re-introduce visual tests (with adjustments)

* fix button appearances

* fix textarea focus styles

* re-introduce appearance classes

* remove 'native styles' note from component pages

* fix checked radio styles

* touch up callout styles

* remove errant `.wa-tag`

* scope appearance classes to relevant elements

* more visual test cases

* fix details borders

* minor visual tests reorg

* add `--box-shadow` to buttons

* fix Awesome theme

* use same layer for all themes (allows unset properties to inherit from Default theme)

* fix box-shadow in wa-textarea

* set button box shadow to `initial`

* fix Active theme

* fix Brutalist theme

* fix Glossy theme

* fix Matter theme (mostly)

* fix Playful theme

* fix Premium theme

* fix Shoelac theme

* fix Tailspin theme

* fix custom radio button styles

* fix links to native styles doc

---------

Co-authored-by: lindsaym-fa <dev@lindsaym.design>
2025-05-29 13:10:53 -04:00

253 lines
6.2 KiB
CSS

@layer wa-component {
:host {
--background-color: var(--wa-color-fill-loud, var(--wa-color-neutral-fill-loud));
--background-color-hover: color-mix(in oklab, var(--background-color), var(--wa-color-mix-hover));
--background-color-active: color-mix(in oklab, var(--background-color), var(--wa-color-mix-active));
--border-color: transparent;
--border-color-hover: var(--border-color);
--border-color-active: var(--border-color);
--border-width: max(1px, var(--wa-form-control-border-width));
--box-shadow: initial;
--text-color: var(--wa-color-on-loud, var(--wa-color-neutral-on-loud));
--text-color-hover: var(--text-color);
--text-color-active: var(--text-color);
display: inline-block;
position: relative;
}
}
.button {
border-radius: var(--wa-form-control-border-radius);
border-style: var(--wa-border-style);
border-width: var(--border-width);
box-shadow: var(--box-shadow);
align-items: center;
justify-content: center;
text-decoration: none;
user-select: none;
-webkit-user-select: none;
white-space: nowrap;
vertical-align: middle;
transition-property: background, border, box-shadow, color;
transition-duration: var(--wa-transition-fast);
transition-timing-function: var(--wa-transition-easing);
cursor: pointer;
padding: 0 var(--wa-space, var(--wa-space-m));
font-family: inherit;
font-size: var(--wa-size, var(--wa-font-size-m));
font-weight: var(--wa-font-weight-action);
line-height: calc(var(--wa-form-control-height) - var(--border-width) * 2);
height: var(--wa-form-control-height);
width: 100%;
display: inline-flex;
background-color: var(--background-color);
border-color: var(--border-color, var(--background-color));
color: var(--text-color);
}
/* Interactive states */
.button:not(.disabled):not(.loading):hover {
background-color: var(--background-color-hover, var(--background-color));
border-color: var(--border-color-hover, var(--border-color, var(--background-color-hover)));
color: var(--text-color-hover, var(--text-color));
}
.button:not(.disabled):not(.loading):active {
background-color: var(--background-color-active, var(--background-color));
border-color: var(--border-color-active, var(--border-color, var(--background-color-active)));
color: var(--text-color-active, var(--text-color));
}
/* Focus states */
.button:focus {
outline: none;
}
.button:focus-visible {
outline: var(--wa-focus-ring);
outline-offset: var(--wa-focus-ring-offset);
}
/* Disabled state */
.button.disabled {
opacity: 0.5;
cursor: not-allowed;
}
/* When disabled, prevent mouse events from bubbling up from children */
.button.disabled * {
pointer-events: none;
}
/* Keep it last so Safari doesn't stop parsing this block */
.button::-moz-focus-inner {
border: 0;
}
/* Pill modifier */
:host([pill]) .button {
border-radius: var(--wa-border-radius-pill);
}
/*
* Label
*/
.prefix,
.suffix {
flex: 0 0 auto;
display: flex;
align-items: center;
pointer-events: none;
}
.label {
display: inline-block;
}
.label::slotted(wa-icon) {
vertical-align: -2px;
}
/*
* Caret modifier
*/
wa-icon[part~='caret'] {
display: flex;
align-self: center;
align-items: center;
&::part(svg) {
width: 0.875em;
height: 0.875em;
}
.button:has(&) .suffix {
display: none;
}
}
/*
* Loading modifier
*/
.loading {
position: relative;
cursor: wait;
.prefix,
.label,
.suffix,
.caret {
visibility: hidden;
}
wa-spinner {
--indicator-color: currentColor;
--track-color: color-mix(in oklab, currentColor, transparent 90%);
position: absolute;
font-size: 1em;
height: 1em;
width: 1em;
top: calc(50% - 0.5em);
left: calc(50% - 0.5em);
}
}
/*
* Badges
*/
button ::slotted(wa-badge) {
border-color: var(--wa-color-surface-default);
position: absolute;
inset-block-start: 0;
inset-inline-end: 0;
translate: 50% -50%;
pointer-events: none;
}
:host(:dir(rtl)) ::slotted(wa-badge) {
translate: -50% -50%;
}
/*
* Button spacing
*/
slot[name='prefix']::slotted(*) {
margin-inline-end: var(--wa-space);
}
slot[name='suffix']::slotted(*),
.button:not(.visually-hidden-label) [part~='caret'] {
margin-inline-start: var(--wa-space);
}
/*
* Button group border radius modifications
*/
/* Remove border radius from all grouped buttons by default */
:host(.wa-button-group__button) .button {
border-radius: 0;
}
/* Horizontal orientation */
:host(.wa-button-group__horizontal.wa-button-group__button-first) .button {
border-start-start-radius: var(--wa-form-control-border-radius);
border-end-start-radius: var(--wa-form-control-border-radius);
}
:host(.wa-button-group__horizontal.wa-button-group__button-last) .button {
border-start-end-radius: var(--wa-form-control-border-radius);
border-end-end-radius: var(--wa-form-control-border-radius);
}
/* Vertical orientation */
:host(.wa-button-group__vertical) {
flex: 1 1 auto;
}
:host(.wa-button-group__vertical) .button {
width: 100%;
justify-content: start;
}
:host(.wa-button-group__vertical.wa-button-group__button-first) .button {
border-start-start-radius: var(--wa-form-control-border-radius);
border-start-end-radius: var(--wa-form-control-border-radius);
}
:host(.wa-button-group__vertical.wa-button-group__button-last) .button {
border-end-start-radius: var(--wa-form-control-border-radius);
border-end-end-radius: var(--wa-form-control-border-radius);
}
/* Handle pill modifier for button groups */
:host([pill]) .wa-button-group__horizontal.wa-button-group__button-first {
border-start-start-radius: var(--wa-border-radius-pill);
border-end-start-radius: var(--wa-border-radius-pill);
}
:host([pill]) .wa-button-group__horizontal.wa-button-group__button-last {
border-start-end-radius: var(--wa-border-radius-pill);
border-end-end-radius: var(--wa-border-radius-pill);
}
:host([pill]) .wa-button-group__vertical.wa-button-group__button-first {
border-start-start-radius: var(--wa-border-radius-pill);
border-start-end-radius: var(--wa-border-radius-pill);
}
:host([pill]) .wa-button-group__vertical.wa-button-group__button-last {
border-end-start-radius: var(--wa-border-radius-pill);
border-end-end-radius: var(--wa-border-radius-pill);
}