Skip to content

Commit ab31bc2

Browse files
committed
refactor: update dark theme variables
1 parent 0d26caa commit ab31bc2

File tree

5 files changed

+69
-27
lines changed

5 files changed

+69
-27
lines changed

scss/mixins/_utilities.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
}
5858

5959
@if $is-css-var {
60-
.#{$property-class + $infix + $property-class-modifier} {
60+
#{if($theme-prefix, theme-prefix("#{$property-class + $infix + $property-class-modifier}"), ".#{$property-class + $infix + $property-class-modifier}")} {
6161
--#{$variable-prefix}#{$css-variable-name}: #{$value};
6262
}
6363

scss/themes/dark.scss

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,7 @@ $theme-prefix: "dark" !default;
99
.#{$theme-name} {
1010
@import "dark/variables";
1111
@import "dark/utilities";
12-
13-
// Colors
14-
@each $color, $value in $theme-colors-dt {
15-
--#{$variable-prefix}#{$color}: #{$value};
16-
}
17-
18-
// Gradients
19-
@each $color, $map in $theme-gradients-dt {
20-
--#{$variable-prefix}#{$color}-start: #{map-get($map, "start")};
21-
--#{$variable-prefix}#{$color}-stop: #{map-get($map, "stop")};
22-
}
12+
@import "dark/root";
2313

2414
@include theme($theme-map);
2515

scss/themes/dark/_root.scss

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// stylelint-disable scss/selector-no-redundant-nesting-selector
2+
& {
3+
@each $color, $value in $theme-colors-dt {
4+
--#{$variable-prefix}#{$color}: #{$value};
5+
}
6+
7+
@each $color, $value in $theme-colors-rgb-dt {
8+
--#{$variable-prefix}#{$color}-rgb: #{$value};
9+
}
10+
11+
--#{$variable-prefix}body-color-rgb: #{to-rgb($body-color-dt)};
12+
--#{$variable-prefix}body-bg-rgb: #{to-rgb($body-bg-dt)};
13+
14+
// Gradients
15+
@each $color, $map in $theme-gradients-dt {
16+
--#{$variable-prefix}#{$color}-start: #{map-get($map, "start")};
17+
--#{$variable-prefix}#{$color}-stop: #{map-get($map, "stop")};
18+
}
19+
}

scss/themes/dark/_utilities.scss

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
1-
// Utilities
1+
// Utilities maps
2+
3+
$utilities-colors-dt: $theme-colors-rgb-dt !default;
4+
$utilities-text-dt: map-merge(
5+
$utilities-colors,
6+
(
7+
"black": to-rgb($black),
8+
"white": to-rgb($white),
9+
"body": to-rgb($body-color-dt),
10+
"high-emphasis": to-rgb($high-emphasis-dt),
11+
"medium-emphasis": to-rgb($medium-emphasis-dt),
12+
"disabled": to-rgb($disabled-dt)
13+
)
14+
) !default;
15+
$utilities-text-colors-dt: map-loop($utilities-text-dt, rgba-css-var, "$key", "text") !default;
16+
$utilities-bg-dt: map-merge(
17+
$utilities-colors-dt,
18+
(
19+
"black": to-rgb($black),
20+
"white": to-rgb($white),
21+
"body": to-rgb($body-bg-dt)
22+
)
23+
) !default;
24+
$utilities-bg-colors-dt: map-loop($utilities-bg-dt, rgba-css-var, "$key", "bg") !default;
25+
226
// stylelint-disable-next-line scss/dollar-variable-default
327
$utilities: ();
428
// stylelint-disable-next-line scss/dollar-variable-default
@@ -8,16 +32,9 @@ $utilities: map-merge(
832
property: color,
933
class: text,
1034
values: map-merge(
11-
$theme-colors,
35+
$utilities-text-colors-dt,
1236
(
13-
"white": $white,
14-
"body": $body-color-dt,
15-
"black-50": rgba($black, .5),
16-
"white-50": rgba($white, .5),
17-
"reset": inherit,
18-
"high-emphasis": $high-emphasis-dt,
19-
"medium-emphasis": $medium-emphasis-dt,
20-
"disabled": $disabled-dt
37+
"reset": inherit
2138
)
2239
),
2340
only-vars: true,
@@ -26,17 +43,31 @@ $utilities: map-merge(
2643
"background-color": (
2744
property: background-color,
2845
class: bg,
46+
local-vars: (
47+
"bg-opacity": 1
48+
),
2949
values: map-merge(
30-
$theme-colors,
50+
$utilities-bg-colors-dt,
3151
(
32-
"body": $body-bg,
33-
"white": $white,
3452
"transparent": transparent
3553
)
3654
),
37-
only-vars: true,
55+
vars: true,
56+
theme-prefix: true
57+
),
58+
"bg-opacity": (
59+
css-var: true,
60+
class: bg-opacity,
61+
values: (
62+
10: .1,
63+
25: .25,
64+
50: .5,
65+
75: .75,
66+
100: 1
67+
),
68+
// only-vars: true,
3869
theme-prefix: true,
39-
)
70+
),
4071
),
4172
$utilities
4273
);

scss/themes/dark/_variables.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ $theme-colors-dt: (
3939
) !default;
4040
// fusv-enable
4141

42+
$theme-colors-rgb-dt: map-loop($theme-colors-dt, to-rgb, "$value") !default;
43+
4244
// Gradients
4345

4446
// scss-docs-start theme-gradients

0 commit comments

Comments
 (0)