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 {
|
body {
|
||||||
@apply w-full h-full;
|
@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;
|
return context;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isWindowAvailable = () => {
|
||||||
|
return typeof window !== "undefined" && window !== null;
|
||||||
|
}
|
||||||
|
|
||||||
export const useDisplayedTheme = () => {
|
export const useDisplayedTheme = () => {
|
||||||
const { theme, setTheme } = useTheme();
|
const { theme, setTheme } = useTheme();
|
||||||
|
|
||||||
if (theme === "system") {
|
if (theme === "system") {
|
||||||
return {
|
return {
|
||||||
theme: window.matchMedia("(prefers-color-scheme: dark)").matches
|
theme: isWindowAvailable() && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light",
|
||||||
? "dark"
|
|
||||||
: "light",
|
|
||||||
setTheme,
|
setTheme,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,8 @@
|
||||||
import { Toaster as Sonner, type ToasterProps } from "sonner";
|
import { Toaster as Sonner, type ToasterProps } from "sonner";
|
||||||
|
|
||||||
const Toaster = ({ ...props }: ToasterProps) => {
|
const Toaster = ({ ...props }: ToasterProps) => {
|
||||||
// TODO: Use theme hook
|
|
||||||
const { theme = "system" } = {};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Sonner
|
<Sonner
|
||||||
theme={theme as ToasterProps["theme"]}
|
|
||||||
className="toaster group"
|
className="toaster group"
|
||||||
style={
|
style={
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue