Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Prevent vertical rhythm rules with variable #156

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions fork-version/_normalize.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
@import 'vertical-rhythm';

// If we've customized any font variables, we'll need extra properties.
@if $base-line-height != 24px
or $base-unit != 'em'
or $h2-font-size != 1.5 * $base-font-size
or $h3-font-size != 1.17 * $base-font-size
or $h4-font-size != 1 * $base-font-size
or $h5-font-size != 0.83 * $base-font-size
or $h6-font-size != 0.67 * $base-font-size
or $indent-amount != 40px {
@if $normalize-vertical-rhythm == null
and (
$base-line-height != 24px
or $base-unit != 'em'
or $h2-font-size != 1.5 * $base-font-size
or $h3-font-size != 1.17 * $base-font-size
or $h4-font-size != 1 * $base-font-size
or $h5-font-size != 0.83 * $base-font-size
or $h6-font-size != 0.67 * $base-font-size
) {
$normalize-vertical-rhythm: true !global;
}

Expand Down
5 changes: 3 additions & 2 deletions fork-version/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ $indent-amount: 40px !default;
// font-sizes, line-heights and block-level top/bottom margins that form a basic
// vertical rhythm on the page, which differs from the original Normalize.css.
// However, changing any of the variables above will cause
// $normalize-vertical-rhythm to be automatically set to true.
$normalize-vertical-rhythm: false !default;
// $normalize-vertical-rhythm to be automatically set to true. To prevent
// outputting any vertical rhythm rules, set this variable to false.
$normalize-vertical-rhythm: null !default;
17 changes: 10 additions & 7 deletions sass/normalize/_normalize-mixin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@
$init: _normalize-include($include, $exclude);

// If we've customized any font variables, we'll need extra properties.
@if $base-line-height != 24px
or $base-unit != 'em'
or $h2-font-size != 1.5 * $base-font-size
or $h3-font-size != 1.17 * $base-font-size
or $h4-font-size != 1 * $base-font-size
or $h5-font-size != 0.83 * $base-font-size
or $h6-font-size != 0.67 * $base-font-size {
@if $normalize-vertical-rhythm == null
and (
$base-line-height != 24px
or $base-unit != 'em'
or $h2-font-size != 1.5 * $base-font-size
or $h3-font-size != 1.17 * $base-font-size
or $h4-font-size != 1 * $base-font-size
or $h5-font-size != 0.83 * $base-font-size
or $h6-font-size != 0.67 * $base-font-size
) {
$normalize-vertical-rhythm: true !global;
}

Expand Down
5 changes: 3 additions & 2 deletions sass/normalize/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ $indent-amount: 40px !default;
// font-sizes, line-heights and block-level top/bottom margins that form a basic
// vertical rhythm on the page, which differs from the original Normalize.css.
// However, changing any of the variables above will cause
// $normalize-vertical-rhythm to be automatically set to true.
$normalize-vertical-rhythm: false !default;
// $normalize-vertical-rhythm to be automatically set to true. To prevent
// outputting any vertical rhythm rules, set this variable to false.
$normalize-vertical-rhythm: null !default;
7 changes: 7 additions & 0 deletions test/fixtures/variables/prevent-vertical-rhythm/input.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This variable only affects output when vertical rhythm is used.
$h2-font-size: 48px;
// Force vertical rhythm off.
$normalize-vertical-rhythm: false;

@import 'normalize';
@include normalize();
Loading