ui: fix sonner theme
This commit is contained in:
parent
4eadd2f195
commit
a80b64dc4a
3 changed files with 13 additions and 7 deletions
|
|
@ -127,3 +127,11 @@ html,
|
|||
body {
|
||||
@apply w-full h-full;
|
||||
}
|
||||
|
||||
[data-sonner-toast][data-styled='true'] [data-description] {
|
||||
color: var(--primary) !important;
|
||||
}
|
||||
|
||||
[data-sonner-toaster][data-sonner-theme='dark'] [data-description] {
|
||||
color: var(--primary) !important;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,14 +84,16 @@ export const useTheme = () => {
|
|||
return context;
|
||||
};
|
||||
|
||||
const isWindowAvailable = () => {
|
||||
return typeof window !== "undefined" && window !== null;
|
||||
}
|
||||
|
||||
export const useDisplayedTheme = () => {
|
||||
const { theme, setTheme } = useTheme();
|
||||
|
||||
if (theme === "system") {
|
||||
return {
|
||||
theme: window.matchMedia("(prefers-color-scheme: dark)").matches
|
||||
? "dark"
|
||||
: "light",
|
||||
theme: isWindowAvailable() && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light",
|
||||
setTheme,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,8 @@
|
|||
import { Toaster as Sonner, type ToasterProps } from "sonner";
|
||||
|
||||
const Toaster = ({ ...props }: ToasterProps) => {
|
||||
// TODO: Use theme hook
|
||||
const { theme = "system" } = {};
|
||||
|
||||
return (
|
||||
<Sonner
|
||||
theme={theme as ToasterProps["theme"]}
|
||||
className="toaster group"
|
||||
style={
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue