Skip to content

Instantly share code, notes, and snippets.

@airen
Created June 9, 2015 03:00
Show Gist options
  • Save airen/45e71913376bfeca536f to your computer and use it in GitHub Desktop.
Save airen/45e71913376bfeca536f to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
<div data-theme="2">
<div class="button">Button</div>
</div>
<div class="button">Button</div>
// ----
// Sass (v3.4.14)
// Compass (v1.0.3)
// ----
$color-stack:
(group: button, id: theme1, color: #e67835),
(group: button, id: theme2, color: #f8a878),
(group: button, id: theme3, color: #ad490c),
(group: button, id: theme4, color: #426682),
(group: title, id: theme1, color: #ff9900),
(group: title, id: theme2, color: #9900ff),
(group: title, id: theme3, color: #00ff99),
(group: title, id: theme4, color: #0f0f0f);
// Color Function
@function color($group, $shade:normal, $transparency:1){
@each $color in $color-stack{
$c-group: map-get($color, group);
$c-shade: map-get($color, id);
@if($group == map-get($color, group) and $shade == map-get($color, id)){
@return rgba(map-get($color, color), $transparency);
}
}
}
.button {
background: color(button,theme1);
@if lightness(color(button,theme1)) > 50% {
color: #fff;
} @else {
color: #000;
}
[data-theme="2"] & {
background: color(button,theme2);
@if lightness(color(button,theme1)) > 50%{
color: #fff;
} @else {
color: #000;
}
}
}
.button {
background: #e67835;
color: #fff;
}
[data-theme="2"] .button {
background: #f8a878;
color: #fff;
}
<div data-theme="2">
<div class="button">Button</div>
</div>
<div class="button">Button</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment