Skip to content

Commit 248b400

Browse files
authored
Merge pull request #406 from BeAPI/fix/scss
Fix/scss
2 parents 9cbf635 + efbd58c commit 248b400

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

src/scss/02-tools/_f-to-number.scss

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
@use "sass:map";
2+
@use "sass:math";
3+
@use "sass:string";
4+
5+
/**
6+
* To number - convert string to number
7+
*
8+
* @author: Stackoverflow - https://stackoverflow.com/questions/47630616/scss-arithmetic-operation-with-string
9+
*
10+
* @param string $value
11+
*
12+
* Examples :
13+
* @for $i from 1 through 6 {
14+
* &[data-per-line="#{$i}"] {
15+
* .card {
16+
* width: column(to-number(#{math.div(12, $i + 1)}));
17+
* }
18+
* }
19+
* }
20+
*/
21+
22+
@function to-number($value) {
23+
@if type-of($value) == "number" {
24+
@return $value;
25+
} @else if type-of($value) != "string" {
26+
@error "Value for `to-number` should be a number or a string.";
27+
}
28+
29+
$result: 0;
30+
$digits: 0;
31+
$minus: string.slice($value, 1, 1) == "-";
32+
$numbers: ("0": 0, "1": 1, "2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7, "8": 8, "9": 9);
33+
34+
@for $i from if($minus, 2, 1) through str-length($value) {
35+
$character: string.slice($value, $i, $i);
36+
37+
@if (index(map-keys($numbers), $character) or $character == ".") {
38+
@if $character == "." {
39+
$digits: 1;
40+
} @else if $digits == 0 {
41+
$result: $result * 10 + map.get($numbers, $character);
42+
} @else {
43+
$digits: $digits * 10;
44+
$result: $result + math.div(map.get($numbers, $character), $digits);
45+
}
46+
}
47+
}
48+
49+
@return if($minus, -$result, $result);
50+
}

src/scss/02-tools/_m-sr-only.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343

4444
@mixin sr-only($focusable: false) {
4545
position: absolute;
46+
top: auto !important;
47+
left: -10000px !important;
4648
width: 1px !important;
4749
height: 1px !important;
4850
padding: 0 !important;

0 commit comments

Comments
 (0)