Created
April 7, 2022 20:24
-
-
Save khamer/a812f238be78a254ee94975059384ee4 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@use "sass:list"; | |
@use "sass:string"; | |
@use "sass:map"; | |
@function unslash-colons($str) { | |
$index: string.index($str, \:); | |
@if $index != null { | |
@return unslash-colons(string.slice($str, 1, $index - 1) + string.slice($str, $index + 1)); | |
} @else { | |
@return $str; | |
} | |
} | |
@mixin modifiers($map, $default-map: (), $prefix: '.-', $suffixes: \:hover \:active \:focus) { | |
@each $pair in $map { | |
$key: list.nth($pair, 1); | |
$value: null; | |
@if list.length($pair) > 1 { | |
$value: list.nth($pair, 2); | |
} @else if map.has-key($default-map, $key) { | |
$value: map.get($default-map, $key); | |
} | |
@if $value != null { | |
&#{$prefix}#{unslash-colons($key)} { | |
@content($value); | |
} | |
} @else { | |
@content($key); | |
} | |
@each $suffix in $suffixes { | |
@if map.has-key($default-map, $key + $suffix) { | |
$value: map.get($default-map, $key + $suffix); | |
&#{$prefix}#{functions.unslash-colons($key + $suffix)} { | |
@content($value); | |
} | |
} | |
} | |
} | |
} | |
.button { | |
@include modifiers(( | |
gold, | |
primary red, | |
primary\:hover pink, | |
secondary blue, | |
secondary\:hover lightblue, | |
)) using ($color) { | |
color: $color; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.button { | |
color: gold; | |
} | |
.button.-primary { | |
color: red; | |
} | |
.button.-primary:hover { | |
color: pink; | |
} | |
.button.-secondary { | |
color: blue; | |
} | |
.button.-secondary:hover { | |
color: lightblue; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"sass": { | |
"compiler": "dart-sass/1.32.12", | |
"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