Skip to content

Commit 1e6e726

Browse files
author
Pickra
committed
Write custom function directive
1 parent 57a64b7 commit 1e6e726

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@function font-scale($exponent, $base-font-size: 14px, $ratio: 1.2) {
2+
$value: 1;
3+
4+
@for $i from 1 through $exponent {
5+
$value: $value * $ratio;
6+
}
7+
8+
@return if($exponent > 0, $base-font-size * $value, $base-font-size);
9+
}
10+
11+
.stuff { font-size: font-scale(4); }
12+
.things { font-size: font-scale(2); }
13+
14+
@for $i from 1 through 6 {
15+
$exponent: 7 - $i;
16+
17+
h#{$i} { font-size: font-scale($exponent, $ratio: 1.5); }
18+
}

scss/main.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
@import "iterate-with-the-each-directive/iterate-with-the-each-directive";
1+
@import "function-directive/_function-directive.scss";

0 commit comments

Comments
 (0)