Skip to content

Commit

Permalink
feat: initial store for toast positions, variants & theme
Browse files Browse the repository at this point in the history
  • Loading branch information
pheralb committed May 14, 2024
1 parent e5b13ad commit 49633c7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
14 changes: 11 additions & 3 deletions website/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ import {
} from 'remix-themes';
import { themeSessionResolver } from './sessions.server';

// Store:
import { useDocsStore } from './store';

export const links: LinksFunction = () => [
{ rel: 'stylesheet', href: stylesheet },
];
Expand All @@ -50,6 +53,7 @@ export default function AppWithProviders() {
function App() {
const data = useLoaderData<typeof loader>();
const [theme] = useTheme();
const { toastPosition } = useDocsStore();
return (
<html lang="en" className={cn(theme)}>
<head>
Expand All @@ -67,11 +71,15 @@ function App() {
)}
>
<Header />
<ToastProvider position="bottom-right" theme={theme!}>
<div className="container mx-auto max-w-7xl">
<ToastProvider
position={toastPosition}
theme={theme!}
toastFont="font-sans"
>
<div className="container w-full max-w-7xl">
<SidebarContent />
<article
className={cn('ml-60 w-full max-w-4xl py-8', proseClasses)}
className={cn('ml-64 max-w-4xl py-8 duration-100', proseClasses)}
>
<Outlet />
</article>
Expand Down
20 changes: 20 additions & 0 deletions website/app/store/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { Position, Theme, Variant } from '@pheralb/toast';
import { create } from 'zustand';

interface DocsStore {
toastPosition: Position;
toastVariant: Variant;
toastTheme: Theme;
setToastPosition: (position: Position) => void;
setToastVariant: (variant: Variant) => void;
setToastTheme: (theme: Theme) => void;
}

export const useDocsStore = create<DocsStore>((set) => ({
toastPosition: 'bottom-right',
toastVariant: 'success',
toastTheme: 'light',
setToastPosition: (position) => set({ toastPosition: position }),
setToastVariant: (variant) => set({ toastVariant: variant }),
setToastTheme: (theme) => set({ toastTheme: theme }),
}));

0 comments on commit 49633c7

Please sign in to comment.