Initial commit
[editorial.git] / assets / main / sass / libs / _mixins.scss
diff --git a/assets/main/sass/libs/_mixins.scss b/assets/main/sass/libs/_mixins.scss
new file mode 100644 (file)
index 0000000..2fc1bda
--- /dev/null
@@ -0,0 +1,63 @@
+/// Makes an element's :before pseudoelement a FontAwesome icon.\r
+/// @param {string} $content Optional content value to use.\r
+/// @param {string} $where Optional pseudoelement to target (before or after).\r
+@mixin icon($content: false, $where: before) {\r
+\r
+       text-decoration: none;\r
+\r
+       &:#{$where} {\r
+\r
+               @if $content {\r
+                       content: $content;\r
+               }\r
+\r
+               -moz-osx-font-smoothing: grayscale;\r
+               -webkit-font-smoothing: antialiased;\r
+               font-family: FontAwesome;\r
+               font-style: normal;\r
+               font-weight: normal;\r
+               text-transform: none !important;\r
+\r
+       }\r
+\r
+}\r
+\r
+/// Applies padding to an element, taking the current element-margin value into account.\r
+/// @param {mixed} $tb Top/bottom padding.\r
+/// @param {mixed} $lr Left/right padding.\r
+/// @param {list} $pad Optional extra padding (in the following order top, right, bottom, left)\r
+/// @param {bool} $important If true, adds !important.\r
+@mixin padding($tb, $lr, $pad: (0,0,0,0), $important: null) {\r
+\r
+       @if $important {\r
+               $important: '!important';\r
+       }\r
+\r
+       $x: 0.1em;\r
+\r
+       @if unit(_size(element-margin)) == 'rem' {\r
+               $x: 0.1rem;\r
+       }\r
+\r
+       padding: ($tb + nth($pad,1)) ($lr + nth($pad,2)) max($x, $tb - _size(element-margin) + nth($pad,3)) ($lr + nth($pad,4)) #{$important};\r
+\r
+}\r
+\r
+/// Encodes a SVG data URL so IE doesn't choke (via codepen.io/jakob-e/pen/YXXBrp).\r
+/// @param {string} $svg SVG data URL.\r
+/// @return {string} Encoded SVG data URL.\r
+@function svg-url($svg) {\r
+\r
+       $svg: str-replace($svg, '"', '\'');\r
+       $svg: str-replace($svg, '%', '%25');\r
+       $svg: str-replace($svg, '<', '%3C');\r
+       $svg: str-replace($svg, '>', '%3E');\r
+       $svg: str-replace($svg, '&', '%26');\r
+       $svg: str-replace($svg, '#', '%23');\r
+       $svg: str-replace($svg, '{', '%7B');\r
+       $svg: str-replace($svg, '}', '%7D');\r
+       $svg: str-replace($svg, ';', '%3B');\r
+\r
+       @return url("data:image/svg+xml;charset=utf8,#{$svg}");\r
+\r
+}
\ No newline at end of file