Skip to content

Commit c5f38ff

Browse files
committed
Add .font-baseline() mixin.
1 parent bead102 commit c5f38ff

File tree

7 files changed

+19
-17
lines changed

7 files changed

+19
-17
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ Less code (see [full listing](examples/003_Baselines/stylesheet.less)):
266266
.use-column-grid(680px, 24px, 3);
267267

268268
html {
269-
font: @baseline-size / @baseline-height @main-font-family;
269+
.font-baseline();
270270
}
271271

272272
h1 {
@@ -388,12 +388,11 @@ You can also define baseline offset by referencing a font definition:
388388
.use-baseline-grid(16px, 1.5, verdana);
389389
```
390390

391-
You must set `font-size` and `line-height` properties of `html` element to the same values:
391+
You must set `font-size` and `line-height` properties of `html` element to the same values using `font-baseline()` mixin:
392392

393393
```less
394394
html {
395-
font-size: @baseline-size;
396-
line-height: @baseline-height;
395+
.font-baseline();
397396
}
398397
```
399398

examples/001_Overview/stylesheet.css

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@ html {
9595
padding: 24px;
9696
margin-left: 80px;
9797
margin-right: 80px;
98-
font-family: 'Verdana', sans-serif;
99-
font-size: 16px;
100-
line-height: 1.5;
98+
font: 16px / 1.5 'Verdana', sans-serif;
10199
}
102100
main {
103101
position: relative;

examples/001_Overview/stylesheet.less

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ html {
5555
padding: @grid-gutter;
5656
margin-left: 80px;
5757
margin-right: 80px;
58-
font-family: @verdana-font-family;
59-
font-size: @baseline-size;
60-
line-height: @baseline-height;
58+
.font-baseline();
6159
}
6260

6361
main {

examples/003_Baselines/stylesheet.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ main {
7070
.use-column-grid(680px, 24px, 3);
7171

7272
html {
73-
font: @baseline-size / @baseline-height @main-font-family;
73+
.font-baseline();
7474
}
7575

7676
h1 {

order.less

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,18 @@
138138
@baseline-name: @name;
139139

140140
@-offset: "@{name}-font-offset";
141+
@-family: "@{name}-font-family";
141142
.use-baseline-grid(@size, @height, @@-offset, @size, @height, @@-offset);
142143

144+
// Setting baseline font properties on root element
145+
.font-baseline () when not(@-family = false) {
146+
font: @baseline-size / @baseline-height @@-family;
147+
}
148+
.font-baseline () when (@-family = false) {
149+
font-size: @baseline-size;
150+
line-height: @baseline-height;
151+
}
152+
143153

144154
//
145155
// Property mixins
@@ -164,6 +174,7 @@
164174
.-baseline-font(@current-size, @baseline-size, @current-height, @@-variation, @@-family);
165175
}
166176

177+
167178
//
168179
// Private mixins
169180
//

tests/stylesheet.css

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,7 @@ html {
378378
line-height: 0.65;
379379
}
380380
html {
381-
font-family: Verdana, sans-serif;
382-
font-size: 16px;
383-
line-height: 1.5;
381+
font: 16px / 1.5 'Verdana', sans-serif;
384382
}
385383
#baseline-horizontal,
386384
#baseline-vertical,

tests/stylesheet.less

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,7 @@ html {
370370
.use-baseline-grid(@scale-base, 1.5, verdana);
371371

372372
html {
373-
font-family: Verdana, sans-serif;
374-
font-size: @baseline-size;
375-
line-height: @baseline-height;
373+
.font-baseline();
376374
}
377375

378376
#baseline-horizontal, #baseline-vertical, #baseline-vertical-family, #baseline-vertical-line, #baseline-vertical-offset {

0 commit comments

Comments
 (0)