-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create a reusable dialog that is theme context aware
- Loading branch information
1 parent
b804267
commit 09fa514
Showing
3 changed files
with
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { ComponentProps, JSX, useContext } from "solid-js"; | ||
import { | ||
AlertDialog, | ||
AlertDialogContent, | ||
AlertDialogDescription, | ||
AlertDialogTitle, | ||
AlertDialogTrigger | ||
} from "~/components/ui/alert-dialog"; | ||
import { Button } from "~/components/ui/button"; | ||
import { IThemeContext, ThemeContext } from "~/context/ThemeContext.tsx"; | ||
|
||
export interface DialogModalProps extends ComponentProps<"div"> { | ||
children?: JSX.Element; | ||
title?: string; | ||
trigger?: JSX.Element; | ||
} | ||
|
||
export function DialogModal(props: DialogModalProps) { | ||
const themeContext: IThemeContext = useContext(ThemeContext); | ||
|
||
return ( | ||
<AlertDialog> | ||
<AlertDialogTrigger>{props.trigger || <Button>Open Dialog</Button>}</AlertDialogTrigger> | ||
<AlertDialogContent | ||
class={`bg-primary dark:bg-blackout text-100 dark:text-white ${themeContext.theme}`} | ||
> | ||
<AlertDialogTitle | ||
class={`font-bold text-100 light:text-black underline underline-offset-2`} | ||
> | ||
{props.title} | ||
</AlertDialogTitle> | ||
<AlertDialogDescription>{props.children}</AlertDialogDescription> | ||
</AlertDialogContent> | ||
</AlertDialog> | ||
); | ||
} |
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