-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make @umami/state package platform agnostic (#2329)
- Loading branch information
1 parent
26ce960
commit 0a3987e
Showing
22 changed files
with
119 additions
and
87 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
import { ChakraProvider, ColorModeScript } from "@chakra-ui/react"; | ||
import { ChakraProvider, ColorModeScript, useToast } from "@chakra-ui/react"; | ||
import { ToastProvider } from "@umami/utils"; | ||
|
||
import theme from "../style/theme"; | ||
|
||
export const UmamiTheme = (props: any) => ( | ||
<ChakraProvider theme={theme}> | ||
<ColorModeScript initialColorMode={theme.config.initialColorMode} /> | ||
{props.children} | ||
</ChakraProvider> | ||
); | ||
export const UmamiTheme = (props: any) => { | ||
const toast = useToast(); | ||
|
||
return ( | ||
<ToastProvider toast={toast}> | ||
<ChakraProvider theme={theme}> | ||
<ColorModeScript initialColorMode={theme.config.initialColorMode} /> | ||
{props.children} | ||
</ChakraProvider> | ||
</ToastProvider> | ||
); | ||
}; |
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
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
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
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 +1,2 @@ | ||
export * from "./ErrorContext"; | ||
export * from "./providers"; |
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,27 @@ | ||
import { type PropsWithChildren, createContext, useContext } from "react"; | ||
|
||
// TODO: fix this type when we have a better toast implementation | ||
export type ToastOptions = any; | ||
|
||
export type Toast = { | ||
show?: (options: ToastOptions) => void; | ||
[key: string]: any; | ||
} & ((options: ToastOptions) => void); | ||
|
||
type ToastContextType = { | ||
toast: Toast; | ||
}; | ||
|
||
const ToastContext = createContext<ToastContextType | undefined>(undefined); | ||
|
||
export const useCustomToast = () => { | ||
const toastContext = useContext(ToastContext); | ||
if (!toastContext) { | ||
throw new Error("useCustomToast must be used within a ToastProvider"); | ||
} | ||
return toastContext.toast; | ||
}; | ||
|
||
export const ToastProvider = ({ children, toast }: PropsWithChildren<{ toast: Toast }>) => ( | ||
<ToastContext.Provider value={{ toast }}>{children}</ToastContext.Provider> | ||
); |
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 @@ | ||
export * from "./ToastProvider"; |
Oops, something went wrong.
0a3987e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.