About
So I was working on this Sidebar for Choc UI😋, and I wanted to create a dropdown - that type you use for Sub Menu Items.
I decided to do this with a Transition transition element, then i thought, this requires keeping a Transitiond state; best done with the useDisclosure Hook.
But then I thought, if I'm going to have several dropdowns, this means several state objects. Why not create a component that manages them internally.
But now, this is going to be reusable, so why not make it into a package, and here we are.
Long Story Short, this is a collection of Chakra Components that have been fussed to meet some specific needs.
Components
Transition
Helps control any Transition component's state internally.
Basic Usage
The Transition
Component accepts all props composed by the type
Set defaultIsOpen
prop to set initial state toin
as true.
<Transition type="{Collapse}" animateOpacity>
<TransitionTrigger>Integrations</TransitionTrigger>
<TransitionContent>
<VStack>
<span>Slack </span>
<span>Jira</span>
<span>Discord</span>
</VStack>
</TransitionContent>
</Transition>
With Internal State
<Transition type={Collapse} animateOpacity>
{({ isOpen, onToggle }) => (
<>
<TransitionTrigger onClick={onToggle}>Integrations</TransitionTrigger>
<TransitionContent>
<VStack>
<span>Slack {isOpen ? "open" : "close"} </span>
<span>Jira</span>
<span>Discord</span>
</VStack>
</TransitionContent>
</>
)}
</Transition>
Hooks
useObjectMemo
Thanks to @dodas
Used to memoize object depending on its values.
The object will be recreated only it some property value changes.
useObjectMemo({ a, b, c })
useMemo(() => ({ a, b, c }), [a, b, c])