Debian Codegraph @

debian/missing-sources/bourbon-neat/app/assets/stylesheets/functions/_private.scss

raw
1 // Not function for Libsass compatibility
2 // https://github.com/sass/libsass/issues/368
3 @function is-not($value) {
4 @return if($value, false, true);
5 }
6
7 // Checks if a number is even
8 @function is-even($int) {
9 @return $int % 2 == 0;
10 }
11
12 // Checks if an element belongs to a list or not
13 @function belongs-to($tested-item, $list) {
14 @return is-not(not-belongs-to($tested-item, $list));
15 }
16
17 @function not-belongs-to($tested-item, $list) {
18 @return is-not(index($list, $tested-item));
19 }
20
21 // Contains display value
22 @function contains-display-value($query) {
23 @return belongs-to(table, $query)
24 or belongs-to(block, $query)
25 or belongs-to(inline-block, $query)
26 or belongs-to(inline, $query);
27 }
28
29 // Parses the first argument of span-columns()
30 @function container-span($span: $span) {
31 @if length($span) == 3 {
32 $container-columns: nth($span, 3);
33 @return $container-columns;
34 } @else if length($span) == 2 {
35 $container-columns: nth($span, 2);
36 @return $container-columns;
37 }
38
39 @return $grid-columns;
40 }
41
42 @function container-shift($shift: $shift) {
43 $parent-columns: $grid-columns !default !global;
44
45 @if length($shift) == 3 {
46 $container-columns: nth($shift, 3);
47 @return $container-columns;
48 } @else if length($shift) == 2 {
49 $container-columns: nth($shift, 2);
50 @return $container-columns;
51 }
52
53 @return $parent-columns;
54 }
55
56 // Generates a striped background
57 @function gradient-stops($grid-columns, $color: $visual-grid-color) {
58 $transparent: transparent;
59 $alt-color: darken($color, 10%);
60
61 $column-width: flex-grid(1, $grid-columns);
62 $gutter-width: flex-gutter($grid-columns);
63 $column-offset: $column-width;
64 $alternate: false;
65
66 $values: ($transparent 0, if($alternate, $color, $alt-color) 0);
67
68 @for $i from 1 to $grid-columns*2 {
69 @if is-even($i) {
70 $values: append($values, $transparent $column-offset, comma);
71 $values: append($values, if($alternate, $color, $alt-color) $column-offset, comma);
72 $column-offset: $column-offset + $column-width;
73 } @else {
74 $values: append($values, if($alternate, $color, $alt-color) $column-offset, comma);
75 $values: append($values, $transparent $column-offset, comma);
76 $column-offset: $column-offset + $gutter-width;
77
78 $alternate: not $alternate;
79 }
80 }
81
82 @return $values;
83 }
84
85 // Layout direction
86 @function get-direction($layout, $default) {
87 $direction: null;
88
89 @if to-upper-case($layout) == "LTR" or to-upper-case($layout) == "RTL" {
90 $direction: direction-from-layout($layout);
91 } @else {
92 $direction: direction-from-layout($default);
93 }
94
95 @return $direction;
96 }
97
98 @function direction-from-layout($layout) {
99 $direction: null;
100
101 @if to-upper-case($layout) == "LTR" {
102 $direction: right;
103 } @else {
104 $direction: left;
105 }
106
107 @return $direction;
108 }
109
110 @function get-opposite-direction($direction) {
111 $opposite-direction: left;
112
113 @if $direction == "left" {
114 $opposite-direction: right;
115 }
116
117 @return $opposite-direction;
118 }
119
120
121 @function to-number($string) {
122 $string: str-replace($string, " ", "");
123 $strings: "0" "1" "2" "3" "4" "5" "6" "7" "8" "9";
124 $numbers: 0 1 2 3 4 5 6 7 8 9;
125 $result: 0;
126
127 @for $i from 1 through str-length($string) {
128 $character: str-slice($string, $i, $i);
129 $index: index($strings, $character);
130
131 @if not $index {
132 @warn "Unknown character `#{$character}`.";
133 @return false;
134 }
135
136 $number: nth($numbers, $index);
137 $result: $result * 10 + $number;
138 }
139
140 @return $result;
141 }
142
143 @function str-replace($string, $search, $replace: "") {
144 $index: str-index($string, $search);
145
146 @if $index {
147 $first: str-slice($string, 1, $index - 1);
148 $last-slice: str-slice($string, $index + str-length($search));
149 $last: str-replace($last-slice, $search, $replace);
150 @return $first + $replace + $last;
151 }
152
153 @return $string;
154 }