-
-
Notifications
You must be signed in to change notification settings - Fork 170
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
2c0a8e3
commit 2c0c861
Showing
6 changed files
with
54 additions
and
50 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 |
---|---|---|
@@ -1,29 +1,24 @@ | ||
import * as dialog from "@zag-js/dialog" | ||
import { Portal, normalizeProps, useMachine } from "@zag-js/react" | ||
import { useState } from "react" | ||
|
||
export default function Dialog() { | ||
const [nextContent, setNextContent] = useState(false) | ||
const [state, send] = useMachine(dialog.machine({ id: "1" })) | ||
const api = dialog.connect(state, send, normalizeProps) | ||
|
||
return ( | ||
<main> | ||
<button {...api.getTriggerProps()}> Click me</button> | ||
{api.open && ( | ||
<Portal> | ||
<div {...api.getBackdropProps()} /> | ||
<div {...api.getPositionerProps()}> | ||
<div {...api.getContentProps()}> | ||
<h2 {...api.getTitleProps()}>Edit profile</h2> | ||
<p {...api.getDescriptionProps()}>Make changes to your profile here. Click save when you are done.</p> | ||
<div> | ||
<input placeholder="Enter name..." /> | ||
<button>Save</button> | ||
</div> | ||
<button {...api.getCloseTriggerProps()}>Close</button> | ||
</div> | ||
<Portal> | ||
<div {...api.getBackdropProps()} /> | ||
<div {...api.getPositionerProps()}> | ||
<div {...api.getContentProps()}> | ||
{!nextContent && <button onClick={() => setNextContent(true)}>Set next content</button>} | ||
{nextContent && <button onClick={() => setNextContent(false)}>Set previous content</button>} | ||
</div> | ||
</Portal> | ||
)} | ||
</div> | ||
</Portal> | ||
</main> | ||
) | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.