feat(dashboard): SO cart item total rules UI (#10386)

This commit is contained in:
Kasper Fabricius Kristensen
2024-12-09 09:44:11 +01:00
committed by GitHub
parent 9e797dc3d2
commit a1a1e0e789
33 changed files with 1947 additions and 190 deletions
@@ -13,12 +13,20 @@ type StackedFocusModalProps = PropsWithChildren<{
* when multiple stacked modals are registered to the same parent modal.
*/
id: string
/**
* An optional callback that is called when the modal is opened or closed.
*/
onOpenChangeCallback?: (open: boolean) => void
}>
/**
* A stacked modal that can be rendered above a parent modal.
*/
export const Root = ({ id, children }: StackedFocusModalProps) => {
export const Root = ({
id,
onOpenChangeCallback,
children,
}: StackedFocusModalProps) => {
const { register, unregister, getIsOpen, setIsOpen } = useStackedModal()
useEffect(() => {
@@ -28,11 +36,13 @@ export const Root = ({ id, children }: StackedFocusModalProps) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
const handleOpenChange = (open: boolean) => {
setIsOpen(id, open)
onOpenChangeCallback?.(open)
}
return (
<FocusModal
open={getIsOpen(id)}
onOpenChange={(open) => setIsOpen(id, open)}
>
<FocusModal open={getIsOpen(id)} onOpenChange={handleOpenChange}>
{children}
</FocusModal>
)