Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/JohnAlbin/normalize-scss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/sass
diff options
context:
space:
mode:
authorJohnAlbin <virtually.johnalbin@gmail.com>2015-11-13 19:01:14 +0300
committerJohnAlbin <virtually.johnalbin@gmail.com>2015-11-13 19:01:14 +0300
commitbb3e7e180aeba3ce1e277de7a63ba3b14ec846e6 (patch)
tree96ecfcb5a3f030c308fe17212b95ac525ee38c2f /sass
parent344a0c0c226c6771af77889fdbd2491feb3cb266 (diff)
Remove compass/typography/vertical_rhythm module.
Diffstat (limited to 'sass')
-rw-r--r--sass/_normalize.scss62
-rw-r--r--sass/normalize/_font-values.scss58
-rw-r--r--sass/normalize/_variables.scss2
3 files changed, 89 insertions, 33 deletions
diff --git a/sass/_normalize.scss b/sass/_normalize.scss
index f121745..4c40c9b 100644
--- a/sass/_normalize.scss
+++ b/sass/_normalize.scss
@@ -1,14 +1,13 @@
@import 'normalize/variables';
@import 'normalize/support-for';
-// After the default variables are set, import the required Compass partials.
-@import "compass/typography/vertical_rhythm";
+@import 'normalize/font-values';
// If we've customized any font sizes, we'll need extra properties.
$_normalize-font-sizes: false;
@if $base-font-size != 16px
or $base-line-height != 24px
- or $rhythm-unit != 'em'
+ or $base-unit != 'em'
or $h1-font-size != 2 * $base-font-size
or $h2-font-size != 1.5 * $base-font-size
or $h3-font-size != 1.17 * $base-font-size
@@ -169,7 +168,7 @@ strong {
*/
blockquote {
- margin: rhythm(1) $indent-amount;
+ @include normalize-rhythm(margin, 1 $indent-amount);
}
}
@@ -187,61 +186,60 @@ dfn {
*/
h1 {
- font-size: if($rhythm-unit == "px", $h1-font-size, #{unquote(inspect($h1-font-size / $base-font-size) + $rhythm-unit)});
-
+ @include normalize-font-size($h1-font-size);
@if $_normalize-font-sizes {
- line-height: rhythm(ceil(($h1-font-size / $base-line-height) + .1), $h1-font-size);
+ @include normalize-line-height($h1-font-size);
}
/* Set 1 unit of vertical rhythm on the top and bottom margins. */
- margin-top: rhythm(1, $h1-font-size);
- margin-bottom: rhythm(1, $h1-font-size);
+ @include normalize-rhythm(margin-top, 1, $h1-font-size);
+ @include normalize-rhythm(margin-bottom, 1, $h1-font-size);
}
@if $_normalize-font-sizes or normalize-support-for(ie, 7) {
h2 {
- font-size: if($rhythm-unit == "px", $h2-font-size, #{unquote(inspect($h2-font-size / $base-font-size) + $rhythm-unit)});
+ @include normalize-font-size($h2-font-size);
@if $_normalize-font-sizes {
- line-height: rhythm(ceil(($h2-font-size / $base-line-height) + .1), $h2-font-size);
+ @include normalize-line-height($h2-font-size);
}
- margin-top: rhythm(1, $h2-font-size);
- margin-bottom: rhythm(1, $h2-font-size);
+ @include normalize-rhythm(margin-top, 1, $h2-font-size);
+ @include normalize-rhythm(margin-bottom, 1, $h2-font-size);
}
h3 {
- font-size: if($rhythm-unit == "px", $h3-font-size, #{unquote(inspect($h3-font-size / $base-font-size) + $rhythm-unit)});
+ @include normalize-font-size($h3-font-size);
@if $_normalize-font-sizes {
- line-height: rhythm(ceil(($h3-font-size / $base-line-height) + .1), $h3-font-size);
+ @include normalize-line-height($h3-font-size);
}
- margin-top: rhythm(1, $h3-font-size);
- margin-bottom: rhythm(1, $h3-font-size);
+ @include normalize-rhythm(margin-top, 1, $h3-font-size);
+ @include normalize-rhythm(margin-bottom, 1, $h3-font-size);
}
h4 {
- font-size: if($rhythm-unit == "px", $h4-font-size, #{unquote(inspect($h4-font-size / $base-font-size) + $rhythm-unit)});
+ @include normalize-font-size($h4-font-size);
@if $_normalize-font-sizes {
- line-height: rhythm(ceil(($h4-font-size / $base-line-height) + .1), $h4-font-size);
+ @include normalize-line-height($h4-font-size);
}
- margin-top: rhythm(1, $h4-font-size);
- margin-bottom: rhythm(1, $h4-font-size);
+ @include normalize-rhythm(margin-top, 1, $h4-font-size);
+ @include normalize-rhythm(margin-bottom, 1, $h4-font-size);
}
h5 {
- font-size: if($rhythm-unit == "px", $h5-font-size, #{unquote(inspect($h5-font-size / $base-font-size) + $rhythm-unit)});
+ @include normalize-font-size($h5-font-size);
@if $_normalize-font-sizes {
- line-height: rhythm(ceil(($h5-font-size / $base-line-height) + .1), $h5-font-size);
+ @include normalize-line-height($h5-font-size);
}
- margin-top: rhythm(1, $h5-font-size);
- margin-bottom: rhythm(1, $h5-font-size);
+ @include normalize-rhythm(margin-top, 1, $h5-font-size);
+ @include normalize-rhythm(margin-bottom, 1, $h5-font-size);
}
h6 {
- font-size: if($rhythm-unit == "px", $h6-font-size, #{unquote(inspect($h6-font-size / $base-font-size) + $rhythm-unit)});
+ @include normalize-font-size($h6-font-size);
@if $_normalize-font-sizes {
- line-height: rhythm(ceil(($h6-font-size / $base-line-height) + .1), $h6-font-size);
+ @include normalize-line-height($h6-font-size);
}
- margin-top: rhythm(1, $h6-font-size);
- margin-bottom: rhythm(1, $h6-font-size);
+ @include normalize-rhythm(margin-top, 1, $h6-font-size);
+ @include normalize-rhythm(margin-bottom, 1, $h6-font-size);
}
}
@@ -263,7 +261,7 @@ h1 {
p,
pre {
- margin: rhythm(1) 0;
+ @include normalize-rhythm(margin, 1 0);
}
}
@@ -307,7 +305,7 @@ sub {
menu,
ol,
ul {
- margin: rhythm(1) 0;
+ @include normalize-rhythm(margin, 1 0);
}
}
@@ -387,7 +385,7 @@ svg:not(:root) {
*/
figure {
- margin: rhythm(1) $indent-amount;
+ @include normalize-rhythm(margin, 1 $indent-amount);
}
}
diff --git a/sass/normalize/_font-values.scss b/sass/normalize/_font-values.scss
new file mode 100644
index 0000000..3a7de03
--- /dev/null
+++ b/sass/normalize/_font-values.scss
@@ -0,0 +1,58 @@
+@mixin normalize-font-size($value, $relative-to: $base-font-size) {
+ @if unit($value) != 'px' {
+ @error "font-size-normalize() only supports px inputs. The typey library is better.";
+ }
+ @if $base-unit == rem {
+ // px fallback for IE 8 and earlier. Note: IE 9/10 don't understand rem
+ // in font shorthand, but font-size longhand is fine.
+ @if normalize-support-for(ie, 8) {
+ font-size: $value;
+ }
+ font-size: ($value / $base-font-size) * 1rem;
+ }
+ @else if $base-unit == em {
+ font-size: ($value / $relative-to) * 1em;
+ }
+ @else { // $base-unit == px
+ font-size: $value;
+ }
+}
+
+@mixin normalize-rhythm($property, $values, $relative-to: $base-font-size) {
+ @if type-of($values) == 'list' {
+ $px-fallback: $values;
+ }
+ @else {
+ $px-fallback: append((), $values);
+ }
+ $sep: list-separator($px-fallback);
+ $normalized-values: ();
+
+ @each $value in $px-fallback {
+ @if unitless($value) and $value != 0 {
+ @if $base-unit == rem {
+ $value: $value * ($base-line-height / $base-font-size) * 1rem;
+ }
+ @else if $base-unit == em {
+ $value: $value * ($base-line-height / $relative-to) * 1em;
+ }
+ @else { // $base-unit == px
+ $value: $value * $base-line-height;
+ }
+ }
+ $normalized-values: append($normalized-values, $value);
+ }
+ @if $base-unit == rem and normalize-support-for(ie, 8) {
+ #{$property}: $px-fallback;
+ }
+ #{$property}: $normalized-values;
+}
+
+@mixin normalize-line-height($font-size, $min-line-padding: 2px) {
+ $lines: ceil($font-size / $base-line-height);
+ // If lines are cramped include some extra lead.
+ @if ($lines * $base-line-height - $font-size) < ($min-line-padding * 2) {
+ $lines: $lines + 1;
+ }
+ @include normalize-rhythm(line-height, $lines, $font-size);
+}
diff --git a/sass/normalize/_variables.scss b/sass/normalize/_variables.scss
index 4ff5fdc..9b4bd39 100644
--- a/sass/normalize/_variables.scss
+++ b/sass/normalize/_variables.scss
@@ -10,7 +10,7 @@ $base-line-height: 24px !default;
// The length unit in which to output vertical rhythm values.
// Supported values: px, em, rem.
-$rhythm-unit: 'em' !default;
+$base-unit: 'em' !default;
// The default font family.
$base-font-family: sans-serif !default;