-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
829e1ea
commit 718066f
Showing
18 changed files
with
615 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible'; | ||
|
||
const Collapsible = CollapsiblePrimitive.Root; | ||
|
||
const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger; | ||
|
||
const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent; | ||
|
||
export { Collapsible, CollapsibleTrigger, CollapsibleContent }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { ComponentProps, PropsWithChildren, useState } from 'react'; | ||
|
||
import { HiChevronDown, HiChevronUp } from 'react-icons/hi'; | ||
|
||
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from 'components/collapsible'; | ||
import { cn } from 'utils/cn'; | ||
|
||
const ICON_COMMON_CLASSES = 'text-white group-data-[state=open]:text-blue-400'; | ||
|
||
const LegendGroup = ({ | ||
title, | ||
children, | ||
defaultOpen = false, | ||
className, | ||
}: PropsWithChildren< | ||
Pick<ComponentProps<typeof Collapsible>, 'defaultOpen' | 'className'> & { | ||
title: string; | ||
} | ||
>): JSX.Element => { | ||
const [isOpen, setOpen] = useState(defaultOpen); | ||
|
||
return ( | ||
<Collapsible | ||
defaultOpen={defaultOpen} | ||
onOpenChange={setOpen} | ||
className={cn({ | ||
[className]: Boolean(className), | ||
})} | ||
> | ||
<CollapsibleTrigger className="group py-2"> | ||
<header className="flex items-center space-x-1"> | ||
{isOpen ? ( | ||
<HiChevronUp className={ICON_COMMON_CLASSES} /> | ||
) : ( | ||
<HiChevronDown className={ICON_COMMON_CLASSES} /> | ||
)} | ||
<h4 className="text-sm font-semibold group-data-[state=open]:text-blue-400">{title}</h4> | ||
</header> | ||
</CollapsibleTrigger> | ||
<CollapsibleContent>{children}</CollapsibleContent> | ||
</Collapsible> | ||
); | ||
}; | ||
|
||
export default LegendGroup; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.