Skip to content

Instantly share code, notes, and snippets.

@jestho
Last active January 30, 2016 21:23
Show Gist options
  • Save jestho/0c1b24357c209b2aa336 to your computer and use it in GitHub Desktop.
Save jestho/0c1b24357c209b2aa336 to your computer and use it in GitHub Desktop.
set/get args
// ----
// libsass (v3.2.5)
// ----
$args-map: () !default;
@function set($id, $args...) {
$new-args: ($id: $args);
$args-map: map-merge($args-map, $new-args) !global;
@return map-get($args-map, $id);
}
@function get($id, $args...) {
@if map-has-key($args-map, $id) {
@if $args {
@return map-get($args-map, $id), $args;
}
@return map-get($args-map, $id);
} @else {
@warn #{$id + " is not defined."};
@return $args;
}
}
@function add($id, $args...) {
@return set($id, get($id), $args);
}
body {
background: #f1f1f1;
font: 1rem "Helvetica Neue", sans-serif;
padding: 2rem;
}
.button {
background: white;
border: none;
font: inherit;
padding: 1em;
animation: set("button-animation", spin 1s infinite linear);
-webkit-font-smoothing: antialiased;
&:hover {
animation: set("button-animation-hover", get("button-animation"), glow 1s infinite linear);
}
&:active {
animation: get("button-animation-hover", size 1s infinite linear);
}
}
@keyframes size {
50% { font-size: 3em; }
}
@keyframes glow {
50% { background: red };
}
@keyframes spin {
100% { transform: rotate(360deg) };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment