Skip to content

Commit ba469b3

Browse files
committed
feat: add line-height ratio (#18)
because: - usually, big font-sizes do have a smaller line-height (in relation to the font-size) than “normal” font-sizes do this commit: - introduces a new Sass variable to control the ratio with which the line-height gets decreased, the bigger the font-size is
1 parent 50273b4 commit ba469b3

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,16 @@ You can define an ideal line-height that is taken into account when calculating
193193
$FLUIDMS-GLOBAL-LINE-HEIGHT: 1.5 !default;
194194
```
195195

196+
### Changing the global line-height ratio
197+
198+
The bigger font-sizes get, the lesser the line-height needs to be in relation to its font-size. Hence, we provide an option to decrease the line-height in proportion to the font-size, the bigger the font-size gets.
199+
200+
```scss
201+
$FLUIDMS-GLOBAL-LINE-HEIGHT-RATIO: 1 !default;
202+
```
203+
204+
Don’t get crazy with this variable’s value! Only nudge the ratio slightly and always test all the possible font-sizes with multiline text.
205+
196206
### Configure the Fluid Typography values
197207

198208
With Fluid Typography, you basically define a viewport range in which all the font-sizes are fluid, i.e. the font-sizes are sized according to the viewport size — if the viewport size is small, the font-size is too. If the viewport size is large, so is the font-size.

src/settings/_settings.config.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ $FLUIDMS-GLOBAL-BASELINE: 0.25rem !default;
2525
/// $FLUIDMS-GLOBAL-LINE-HEIGHT: 1.35 !default
2626
$FLUIDMS-GLOBAL-LINE-HEIGHT: 1.5 !default;
2727
28+
/// Define the ratio with which the line-height is decreased relatively for
29+
/// larger font-sizes. That is, the calculated line-height value is getting
30+
/// smaller in ralation to the font-size, the bigger the font-size gets.
31+
///
32+
/// @type number
33+
$FLUIDMS-GLOBAL-LINE-HEIGHT-RATIO: 1 !default;
34+
2835
/// Hold all the relevant settings for Fluid Typography.
2936
///
3037
/// @prop {length (in `px`)} min-font-size [16px] - Defines the font-size at

src/tools/_tools.line-height.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/// our `$FLUIDMS-GLOBAL-BASELINE`.
2222
@function fluidms-line-height($scale, $ratio) {
2323
// Calculate the default line-height (in `rem`).
24-
$_default-line-height: (fluidms-pow($ratio, $scale)) * $FLUIDMS-GLOBAL-LINE-HEIGHT;
24+
$_default-line-height: (fluidms-pow($ratio, $scale)) * ($FLUIDMS-GLOBAL-LINE-HEIGHT / fluidms-pow($FLUIDMS-GLOBAL-LINE-HEIGHT-RATIO, $scale));
2525
// Get the “offset” of the vertical grid.
2626
$_remainder: $_default-line-height;
2727
@while $_remainder >= fluidms-strip-unit($FLUIDMS-GLOBAL-BASELINE) {

0 commit comments

Comments
 (0)