-
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
e0e9af6
commit 7f4846a
Showing
53 changed files
with
1,900 additions
and
743 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 was deleted.
Oops, something went wrong.
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,63 @@ | ||
import { ComponentProps, PropsWithChildren, useEffect, 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 group-data-[disabled]:hidden'; | ||
|
||
const LegendGroup = ({ | ||
title, | ||
children, | ||
defaultOpen = true, | ||
className, | ||
disabled = false, | ||
...props | ||
}: PropsWithChildren< | ||
ComponentProps<typeof Collapsible> & { | ||
title: string; | ||
} | ||
>): JSX.Element => { | ||
const [isOpen, setOpen] = useState(defaultOpen && !disabled); | ||
|
||
useEffect(() => { | ||
if (!disabled && defaultOpen) setOpen(true); | ||
}, [disabled, defaultOpen]); | ||
|
||
return ( | ||
<Collapsible | ||
defaultOpen={defaultOpen && !disabled} | ||
onOpenChange={setOpen} | ||
className={cn({ | ||
group: true, | ||
[className]: Boolean(className), | ||
})} | ||
disabled={disabled} | ||
open={isOpen} | ||
{...props} | ||
> | ||
<CollapsibleTrigger className="py-2"> | ||
<header | ||
className={cn({ | ||
'flex items-center space-x-1': true, | ||
'group-data-[disabled]:pl-4': true, | ||
})} | ||
> | ||
{isOpen ? ( | ||
<HiChevronUp className={ICON_COMMON_CLASSES} /> | ||
) : ( | ||
<HiChevronDown className={ICON_COMMON_CLASSES} /> | ||
)} | ||
<h4 className="text-sm font-semibold group-data-[disabled]:text-gray-300 group-data-[state=open]:text-blue-400"> | ||
{title} | ||
</h4> | ||
</header> | ||
</CollapsibleTrigger> | ||
<CollapsibleContent>{children}</CollapsibleContent> | ||
</Collapsible> | ||
); | ||
}; | ||
|
||
export default LegendGroup; |
This file was deleted.
Oops, something went wrong.
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,54 @@ | ||
import React, { useMemo, Children, isValidElement, PropsWithChildren } from 'react'; | ||
|
||
import { ScrollArea } from 'components/scroll-area'; | ||
import { cn } from 'utils/cn'; | ||
|
||
import SortableList from './sortable/list'; | ||
|
||
export const Legend = ({ | ||
open, | ||
children, | ||
className = '', | ||
sortable, | ||
onChangeOrder, | ||
}: PropsWithChildren<{ | ||
open: boolean; | ||
className?: string; | ||
sortable?: { | ||
enabled: boolean; | ||
handle: boolean; | ||
handleIcon: React.ReactNode; | ||
}; | ||
onChangeOrder?: (id: string[]) => void; | ||
onChangeOpen?: (open: boolean) => void; | ||
}>): JSX.Element => { | ||
const isChildren = useMemo(() => { | ||
return !!Children.count(Children.toArray(children).filter((c) => isValidElement(c))); | ||
}, [children]); | ||
|
||
return ( | ||
<div | ||
className={cn({ | ||
'flex flex-col': true, | ||
hidden: !isChildren, | ||
[className]: !!className, | ||
})} | ||
> | ||
{open && ( | ||
<ScrollArea className="relative flex w-full flex-col rounded-3xl bg-black px-2 py-2 before:pointer-events-none before:absolute before:left-0 before:top-0 before:z-10 before:h-6 before:w-full before:bg-gradient-to-b before:from-black before:via-black after:pointer-events-none after:absolute after:bottom-0 after:left-0 after:z-10 after:h-6 after:w-full after:bg-gradient-to-t after:from-black after:via-black"> | ||
<div className="divide-y divide-gray-600 divide-opacity-50 py-2"> | ||
{!!sortable && ( | ||
<SortableList sortable={sortable} onChangeOrder={onChangeOrder}> | ||
{children} | ||
</SortableList> | ||
)} | ||
|
||
{!sortable && children} | ||
</div> | ||
</ScrollArea> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Legend; |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
export type LegendItemType = 'matrix' | 'basic' | 'choropleth' | 'gradient'; |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.