Skip to content

Commit

Permalink
Update theme scss mixin to not increase selector specificity
Browse files Browse the repository at this point in the history
  • Loading branch information
danon committed Dec 6, 2024
1 parent 3a13211 commit 979963f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 33 deletions.
35 changes: 16 additions & 19 deletions resources/feature/lookAndFeel/lookAndFeel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,18 @@ $forum-aside-radius: 8px;
--var-navbar-user-avatar-padding: 0.25rem;
}

@include theme.both {
body {
background: var(--body-background);
}
.neon-post {
border: var(--post-border);
background: var(--post-background);
border-radius: $post-radius;
.neon-post-header,
.neon-post-footer {
background: var(--post-header-background);
border-color: var(--post-header-border-color);
}
body {
background: var(--body-background) !important; // overrides _reboot.scss body {background}
}

.neon-post {
border: var(--post-border) !important; // overrides .card {border}
background: var(--post-background);
border-radius: $post-radius;
.neon-post-header,
.neon-post-footer {
background: var(--post-header-background);
border-color: var(--post-header-border-color);
}
}

Expand All @@ -90,11 +89,9 @@ $forum-aside-radius: 8px;
}
}

@include theme.both {
.neon-section-heading {
border-bottom-width: 2px;
border-bottom-color: var(--section-heading-divider-color) !important; // !important for h4.section
}
.neon-section-heading {
border-bottom-width: 2px;
border-bottom-color: var(--section-heading-divider-color) !important; // !important for h4.section
}

.default-avatar {
Expand Down Expand Up @@ -125,7 +122,7 @@ $forum-aside-radius: 8px;

.neon-navbar-text,
.neon-navbar-link {
color: var(--navbar-text-color) !important;
color: var(--navbar-text-color) !important; // overrides .nav-link {color}
}

.viewers-online {
Expand Down
17 changes: 3 additions & 14 deletions resources/feature/theme/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,14 @@

@mixin scope($class) {
@if & {
html.#{$class} & {@content}
*:where(html.#{$class}) & {@content}
} @else {
html.#{$class} {@content}
*:where(html.#{$class}) {@content}
}
}

@mixin both {
/**
* The dark() and light() mixins increase selector specificity.
* In some cases, it's necessary to apply a common style to both
* themes, overriding a previously defined style.
* For that we need to artificially elevate the specificity
* of the style, without actually changing any style.
*/
@if & {
html.theme-light &, html.theme-dark & {@content}
} @else {
html.theme-light, html.theme-dark {@content}
}
@content;
}

@mixin property($property, $light, $dark) {
Expand Down

0 comments on commit 979963f

Please sign in to comment.