Skip to content

Commit

Permalink
Update scss mixins light() and dark() to be used without parent selector
Browse files Browse the repository at this point in the history
  • Loading branch information
danon committed Oct 15, 2024
1 parent 0948b53 commit 5185757
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions resources/feature/theme/theme.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
@mixin light {
body.theme-light & {
@include scope(theme-light) {
@content;
}
}

@mixin dark {
body.theme-dark & {
@include scope(theme-dark) {
@content;
}
}

@mixin scope($class) {
@if & {
html.#{$class} & {
@content;
}
} @else {
body.#{$class} {
@content;
}
}
}
1 change: 1 addition & 0 deletions resources/js/components/navbar-toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function setViewTheme(isDark: boolean): void {

function setBodyTheme(isDark: boolean): void {
document.querySelector('html')!.classList.toggle('theme-dark', isDark);
document.querySelector('html')!.classList.toggle('theme-light', !isDark);
document.body.classList.toggle('theme-dark', isDark);
document.body.classList.toggle('theme-light', !isDark);
}
Expand Down

0 comments on commit 5185757

Please sign in to comment.