-
-
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.
🧩
ui
Create reusable modal provider (#43)
* 🧩 `ui` Add `ModalProvider` with custom hook * 🔧 `worxpace` Migrate `ModalProvider` to new one & fix related components
- Loading branch information
1 parent
0f2aaa0
commit b7a0e39
Showing
19 changed files
with
250 additions
and
104 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
apps/storybook/src/stories/custom/modal-provider/_components.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,24 @@ | ||
import { useModal } from "@acme/ui/custom"; | ||
import { Button, Dialog, DialogClose, DialogContent } from "@acme/ui/shadcn"; | ||
|
||
export const Modal = () => { | ||
const { isOpen, setClose } = useModal(); | ||
return ( | ||
<Dialog open={isOpen} onOpenChange={setClose}> | ||
<DialogContent className="flex items-center text-2xl font-bold"> | ||
Modal | ||
<DialogClose /> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
}; | ||
|
||
export const Trigger = () => { | ||
const { setOpen } = useModal(); | ||
const handleClick = () => void setOpen(<Modal />); | ||
return ( | ||
<Button onClick={handleClick} variant="outline"> | ||
Open | ||
</Button> | ||
); | ||
}; |
21 changes: 21 additions & 0 deletions
21
apps/storybook/src/stories/custom/modal-provider/index.stories.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,21 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { ModalProvider } from "@acme/ui/custom"; | ||
|
||
import { Trigger } from "./_components"; | ||
|
||
const meta = { | ||
title: "custom/Modal Provider", | ||
component: ModalProvider, | ||
parameters: { layout: "centered" }, | ||
tags: ["autodocs"], | ||
} satisfies Meta<typeof ModalProvider>; | ||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
children: <Trigger />, | ||
}, | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from "./confirm-modal"; | ||
export { default as SearchCommand } from "./search-command"; | ||
export * from "./settings-modal"; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
export * from "./modal-provider"; | ||
export * from "./worxpace-provider"; |
This file was deleted.
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
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,13 @@ | ||
"use client"; | ||
|
||
import { useRouter } from "next/navigation"; | ||
|
||
export const usePlatform = () => { | ||
const router = useRouter(); | ||
const toToolsPage = (id: string, group: string | null) => { | ||
if (group === "document") router.push(`/documents/${id}`); | ||
if (group === "kanban") router.push(`/kanban/${id}`); | ||
if (group === "whiteboard") router.push(`/whiteboard/${id}`); | ||
}; | ||
return { toToolsPage }; | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
Oops, something went wrong.