forked from epicweb-dev/epic-stack
-
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.
bring over latest improvements from the workshops
- Loading branch information
1 parent
eab3f01
commit 5cb5110
Showing
141 changed files
with
7,462 additions
and
5,431 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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { useEffect } from 'react' | ||
import { Toaster, toast as showToast } from 'sonner' | ||
import { type Toast } from '~/utils/toast.server.ts' | ||
|
||
export function EpicToaster({ toast }: { toast?: Toast | null }) { | ||
return ( | ||
<> | ||
<Toaster closeButton position="top-center" /> | ||
{toast ? <ShowToast toast={toast} /> : null} | ||
</> | ||
) | ||
} | ||
|
||
function ShowToast({ toast }: { toast: Toast }) { | ||
const { id, type, title, description } = toast | ||
useEffect(() => { | ||
setTimeout(() => { | ||
showToast[type](title, { id, description }) | ||
}, 0) | ||
}, [description, id, title, type]) | ||
return null | ||
} |
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,33 +1,22 @@ | ||
import { | ||
Toast, | ||
ToastClose, | ||
ToastDescription, | ||
ToastProvider, | ||
ToastTitle, | ||
ToastViewport, | ||
} from '~/components/ui/toast.tsx' | ||
import { useToast } from '~/components/ui/use-toast.ts' | ||
|
||
export function Toaster() { | ||
const { toasts } = useToast() | ||
import { useEffect } from 'react' | ||
import { Toaster, toast as showToast } from 'sonner' | ||
import { type Toast } from '~/utils/toast.server.ts' | ||
|
||
export function EpicToaster({ toast }: { toast?: Toast | null }) { | ||
return ( | ||
<ToastProvider> | ||
{toasts.map(function ({ id, title, description, action, ...props }) { | ||
return ( | ||
<Toast key={id} {...props}> | ||
<div className="grid gap-1"> | ||
{title && <ToastTitle>{title}</ToastTitle>} | ||
{description && ( | ||
<ToastDescription>{description}</ToastDescription> | ||
)} | ||
</div> | ||
{action} | ||
<ToastClose /> | ||
</Toast> | ||
) | ||
})} | ||
<ToastViewport /> | ||
</ToastProvider> | ||
<> | ||
<Toaster closeButton position="top-center" /> | ||
{toast ? <ShowToast toast={toast} /> : null} | ||
</> | ||
) | ||
} | ||
|
||
function ShowToast({ toast }: { toast: Toast }) { | ||
const { id, type, title, description } = toast | ||
useEffect(() => { | ||
setTimeout(() => { | ||
showToast[type](title, { id, description }) | ||
}, 0) | ||
}, [description, id, title, type]) | ||
return null | ||
} |
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.