style(storybook): refine search and date story layout

This commit is contained in:
shkim4 committed 2026-11-09 16:09:01 +09:00
1 parent 8827eb2681
commit 0ea5b46f74
4 files changed
+117 -79

No files matched your search

+30 -23
View File
@@ -21,10 +21,11 @@ const longOptions: ComboboxOption[] = [
{ value: "b", label: "짧은 옵션" },
]
function Field({ label, id, children }: { label: string; id: string; children: ReactNode }) {
// Label 14/20/500 in the default text color; a Disabled field keeps the secondary color at 0.6 (same as the Form pages).
function Field({ label, id, disabled, children }: { label: string; id: string; disabled?: boolean; children: ReactNode }) {
return (
<div className="grid max-w-xs gap-2">
<label htmlFor={id} className="justify-self-start text-sm font-medium text-muted-foreground">
<label htmlFor={id} className={`justify-self-start text-sm font-medium ${disabled ? "text-muted-foreground opacity-60" : "text-foreground"}`}>
{label}
</label>
{children}
@@ -71,7 +72,7 @@ function LongLabel() {
function Disabled() {
return (
<Field label="비활성" id="cb-disabled">
<Field label="비활성" id="cb-disabled" disabled>
<Combobox id="cb-disabled" options={frameworks} defaultValue="next" disabled />
</Field>
)
@@ -99,22 +100,22 @@ function SelectComparison() {
)
}
const sections = [
{ id: "empty", label: "Placeholder", node: <Empty /> },
{ id: "controlled", label: "Selected", node: <Controlled showValue={false} /> },
{ id: "long", label: "Long option", node: <LongLabel /> },
{ id: "disabled", label: "Disabled", node: <Disabled /> },
]
// Same 3-column track as the Form pages (1 column on narrow screens). Each cell is a one-specimen StateBoard so subtitles, dividers and
// fields line up; sections with fewer specimens leave the remaining tracks empty. A wide cell takes two tracks (the full row on narrow screens).
const Grid = ({ children }: { children: ReactNode }) => (
<div className="grid items-start gap-6 [grid-template-columns:repeat(auto-fill,minmax(min(100%,300px),1fr))] min-[1000px]:grid-cols-3">{children}</div>
)
const Cell = ({ id, label, wide, children }: { id: string; label: string; wide?: boolean; children: ReactNode }) => (
<div className={wide ? "col-span-full min-w-0 min-[1000px]:col-span-2" : "min-w-0"}>
<StateBoard min={10000} states={[{ id, label, children }]} />
</div>
)
// No `component`: Combobox has a required `options` prop, so Stories without args would not type-check.
const meta = { title: "Components/Search & Date/Combobox", parameters: { layout: "padded" } } satisfies Meta
export default meta
type Story = StoryObj<typeof meta>
const board = (...ids: string[]) => (
<StateBoard min={320} states={sections.filter((s) => ids.includes(s.id)).map((s) => ({ id: s.id, label: s.label, children: s.node }))} />
)
// Representative Story: the common Story page; the sections group the same specimens.
export const All: Story = {
name: "Combobox",
@@ -122,18 +123,24 @@ export const All: Story = {
render: () => (
<StoryPage>
<StoryPageHeader title="Combobox" />
<StorySection title="Overview">{board("empty")}</StorySection>
<StorySection title="Sizes">
{/* The field label already names the size, so the Medium specimen has no separate example title. */}
<div className="grid gap-10">
<div className="max-w-sm">
<Medium />
</div>
<StateBoard min={320} states={[{ id: "select-comparison", label: "Select / Combobox", wide: true, children: <SelectComparison /> }]} />
</div>
<Grid>
<Cell id="empty" label="Default"><Empty /></Cell>
<Cell id="medium" label="Medium"><Medium /></Cell>
</Grid>
</StorySection>
<StorySection title="States">
<Grid>
<Cell id="controlled" label="Selected"><Controlled showValue={false} /></Cell>
<Cell id="disabled" label="Disabled"><Disabled /></Cell>
</Grid>
</StorySection>
<StorySection title="Usage">
<Grid>
<Cell id="long" label="Long option"><LongLabel /></Cell>
<Cell id="select-comparison" label="Select / Combobox" wide><SelectComparison /></Cell>
</Grid>
</StorySection>
<StorySection title="States">{board("controlled", "disabled")}</StorySection>
<StorySection title="Usage">{board("long")}</StorySection>
</StoryPage>
),
}