Enhance color theme management with improved set-color-shades mixin; add scrollbar styling

This commit is contained in:
Christian Werner 2025-10-21 01:25:16 +02:00
parent ceb1489eda
commit f391db4fba
2 changed files with 42 additions and 12 deletions

View File

@ -8,9 +8,33 @@ $success-color: hsl(110, 60%, 50%);
$warn-color: hsl(50, 70%, 50%); $warn-color: hsl(50, 70%, 50%);
$danger-color: hsl(10, 80%, 50%); $danger-color: hsl(10, 80%, 50%);
@mixin set-color-shades($name, $color, $step: 10) { @mixin set-color-shades($name, $color, $step: 10, $padded: false, $reverse: false) {
@for $i from 1 through (100/$step)-1 { $from: 1;
--#{$name}-#{$i * $step}: hsl(#{color.hue($color)}, #{color.saturation($color)}, #{$i * $step}%); $to: 100/$step;
@if $padded {
$from: 0;
}
@if not $padded {
$to: $to - 1;
}
@for $i from $from through $to {
$index: $i;
@if $reverse {
@if $padded {
$index: ($to - $i);
} @else {
$index: ($to - $i) + 1;
}
}
@debug $reverse, $index, $i, $to;
--#{$name}-#{$i * $step}: hsl(#{color.hue($color)}, #{color.saturation($color)}, #{$index * $step}%);
} }
} }
@ -37,7 +61,7 @@ $danger-color: hsl(10, 80%, 50%);
@for $i from $from through $to { @for $i from $from through $to {
.#{$name}-#{$i * $step} { .#{$name}-#{$i * $step} {
--bg-color: hsl(#{color.hue($color)}, #{color.saturation($color)}, #{$i * $step}%); --bg-color: var(--#{$name}-#{$i * $step});
@if $i * $step <= $text-color-swap-step { @if $i * $step <= $text-color-swap-step {
--text-color: #{$text-color-swap-dark}; --text-color: #{$text-color-swap-dark};
@ -49,16 +73,16 @@ $danger-color: hsl(10, 80%, 50%);
@for $i from $from through $to { @for $i from $from through $to {
.#{$name}-icon-#{$i * $step} { .#{$name}-icon-#{$i * $step} {
--text-color: hsl(#{color.hue($color)}, #{color.saturation($color)}, #{$i * $step}%); --text-color: var(--#{$name}-#{$i * $step});
} }
} }
} }
:root { :root {
@include set-color-shades("neutral", hsl(0, 0%, 0%), 10); @include set-color-shades("neutral", hsl(240, 25%, 0%), 10, true, false);
@include set-common-colors(); @include set-common-colors();
@include set-color-shades("primary", $primary-color, 10); @include set-color-shades("primary", $primary-color, 10, false, false);
@include set-color-shades("secondary", $secondary-color, 10); @include set-color-shades("secondary", $secondary-color, 10, false, false);
--bg-color: var(--neutral-90); --bg-color: var(--neutral-90);
--text-color: var(--neutral-10); --text-color: var(--neutral-10);
@ -66,13 +90,14 @@ $danger-color: hsl(10, 80%, 50%);
@media (prefers-color-scheme: dark) { @media (prefers-color-scheme: dark) {
:root { :root {
--bg-color: var(--neutral-10); @include set-color-shades("neutral", hsl(240, 25%, 0%), 10, true, true);
--text-color: var(--neutral-90); @include set-color-shades("primary", $primary-color, 10, false, true);
@include set-color-shades("secondary", $secondary-color, 10, false, true);
} }
} }
a { a {
color: var(--secondary-70); color: var(--secondary-30);
text-decoration: none; text-decoration: none;
&:hover { &:hover {
@ -80,7 +105,7 @@ a {
} }
} }
@include set-color-classes("neutral", hsl(0, 0%, 0%), 10, true); @include set-color-classes("neutral", hsl(240, 25%, 0%), 10, true);
@include set-color-classes("primary", $primary-color, 10, false); @include set-color-classes("primary", $primary-color, 10, false);
@include set-color-classes("secondary", $secondary-color, 10, false, 60); @include set-color-classes("secondary", $secondary-color, 10, false, 60);

View File

@ -15,3 +15,8 @@ body {
background-color: var(--bg-color); background-color: var(--bg-color);
color: var(--text-color); color: var(--text-color);
} }
* {
scrollbar-color: var(--neutral-70)var(--neutral-80);
scrollbar-width: thin;
}