import type { TailwindSize } from "./types" import "hono/jsx" import type { FC, PropsWithChildren, JSX } from "hono/jsx" import { Grid } from "./grid" import { Section } from "./section" import { H2 } from "./text" import { RedBox, GreenBox, BlueBox } from "./box" import { CodeExamples } from "./code" export const VStack: FC = (props) => { return ( {props.children} ) } export const HStack: FC = (props) => { return ( {props.children} ) } const Stack: FC = (props) => { const gapPx = props.gap ? props.gap * 4 : 0 const baseStyles: JSX.CSSProperties = { display: "flex", flexDirection: props.direction === "row" ? "row" : "column", flexWrap: props.wrap ? "wrap" : "nowrap", gap: `${gapPx}px`, } if (props.mainAxis) { baseStyles.justifyContent = getJustifyContent(props.mainAxis) } if (props.crossAxis) { baseStyles.alignItems = getAlignItems(props.crossAxis) } const combinedStyles = { ...baseStyles, ...props.style, } return
{props.children}
} export const Test = () => { const mainAxisOpts: MainAxisOpts[] = ["start", "center", "end", "between", "around", "evenly"] const crossAxisOpts: CrossAxisOpts[] = ["start", "center", "end", "stretch", "baseline"] return (
{/* API Usage Examples */} ...', '...', '...', '...', ]} /> {/* HStack layout matrix */}

HStack Layout

{/* Header row: blank + h labels */}
{mainAxisOpts.map((h) => (
h: {h}
))} {/* Each row: v label + HStack cells */} {crossAxisOpts.map((v) => [
v: {v}
, ...mainAxisOpts.map((h) => ( Aa Aa Aa )), ])}
{/* VStack layout matrix */}

VStack Layout

{/* Header row: blank + h labels */}
{crossAxisOpts.map((h) => (
h: {h}
))} {/* Each row: v label + VStack cells */} {mainAxisOpts.map((v) => [
v: {v}
, ...crossAxisOpts.map((h) => ( Aa Aa Aa )), ])}
) } type StackDirection = "row" | "col" type StackProps = { direction: StackDirection mainAxis?: string crossAxis?: string wrap?: boolean gap?: TailwindSize class?: string style?: JSX.CSSProperties children?: any } type MainAxisOpts = "start" | "center" | "end" | "between" | "around" | "evenly" type CrossAxisOpts = "start" | "center" | "end" | "stretch" | "baseline" type CommonStackProps = PropsWithChildren & { wrap?: boolean gap?: TailwindSize class?: string style?: JSX.CSSProperties } type VStackProps = CommonStackProps & { v?: MainAxisOpts // main axis for vertical stack h?: CrossAxisOpts // cross axis for vertical stack } type HStackProps = CommonStackProps & { h?: MainAxisOpts // main axis for horizontal stack v?: CrossAxisOpts // cross axis for horizontal stack } function getJustifyContent(axis: string): string { const map: Record = { start: "flex-start", center: "center", end: "flex-end", between: "space-between", around: "space-around", evenly: "space-evenly", } return map[axis] || "flex-start" } function getAlignItems(axis: string): string { const map: Record = { start: "flex-start", center: "center", end: "flex-end", stretch: "stretch", baseline: "baseline", } return map[axis] || "stretch" }