mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-25 10:18:31 +02:00
Put toast on top
This commit is contained in:
@@ -32,6 +32,8 @@ import { monokaiProDefault } from '../lib/theme/themes/monokai-pro';
|
|||||||
import { rosePineDefault } from '../lib/theme/themes/rose-pine';
|
import { rosePineDefault } from '../lib/theme/themes/rose-pine';
|
||||||
import { yaakDark } from '../lib/theme/themes/yaak';
|
import { yaakDark } from '../lib/theme/themes/yaak';
|
||||||
import { getThemeCSS } from '../lib/theme/window';
|
import { getThemeCSS } from '../lib/theme/window';
|
||||||
|
import { Button } from './core/Button';
|
||||||
|
import { useToast } from './ToastContext';
|
||||||
|
|
||||||
export function GlobalHooks() {
|
export function GlobalHooks() {
|
||||||
// Include here so they always update, even if no component references them
|
// Include here so they always update, even if no component references them
|
||||||
@@ -39,6 +41,16 @@ export function GlobalHooks() {
|
|||||||
useRecentEnvironments();
|
useRecentEnvironments();
|
||||||
useRecentRequests();
|
useRecentRequests();
|
||||||
|
|
||||||
|
const toast = useToast();
|
||||||
|
useEffect(() => {
|
||||||
|
toast.show({
|
||||||
|
id: 'test',
|
||||||
|
message: 'Hello Toast!',
|
||||||
|
action: <Button color="primary">HEllo</Button>,
|
||||||
|
timeout: 1000000,
|
||||||
|
});
|
||||||
|
}, [toast]);
|
||||||
|
|
||||||
// Other useful things
|
// Other useful things
|
||||||
useSyncThemeToDocument();
|
useSyncThemeToDocument();
|
||||||
useCommandPalette();
|
useCommandPalette();
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export const ToastProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
<ToastContext.Provider value={state}>
|
<ToastContext.Provider value={state}>
|
||||||
{children}
|
{children}
|
||||||
<Portal name="toasts">
|
<Portal name="toasts">
|
||||||
<div className="absolute right-0 bottom-0">
|
<div className="absolute right-0 bottom-0 z-10">
|
||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
{toasts.map((props: PrivateToastEntry) => (
|
{toasts.map((props: PrivateToastEntry) => (
|
||||||
<ToastInstance key={props.id} {...props} />
|
<ToastInstance key={props.id} {...props} />
|
||||||
|
|||||||
Reference in New Issue
Block a user