Skip to content

Instantly share code, notes, and snippets.

@theer1k
Created June 10, 2023 00:08
Show Gist options
  • Save theer1k/bfce556506d5a396cb7ee7c3aa7d332d to your computer and use it in GitHub Desktop.
Save theer1k/bfce556506d5a396cb7ee7c3aa7d332d to your computer and use it in GitHub Desktop.
Theme Colors Props Shades Mixin Generator
$separator: '\\:' !default;
@mixin theme-colors-props-shades($name, $prop, $colors, $shades) {
@each $color in $colors {
@each $shade in $shades {
.#{$name}-#{$color}-#{$shade} {
#{$prop}: var(--#{$color}-#{$shade});
}
}
.focus#{$separator} {
&#{$name}-#{$color} {
@each $shade in $shades {
&-#{$shade}:focus {
#{$prop}: var(--#{$color}-#{$shade}) !important;
}
}
}
}
.hover#{$separator} {
&#{$name}-#{$color} {
@each $shade in $shades {
&-#{$shade}:hover {
#{$prop}: var(--#{$color}-#{$shade}) !important;
}
}
}
}
.active#{$separator} {
&#{$name}-#{$color} {
@each $shade in $shades {
&-#{$shade}:active {
#{$prop}: var(--#{$color}-#{$shade}) !important;
}
}
}
}
}
}
// * Usage example *
// $themeColors: 'primary', 'secondary';
// $colorShades: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900;
// @include theme-colors-props-shades('text', 'color', $themeColors, $colorShades);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment