feat(ui): add xs button type

This commit is contained in:
Brian McGee
2025-08-18 11:17:44 +01:00
parent 683ffbdc76
commit f7f897a311
3 changed files with 90 additions and 9 deletions

View File

@@ -1,17 +1,12 @@
.button { .button {
@apply flex gap-2 shrink-0 items-center justify-center; @apply flex gap-2 shrink-0 items-center justify-center;
@apply px-4 py-2; @apply h-[2.125rem] px-4 py-2 rounded-[0.1875rem];
height: theme(height.9);
border-radius: 3px;
/* Add transition for smooth width animation */ /* Add transition for smooth width animation */
transition: width 0.5s ease 0.1s; transition: width 0.5s ease 0.1s;
&.s { &.s {
@apply px-3 py-1.5; @apply h-[1.625rem] px-3 py-1.5 rounded-[0.125rem];
height: theme(height.7);
border-radius: 2px;
&:has(> .icon-start):has(> .label) { &:has(> .icon-start):has(> .label) {
@apply pl-2; @apply pl-2;
@@ -22,6 +17,18 @@
} }
} }
&.xs {
@apply h-[1.125rem] gap-0.5 p-2 rounded-[0.125rem];
&:has(> .icon-start):has(> .label) {
@apply pl-1.5;
}
&:has(> .icon-end):has(> .label) {
@apply pr-1.5;
}
}
&.primary { &.primary {
@apply bg-inv-acc-4 fg-inv-1; @apply bg-inv-acc-4 fg-inv-1;
@apply border border-solid border-inv-4; @apply border border-solid border-inv-4;

View File

@@ -8,7 +8,7 @@ const getCursorStyle = (el: Element) => window.getComputedStyle(el).cursor;
const ButtonExamples: Component<ButtonProps> = (props) => ( const ButtonExamples: Component<ButtonProps> = (props) => (
<> <>
<div class="grid w-fit grid-cols-4 gap-8"> <div class="grid w-fit grid-cols-6 gap-8">
<div> <div>
<Button data-testid="default" {...props}> <Button data-testid="default" {...props}>
Label Label
@@ -19,6 +19,11 @@ const ButtonExamples: Component<ButtonProps> = (props) => (
Label Label
</Button> </Button>
</div> </div>
<div>
<Button data-testid="xsmall" size="xs" {...props}>
Label
</Button>
</div>
<div> <div>
<Button data-testid="default-disabled" {...props} disabled={true}> <Button data-testid="default-disabled" {...props} disabled={true}>
Disabled Disabled
@@ -35,6 +40,18 @@ const ButtonExamples: Component<ButtonProps> = (props) => (
</Button> </Button>
</div> </div>
<div>
<Button
data-testid="xsmall-disabled"
{...props}
disabled={true}
size="xs"
>
Disabled
</Button>
</div>
<div> <div>
<Button data-testid="default-start-icon" {...props} startIcon="Flash"> <Button data-testid="default-start-icon" {...props} startIcon="Flash">
Label Label
@@ -50,6 +67,16 @@ const ButtonExamples: Component<ButtonProps> = (props) => (
Label Label
</Button> </Button>
</div> </div>
<div>
<Button
data-testid="xsmall-start-icon"
{...props}
startIcon="Flash"
size="xs"
>
Label
</Button>
</div>
<div> <div>
<Button <Button
data-testid="default-disabled-start-icon" data-testid="default-disabled-start-icon"
@@ -72,6 +99,18 @@ const ButtonExamples: Component<ButtonProps> = (props) => (
</Button> </Button>
</div> </div>
<div>
<Button
data-testid="xsmall-disabled-start-icon"
{...props}
startIcon="Flash"
size="xs"
disabled={true}
>
Disabled
</Button>
</div>
<div> <div>
<Button data-testid="default-end-icon" {...props} endIcon="Flash"> <Button data-testid="default-end-icon" {...props} endIcon="Flash">
Label Label
@@ -87,6 +126,16 @@ const ButtonExamples: Component<ButtonProps> = (props) => (
Label Label
</Button> </Button>
</div> </div>
<div>
<Button
data-testid="xsmall-end-icon"
{...props}
endIcon="Flash"
size="xs"
>
Label
</Button>
</div>
<div> <div>
<Button <Button
data-testid="default-disabled-end-icon" data-testid="default-disabled-end-icon"
@@ -108,12 +157,27 @@ const ButtonExamples: Component<ButtonProps> = (props) => (
Disabled Disabled
</Button> </Button>
</div> </div>
<div>
<Button
data-testid="xsmall-disabled-end-icon"
{...props}
endIcon="Flash"
size="xs"
disabled={true}
>
Disabled
</Button>
</div>
<div> <div>
<Button data-testid="default-icon" {...props} icon="Flash" /> <Button data-testid="default-icon" {...props} icon="Flash" />
</div> </div>
<div> <div>
<Button data-testid="small-icon" {...props} icon="Flash" size="s" /> <Button data-testid="small-icon" {...props} icon="Flash" size="s" />
</div> </div>
<div>
<Button data-testid="xsmall-icon" {...props} icon="Flash" size="xs" />
</div>
<div> <div>
<Button <Button
data-testid="default-disabled-icon" data-testid="default-disabled-icon"
@@ -131,6 +195,15 @@ const ButtonExamples: Component<ButtonProps> = (props) => (
size="s" size="s"
/> />
</div> </div>
<div>
<Button
data-testid="xsmall-disabled-icon"
{...props}
icon="Flash"
disabled={true}
size="xs"
/>
</div>
</div> </div>
</> </>
); );

View File

@@ -7,7 +7,7 @@ import "./Button.css";
import Icon, { IconVariant } from "@/src/components/Icon/Icon"; import Icon, { IconVariant } from "@/src/components/Icon/Icon";
import { Loader } from "@/src/components/Loader/Loader"; import { Loader } from "@/src/components/Loader/Loader";
export type Size = "default" | "s"; export type Size = "default" | "s" | "xs";
export type Hierarchy = "primary" | "secondary"; export type Hierarchy = "primary" | "secondary";
export type Action = () => Promise<void>; export type Action = () => Promise<void>;
@@ -28,6 +28,7 @@ export interface ButtonProps
const iconSizes: Record<Size, string> = { const iconSizes: Record<Size, string> = {
default: "1rem", default: "1rem",
s: "0.8125rem", s: "0.8125rem",
xs: "0.625rem",
}; };
export const Button = (props: ButtonProps) => { export const Button = (props: ButtonProps) => {