| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,88 @@ |
| 1 |
+@if not-imported("import_once_func") { @import "import_once_func"; }
|
|
| 2 |
+@if not-imported("settings") { @import "settings"; }
|
|
| 3 |
+ |
|
| 4 |
+@function font-size($size,$ascendant-font-size: $font-size-default) {
|
|
| 5 |
+ @return $size / $ascendant-font-size * 1rem |
|
| 6 |
+} |
|
| 7 |
+ |
|
| 8 |
+@function str-replace($string, $search, $replace: '') {
|
|
| 9 |
+ $index: str-index($string, $search); |
|
| 10 |
+ |
|
| 11 |
+ @if $index {
|
|
| 12 |
+ @return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace); |
|
| 13 |
+ } |
|
| 14 |
+ |
|
| 15 |
+ @return $string; |
|
| 16 |
+} |
|
| 17 |
+ |
|
| 18 |
+@function repeat($character, $n){
|
|
| 19 |
+ $c:""; |
|
| 20 |
+ @if $n > 0 {
|
|
| 21 |
+ @for $i from 1 through $n {
|
|
| 22 |
+ $c: $c + $character; |
|
| 23 |
+ } |
|
| 24 |
+ } |
|
| 25 |
+ @return $c; |
|
| 26 |
+} |
|
| 27 |
+ |
|
| 28 |
+/// Convert angle |
|
| 29 |
+/// @author Chris Eppstein |
|
| 30 |
+/// @param {Number} $value - Value to convert
|
|
| 31 |
+/// @param {String} $unit - Unit to convert to
|
|
| 32 |
+/// @return {Number} Converted angle
|
|
| 33 |
+@function convert-angle($value, $unit) {
|
|
| 34 |
+ $convertable-units: deg grad turn rad; |
|
| 35 |
+ $conversion-factors: 1 (10grad/9deg) (1turn/360deg) (3.1415926rad/180deg); |
|
| 36 |
+ @if index($convertable-units, unit($value)) and index($convertable-units, $unit) {
|
|
| 37 |
+ @return $value |
|
| 38 |
+ / nth($conversion-factors, index($convertable-units, unit($value))) |
|
| 39 |
+ * nth($conversion-factors, index($convertable-units, $unit)); |
|
| 40 |
+ } |
|
| 41 |
+ |
|
| 42 |
+ @warn "Cannot convert `#{unit($value)}` to `#{$unit}`.";
|
|
| 43 |
+} |
|
| 44 |
+ |
|
| 45 |
+/// Test if `$value` is an angle |
|
| 46 |
+/// @param {*} $value - Value to test
|
|
| 47 |
+/// @return {Bool}
|
|
| 48 |
+@function is-direction($value) {
|
|
| 49 |
+ $is-direction: index((to top, to top right, to right top, to right, to bottom right, to right bottom, to bottom, to bottom left, to left bottom, to left, to left top, to top left), $value); |
|
| 50 |
+ $is-angle: type-of($value) == 'number' and index('deg' 'grad' 'turn' 'rad', unit($value));
|
|
| 51 |
+ |
|
| 52 |
+ @return $is-direction or $is-angle; |
|
| 53 |
+} |
|
| 54 |
+ |
|
| 55 |
+/// Convert a direction to legacy syntax |
|
| 56 |
+/// @param {Keyword | Angle} $value - Value to convert
|
|
| 57 |
+/// @require {function} is-direction
|
|
| 58 |
+/// @require {function} convert-angle
|
|
| 59 |
+@function legacy-direction($value) {
|
|
| 60 |
+ @if is-direction($value) == false {
|
|
| 61 |
+ @warn "Cannot convert `#{$value}` to legacy syntax because it doesn't seem to be an angle or a direction";
|
|
| 62 |
+ } |
|
| 63 |
+ |
|
| 64 |
+ $conversion-map: ( |
|
| 65 |
+ to top : bottom, |
|
| 66 |
+ to top right : bottom left, |
|
| 67 |
+ to right top : left bottom, |
|
| 68 |
+ to right : left, |
|
| 69 |
+ to bottom right : top left, |
|
| 70 |
+ to right bottom : left top, |
|
| 71 |
+ to bottom : top, |
|
| 72 |
+ to bottom left : top right, |
|
| 73 |
+ to left bottom : right top, |
|
| 74 |
+ to left : right, |
|
| 75 |
+ to left top : right bottom, |
|
| 76 |
+ to top left : bottom right |
|
| 77 |
+ ); |
|
| 78 |
+ |
|
| 79 |
+ @if map-has-key($conversion-map, $value) {
|
|
| 80 |
+ @return map-get($conversion-map, $value); |
|
| 81 |
+ } |
|
| 82 |
+ |
|
| 83 |
+ @return 90deg - convert-angle($value, 'deg'); |
|
| 84 |
+} |
|
| 85 |
+ |
|
| 86 |
+@function col($columns, $container-columns, $gap: 0) {
|
|
| 87 |
+ @return $columns / $container-columns * 100% - ($gap * 100%); |
|
| 88 |
+} |