-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
example: update example project, link to local npm package
- Loading branch information
ArielBenichou
committed
Nov 26, 2023
1 parent
3b181e0
commit 7174101
Showing
8 changed files
with
72 additions
and
46 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
@@ -1,46 +1,51 @@ | ||
import { useState } from "react"; | ||
import { useOpenModal } from "@tembell/paresseux" | ||
import useOpenModal from "../../../src/core/useOpenModal"; | ||
import ChooseMathOpModal from "./components/ChooseMathOpModal"; | ||
import NumbersModal from "./components/NumbersModal"; | ||
|
||
function App() { | ||
const openModal = useOpenModal(); | ||
const [count, setCount] = useState(0); | ||
|
||
const addModalFlow = async () => { | ||
const mathOp = await openModal<"add" | "remove" | undefined>((resolve) => | ||
<ChooseMathOpModal | ||
onAdd={() => resolve("add")} | ||
onRemove={() => resolve("remove")} | ||
onCancel={() => resolve(undefined)} /> | ||
); | ||
if (!mathOp) return; | ||
try { | ||
const mathOp = await openModal<"add" | "remove">((resolve, reject) => ( | ||
<ChooseMathOpModal | ||
onAdd={() => resolve("add")} | ||
onRemove={() => resolve("remove")} | ||
onCancel={() => reject()} | ||
/> | ||
)); | ||
|
||
const amount = await openModal<number | undefined>((resolve) => | ||
<NumbersModal | ||
title="How Much?" | ||
onCancel={() => resolve(undefined)} | ||
onSubmit={(v) => resolve(v)} /> | ||
); | ||
if (!amount) return; | ||
const amount = await openModal<number>((resolve, reject) => ( | ||
<NumbersModal title="How Much?" onCancel={() => reject()} onSubmit={(v) => resolve(v)} /> | ||
)); | ||
|
||
const mathOpMult = mathOp === "add" ? 1 : -1; | ||
setCount(count + (amount * mathOpMult)) | ||
} | ||
const mathOpMult = mathOp === "add" ? 1 : -1; | ||
setCount(count + amount * mathOpMult); | ||
} catch (error) { | ||
console.log({ error }); | ||
return; | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="flex flex-col justify-center items-center gap-2 w-screen h-screen"> | ||
<div className="font-thin text-6xl">Paresseux Demo</div> | ||
<div className="text-gray-300">Click on the button to start the Demo flow</div> | ||
<div className="text-lg">Your current count is <span className="text-4xl">{count}</span>.</div> | ||
<div className="text-lg"> | ||
Your current count is <span className="text-4xl">{count}</span>. | ||
</div> | ||
<div className="m-8"> | ||
<div className="flex justify-center gap-4 mb-4"> | ||
<button onClick={() => addModalFlow()}>Modify Count</button> | ||
</div> | ||
</div> | ||
<p className="text-sm text-gray-400">Go to the <a>docs</a> to learn more</p> | ||
<p className="text-sm text-gray-400"> | ||
Go to the <a>docs</a> to learn more | ||
</p> | ||
</div> | ||
); | ||
} | ||
|
||
|
||
export default App; |
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,11 +1,18 @@ | ||
import { ReactNode } from "react"; | ||
|
||
export default function CancelModal({ children, onCancel }: { children: ReactNode, onCancel: () => void }) { | ||
export default function CancelModal({ | ||
children, | ||
onCancel, | ||
}: { | ||
children: ReactNode; | ||
onCancel: () => void; | ||
}) { | ||
return ( | ||
<div className="flex justify-center items-center fixed top-0 right-0 bg-black/30 backdrop-blur w-screen h-screen"> | ||
<div className="bg-gray-700 rounded p-8 flex flex-col gap-4"> | ||
{children} | ||
<button onClick={() => onCancel()}>Cancel</button> | ||
</div> | ||
</div>); | ||
</div> | ||
); | ||
} |
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