Skip to content

Instantly share code, notes, and snippets.

@joshblack
Created February 2, 2021 18:30
Show Gist options
  • Save joshblack/43e0b14ada5b7ac563063850aebdab30 to your computer and use it in GitHub Desktop.
Save joshblack/43e0b14ada5b7ac563063850aebdab30 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
@use 'sass:color';
@use 'sass:map';
@mixin theme($theme) {
@each $key, $value in $theme {
--#{$key}: #{$value};
}
}
$light: (
ui-background: #f3f3f3,
text-color: black,
);
$dark: (
ui-background: black,
text-color: white,
);
:root {
@include theme($light);
}
.dark {
@include theme($dark);
}
@mixin format($theme, $tokens, $format: 'rgb') {
@each $token in $tokens {
$value: map.get($theme, $token);
@if $format == 'rgb' {
--#{$token}-rgb: #{color.red($value)}, #{color.green($value)}, #{color.blue($value)};
}
}
}
.my-selector {
@include format($light, ui-background);
background: rgba(var(--ui-background-rgb), 0.25);
}
:root {
--ui-background: #f3f3f3;
--text-color: black;
}
.dark {
--ui-background: black;
--text-color: white;
}
.my-selector {
--ui-background-rgb: 243, 243, 243;
background: rgba(var(--ui-background-rgb), 0.25);
}
{
"sass": {
"compiler": "dart-sass/1.26.11",
"extensions": {},
"syntax": "SCSS",
"outputStyle": "expanded"
},
"autoprefixer": false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment