Skip to content

Commit

Permalink
ThemeToggle: fix native Tailwind support (#264)
Browse files Browse the repository at this point in the history
Use native Tailwind dark mode support
  • Loading branch information
robsontenorio authored Jan 11, 2024
1 parent f21eb2c commit 731522d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/View/Components/ThemeToggle.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function render(): View|Closure|string
toggle() {
this.theme = this.theme == 'light' ? 'dark' : 'light'
document.documentElement.setAttribute('data-theme', this.theme)
document.documentElement.setAttribute('class', this.theme)
this.$dispatch('theme-changed', this.theme)
}
}"
Expand All @@ -51,6 +52,7 @@ public function render(): View|Closure|string
</div>
<script>
document.documentElement.setAttribute("data-theme", localStorage.getItem("mary-theme")?.replaceAll("\"", ""))
document.documentElement.setAttribute("class", localStorage.getItem("mary-theme")?.replaceAll("\"", ""))
</script>
HTML;
}
Expand Down

0 comments on commit 731522d

Please sign in to comment.