diff --git a/src/components/Collapse/Collapse.css b/src/components/Collapse/Collapse.css new file mode 100644 index 0000000..851851c --- /dev/null +++ b/src/components/Collapse/Collapse.css @@ -0,0 +1,30 @@ +.collapse { + width: 100%; +} + +.collapse-summary { + color: var(--codex-color-primary); + font-weight: 600; + cursor: pointer; + display: flex; + align-items: center; + gap: 0.5rem; +} + +.collapse-summary:hover { + text-decoration: underline; + opacity: 0.7; + text-decoration-thickness: 2px; +} + +.collapse-details { + max-height: 0; + transition: max-height 0.2s; + overflow: hidden; + word-break: break-word; + color: var(--codex-color); +} + +.collapse-details[aria-expanded] { + max-height: 50px; +} diff --git a/src/components/Collapse/Collapse.tsx b/src/components/Collapse/Collapse.tsx new file mode 100644 index 0000000..e3cd96f --- /dev/null +++ b/src/components/Collapse/Collapse.tsx @@ -0,0 +1,46 @@ +import { useState } from "react"; +import "./Collapse.css"; +import { attributes } from "../utils/attributes"; + +type Props = { + summary: string; + details: string; + className?: string; +}; + +export function Collapse({ summary, details, className = "" }: Props) { + const [expanded, setExpanded] = useState(false); + + const onClick = () => setExpanded(!expanded); + + return ( +