.ui-button had a pointer cursor and nothing else: no hover, no pressed state and no focus style of its own. Each variant gets a hover fill, a press nudge and a purple focus ring, with the transition off under reduced motion.
85 lines
2.3 KiB
CSS
85 lines
2.3 KiB
CSS
/* <Button> — same touch-target floor as `.ui-form-control`
|
|
(../form-field/FormField.css: 2.75em ≈ 44px at the default root font,
|
|
WCAG 2.5.5) so a button never reads as a smaller tap target than the
|
|
input sitting next to it. Colours are the shared base16-derived vars
|
|
(../../theme.css). */
|
|
.ui-button {
|
|
border-radius: var(--radius-sm);
|
|
padding: 0.5em 1.2em;
|
|
font: inherit;
|
|
cursor: pointer;
|
|
min-height: 2.75em;
|
|
}
|
|
.ui-button-primary {
|
|
background: var(--purple-dim);
|
|
color: var(--fg);
|
|
border: none;
|
|
}
|
|
.ui-button-danger {
|
|
background: color-mix(in srgb, var(--red) 14%, var(--bg-elev));
|
|
color: var(--red);
|
|
border: 1px solid var(--red);
|
|
}
|
|
.ui-button-default {
|
|
background: var(--bg-elev);
|
|
color: var(--fg);
|
|
border: 1px solid var(--border);
|
|
}
|
|
.ui-button:disabled {
|
|
opacity: 0.6;
|
|
cursor: default;
|
|
}
|
|
.ui-button {
|
|
position: relative;
|
|
transition:
|
|
background-color 0.12s ease,
|
|
border-color 0.12s ease,
|
|
filter 0.12s ease;
|
|
}
|
|
/* Hover, press and keyboard focus: a button answers the pointer. The primary
|
|
fill brightens (on a light palette that raises the label's contrast; on a dark
|
|
one it stays above 6:1). */
|
|
.ui-button-default:hover:not(:disabled) {
|
|
border-color: var(--purple);
|
|
background: color-mix(in srgb, var(--purple) 8%, var(--bg-elev));
|
|
}
|
|
.ui-button-primary:hover:not(:disabled) {
|
|
filter: brightness(1.12);
|
|
}
|
|
.ui-button-danger:hover:not(:disabled) {
|
|
background: color-mix(in srgb, var(--red) 24%, var(--bg-elev));
|
|
}
|
|
.ui-button:active:not(:disabled) {
|
|
transform: translateY(1px);
|
|
}
|
|
.ui-button:focus-visible {
|
|
outline: 2px solid var(--purple);
|
|
outline-offset: 2px;
|
|
}
|
|
@media (prefers-reduced-motion: reduce) {
|
|
.ui-button {
|
|
transition: none;
|
|
}
|
|
}
|
|
:root[data-motion="reduce"] .ui-button {
|
|
transition: none;
|
|
}
|
|
:root[data-motion="allow"] .ui-button {
|
|
transition:
|
|
background-color 0.12s ease,
|
|
border-color 0.12s ease,
|
|
filter 0.12s ease;
|
|
}
|
|
/* Busy: the label keeps its space, invisible, and the spinner sits over it.
|
|
`opacity`, not `visibility`: the label stays in the accessibility tree, so the
|
|
button keeps its name (the button is `aria-busy` and disabled). */
|
|
.ui-button-busy .ui-button-label {
|
|
opacity: 0;
|
|
}
|
|
.ui-button-spinner {
|
|
position: absolute;
|
|
inset: 0;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|