feat: adopt kumo green ui system

This commit is contained in:
2026-07-02 07:12:31 -07:00
parent 4bb4312b08
commit 0f0bd8813d
32 changed files with 1453 additions and 796 deletions

View File

@@ -1,50 +1,59 @@
import * as React from "react";
import { Slot } from "@radix-ui/react-slot";
import { cva, type VariantProps } from "class-variance-authority";
import {
Button as KumoButton,
LinkButton as KumoLinkButton,
type ButtonProps as KumoButtonProps,
type LinkButtonProps as KumoLinkButtonProps,
} from "@cloudflare/kumo/components/button";
import { cn } from "@/lib/utils";
type ButtonVariant = "default" | "secondary" | "outline" | "ghost" | "destructive";
type ButtonSize = "default" | "sm" | "lg" | "icon";
const buttonVariants = cva(
"inline-flex min-h-11 shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0",
{
variants: {
variant: {
default: "bg-primary text-primary-foreground hover:bg-primary/90",
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
outline: "border bg-background hover:bg-accent hover:text-accent-foreground",
ghost: "hover:bg-accent hover:text-accent-foreground",
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
},
size: {
default: "h-11 px-4 py-2",
sm: "h-9 min-h-9 px-3",
lg: "h-12 px-6",
icon: "h-11 w-11",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
},
);
const variantMap: Record<ButtonVariant, KumoButtonProps["variant"]> = {
default: "primary",
secondary: "secondary",
outline: "outline",
ghost: "ghost",
destructive: "destructive",
};
export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
asChild?: boolean;
}
const sizeMap: Record<ButtonSize, KumoButtonProps["size"]> = {
default: "base",
sm: "sm",
lg: "lg",
icon: "base",
};
export function Button({
className,
variant,
size,
asChild = false,
...props
}: ButtonProps): React.ReactElement {
const Comp = asChild ? Slot : "button";
export type ButtonProps = Omit<KumoButtonProps, "variant" | "size" | "shape"> & {
variant?: ButtonVariant;
size?: ButtonSize;
};
return <Comp className={cn(buttonVariants({ variant, size, className }))} {...props} />;
}
export type LinkButtonProps = Omit<KumoLinkButtonProps, "variant" | "size"> & {
variant?: ButtonVariant;
size?: Exclude<ButtonSize, "icon">;
};
export { buttonVariants };
export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Button(
{ variant = "default", size = "default", ...props },
ref,
): React.ReactElement {
const kumoProps = {
ref,
shape: size === "icon" ? "square" : "base",
size: sizeMap[size],
variant: variantMap[variant],
...props,
} as KumoButtonProps & React.RefAttributes<HTMLButtonElement>;
return (
<KumoButton {...kumoProps} />
);
});
export const LinkButton = React.forwardRef<HTMLAnchorElement, LinkButtonProps>(function LinkButton(
{ variant = "default", size = "default", ...props },
ref,
): React.ReactElement {
return <KumoLinkButton ref={ref} size={sizeMap[size]} variant={variantMap[variant]} {...props} />;
});