-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dialog): add dialog component (#39)
- Loading branch information
Showing
6 changed files
with
823 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { cn, tcva, type VariantProps } from "@nyanpasu/material-design-libs"; | ||
|
||
export const dialogOverlayClassName = cn( | ||
"fixed inset-0 z-50", | ||
"backdrop-blur-xl", | ||
"bg-opacity-10 bg-primary", | ||
); | ||
|
||
export const dialogContainerClassName = cn( | ||
"fixed inset-0 z-50 grid place-items-center", | ||
); | ||
|
||
export const dialogContentVariants = tcva(["bg-surface"], { | ||
variants: { | ||
fullScreen: { | ||
true: "fixed inset-0", | ||
false: "min-w-96 rounded-3xl shadow", | ||
}, | ||
}, | ||
defaultVariants: { | ||
fullScreen: false, | ||
}, | ||
}); | ||
|
||
export const dialogContentContainerVariants = tcva(["overflow-auto p-4"], { | ||
variants: { | ||
fullScreen: { | ||
true: "", | ||
false: "h-dvh-subtract-40", | ||
}, | ||
subtract: { | ||
0: "", | ||
1: "h-dvh-subtract-14", | ||
2: "h-dvh-subtract-28", | ||
}, | ||
}, | ||
defaultVariants: { | ||
fullScreen: false, | ||
subtract: 0, | ||
}, | ||
}); | ||
|
||
export const dialogHeaderClassName = cn( | ||
"flex h-14 items-center gap-2 border-b p-4 text-xl", | ||
); | ||
|
||
export const dialogFooterClassName = cn( | ||
"flex h-14 flex-row-reverse items-center gap-2 border-t p-2", | ||
); | ||
|
||
export interface DialogContentContainerVariantsProps | ||
extends VariantProps<typeof dialogContentContainerVariants> {} | ||
|
||
export interface DialogContentVariantsProps | ||
extends VariantProps<typeof dialogContentVariants> {} |
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 +1,2 @@ | ||
export * from "./button"; | ||
export * from "./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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { motion } from "framer-motion"; | ||
import React from "react"; | ||
import { Button } from "../button"; | ||
import { | ||
Dialog, | ||
DialogClose, | ||
DialogContent, | ||
DialogFooter, | ||
DialogHeader, | ||
DialogTrigger, | ||
} from "./"; | ||
|
||
type Story = StoryObj<typeof Dialog>; | ||
|
||
export default { | ||
title: "Components/Dialog", | ||
component: Dialog, | ||
} as Meta<typeof Dialog>; | ||
|
||
export const Default: Story = { | ||
decorators: [ | ||
() => ( | ||
<Dialog> | ||
<DialogTrigger asChild> | ||
<Button asChild> | ||
<motion.button>open dialog</motion.button> | ||
</Button> | ||
</DialogTrigger> | ||
|
||
<DialogContent | ||
contentPrefix={<DialogHeader>Nyanpasu</DialogHeader>} | ||
contentSuffix={ | ||
<DialogFooter> | ||
<Button variant="flat">Submit</Button> | ||
<DialogClose>Close</DialogClose> | ||
</DialogFooter> | ||
} | ||
> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
</DialogContent> | ||
</Dialog> | ||
), | ||
], | ||
}; | ||
|
||
export const FullScreen: Story = { | ||
decorators: [ | ||
() => ( | ||
<Dialog> | ||
<DialogTrigger asChild> | ||
<Button asChild> | ||
<motion.button>open dialog</motion.button> | ||
</Button> | ||
</DialogTrigger> | ||
|
||
<DialogContent | ||
fullScreen | ||
contentPrefix={<DialogHeader>Nyanpasu</DialogHeader>} | ||
contentSuffix={ | ||
<DialogFooter> | ||
<Button variant="flat">Submit</Button> | ||
<DialogClose>Close</DialogClose> | ||
</DialogFooter> | ||
} | ||
> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
<div>my content</div> | ||
</DialogContent> | ||
</Dialog> | ||
), | ||
], | ||
}; |
Oops, something went wrong.