DEV: Use CSS custom properties for complex color variations

DEV: Use CSS custom properties for complex color variations

diff --git a/assets/stylesheets/colors.scss b/assets/stylesheets/colors.scss
new file mode 100644
index 0000000..7dd26ff
--- /dev/null
+++ b/assets/stylesheets/colors.scss
@@ -0,0 +1,14 @@
+:root {
+  --calendar-normal: #{dark-light-choose(
+      lighten($tertiary, 55%),
+      darken($tertiary, 25%)
+    )};
+  --calendar-close-to-working-hours: #{dark-light-choose(
+      desaturate(lighten($tertiary, 45%), 15%),
+      darken($tertiary, 15%)
+    )};
+  --calendar-in-working-hours: #{dark-light-choose(
+      desaturate(lighten($tertiary, 40%), 20%),
+      darken($tertiary, 10%)
+    )};
+}
diff --git a/assets/stylesheets/common/discourse-calendar.scss b/assets/stylesheets/common/discourse-calendar.scss
index eb9bb32..5719699 100644
--- a/assets/stylesheets/common/discourse-calendar.scss
+++ b/assets/stylesheets/common/discourse-calendar.scss
@@ -202,6 +202,7 @@ a.holiday {
   font-size: 16px;
 }
 
+// TODO: remove fallbacks when colors CSS custom properties are in stable in core
 $bg-normal: dark-light-choose(lighten($tertiary, 55%), darken($tertiary, 25%));
 $bg-close-to-working-hours: dark-light-choose(
   desaturate(lighten($tertiary, 45%), 15%),
@@ -283,6 +284,7 @@ $bg-in-working-hours: dark-light-choose(
       "<svg xmlns='http://www.w3.org/2000/svg' width='2' height='2'><rect fill='#{$tertiary}' x='0' y='0' width='2' height='2'/></svg>"
     )
     50% 50% repeat-x;
+
   box-sizing: border-box;
   transition: opacity 0.2s;
 }
@@ -328,7 +330,7 @@ $bg-in-working-hours: dark-light-choose(
 
   .group-timezone {
     color: var(--primary, $primary);
-    background-color: $bg-normal;
+    background-color: var(--calendar-normal, $bg-normal);
     transition: opacity 0.4s;
     opacity: 0.5;
 
@@ -341,12 +343,15 @@ $bg-in-working-hours: dark-light-choose(
     }
 
     &.close-to-working-hours {
-      background-color: $bg-close-to-working-hours;
+      background-color: var(
+        --calendar-close-to-working-hours,
+        $bg-close-to-working-hours
+      );
       opacity: 0.7;
     }
 
     &.in-working-hours {
-      background-color: $bg-in-working-hours;
+      background-color: var(--calendar-in-working-hours, $bg-in-working-hours);
       opacity: 1;
     }
 
diff --git a/plugin.rb b/plugin.rb
index 67638fa..f8a44e5 100644
--- a/plugin.rb
+++ b/plugin.rb
@@ -24,6 +24,7 @@ register_asset "stylesheets/common/discourse-post-event-core-ext.scss"
 register_asset "stylesheets/mobile/discourse-calendar.scss", :mobile
 register_asset "stylesheets/mobile/discourse-post-event.scss", :mobile
 register_asset "stylesheets/desktop/discourse-calendar.scss", :desktop
+register_asset "stylesheets/colors.scss", :color_definitions
 register_svg_icon "fas fa-calendar-day"
 register_svg_icon "fas fa-clock"
 register_svg_icon "fas fa-file-csv"

GitHub sha: bf31bb35