-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clean up
- Loading branch information
Showing
5 changed files
with
152 additions
and
57 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
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,77 @@ | ||
import { ChevronDownIcon, ChevronUpIcon } from '@chakra-ui/icons'; | ||
import { | ||
Button, | ||
Checkbox, | ||
Flex, | ||
Popover, | ||
PopoverBody, | ||
PopoverContent, | ||
PopoverTrigger, | ||
Text, | ||
useDisclosure, | ||
} from '@chakra-ui/react'; | ||
|
||
import { SortBy } from './QuestChains'; | ||
|
||
const SortDropdown: React.FC<{ | ||
sortBy: Record<SortBy, boolean>; | ||
setSortBy: (value: Record<SortBy, boolean>) => void; | ||
label: string; | ||
}> = ({ sortBy, setSortBy, label }) => { | ||
const { onOpen, onClose, isOpen } = useDisclosure(); | ||
|
||
return ( | ||
<Popover | ||
placement="bottom-start" | ||
isOpen={isOpen} | ||
onOpen={onOpen} | ||
onClose={onClose} | ||
> | ||
<PopoverTrigger> | ||
<Button | ||
gap={3} | ||
fontSize={14} | ||
fontWeight="bold" | ||
bgColor="whiteAlpha.100" | ||
borderRadius={24} | ||
// borderColor="transparent" | ||
> | ||
<Text>{label}</Text> | ||
{isOpen ? <ChevronUpIcon /> : <ChevronDownIcon />} | ||
</Button> | ||
</PopoverTrigger> | ||
<PopoverContent bgColor="#0F172A" maxW={200}> | ||
{/* <PopoverArrow /> */} | ||
<PopoverBody gap={2}> | ||
<Flex direction="column" gap={3}> | ||
{Object.keys(sortBy).map((item, index) => { | ||
return ( | ||
<Flex justifyContent="space-between" key={index}> | ||
<Text fontSize="sm">{item}</Text> | ||
<Checkbox | ||
isChecked={sortBy[item as SortBy]} | ||
variant="circular" | ||
fontSize="xs" | ||
onChange={() => | ||
setSortBy({ | ||
...sortBy, | ||
// set the item that was previously true to false | ||
[Object.keys(sortBy).find( | ||
key => sortBy[key as SortBy], | ||
) as SortBy]: false, | ||
// set the item that was clicked to true | ||
[item as SortBy]: !sortBy[item as SortBy], | ||
}) | ||
} | ||
/> | ||
</Flex> | ||
); | ||
})} | ||
</Flex> | ||
</PopoverBody> | ||
</PopoverContent> | ||
</Popover> | ||
); | ||
}; | ||
|
||
export default SortDropdown; |
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,35 @@ | ||
import { checkboxAnatomy } from '@chakra-ui/anatomy'; | ||
import { createMultiStyleConfigHelpers, defineStyle } from '@chakra-ui/react'; | ||
|
||
const { definePartsStyle, defineMultiStyleConfig } = | ||
createMultiStyleConfigHelpers(checkboxAnatomy.keys); | ||
|
||
const circular = definePartsStyle({ | ||
control: defineStyle({ | ||
rounded: 'full', | ||
borderWidth: '1.5px', | ||
padding: '0.5rem', | ||
transform: 'scale(0.9)', | ||
}), | ||
}); | ||
|
||
const baseStyle = definePartsStyle({ | ||
control: { | ||
borderWidth: '1.5px', | ||
_checked: { | ||
backgroundColor: 'transparent', | ||
borderWidth: '1.5px', | ||
color: 'white', | ||
_hover: { | ||
bg: 'transparent', | ||
borderColor: 'white', | ||
}, | ||
borderColor: 'white', | ||
}, | ||
}, | ||
}); | ||
|
||
export const checkboxTheme = defineMultiStyleConfig({ | ||
baseStyle, | ||
variants: { circular }, | ||
}); |
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