'use client'; import { ChevronRight } from 'lucide-react'; import { useState } from 'react'; import { cn } from '@djangocfg/ui-core/lib'; import type { ApiEndpoint } from '../../../../types'; import { ResponseBody } from './ResponseBody'; import { StatusTag } from './StatusTag'; interface ResponseRowProps { response: NonNullable[number]; } /** One status-code row in the Responses section. * * Layout: * - Chevron column only renders when there's an example to expand. * Otherwise the row is inert (no button wrapper, no hover state) * and the space stays tight instead of reserving an empty gutter * under a disabled chevron. * - Status tag column is ``48px`` wide — enough for ``default`` and * 3-digit codes in the font size we use. Keeps descriptions * aligned on their left edge across all rows regardless of code. * * Expansion defaults: * - 2xx with example → open (happy-path is what readers want first). * - Everything else → closed, one click to inspect. */ export function ResponseRow({ response }: ResponseRowProps) { const hasExample = Boolean(response.example); const numeric = Number.parseInt(response.code, 10); const isSuccess = Number.isFinite(numeric) && numeric >= 200 && numeric < 300; const [open, setOpen] = useState(hasExample && isSuccess); // Inert row (no example available) — render as a plain div so the // layout stays identical but without button affordances. if (!hasExample) { return (
{response.description}
); } return (
{open && ( )}
); }