Skip to content

Instantly share code, notes, and snippets.

@binary-solo
Created June 15, 2015 12:33
Show Gist options
  • Select an option

  • Save binary-solo/8edf4323b22e6e87cc0e to your computer and use it in GitHub Desktop.

Select an option

Save binary-solo/8edf4323b22e6e87cc0e to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.4.14)
// Compass (v1.0.3)
// ----
@function map-fetch($map, $keys) {
$key: nth($keys, 1);
$length: length($keys);
$value: map-get($map, $key);
@if ($length > 1) {
$rest: ();
@for $i from 2 through $length {
$rest: append($rest, nth($keys, $i))
}
@return map-fetch($value, $rest)
} @else {
@return $value;
}
}
$notice-boxes: (
types: (
warning: (
border: yellow,
background: lighten(yellow, 20)
),
error: (
border: red,
background: red
)
)
);
@each $type in map-keys(map-get($notice-boxes, types)) {
.notice-box-#{$type} {
background-color: map-fetch($notice-boxes, types $type background);
border: map-fetch($notice-boxes, types $type border);
}
}
.notice-box-warning {
background-color: #ffff66;
border: yellow;
}
.notice-box-error {
background-color: red;
border: red;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment