This repository has been archived by the owner on Oct 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_functions.scss
68 lines (56 loc) · 1.52 KB
/
_functions.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*===============================================
Functions - Co-op Front-end Toolkit
===============================================*/
@import "variables";
/**
* Returns a full-formed url based on the $base-url setting.
* @param {string} $url the relative URL for the resource
* @return {string} the fully-formed url() value
*/
@function asset-url($url) {
@return url($base-asset-url + $url);
}
/**
* Strip unit from given value
* @param {Number} $value Value to remove unit from
* @return {Number} Raw value without unit
*/
@function strip-unit($value) {
@if type-of($value) == 'number' and not unitless($value) {
@return $value / ($value * 0 + 1);
}
@return $value;
}
/**
* Convert a pixel value to em
* @param {Number} $value The pixel value to convert
* @return {Number} The value converted to em
*/
@function em-calc($value) {
$base-font-size: map-deep-get($typographic-scale, "base", "body");
@return (strip-unit($value) / strip-unit($base-font-size)) * 1em;
}
@function emCalc($value) {
@warn "emCalc is deprecated. Please use em-calc() instead.";
@return em-calc($value);
}
/**
* Returns map-get($map, $key) or the default if the key doesn't exist
*/
@function map-get-default($map, $key, $default) {
@if map-has-key($map, $key) {
@return map-get($map, $key);
}
@else {
@return $default;
}
}
/**
* Returns a value from a deeply-nested map
*/
@function map-deep-get($map, $keys...) {
@each $key in $keys {
$map: map-get($map, $key);
}
@return $map;
}