fulldev-ui 0.22.2 → 0.23.0
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.
- package/CHANGELOG.md +14 -0
- package/README.md +6 -2
- package/liquid/LICENSE-DATA-SLOT.md +21 -0
- package/liquid/LICENSE-FULLDEV.txt +21 -0
- package/liquid/LICENSE-SHADCN.md +21 -0
- package/liquid/README.md +17 -0
- package/liquid/components/accordion.liquid +5 -0
- package/liquid/components/alert-dialog.liquid +116 -0
- package/liquid/components/alert.liquid +45 -0
- package/liquid/components/aspect-ratio.liquid +28 -0
- package/liquid/components/attachment.liquid +134 -0
- package/liquid/components/avatar.liquid +52 -0
- package/liquid/components/badge.liquid +86 -0
- package/liquid/components/banner.liquid +40 -0
- package/liquid/components/base.liquid +112 -0
- package/liquid/components/breadcrumb.liquid +46 -0
- package/liquid/components/button-group.liquid +56 -0
- package/liquid/components/button.liquid +232 -0
- package/liquid/components/card.liquid +5 -0
- package/liquid/components/carousel.liquid +5 -0
- package/liquid/components/checkbox.liquid +54 -0
- package/liquid/components/collapsible.liquid +3 -0
- package/liquid/components/combobox.liquid +87 -0
- package/liquid/components/command.liquid +86 -0
- package/liquid/components/dialog.liquid +80 -0
- package/liquid/components/drawer.liquid +97 -0
- package/liquid/components/dropdown-menu.liquid +3 -0
- package/liquid/components/empty.liquid +77 -0
- package/liquid/components/field.liquid +5 -0
- package/liquid/components/form.liquid +5 -0
- package/liquid/components/header.liquid +33 -0
- package/liquid/components/hover-card.liquid +3 -0
- package/liquid/components/icon.liquid +5 -0
- package/liquid/components/input-group.liquid +53 -0
- package/liquid/components/input.liquid +84 -0
- package/liquid/components/invalid-controls.liquid +18 -0
- package/liquid/components/item.liquid +114 -0
- package/liquid/components/kbd.liquid +20 -0
- package/liquid/components/logo.liquid +33 -0
- package/liquid/components/marquee.liquid +5 -0
- package/liquid/components/navigation-menu.liquid +5 -0
- package/liquid/components/pagination.liquid +32 -0
- package/liquid/components/popover.liquid +3 -0
- package/liquid/components/popup.liquid +189 -0
- package/liquid/components/price.liquid +5 -0
- package/liquid/components/radio-group.liquid +53 -0
- package/liquid/components/rating.liquid +5 -0
- package/liquid/components/section.liquid +5 -0
- package/liquid/components/select.liquid +51 -0
- package/liquid/components/separator.liquid +19 -0
- package/liquid/components/sheet.liquid +68 -0
- package/liquid/components/skeleton.liquid +17 -0
- package/liquid/components/slider.liquid +50 -0
- package/liquid/components/spinner.liquid +28 -0
- package/liquid/components/switch.liquid +54 -0
- package/liquid/components/table.liquid +64 -0
- package/liquid/components/tabs.liquid +88 -0
- package/liquid/components/toast.liquid +5 -0
- package/liquid/components/toc.liquid +45 -0
- package/liquid/components/toggle-group.liquid +77 -0
- package/liquid/components/toggle.liquid +61 -0
- package/liquid/components/tooltip.liquid +45 -0
- package/liquid/components/triggers.liquid +20 -0
- package/liquid/components/typography.liquid +5 -0
- package/liquid/components/video.liquid +5 -0
- package/liquid/contracts.json +428 -0
- package/liquid/examples/accordion.liquid +10 -0
- package/liquid/examples/alert-dialog.liquid +40 -0
- package/liquid/examples/alert.liquid +4 -0
- package/liquid/examples/aspect-ratio.liquid +1 -0
- package/liquid/examples/attachment.liquid +22 -0
- package/liquid/examples/avatar.liquid +1 -0
- package/liquid/examples/badge.liquid +5 -0
- package/liquid/examples/banner.liquid +3 -0
- package/liquid/examples/breadcrumb.liquid +7 -0
- package/liquid/examples/button-group.liquid +6 -0
- package/liquid/examples/button.liquid +8 -0
- package/liquid/examples/card.liquid +11 -0
- package/liquid/examples/carousel.liquid +12 -0
- package/liquid/examples/checkbox.liquid +4 -0
- package/liquid/examples/collapsible.liquid +29 -0
- package/liquid/examples/combobox.liquid +13 -0
- package/liquid/examples/command.liquid +10 -0
- package/liquid/examples/dependencies.json +60 -0
- package/liquid/examples/dialog.liquid +11 -0
- package/liquid/examples/drawer.liquid +18 -0
- package/liquid/examples/dropdown-menu.liquid +88 -0
- package/liquid/examples/empty.liquid +9 -0
- package/liquid/examples/field.liquid +105 -0
- package/liquid/examples/form.liquid +9 -0
- package/liquid/examples/header.liquid +8 -0
- package/liquid/examples/hover-card.liquid +16 -0
- package/liquid/examples/icon.liquid +3 -0
- package/liquid/examples/input-group.liquid +6 -0
- package/liquid/examples/input.liquid +4 -0
- package/liquid/examples/item.liquid +72 -0
- package/liquid/examples/kbd.liquid +1 -0
- package/liquid/examples/label.liquid +3 -0
- package/liquid/examples/logo.liquid +3 -0
- package/liquid/examples/marquee.liquid +5 -0
- package/liquid/examples/native-select.liquid +8 -0
- package/liquid/examples/navigation-menu.liquid +11 -0
- package/liquid/examples/pagination.liquid +11 -0
- package/liquid/examples/popover.liquid +14 -0
- package/liquid/examples/price.liquid +1 -0
- package/liquid/examples/radio-group.liquid +62 -0
- package/liquid/examples/rating.liquid +17 -0
- package/liquid/examples/section.liquid +9 -0
- package/liquid/examples/select.liquid +105 -0
- package/liquid/examples/separator.liquid +3 -0
- package/liquid/examples/sheet.liquid +11 -0
- package/liquid/examples/skeleton.liquid +5 -0
- package/liquid/examples/slider.liquid +46 -0
- package/liquid/examples/spinner.liquid +11 -0
- package/liquid/examples/switch.liquid +7 -0
- package/liquid/examples/table.liquid +37 -0
- package/liquid/examples/tabs.liquid +21 -0
- package/liquid/examples/textarea.liquid +9 -0
- package/liquid/examples/toast.liquid +47 -0
- package/liquid/examples/toc.liquid +11 -0
- package/liquid/examples/toggle-group.liquid +50 -0
- package/liquid/examples/toggle.liquid +21 -0
- package/liquid/examples/tooltip.liquid +33 -0
- package/liquid/examples/typography.liquid +9 -0
- package/liquid/examples/video.liquid +7 -0
- package/liquid/licenses.json +14 -0
- package/liquid/manifest.json +110 -0
- package/liquid/registry.json +1295 -0
- package/liquid/runtime/ui-carousel.js +44 -0
- package/liquid/runtime/ui-controls.js +195 -0
- package/liquid/runtime/ui-lifecycle.js +107 -0
- package/liquid/runtime/ui-motion.js +45 -0
- package/liquid/runtime/ui-start.js +37 -0
- package/liquid/snippets/init.liquid +6 -0
- package/liquid/snippets/runtime.liquid +9 -0
- package/liquid/snippets/ui.liquid +68 -0
- package/liquid/styles/accordion.css +66 -0
- package/liquid/styles/card.css +114 -0
- package/liquid/styles/carousel.css +58 -0
- package/liquid/styles/field.css +70 -0
- package/liquid/styles/form.css +14 -0
- package/liquid/styles/icon.css +32 -0
- package/liquid/styles/marquee.css +65 -0
- package/liquid/styles/navigation-menu.css +235 -0
- package/liquid/styles/price.css +41 -0
- package/liquid/styles/primitives.css +53 -0
- package/liquid/styles/rating.css +23 -0
- package/liquid/styles/section.css +92 -0
- package/liquid/styles/toast.css +125 -0
- package/liquid/styles/tokens.css +118 -0
- package/liquid/styles/typography.css +670 -0
- package/liquid/styles/video.css +10 -0
- package/liquid/vendor/data-slot-accordion.js +1 -0
- package/liquid/vendor/data-slot-alert-dialog.js +1 -0
- package/liquid/vendor/data-slot-carousel.js +1 -0
- package/liquid/vendor/data-slot-collapsible.js +1 -0
- package/liquid/vendor/data-slot-combobox.js +1 -0
- package/liquid/vendor/data-slot-command.js +1 -0
- package/liquid/vendor/data-slot-core.js +1 -0
- package/liquid/vendor/data-slot-dialog.js +1 -0
- package/liquid/vendor/data-slot-drawer.js +1 -0
- package/liquid/vendor/data-slot-dropdown-menu.js +1 -0
- package/liquid/vendor/data-slot-hover-card.js +1 -0
- package/liquid/vendor/data-slot-navigation-menu.js +1 -0
- package/liquid/vendor/data-slot-popover.js +1 -0
- package/liquid/vendor/data-slot-radio-group.js +1 -0
- package/liquid/vendor/data-slot-select.js +1 -0
- package/liquid/vendor/data-slot-slider.js +1 -0
- package/liquid/vendor/data-slot-switch.js +1 -0
- package/liquid/vendor/data-slot-tabs.js +1 -0
- package/liquid/vendor/data-slot-toast.js +8 -0
- package/liquid/vendor/data-slot-toggle-group.js +1 -0
- package/liquid/vendor/data-slot-toggle.js +1 -0
- package/liquid/vendor/data-slot-tooltip.js +1 -0
- package/liquid/vendor.json +180 -0
- package/package.json +16 -10
- package/public/r/liquid/accordion.json +25 -0
- package/public/r/liquid/alert-dialog.json +21 -0
- package/public/r/liquid/alert.json +18 -0
- package/public/r/liquid/aspect-ratio.json +18 -0
- package/public/r/liquid/attachment.json +20 -0
- package/public/r/liquid/avatar.json +18 -0
- package/public/r/liquid/badge.json +18 -0
- package/public/r/liquid/banner.json +18 -0
- package/public/r/liquid/breadcrumb.json +18 -0
- package/public/r/liquid/button-group.json +19 -0
- package/public/r/liquid/button.json +18 -0
- package/public/r/liquid/card.json +25 -0
- package/public/r/liquid/carousel.json +26 -0
- package/public/r/liquid/checkbox.json +19 -0
- package/public/r/liquid/collapsible.json +19 -0
- package/public/r/liquid/combobox.json +21 -0
- package/public/r/liquid/command.json +19 -0
- package/public/r/liquid/components.json +83 -0
- package/public/r/liquid/dialog.json +19 -0
- package/public/r/liquid/drawer.json +21 -0
- package/public/r/liquid/dropdown-menu.json +21 -0
- package/public/r/liquid/empty.json +18 -0
- package/public/r/liquid/field.json +25 -0
- package/public/r/liquid/form.json +25 -0
- package/public/r/liquid/header.json +19 -0
- package/public/r/liquid/hover-card.json +20 -0
- package/public/r/liquid/icon.json +24 -0
- package/public/r/liquid/init.json +34 -0
- package/public/r/liquid/input-group.json +20 -0
- package/public/r/liquid/input.json +18 -0
- package/public/r/liquid/invalid-controls.json +18 -0
- package/public/r/liquid/item.json +18 -0
- package/public/r/liquid/kbd.json +18 -0
- package/public/r/liquid/label.json +11 -0
- package/public/r/liquid/logo.json +18 -0
- package/public/r/liquid/marquee.json +25 -0
- package/public/r/liquid/native-select.json +11 -0
- package/public/r/liquid/navigation-menu.json +26 -0
- package/public/r/liquid/pagination.json +18 -0
- package/public/r/liquid/popover.json +21 -0
- package/public/r/liquid/popup.json +18 -0
- package/public/r/liquid/price.json +24 -0
- package/public/r/liquid/radio-group.json +20 -0
- package/public/r/liquid/rating.json +24 -0
- package/public/r/liquid/registry.json +1295 -0
- package/public/r/liquid/runtime.json +180 -0
- package/public/r/liquid/section.json +24 -0
- package/public/r/liquid/select.json +22 -0
- package/public/r/liquid/separator.json +18 -0
- package/public/r/liquid/sheet.json +20 -0
- package/public/r/liquid/skeleton.json +18 -0
- package/public/r/liquid/slider.json +19 -0
- package/public/r/liquid/spinner.json +18 -0
- package/public/r/liquid/switch.json +20 -0
- package/public/r/liquid/table.json +18 -0
- package/public/r/liquid/tabs.json +20 -0
- package/public/r/liquid/textarea.json +11 -0
- package/public/r/liquid/toast.json +27 -0
- package/public/r/liquid/toc.json +18 -0
- package/public/r/liquid/toggle-group.json +21 -0
- package/public/r/liquid/toggle.json +20 -0
- package/public/r/liquid/tooltip.json +20 -0
- package/public/r/liquid/triggers.json +18 -0
- package/public/r/liquid/typography.json +24 -0
- package/public/r/liquid/video.json +25 -0
- package/public/r/styles/base-luma/theme-toggle.json +1 -1
- package/public/r/styles/base-lyra/theme-toggle.json +1 -1
- package/public/r/styles/base-maia/theme-toggle.json +1 -1
- package/public/r/styles/base-mira/theme-toggle.json +1 -1
- package/public/r/styles/base-nova/theme-toggle.json +1 -1
- package/public/r/styles/base-rhea/theme-toggle.json +1 -1
- package/public/r/styles/base-sera/theme-toggle.json +1 -1
- package/public/r/styles/base-vega/theme-toggle.json +1 -1
- package/public/r/theme-toggle.json +1 -1
- package/src/components/ui/theme-toggle/theme-provider.astro +14 -0
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
"path": "src/components/ui/theme-toggle/theme-provider.astro",
|
|
20
|
-
"content": "<script is:inline>\n // A stored \"dark\" or \"light\" is the visitor's choice. Without one, such as\n // no value or \"system\", the theme follows the system.\n const getStoredTheme = () => {\n if (typeof localStorage === \"undefined\") return null\n const theme = localStorage.getItem(\"theme\")\n return theme === \"dark\" || theme === \"light\" ? theme : null\n }\n\n const media = window.matchMedia(\"(prefers-color-scheme: dark)\")\n\n const getThemePreference = () =>\n getStoredTheme() ?? (media.matches ? \"dark\" : \"light\")\n\n const disableTransitionsTemporarily = () => {\n const style = document.createElement(\"style\")\n\n style.appendChild(\n document.createTextNode(\n \"*, *::before, *::after { transition: none !important; }\"\n )\n )\n\n document.head.appendChild(style)\n\n return () => {\n void document.documentElement.offsetHeight\n\n requestAnimationFrame(() => {\n style.remove()\n })\n }\n }\n\n // The theme this provider applied last. A class change to another theme\n // comes from outside, such as a toggle without the provider, and is saved\n // as the visitor's choice.\n let appliedTheme\n\n const applyTheme = (theme, disableTransitions = false) => {\n const restoreTransitions = disableTransitions\n ? disableTransitionsTemporarily()\n : null\n\n appliedTheme = theme\n document.documentElement.classList[theme === \"dark\" ? \"add\" : \"remove\"](\n \"dark\"\n )\n\n restoreTransitions?.()\n }\n\n // \"dark\" or \"light\" saves a choice; \"system\" follows the system again.\n window.__setTheme = (theme) => {\n if (typeof localStorage !== \"undefined\")\n localStorage.setItem(\"theme\", theme)\n applyTheme(getThemePreference(), true)\n }\n\n applyTheme(getThemePreference())\n\n // Follow the system while there is no choice, and a choice made in\n // another window or frame of the site.\n media.addEventListener(\"change\", () => {\n if (!getStoredTheme()) applyTheme(getThemePreference(), true)\n })\n window.addEventListener(\"storage\", (event) => {\n if (event.storageArea !== localStorage) return\n if (event.key === \"theme\" || event.key === null)\n applyTheme(getThemePreference(), true)\n })\n\n if (typeof localStorage !== \"undefined\") {\n const observer = new MutationObserver(() => {\n const theme = document.documentElement.classList.contains(\"dark\")\n ? \"dark\"\n : \"light\"\n if (theme === appliedTheme) return\n appliedTheme = theme\n localStorage.setItem(\"theme\", theme)\n })\n\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: [\"class\"],\n })\n }\n</script>\n",
|
|
20
|
+
"content": "<script is:inline>\n // A stored \"dark\" or \"light\" is the visitor's choice. Without one, such as\n // no value or \"system\", the theme follows the system.\n const getStoredTheme = () => {\n if (typeof localStorage === \"undefined\") return null\n const theme = localStorage.getItem(\"theme\")\n return theme === \"dark\" || theme === \"light\" ? theme : null\n }\n\n const media = window.matchMedia(\"(prefers-color-scheme: dark)\")\n\n const getThemePreference = () =>\n getStoredTheme() ?? (media.matches ? \"dark\" : \"light\")\n\n const disableTransitionsTemporarily = () => {\n const style = document.createElement(\"style\")\n\n style.appendChild(\n document.createTextNode(\n \"*, *::before, *::after { transition: none !important; }\"\n )\n )\n\n document.head.appendChild(style)\n\n return () => {\n void document.documentElement.offsetHeight\n\n requestAnimationFrame(() => {\n style.remove()\n })\n }\n }\n\n // The theme this provider applied last. A class change to another theme\n // comes from outside, such as a toggle without the provider, and is saved\n // as the visitor's choice.\n let appliedTheme\n\n const applyTheme = (theme, disableTransitions = false) => {\n const restoreTransitions = disableTransitions\n ? disableTransitionsTemporarily()\n : null\n\n appliedTheme = theme\n document.documentElement.classList[theme === \"dark\" ? \"add\" : \"remove\"](\n \"dark\"\n )\n\n restoreTransitions?.()\n }\n\n // \"dark\" or \"light\" saves a choice; \"system\" follows the system again.\n window.__setTheme = (theme) => {\n if (typeof localStorage !== \"undefined\")\n localStorage.setItem(\"theme\", theme)\n applyTheme(getThemePreference(), true)\n }\n\n applyTheme(getThemePreference())\n\n // Follow the system while there is no choice, and a choice made in\n // another window or frame of the site.\n media.addEventListener(\"change\", () => {\n if (!getStoredTheme()) applyTheme(getThemePreference(), true)\n })\n window.addEventListener(\"storage\", (event) => {\n if (event.storageArea !== localStorage) return\n if (event.key === \"theme\" || event.key === null)\n applyTheme(getThemePreference(), true)\n })\n\n // Astro's <ClientRouter /> replaces the <html> attributes with those of the\n // next page, which cannot know the theme. Carry the theme over before the\n // swap, so it neither flashes nor reaches the observer below as a choice.\n document.addEventListener(\"astro:before-swap\", (event) => {\n const swap = event.swap\n event.swap = function (...args) {\n event.newDocument.documentElement.classList.toggle(\n \"dark\",\n appliedTheme === \"dark\"\n )\n return swap.apply(this, args)\n }\n })\n\n if (typeof localStorage !== \"undefined\") {\n const observer = new MutationObserver(() => {\n const theme = document.documentElement.classList.contains(\"dark\")\n ? \"dark\"\n : \"light\"\n if (theme === appliedTheme) return\n appliedTheme = theme\n localStorage.setItem(\"theme\", theme)\n })\n\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: [\"class\"],\n })\n }\n</script>\n",
|
|
21
21
|
"type": "registry:ui"
|
|
22
22
|
},
|
|
23
23
|
{
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
"path": "src/components/ui/theme-toggle/theme-provider.astro",
|
|
20
|
-
"content": "<script is:inline>\n // A stored \"dark\" or \"light\" is the visitor's choice. Without one, such as\n // no value or \"system\", the theme follows the system.\n const getStoredTheme = () => {\n if (typeof localStorage === \"undefined\") return null\n const theme = localStorage.getItem(\"theme\")\n return theme === \"dark\" || theme === \"light\" ? theme : null\n }\n\n const media = window.matchMedia(\"(prefers-color-scheme: dark)\")\n\n const getThemePreference = () =>\n getStoredTheme() ?? (media.matches ? \"dark\" : \"light\")\n\n const disableTransitionsTemporarily = () => {\n const style = document.createElement(\"style\")\n\n style.appendChild(\n document.createTextNode(\n \"*, *::before, *::after { transition: none !important; }\"\n )\n )\n\n document.head.appendChild(style)\n\n return () => {\n void document.documentElement.offsetHeight\n\n requestAnimationFrame(() => {\n style.remove()\n })\n }\n }\n\n // The theme this provider applied last. A class change to another theme\n // comes from outside, such as a toggle without the provider, and is saved\n // as the visitor's choice.\n let appliedTheme\n\n const applyTheme = (theme, disableTransitions = false) => {\n const restoreTransitions = disableTransitions\n ? disableTransitionsTemporarily()\n : null\n\n appliedTheme = theme\n document.documentElement.classList[theme === \"dark\" ? \"add\" : \"remove\"](\n \"dark\"\n )\n\n restoreTransitions?.()\n }\n\n // \"dark\" or \"light\" saves a choice; \"system\" follows the system again.\n window.__setTheme = (theme) => {\n if (typeof localStorage !== \"undefined\")\n localStorage.setItem(\"theme\", theme)\n applyTheme(getThemePreference(), true)\n }\n\n applyTheme(getThemePreference())\n\n // Follow the system while there is no choice, and a choice made in\n // another window or frame of the site.\n media.addEventListener(\"change\", () => {\n if (!getStoredTheme()) applyTheme(getThemePreference(), true)\n })\n window.addEventListener(\"storage\", (event) => {\n if (event.storageArea !== localStorage) return\n if (event.key === \"theme\" || event.key === null)\n applyTheme(getThemePreference(), true)\n })\n\n if (typeof localStorage !== \"undefined\") {\n const observer = new MutationObserver(() => {\n const theme = document.documentElement.classList.contains(\"dark\")\n ? \"dark\"\n : \"light\"\n if (theme === appliedTheme) return\n appliedTheme = theme\n localStorage.setItem(\"theme\", theme)\n })\n\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: [\"class\"],\n })\n }\n</script>\n",
|
|
20
|
+
"content": "<script is:inline>\n // A stored \"dark\" or \"light\" is the visitor's choice. Without one, such as\n // no value or \"system\", the theme follows the system.\n const getStoredTheme = () => {\n if (typeof localStorage === \"undefined\") return null\n const theme = localStorage.getItem(\"theme\")\n return theme === \"dark\" || theme === \"light\" ? theme : null\n }\n\n const media = window.matchMedia(\"(prefers-color-scheme: dark)\")\n\n const getThemePreference = () =>\n getStoredTheme() ?? (media.matches ? \"dark\" : \"light\")\n\n const disableTransitionsTemporarily = () => {\n const style = document.createElement(\"style\")\n\n style.appendChild(\n document.createTextNode(\n \"*, *::before, *::after { transition: none !important; }\"\n )\n )\n\n document.head.appendChild(style)\n\n return () => {\n void document.documentElement.offsetHeight\n\n requestAnimationFrame(() => {\n style.remove()\n })\n }\n }\n\n // The theme this provider applied last. A class change to another theme\n // comes from outside, such as a toggle without the provider, and is saved\n // as the visitor's choice.\n let appliedTheme\n\n const applyTheme = (theme, disableTransitions = false) => {\n const restoreTransitions = disableTransitions\n ? disableTransitionsTemporarily()\n : null\n\n appliedTheme = theme\n document.documentElement.classList[theme === \"dark\" ? \"add\" : \"remove\"](\n \"dark\"\n )\n\n restoreTransitions?.()\n }\n\n // \"dark\" or \"light\" saves a choice; \"system\" follows the system again.\n window.__setTheme = (theme) => {\n if (typeof localStorage !== \"undefined\")\n localStorage.setItem(\"theme\", theme)\n applyTheme(getThemePreference(), true)\n }\n\n applyTheme(getThemePreference())\n\n // Follow the system while there is no choice, and a choice made in\n // another window or frame of the site.\n media.addEventListener(\"change\", () => {\n if (!getStoredTheme()) applyTheme(getThemePreference(), true)\n })\n window.addEventListener(\"storage\", (event) => {\n if (event.storageArea !== localStorage) return\n if (event.key === \"theme\" || event.key === null)\n applyTheme(getThemePreference(), true)\n })\n\n // Astro's <ClientRouter /> replaces the <html> attributes with those of the\n // next page, which cannot know the theme. Carry the theme over before the\n // swap, so it neither flashes nor reaches the observer below as a choice.\n document.addEventListener(\"astro:before-swap\", (event) => {\n const swap = event.swap\n event.swap = function (...args) {\n event.newDocument.documentElement.classList.toggle(\n \"dark\",\n appliedTheme === \"dark\"\n )\n return swap.apply(this, args)\n }\n })\n\n if (typeof localStorage !== \"undefined\") {\n const observer = new MutationObserver(() => {\n const theme = document.documentElement.classList.contains(\"dark\")\n ? \"dark\"\n : \"light\"\n if (theme === appliedTheme) return\n appliedTheme = theme\n localStorage.setItem(\"theme\", theme)\n })\n\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: [\"class\"],\n })\n }\n</script>\n",
|
|
21
21
|
"type": "registry:ui"
|
|
22
22
|
},
|
|
23
23
|
{
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
"path": "src/components/ui/theme-toggle/theme-provider.astro",
|
|
20
|
-
"content": "<script is:inline>\n // A stored \"dark\" or \"light\" is the visitor's choice. Without one, such as\n // no value or \"system\", the theme follows the system.\n const getStoredTheme = () => {\n if (typeof localStorage === \"undefined\") return null\n const theme = localStorage.getItem(\"theme\")\n return theme === \"dark\" || theme === \"light\" ? theme : null\n }\n\n const media = window.matchMedia(\"(prefers-color-scheme: dark)\")\n\n const getThemePreference = () =>\n getStoredTheme() ?? (media.matches ? \"dark\" : \"light\")\n\n const disableTransitionsTemporarily = () => {\n const style = document.createElement(\"style\")\n\n style.appendChild(\n document.createTextNode(\n \"*, *::before, *::after { transition: none !important; }\"\n )\n )\n\n document.head.appendChild(style)\n\n return () => {\n void document.documentElement.offsetHeight\n\n requestAnimationFrame(() => {\n style.remove()\n })\n }\n }\n\n // The theme this provider applied last. A class change to another theme\n // comes from outside, such as a toggle without the provider, and is saved\n // as the visitor's choice.\n let appliedTheme\n\n const applyTheme = (theme, disableTransitions = false) => {\n const restoreTransitions = disableTransitions\n ? disableTransitionsTemporarily()\n : null\n\n appliedTheme = theme\n document.documentElement.classList[theme === \"dark\" ? \"add\" : \"remove\"](\n \"dark\"\n )\n\n restoreTransitions?.()\n }\n\n // \"dark\" or \"light\" saves a choice; \"system\" follows the system again.\n window.__setTheme = (theme) => {\n if (typeof localStorage !== \"undefined\")\n localStorage.setItem(\"theme\", theme)\n applyTheme(getThemePreference(), true)\n }\n\n applyTheme(getThemePreference())\n\n // Follow the system while there is no choice, and a choice made in\n // another window or frame of the site.\n media.addEventListener(\"change\", () => {\n if (!getStoredTheme()) applyTheme(getThemePreference(), true)\n })\n window.addEventListener(\"storage\", (event) => {\n if (event.storageArea !== localStorage) return\n if (event.key === \"theme\" || event.key === null)\n applyTheme(getThemePreference(), true)\n })\n\n if (typeof localStorage !== \"undefined\") {\n const observer = new MutationObserver(() => {\n const theme = document.documentElement.classList.contains(\"dark\")\n ? \"dark\"\n : \"light\"\n if (theme === appliedTheme) return\n appliedTheme = theme\n localStorage.setItem(\"theme\", theme)\n })\n\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: [\"class\"],\n })\n }\n</script>\n",
|
|
20
|
+
"content": "<script is:inline>\n // A stored \"dark\" or \"light\" is the visitor's choice. Without one, such as\n // no value or \"system\", the theme follows the system.\n const getStoredTheme = () => {\n if (typeof localStorage === \"undefined\") return null\n const theme = localStorage.getItem(\"theme\")\n return theme === \"dark\" || theme === \"light\" ? theme : null\n }\n\n const media = window.matchMedia(\"(prefers-color-scheme: dark)\")\n\n const getThemePreference = () =>\n getStoredTheme() ?? (media.matches ? \"dark\" : \"light\")\n\n const disableTransitionsTemporarily = () => {\n const style = document.createElement(\"style\")\n\n style.appendChild(\n document.createTextNode(\n \"*, *::before, *::after { transition: none !important; }\"\n )\n )\n\n document.head.appendChild(style)\n\n return () => {\n void document.documentElement.offsetHeight\n\n requestAnimationFrame(() => {\n style.remove()\n })\n }\n }\n\n // The theme this provider applied last. A class change to another theme\n // comes from outside, such as a toggle without the provider, and is saved\n // as the visitor's choice.\n let appliedTheme\n\n const applyTheme = (theme, disableTransitions = false) => {\n const restoreTransitions = disableTransitions\n ? disableTransitionsTemporarily()\n : null\n\n appliedTheme = theme\n document.documentElement.classList[theme === \"dark\" ? \"add\" : \"remove\"](\n \"dark\"\n )\n\n restoreTransitions?.()\n }\n\n // \"dark\" or \"light\" saves a choice; \"system\" follows the system again.\n window.__setTheme = (theme) => {\n if (typeof localStorage !== \"undefined\")\n localStorage.setItem(\"theme\", theme)\n applyTheme(getThemePreference(), true)\n }\n\n applyTheme(getThemePreference())\n\n // Follow the system while there is no choice, and a choice made in\n // another window or frame of the site.\n media.addEventListener(\"change\", () => {\n if (!getStoredTheme()) applyTheme(getThemePreference(), true)\n })\n window.addEventListener(\"storage\", (event) => {\n if (event.storageArea !== localStorage) return\n if (event.key === \"theme\" || event.key === null)\n applyTheme(getThemePreference(), true)\n })\n\n // Astro's <ClientRouter /> replaces the <html> attributes with those of the\n // next page, which cannot know the theme. Carry the theme over before the\n // swap, so it neither flashes nor reaches the observer below as a choice.\n document.addEventListener(\"astro:before-swap\", (event) => {\n const swap = event.swap\n event.swap = function (...args) {\n event.newDocument.documentElement.classList.toggle(\n \"dark\",\n appliedTheme === \"dark\"\n )\n return swap.apply(this, args)\n }\n })\n\n if (typeof localStorage !== \"undefined\") {\n const observer = new MutationObserver(() => {\n const theme = document.documentElement.classList.contains(\"dark\")\n ? \"dark\"\n : \"light\"\n if (theme === appliedTheme) return\n appliedTheme = theme\n localStorage.setItem(\"theme\", theme)\n })\n\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: [\"class\"],\n })\n }\n</script>\n",
|
|
21
21
|
"type": "registry:ui"
|
|
22
22
|
},
|
|
23
23
|
{
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
"path": "src/components/ui/theme-toggle/theme-provider.astro",
|
|
20
|
-
"content": "<script is:inline>\n // A stored \"dark\" or \"light\" is the visitor's choice. Without one, such as\n // no value or \"system\", the theme follows the system.\n const getStoredTheme = () => {\n if (typeof localStorage === \"undefined\") return null\n const theme = localStorage.getItem(\"theme\")\n return theme === \"dark\" || theme === \"light\" ? theme : null\n }\n\n const media = window.matchMedia(\"(prefers-color-scheme: dark)\")\n\n const getThemePreference = () =>\n getStoredTheme() ?? (media.matches ? \"dark\" : \"light\")\n\n const disableTransitionsTemporarily = () => {\n const style = document.createElement(\"style\")\n\n style.appendChild(\n document.createTextNode(\n \"*, *::before, *::after { transition: none !important; }\"\n )\n )\n\n document.head.appendChild(style)\n\n return () => {\n void document.documentElement.offsetHeight\n\n requestAnimationFrame(() => {\n style.remove()\n })\n }\n }\n\n // The theme this provider applied last. A class change to another theme\n // comes from outside, such as a toggle without the provider, and is saved\n // as the visitor's choice.\n let appliedTheme\n\n const applyTheme = (theme, disableTransitions = false) => {\n const restoreTransitions = disableTransitions\n ? disableTransitionsTemporarily()\n : null\n\n appliedTheme = theme\n document.documentElement.classList[theme === \"dark\" ? \"add\" : \"remove\"](\n \"dark\"\n )\n\n restoreTransitions?.()\n }\n\n // \"dark\" or \"light\" saves a choice; \"system\" follows the system again.\n window.__setTheme = (theme) => {\n if (typeof localStorage !== \"undefined\")\n localStorage.setItem(\"theme\", theme)\n applyTheme(getThemePreference(), true)\n }\n\n applyTheme(getThemePreference())\n\n // Follow the system while there is no choice, and a choice made in\n // another window or frame of the site.\n media.addEventListener(\"change\", () => {\n if (!getStoredTheme()) applyTheme(getThemePreference(), true)\n })\n window.addEventListener(\"storage\", (event) => {\n if (event.storageArea !== localStorage) return\n if (event.key === \"theme\" || event.key === null)\n applyTheme(getThemePreference(), true)\n })\n\n if (typeof localStorage !== \"undefined\") {\n const observer = new MutationObserver(() => {\n const theme = document.documentElement.classList.contains(\"dark\")\n ? \"dark\"\n : \"light\"\n if (theme === appliedTheme) return\n appliedTheme = theme\n localStorage.setItem(\"theme\", theme)\n })\n\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: [\"class\"],\n })\n }\n</script>\n",
|
|
20
|
+
"content": "<script is:inline>\n // A stored \"dark\" or \"light\" is the visitor's choice. Without one, such as\n // no value or \"system\", the theme follows the system.\n const getStoredTheme = () => {\n if (typeof localStorage === \"undefined\") return null\n const theme = localStorage.getItem(\"theme\")\n return theme === \"dark\" || theme === \"light\" ? theme : null\n }\n\n const media = window.matchMedia(\"(prefers-color-scheme: dark)\")\n\n const getThemePreference = () =>\n getStoredTheme() ?? (media.matches ? \"dark\" : \"light\")\n\n const disableTransitionsTemporarily = () => {\n const style = document.createElement(\"style\")\n\n style.appendChild(\n document.createTextNode(\n \"*, *::before, *::after { transition: none !important; }\"\n )\n )\n\n document.head.appendChild(style)\n\n return () => {\n void document.documentElement.offsetHeight\n\n requestAnimationFrame(() => {\n style.remove()\n })\n }\n }\n\n // The theme this provider applied last. A class change to another theme\n // comes from outside, such as a toggle without the provider, and is saved\n // as the visitor's choice.\n let appliedTheme\n\n const applyTheme = (theme, disableTransitions = false) => {\n const restoreTransitions = disableTransitions\n ? disableTransitionsTemporarily()\n : null\n\n appliedTheme = theme\n document.documentElement.classList[theme === \"dark\" ? \"add\" : \"remove\"](\n \"dark\"\n )\n\n restoreTransitions?.()\n }\n\n // \"dark\" or \"light\" saves a choice; \"system\" follows the system again.\n window.__setTheme = (theme) => {\n if (typeof localStorage !== \"undefined\")\n localStorage.setItem(\"theme\", theme)\n applyTheme(getThemePreference(), true)\n }\n\n applyTheme(getThemePreference())\n\n // Follow the system while there is no choice, and a choice made in\n // another window or frame of the site.\n media.addEventListener(\"change\", () => {\n if (!getStoredTheme()) applyTheme(getThemePreference(), true)\n })\n window.addEventListener(\"storage\", (event) => {\n if (event.storageArea !== localStorage) return\n if (event.key === \"theme\" || event.key === null)\n applyTheme(getThemePreference(), true)\n })\n\n // Astro's <ClientRouter /> replaces the <html> attributes with those of the\n // next page, which cannot know the theme. Carry the theme over before the\n // swap, so it neither flashes nor reaches the observer below as a choice.\n document.addEventListener(\"astro:before-swap\", (event) => {\n const swap = event.swap\n event.swap = function (...args) {\n event.newDocument.documentElement.classList.toggle(\n \"dark\",\n appliedTheme === \"dark\"\n )\n return swap.apply(this, args)\n }\n })\n\n if (typeof localStorage !== \"undefined\") {\n const observer = new MutationObserver(() => {\n const theme = document.documentElement.classList.contains(\"dark\")\n ? \"dark\"\n : \"light\"\n if (theme === appliedTheme) return\n appliedTheme = theme\n localStorage.setItem(\"theme\", theme)\n })\n\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: [\"class\"],\n })\n }\n</script>\n",
|
|
21
21
|
"type": "registry:ui"
|
|
22
22
|
},
|
|
23
23
|
{
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
"path": "src/components/ui/theme-toggle/theme-provider.astro",
|
|
20
|
-
"content": "<script is:inline>\n // A stored \"dark\" or \"light\" is the visitor's choice. Without one, such as\n // no value or \"system\", the theme follows the system.\n const getStoredTheme = () => {\n if (typeof localStorage === \"undefined\") return null\n const theme = localStorage.getItem(\"theme\")\n return theme === \"dark\" || theme === \"light\" ? theme : null\n }\n\n const media = window.matchMedia(\"(prefers-color-scheme: dark)\")\n\n const getThemePreference = () =>\n getStoredTheme() ?? (media.matches ? \"dark\" : \"light\")\n\n const disableTransitionsTemporarily = () => {\n const style = document.createElement(\"style\")\n\n style.appendChild(\n document.createTextNode(\n \"*, *::before, *::after { transition: none !important; }\"\n )\n )\n\n document.head.appendChild(style)\n\n return () => {\n void document.documentElement.offsetHeight\n\n requestAnimationFrame(() => {\n style.remove()\n })\n }\n }\n\n // The theme this provider applied last. A class change to another theme\n // comes from outside, such as a toggle without the provider, and is saved\n // as the visitor's choice.\n let appliedTheme\n\n const applyTheme = (theme, disableTransitions = false) => {\n const restoreTransitions = disableTransitions\n ? disableTransitionsTemporarily()\n : null\n\n appliedTheme = theme\n document.documentElement.classList[theme === \"dark\" ? \"add\" : \"remove\"](\n \"dark\"\n )\n\n restoreTransitions?.()\n }\n\n // \"dark\" or \"light\" saves a choice; \"system\" follows the system again.\n window.__setTheme = (theme) => {\n if (typeof localStorage !== \"undefined\")\n localStorage.setItem(\"theme\", theme)\n applyTheme(getThemePreference(), true)\n }\n\n applyTheme(getThemePreference())\n\n // Follow the system while there is no choice, and a choice made in\n // another window or frame of the site.\n media.addEventListener(\"change\", () => {\n if (!getStoredTheme()) applyTheme(getThemePreference(), true)\n })\n window.addEventListener(\"storage\", (event) => {\n if (event.storageArea !== localStorage) return\n if (event.key === \"theme\" || event.key === null)\n applyTheme(getThemePreference(), true)\n })\n\n if (typeof localStorage !== \"undefined\") {\n const observer = new MutationObserver(() => {\n const theme = document.documentElement.classList.contains(\"dark\")\n ? \"dark\"\n : \"light\"\n if (theme === appliedTheme) return\n appliedTheme = theme\n localStorage.setItem(\"theme\", theme)\n })\n\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: [\"class\"],\n })\n }\n</script>\n",
|
|
20
|
+
"content": "<script is:inline>\n // A stored \"dark\" or \"light\" is the visitor's choice. Without one, such as\n // no value or \"system\", the theme follows the system.\n const getStoredTheme = () => {\n if (typeof localStorage === \"undefined\") return null\n const theme = localStorage.getItem(\"theme\")\n return theme === \"dark\" || theme === \"light\" ? theme : null\n }\n\n const media = window.matchMedia(\"(prefers-color-scheme: dark)\")\n\n const getThemePreference = () =>\n getStoredTheme() ?? (media.matches ? \"dark\" : \"light\")\n\n const disableTransitionsTemporarily = () => {\n const style = document.createElement(\"style\")\n\n style.appendChild(\n document.createTextNode(\n \"*, *::before, *::after { transition: none !important; }\"\n )\n )\n\n document.head.appendChild(style)\n\n return () => {\n void document.documentElement.offsetHeight\n\n requestAnimationFrame(() => {\n style.remove()\n })\n }\n }\n\n // The theme this provider applied last. A class change to another theme\n // comes from outside, such as a toggle without the provider, and is saved\n // as the visitor's choice.\n let appliedTheme\n\n const applyTheme = (theme, disableTransitions = false) => {\n const restoreTransitions = disableTransitions\n ? disableTransitionsTemporarily()\n : null\n\n appliedTheme = theme\n document.documentElement.classList[theme === \"dark\" ? \"add\" : \"remove\"](\n \"dark\"\n )\n\n restoreTransitions?.()\n }\n\n // \"dark\" or \"light\" saves a choice; \"system\" follows the system again.\n window.__setTheme = (theme) => {\n if (typeof localStorage !== \"undefined\")\n localStorage.setItem(\"theme\", theme)\n applyTheme(getThemePreference(), true)\n }\n\n applyTheme(getThemePreference())\n\n // Follow the system while there is no choice, and a choice made in\n // another window or frame of the site.\n media.addEventListener(\"change\", () => {\n if (!getStoredTheme()) applyTheme(getThemePreference(), true)\n })\n window.addEventListener(\"storage\", (event) => {\n if (event.storageArea !== localStorage) return\n if (event.key === \"theme\" || event.key === null)\n applyTheme(getThemePreference(), true)\n })\n\n // Astro's <ClientRouter /> replaces the <html> attributes with those of the\n // next page, which cannot know the theme. Carry the theme over before the\n // swap, so it neither flashes nor reaches the observer below as a choice.\n document.addEventListener(\"astro:before-swap\", (event) => {\n const swap = event.swap\n event.swap = function (...args) {\n event.newDocument.documentElement.classList.toggle(\n \"dark\",\n appliedTheme === \"dark\"\n )\n return swap.apply(this, args)\n }\n })\n\n if (typeof localStorage !== \"undefined\") {\n const observer = new MutationObserver(() => {\n const theme = document.documentElement.classList.contains(\"dark\")\n ? \"dark\"\n : \"light\"\n if (theme === appliedTheme) return\n appliedTheme = theme\n localStorage.setItem(\"theme\", theme)\n })\n\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: [\"class\"],\n })\n }\n</script>\n",
|
|
21
21
|
"type": "registry:ui"
|
|
22
22
|
},
|
|
23
23
|
{
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
"path": "src/components/ui/theme-toggle/theme-provider.astro",
|
|
20
|
-
"content": "<script is:inline>\n // A stored \"dark\" or \"light\" is the visitor's choice. Without one, such as\n // no value or \"system\", the theme follows the system.\n const getStoredTheme = () => {\n if (typeof localStorage === \"undefined\") return null\n const theme = localStorage.getItem(\"theme\")\n return theme === \"dark\" || theme === \"light\" ? theme : null\n }\n\n const media = window.matchMedia(\"(prefers-color-scheme: dark)\")\n\n const getThemePreference = () =>\n getStoredTheme() ?? (media.matches ? \"dark\" : \"light\")\n\n const disableTransitionsTemporarily = () => {\n const style = document.createElement(\"style\")\n\n style.appendChild(\n document.createTextNode(\n \"*, *::before, *::after { transition: none !important; }\"\n )\n )\n\n document.head.appendChild(style)\n\n return () => {\n void document.documentElement.offsetHeight\n\n requestAnimationFrame(() => {\n style.remove()\n })\n }\n }\n\n // The theme this provider applied last. A class change to another theme\n // comes from outside, such as a toggle without the provider, and is saved\n // as the visitor's choice.\n let appliedTheme\n\n const applyTheme = (theme, disableTransitions = false) => {\n const restoreTransitions = disableTransitions\n ? disableTransitionsTemporarily()\n : null\n\n appliedTheme = theme\n document.documentElement.classList[theme === \"dark\" ? \"add\" : \"remove\"](\n \"dark\"\n )\n\n restoreTransitions?.()\n }\n\n // \"dark\" or \"light\" saves a choice; \"system\" follows the system again.\n window.__setTheme = (theme) => {\n if (typeof localStorage !== \"undefined\")\n localStorage.setItem(\"theme\", theme)\n applyTheme(getThemePreference(), true)\n }\n\n applyTheme(getThemePreference())\n\n // Follow the system while there is no choice, and a choice made in\n // another window or frame of the site.\n media.addEventListener(\"change\", () => {\n if (!getStoredTheme()) applyTheme(getThemePreference(), true)\n })\n window.addEventListener(\"storage\", (event) => {\n if (event.storageArea !== localStorage) return\n if (event.key === \"theme\" || event.key === null)\n applyTheme(getThemePreference(), true)\n })\n\n if (typeof localStorage !== \"undefined\") {\n const observer = new MutationObserver(() => {\n const theme = document.documentElement.classList.contains(\"dark\")\n ? \"dark\"\n : \"light\"\n if (theme === appliedTheme) return\n appliedTheme = theme\n localStorage.setItem(\"theme\", theme)\n })\n\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: [\"class\"],\n })\n }\n</script>\n",
|
|
20
|
+
"content": "<script is:inline>\n // A stored \"dark\" or \"light\" is the visitor's choice. Without one, such as\n // no value or \"system\", the theme follows the system.\n const getStoredTheme = () => {\n if (typeof localStorage === \"undefined\") return null\n const theme = localStorage.getItem(\"theme\")\n return theme === \"dark\" || theme === \"light\" ? theme : null\n }\n\n const media = window.matchMedia(\"(prefers-color-scheme: dark)\")\n\n const getThemePreference = () =>\n getStoredTheme() ?? (media.matches ? \"dark\" : \"light\")\n\n const disableTransitionsTemporarily = () => {\n const style = document.createElement(\"style\")\n\n style.appendChild(\n document.createTextNode(\n \"*, *::before, *::after { transition: none !important; }\"\n )\n )\n\n document.head.appendChild(style)\n\n return () => {\n void document.documentElement.offsetHeight\n\n requestAnimationFrame(() => {\n style.remove()\n })\n }\n }\n\n // The theme this provider applied last. A class change to another theme\n // comes from outside, such as a toggle without the provider, and is saved\n // as the visitor's choice.\n let appliedTheme\n\n const applyTheme = (theme, disableTransitions = false) => {\n const restoreTransitions = disableTransitions\n ? disableTransitionsTemporarily()\n : null\n\n appliedTheme = theme\n document.documentElement.classList[theme === \"dark\" ? \"add\" : \"remove\"](\n \"dark\"\n )\n\n restoreTransitions?.()\n }\n\n // \"dark\" or \"light\" saves a choice; \"system\" follows the system again.\n window.__setTheme = (theme) => {\n if (typeof localStorage !== \"undefined\")\n localStorage.setItem(\"theme\", theme)\n applyTheme(getThemePreference(), true)\n }\n\n applyTheme(getThemePreference())\n\n // Follow the system while there is no choice, and a choice made in\n // another window or frame of the site.\n media.addEventListener(\"change\", () => {\n if (!getStoredTheme()) applyTheme(getThemePreference(), true)\n })\n window.addEventListener(\"storage\", (event) => {\n if (event.storageArea !== localStorage) return\n if (event.key === \"theme\" || event.key === null)\n applyTheme(getThemePreference(), true)\n })\n\n // Astro's <ClientRouter /> replaces the <html> attributes with those of the\n // next page, which cannot know the theme. Carry the theme over before the\n // swap, so it neither flashes nor reaches the observer below as a choice.\n document.addEventListener(\"astro:before-swap\", (event) => {\n const swap = event.swap\n event.swap = function (...args) {\n event.newDocument.documentElement.classList.toggle(\n \"dark\",\n appliedTheme === \"dark\"\n )\n return swap.apply(this, args)\n }\n })\n\n if (typeof localStorage !== \"undefined\") {\n const observer = new MutationObserver(() => {\n const theme = document.documentElement.classList.contains(\"dark\")\n ? \"dark\"\n : \"light\"\n if (theme === appliedTheme) return\n appliedTheme = theme\n localStorage.setItem(\"theme\", theme)\n })\n\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: [\"class\"],\n })\n }\n</script>\n",
|
|
21
21
|
"type": "registry:ui"
|
|
22
22
|
},
|
|
23
23
|
{
|
|
@@ -70,6 +70,20 @@
|
|
|
70
70
|
applyTheme(getThemePreference(), true)
|
|
71
71
|
})
|
|
72
72
|
|
|
73
|
+
// Astro's <ClientRouter /> replaces the <html> attributes with those of the
|
|
74
|
+
// next page, which cannot know the theme. Carry the theme over before the
|
|
75
|
+
// swap, so it neither flashes nor reaches the observer below as a choice.
|
|
76
|
+
document.addEventListener("astro:before-swap", (event) => {
|
|
77
|
+
const swap = event.swap
|
|
78
|
+
event.swap = function (...args) {
|
|
79
|
+
event.newDocument.documentElement.classList.toggle(
|
|
80
|
+
"dark",
|
|
81
|
+
appliedTheme === "dark"
|
|
82
|
+
)
|
|
83
|
+
return swap.apply(this, args)
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
|
|
73
87
|
if (typeof localStorage !== "undefined") {
|
|
74
88
|
const observer = new MutationObserver(() => {
|
|
75
89
|
const theme = document.documentElement.classList.contains("dark")
|