[Glitch] Adjust button states

Port d3b6902426 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Echo authored and Claire committed 2026-07-24 18:43:38 +02:00
1 parent dd3cd182e5
commit 6a741d296d
3 files changed
+58 -38

No files matched your search

@@ -1,5 +1,6 @@
.base {
--bg: transparent;
--bg-hover: color-mix(in srgb, var(--bg) 90%, var(--fg));
--fg: var(--color-text-primary);
background-color: var(--bg);
@@ -17,11 +18,15 @@
font-size: var(--fs-sm);
line-height: 1;
box-sizing: border-box;
gap: var(--space-2xs);
&:hover:not(:active) {
background-color: var(--bg-hover);
}
&:focus-visible,
&:focus-within {
outline: 2px solid var(--fg);
outline: 2px solid var(--color-bg-brand-base);
outline-offset: 2px;
}
&:disabled,
@@ -41,10 +46,12 @@ a.base {
}
}
// Sizes
.xs {
padding: var(--space-3xs) var(--space-xs);
padding: var(--space-3xs) var(--space-2xs);
font-size: var(--fs-2xs);
min-height: 24px;
min-height: 20px;
}
.sm {
@@ -62,32 +69,24 @@ a.base {
min-height: 48px;
}
// Solid variant
.solid {
--bg: var(--color-bg-inverted);
--bg-hover: color-mix(in srgb, var(--bg) 90%, var(--fg));
--fg: var(--color-text-inverted);
background-color: var(--bg);
border-radius: var(--radius-round);
color: var(--fg);
transition:
background-color 200ms,
color 200ms;
&:hover {
background-color: var(--bg-hover);
}
&:active {
background-color: color-mix(in srgb, var(--bg-hover) 80%, var(--fg));
}
&.accent {
--bg: var(--color-bg-brand-base);
--bg-hover: var(--color-bg-brand-base-hover);
}
&.tonal {
.neutral {
// This technically is a duplicate, but it's added so TS realizes this class is an option.
--bg: var(--color-bg-inverted);
--fg: var(--color-text-inverted);
}
&.tonal:not(:active) {
--bg: var(--color-bg-highlight);
--fg: var(--color-text-primary);
}
@@ -97,41 +96,62 @@ a.base {
--bg-hover: var(--color-bg-error-base-hover);
}
&:disabled {
&.solid:disabled {
--bg: var(--color-bg-disabled);
--bg-hover: var(--bg);
--fg: var(--color-text-primary);
--fg: var(--color-text-on-disabled);
}
}
.text {
// Ghost
.ghost {
&:active {
--bg: var(--color-bg-inverted);
--fg: var(--color-text-inverted);
}
&.accent {
--fg: var(--color-text-brand);
&:hover {
--fg: var(--color-text-brand-soft);
}
}
&.neutral,
&.tonal {
&:hover {
--fg: rgb(from var(--color-text-primary) r g b / 80%);
&:active {
--bg: var(--color-bg-brand-base);
--fg: var(--color-text-on-brand-base);
}
}
&.destructive {
--fg: var(--color-text-error);
&:active {
--fg: var(--color-text-on-error-base);
--bg: var(--color-bg-error-base);
}
}
&:disabled,
&:hover:disabled {
--fg: var(--color-text-disabled);
--bg: transparent;
--bg-hover: transparent;
}
}
// Helper classes
.icon {
width: var(--fs-lg);
width: 1em;
height: 1em;
}
// Adds padding to the text label. This is supposed to be there even if there is no icon.
.content {
display: inline-block;
margin: 0 var(--space-2xs);
.xs & {
margin: 0 var(--space-3xs);
}
}
.iconOnly {
@@ -44,7 +44,7 @@ const meta = {
},
variant: {
control: 'inline-radio',
options: ['solid', 'text'],
options: ['solid', 'ghost'],
},
color: {
control: 'inline-radio',
@@ -14,7 +14,7 @@ import classes from './redesign.module.scss';
interface ButtonPropsBase<As extends 'a' | 'button'> {
size?: 'lg' | 'md' | 'sm' | 'xs';
variant?: 'solid' | 'text';
variant?: 'solid' | 'ghost';
color?: 'accent' | 'neutral' | 'tonal' | 'destructive';
onClick?: React.MouseEventHandler<
As extends 'button' ? HTMLButtonElement : HTMLAnchorElement
@@ -35,7 +35,7 @@ type ButtonProps = ButtonButtonProps | ButtonAnchorProps | ButtonLinkProps;
const BaseButton: React.FC<ButtonProps> = ({
size = 'md',
variant = 'solid',
color = 'neutral',
color = 'tonal',
as: asComp = 'button',
children,
className,
@@ -100,7 +100,7 @@ export const Button: React.FC<
<Icon id='leading' icon={leadingIcon} className={classes.icon} />
)}
{props.loading && <LoadingIcon />}
{children}
<span className={classes.content}>{children}</span>
{trailingIcon && (
<Icon id='trailing' icon={trailingIcon} className={classes.icon} />
)}