ui: fix sonner theme

This commit is contained in:
Nathan Lamy 2025-07-30 18:45:17 +02:00
parent 4eadd2f195
commit a80b64dc4a
3 changed files with 13 additions and 7 deletions

View file

@ -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;
}

View file

@ -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,
};
}

View file

@ -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={
{