27 lines
1.2 KiB
TypeScript
27 lines
1.2 KiB
TypeScript
import { FeatherChevronDown, FeatherChevronUp } from "@subframe/core"
|
|
import { useTranslation } from "react-i18next"
|
|
|
|
interface Props {
|
|
open: boolean
|
|
setOpen: React.Dispatch<React.SetStateAction<boolean>>
|
|
}
|
|
|
|
// Unlike the other icons in this folder, this is a stateful toggle button (not a
|
|
// bare `{ className }` icon). It keeps its public `{ open, setOpen }` API so its
|
|
// only call site (tables/CollapsibleRow) stays unchanged, but renders Subframe
|
|
// Feather chevrons instead of the previous hand-authored SVGs.
|
|
export default function OpenCloseArrowIcon({ open, setOpen }: Props) {
|
|
const { t } = useTranslation()
|
|
const Chevron = open ? FeatherChevronUp : FeatherChevronDown
|
|
return (
|
|
<button
|
|
type="button"
|
|
onClick={() => setOpen(!open)}
|
|
aria-label={open ? t("shared.collapse") : t("shared.expand")}
|
|
className="hover:bg-secondary hover:border-border text-muted-foreground bg-background inline-flex w-full justify-center rounded-md border border-transparent p-1 text-sm font-medium hover:shadow-2xs focus:outline-hidden"
|
|
>
|
|
<Chevron className="text-muted-foreground inline-flex size-5 shrink-0 [&>svg]:size-full" />
|
|
</button>
|
|
)
|
|
}
|