import * as stylex from "@stylexjs/stylex"; import { type ComponentPropsWithoutRef, createElement, type HTMLAttributes, type Ref } from "react"; import { type Color, colors, fonts, motion, type Radius, radius, type Space, space, } from "./tokens.stylex"; type Container = | "div" | "main" | "section" | "article" | "aside" | "header" | "footer" | "nav" | "ul" | "ol" | "li"; type Native = Omit< ComponentPropsWithoutRef, "className" | "style" | "color" >; export type BoxProps = Native & { as?: T; direction?: "row" | "column"; gap?: Space; padding?: Space; align?: "start" | "center" | "end" | "stretch"; justify?: "start" | "center" | "end" | "between"; wrap?: boolean; background?: Color; border?: boolean; radius?: Radius; }; export function Box({ as, direction = "column", gap = "none", padding = "none", align = "stretch", justify = "start", wrap = false, background, border = false, radius: rounding = "none", ...native }: BoxProps) { return createElement(as ?? "div", { ...native, ...stylex.props( styles.box, directions[direction], gaps[gap], paddings[padding], aligns[align], justifies[justify], wrap && styles.wrap, background && backgrounds[background], border && styles.border, roundings[rounding], ), }); } type TextTag = "span" | "p" | "h1" | "h2" | "h3" | "strong" | "small"; export type TextProps = Omit, "className" | "style" | "color"> & { as?: TextTag; variant?: "body" | "caption" | "label" | "heading" | "title"; color?: "text" | "textMuted" | "brand" | "onBrand" | "danger"; }; export function Text({ as = "span", variant = "body", color = "text", ...native }: TextProps) { return createElement(as, { ...native, ...stylex.props(styles.text, typography[variant], foregrounds[color]), }); } export type ButtonProps = Omit, "className" | "style"> & { variant?: "primary" | "secondary" | "quiet" | "suggestion"; size?: "small" | "medium"; ref?: Ref; }; export function Button({ variant = "primary", size = "medium", type = "button", ...native }: ButtonProps) { return (