Skip to content

Instantly share code, notes, and snippets.

@njb-said
Created January 18, 2018 21:21
Show Gist options
  • Save njb-said/f9e93742024644964163fc75ced618e9 to your computer and use it in GitHub Desktop.
Save njb-said/f9e93742024644964163fc75ced618e9 to your computer and use it in GitHub Desktop.
Example of Sass mixins
@mixin accent-colors($position, $direction) {
@if $direction == 'x' {
border-#{$position}-left-radius: 0;
border-#{$position}-right-radius: 0;
} @else {
border-top-#{$position}-radius: 0;
border-bottom-#{$position}-radius: 0;
}
border-#{$position}: 3px solid transparent;
padding-#{$position}: 2.5rem;
&.blue {
border-#{$position}-color: #2196f3;
}
&.red {
border-#{$position}-color: #f44336;
}
&.gold {
border-#{$position}-color: #ffc107;
}
&.green {
border-#{$position}-color: #4caf50;
}
&.purple {
border-#{$position}-color: #673ab7;
}
}
.card {
display: block;
background-color: white;
padding: 1rem;
border: 1px solid #b3b3b3;
border-radius: 3px;
box-shadow: 0 1px 3px 0px #c7c7c7;
&.accent-top {
@include accent-colors('top', 'x');
}
&.accent-bottom {
@include accent-colors('bottom', 'x');
}
&.accent-left {
@include accent-colors('left', 'y');
}
&.accent-right {
@include accent-colors('right', 'y');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment