@widgetic/design-system 0.3.87 → 0.3.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { Toaster as Sonner, type ToasterProps as SonnerProps } from "svelte-sonner";
|
|
3
|
-
import {
|
|
3
|
+
import { browser } from "$app/environment";
|
|
4
4
|
|
|
5
5
|
let restProps: SonnerProps = $props();
|
|
6
|
+
|
|
7
|
+
// Determine theme based on browser preference, fallback to 'light'
|
|
8
|
+
// This removes the dependency on mode-watcher which requires ModeWatcher component to be mounted
|
|
9
|
+
function getTheme(): 'light' | 'dark' | 'system' {
|
|
10
|
+
if (!browser) return 'light';
|
|
11
|
+
if (typeof window !== 'undefined' && window.matchMedia?.('(prefers-color-scheme: dark)').matches) {
|
|
12
|
+
return 'dark';
|
|
13
|
+
}
|
|
14
|
+
return 'light';
|
|
15
|
+
}
|
|
6
16
|
</script>
|
|
7
17
|
|
|
8
18
|
<Sonner
|
|
9
|
-
theme={
|
|
19
|
+
theme={getTheme()}
|
|
10
20
|
class="toaster group"
|
|
11
21
|
toastOptions={{
|
|
12
22
|
classes: {
|