Skip to content

Instantly share code, notes, and snippets.

@Aupajo
Last active August 29, 2015 14:17
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 Aupajo/f998208c99b07534262b to your computer and use it in GitHub Desktop.
Save Aupajo/f998208c99b07534262b to your computer and use it in GitHub Desktop.
Sass maps
@import "palette";
body {
font: 20pt "Helvetica Neue", sans-serif;
}
$actions: (
primary: (
link: $blue,
hover: lighten($blue, 0.1),
active: darken($blue, 0.2)
),
secondary: (
link: $light-blue,
hover: lighten($light-blue, 0.2),
active: darken($light-blue, 0.2)
),
destructive: (
link: $red,
hover: lighten($red, 0.05),
active: darken($red, 0.1)
)
);
@each $action, $states in $actions {
.#{$action}-button {
background: map_get($states, link);
border: none;
border-radius: 0.4em;
padding: 1em 2em;
display: inline-block;
font-size: 1em;
text-decoration: none;
color: white;
@each $state, $colour in $states {
&:#{$state} { background: $colour; }
}
}
}
<button class="primary-button">Primary</button>
<a href=".." class="secondary-button">Secondary</a>
<button class="destructive-button">Delete</button>
// Colours
$blue: rgb(0, 119, 255);
$light-blue: rgb(47, 163, 200);
$red: #cc0000;
// Derived colours
$brand-colour: $blue;
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment