Skip to content

Instantly share code, notes, and snippets.

@esr360
Last active August 12, 2021 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esr360/5409103b0ddee8f8954215194b1e430e to your computer and use it in GitHub Desktop.
Save esr360/5409103b0ddee8f8954215194b1e430e to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
@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,
));
.myScope_panel {
margin-left: 1rem;
}
.myScope_title {
color: red;
font-size: 2rem;
}
{
"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