Skip to content

Commit 49633c7

Browse files
committed
feat: initial store for toast positions, variants & theme
1 parent e5b13ad commit 49633c7

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

website/app/root.tsx

+11-3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ import {
2727
} from 'remix-themes';
2828
import { themeSessionResolver } from './sessions.server';
2929

30+
// Store:
31+
import { useDocsStore } from './store';
32+
3033
export const links: LinksFunction = () => [
3134
{ rel: 'stylesheet', href: stylesheet },
3235
];
@@ -50,6 +53,7 @@ export default function AppWithProviders() {
5053
function App() {
5154
const data = useLoaderData<typeof loader>();
5255
const [theme] = useTheme();
56+
const { toastPosition } = useDocsStore();
5357
return (
5458
<html lang="en" className={cn(theme)}>
5559
<head>
@@ -67,11 +71,15 @@ function App() {
6771
)}
6872
>
6973
<Header />
70-
<ToastProvider position="bottom-right" theme={theme!}>
71-
<div className="container mx-auto max-w-7xl">
74+
<ToastProvider
75+
position={toastPosition}
76+
theme={theme!}
77+
toastFont="font-sans"
78+
>
79+
<div className="container w-full max-w-7xl">
7280
<SidebarContent />
7381
<article
74-
className={cn('ml-60 w-full max-w-4xl py-8', proseClasses)}
82+
className={cn('ml-64 max-w-4xl py-8 duration-100', proseClasses)}
7583
>
7684
<Outlet />
7785
</article>

website/app/store/index.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { Position, Theme, Variant } from '@pheralb/toast';
2+
import { create } from 'zustand';
3+
4+
interface DocsStore {
5+
toastPosition: Position;
6+
toastVariant: Variant;
7+
toastTheme: Theme;
8+
setToastPosition: (position: Position) => void;
9+
setToastVariant: (variant: Variant) => void;
10+
setToastTheme: (theme: Theme) => void;
11+
}
12+
13+
export const useDocsStore = create<DocsStore>((set) => ({
14+
toastPosition: 'bottom-right',
15+
toastVariant: 'success',
16+
toastTheme: 'light',
17+
setToastPosition: (position) => set({ toastPosition: position }),
18+
setToastVariant: (variant) => set({ toastVariant: variant }),
19+
setToastTheme: (theme) => set({ toastTheme: theme }),
20+
}));

0 commit comments

Comments
 (0)