-
-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(dialog): update nested dialog css performance and fix disabled …
…transitions
- Loading branch information
Showing
9 changed files
with
188 additions
and
17 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
apps/docs/src/app/(main)/(markdown)/(demos)/components/dialog/NestedDialogsExample.tsx
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,43 @@ | ||
"use client"; | ||
import { Button } from "@react-md/core/button/Button"; | ||
import { Dialog } from "@react-md/core/dialog/Dialog"; | ||
import { DialogContent } from "@react-md/core/dialog/DialogContent"; | ||
import { DialogFooter } from "@react-md/core/dialog/DialogFooter"; | ||
import { DialogHeader } from "@react-md/core/dialog/DialogHeader"; | ||
import { DialogTitle } from "@react-md/core/dialog/DialogTitle"; | ||
import { useToggle } from "@react-md/core/useToggle"; | ||
import { type ReactElement } from "react"; | ||
|
||
export default function NestedDialogsExample(): ReactElement { | ||
const { toggle, toggled } = useToggle(); | ||
return <InfiniteDialog key={`${toggled}`} depth={0} closeAll={toggle} />; | ||
} | ||
|
||
interface InfiniteDialogProps { | ||
depth: number; | ||
closeAll(): void; | ||
} | ||
|
||
function InfiniteDialog(props: InfiniteDialogProps): ReactElement { | ||
const { depth, closeAll } = props; | ||
const { enable: show, disable: hide, toggled: visible } = useToggle(); | ||
|
||
return ( | ||
<> | ||
<Button onClick={show}>Show</Button> | ||
<Dialog aria-label="Dialog" visible={visible} onRequestClose={hide}> | ||
<DialogHeader> | ||
<DialogTitle>Dialog Depth {depth}</DialogTitle> | ||
</DialogHeader> | ||
<DialogContent> | ||
<InfiniteDialog depth={depth + 1} closeAll={closeAll} /> | ||
</DialogContent> | ||
<DialogFooter> | ||
<Button theme="error" onClick={closeAll}> | ||
Close All | ||
</Button> | ||
</DialogFooter> | ||
</Dialog> | ||
</> | ||
); | ||
} |
51 changes: 51 additions & 0 deletions
51
.../docs/src/app/(main)/(markdown)/(demos)/components/dialog/NestedDialogsVisibleExample.tsx
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,51 @@ | ||
"use client"; | ||
import { Button } from "@react-md/core/button/Button"; | ||
import { Dialog } from "@react-md/core/dialog/Dialog"; | ||
import { DialogContent } from "@react-md/core/dialog/DialogContent"; | ||
import { DialogFooter } from "@react-md/core/dialog/DialogFooter"; | ||
import { DialogHeader } from "@react-md/core/dialog/DialogHeader"; | ||
import { DialogTitle } from "@react-md/core/dialog/DialogTitle"; | ||
import { useToggle } from "@react-md/core/useToggle"; | ||
import { useEffect, type ReactElement } from "react"; | ||
|
||
export default function NestedDialogsVisibleExample(): ReactElement { | ||
const { toggle, toggled } = useToggle(); | ||
return <InfiniteDialog key={`${toggled}`} depth={0} closeAll={toggle} />; | ||
} | ||
|
||
interface InfiniteDialogProps { | ||
depth: number; | ||
closeAll(): void; | ||
} | ||
|
||
function InfiniteDialog(props: InfiniteDialogProps): ReactElement { | ||
const { depth, closeAll } = props; | ||
|
||
const defaultVisible = depth > 0 && depth < 3; | ||
// try setting `useToggle(defaultVisible)` to see the difference | ||
const { enable: show, disable: hide, toggled: visible } = useToggle(); | ||
useEffect(() => { | ||
if (defaultVisible) { | ||
show(); | ||
} | ||
}, [defaultVisible, show]); | ||
|
||
return ( | ||
<> | ||
<Button onClick={show}>Show</Button> | ||
<Dialog aria-label="Dialog" visible={visible} onRequestClose={hide}> | ||
<DialogHeader> | ||
<DialogTitle>Dialog Depth {depth}</DialogTitle> | ||
</DialogHeader> | ||
<DialogContent> | ||
<InfiniteDialog depth={depth + 1} closeAll={closeAll} /> | ||
</DialogContent> | ||
<DialogFooter> | ||
<Button theme="error" onClick={closeAll}> | ||
Close All | ||
</Button> | ||
</DialogFooter> | ||
</Dialog> | ||
</> | ||
); | ||
} |
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
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
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