Last active
August 12, 2021 19:01
-
-
Save esr360/5409103b0ddee8f8954215194b1e430e 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:map"; | |
$types: (( | |
"box": ("padding", "margin-left"), | |
"typography": ("font-size", "color"), | |
)); | |
@mixin component($name, $type, $styles, $scope: "myScope_") { | |
.#{$scope + $name} { | |
@each $property, $value in $styles { | |
@each $type, $properties in $type { | |
@if list.index(map.get($types, $type), $property) { | |
#{$property}: $value; | |
} @else { | |
@error "TypeError: Property `#{$property}` does not exist on type `#{$type}`"; | |
} | |
} | |
} | |
} | |
} | |
@include component("panel", $type: ("box"), $styles: ( | |
margin-left: 1rem, | |
color: blue | |
)); | |
@include component("title", $type: ("typography"), $styles: ( | |
color: red, | |
font-size: 2rem, | |
)); |
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
.myScope_panel { | |
margin-left: 1rem; | |
} | |
.myScope_title { | |
color: red; | |
font-size: 2rem; | |
} |
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