Skip to content

Instantly share code, notes, and snippets.

@KittyGiraudel
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save KittyGiraudel/324e5d32934df4cef69d to your computer and use it in GitHub Desktop.

Select an option

Save KittyGiraudel/324e5d32934df4cef69d to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.4.5)
// Compass (v1.0.1)
// ----
/// Constants map
/// @type Map
$CONSTANTS: ();
/// Constant getter
/// @param {String} $name - Name of constant to get
/// @return {*} Constant value
/// @require $CONSTANTS
/// @throw 'Unknown constant `#{$name}`.'
@function const($name) {
@if not map-has-key($CONSTANTS, $name) {
@error 'Unknown constant `#{$name}`.';
}
@return map-get($CONSTANTS, $name);
}
/// Constant setter
/// @param {String} $name - Name of constant to get
/// @param {*} $value - Constant value
/// @return {*} Constant value
/// @require $CONSTANTS
/// @throw 'Constant `#{$name}` already defined.'
/// @output Nothing
@mixin const($name, $value) {
@if map-has-key($CONSTANTS, $name) {
@error 'Constant `#{$name}` already defined.';
}
$CONSTANTS: map-merge($CONSTANTS, ($name: $value)) !global;
}
@include const('MAX_Z_INDEX', 2147483647);
@include const('PI', 3.1415926535897932384626433832795028841971693993751);
@include const('E', 2.71828182845904523536028747135266249775724709369995);
test {
z-index: const('MAX_Z_INDEX');
}
test {
z-index: 2147483647;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment