-
-
Notifications
You must be signed in to change notification settings - Fork 170
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
Fluid type scale #216
base: prod
Are you sure you want to change the base?
Fluid type scale #216
Changes from 10 commits
b244a0d
154edd0
ae2b04f
321fe4e
b4d402e
c307d01
45d96d7
9a4103e
656d822
1f41ee4
f8b21cc
a6274bc
1339f14
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,7 +1,10 @@ | ||||||
@import 'typography'; | ||||||
|
||||||
body { | ||||||
border-top: 1rem solid $primary-color; | ||||||
font-family: $sans-serif; | ||||||
font-size: pxToRem(20); | ||||||
font-size: var(--step0); | ||||||
line-height: $line-height-heading; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you adding
Suggested change
|
||||||
margin: 0; | ||||||
padding: 2rem; | ||||||
} | ||||||
|
@@ -11,7 +14,7 @@ code { | |||||
border: pxToRem(1px) solid $black; | ||||||
border-radius: 0.25em; | ||||||
color: $white; | ||||||
font-size: 95%; | ||||||
font-size: var(--step-2); | ||||||
padding: 0.15em; | ||||||
|
||||||
pre & { | ||||||
|
@@ -33,5 +36,5 @@ th { | |||||
} | ||||||
|
||||||
pre[class*='language-'] { | ||||||
font-size: 1rem; | ||||||
font-size: var(--step-1); | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
@use "sass:map"; | ||
|
||
/// Create new/different scales by editing the config | ||
/// This is the single source of truth | ||
$fluid-config: ( | ||
// Typescale ratio for calculating steps | ||
typescale-ratio: 1.25, | ||
// base font size to use for --step0 | ||
base-fontsize: 1rem, | ||
// adjustment added to base-fontsize in --step0 for scaling | ||
viewport-scale: 0.5vw, | ||
// number of positive steps (--step1, --step2 etc) | ||
// and number of negative steps (--step-1, --step-2 etc) | ||
Comment on lines
+12
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These names are not really clear. Hyphenating is common to separate words, especially in CSS where we don’t use camel case. Can you change these two be either There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. Will update |
||
steps: | ||
( | ||
pos: 10, | ||
neg: 3 | ||
) | ||
); | ||
|
||
/// Creates all required css step variables | ||
/// for the type scale | ||
/// | ||
/// @param {number} $typescale-ratio | ||
/// The ratio we use to compute steps. | ||
/// @example | ||
/// --step1 : calc(var(--step0 * #{$typescale-ratio})) | ||
/// | ||
/// @param {integer (rem)} $base-fontsize | ||
/// The base fontsize we use for step0 | ||
/// @param {integer (vw)} $viewport-scale | ||
/// adjustment added to base-fontsize for scaling | ||
/// @example | ||
/// --step0: calc(#{$base-fontsize}+#{$viewport-scale}) | ||
/// | ||
/// @param {map} $steps | ||
/// no of positive and negative steps to create in font scales | ||
/// @example | ||
/// $steps: (pos: 7, neg: 3) | ||
|
||
@mixin create-typescale( | ||
$typescale-ratio, | ||
$base-fontsize, | ||
$viewport-scale, | ||
$steps | ||
) { | ||
$pos-steps: map.get($steps, pos); | ||
$neg-steps: map.get($steps, neg); | ||
--step0: calc(#{$base-fontsize} + #{$viewport-scale}); | ||
@for $step from 1 to $pos-steps { | ||
& { | ||
--step#{$step}: calc(var(--step#{$step - 1}) * #{$typescale-ratio}); | ||
} | ||
} | ||
|
||
@for $step from 1 to $neg-steps { | ||
// to account for the lack of dash(-) in step0 | ||
// --step-0 doesn't exist so we need to use a different expression | ||
// while computing --step-1 | ||
@if $step != 1 { | ||
& { | ||
--step-#{$step}: calc(var(--step-#{$step - 1}) / #{$typescale-ratio}); | ||
} | ||
} @else { | ||
& { | ||
--step-#{$step}: calc(var(--step0) / #{$typescale-ratio}); | ||
} | ||
} | ||
} | ||
} | ||
|
||
:root { | ||
@include create-typescale($fluid-config...); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,57 @@ | ||
$line-height-heading: 1; | ||
$line-height-body: 1.4; | ||
$line-height-tight: 0.8; | ||
|
||
h1 { | ||
font-family: $ext-sans; | ||
font-weight: $bold; | ||
font-family: $ext-sans; | ||
font-weight: $bold; | ||
line-height: $line-height-heading; | ||
} | ||
|
||
h1, | ||
h2, | ||
h3, | ||
h4 { | ||
margin-bottom: 0.5em; | ||
margin-top: 1em; | ||
word-break: break-word; | ||
line-height: $line-height-heading; | ||
margin-bottom: 0.5em; | ||
margin-top: 1em; | ||
word-break: break-word; | ||
} | ||
|
||
p { | ||
font-size: 1.25rem; | ||
line-height: 1.25; | ||
margin: 0.75rem 0; | ||
} | ||
|
||
.thicc-headline { | ||
// a sensible base font size | ||
font-size: 3rem; | ||
line-height: 0.75; | ||
margin: 0.5rem 0rem; | ||
padding: 0; | ||
font-size: var(--step-1); | ||
line-height: $line-height-body; | ||
margin: 0.75rem 0; | ||
} | ||
|
||
@media (min-width: 51rem) and (min-height: 400px) { | ||
// a dramatic font size | ||
.thicc-headline { | ||
font-size: 12vh; | ||
} | ||
li { | ||
font-size: var(--step-1); | ||
line-height: $line-height-body; | ||
} | ||
|
||
@media (min-width: 51rem) and (min-height: 850px) { | ||
// cap the maximum font size of the title | ||
// at the same size that 12vh computes to | ||
// when the viewport is 850px high | ||
// One day we can use CSS clamp https://caniuse.com/#feat=mdn-css_types_clamp | ||
.thicc-headline { | ||
font-size: 6.75rem; | ||
} | ||
.thicc-headline { | ||
font-size: var(--step6); | ||
line-height: $line-height-tight; | ||
margin: 0.5rem 0; | ||
padding: 0; | ||
} | ||
|
||
.main-headline { | ||
font-family: orpheuspro, Palatino, Times, serif; | ||
font-size: 3.5rem; | ||
line-height: 1.2; | ||
margin: 0; | ||
font-family: orpheuspro, Palatino, Times, serif; | ||
font-size: var(--step4); | ||
line-height: $line-height-heading; | ||
margin: 0; | ||
} | ||
|
||
.sub-headline { | ||
font-family: $ext-sans; | ||
font-size: 1.25rem; | ||
font-weight: $bold; | ||
letter-spacing: 0.1; | ||
margin: .75rem 0; | ||
font-family: $ext-sans; | ||
font-size: var(--step0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe |
||
font-weight: $bold; | ||
letter-spacing: 0.01rem; | ||
line-height: $line-height-heading; | ||
margin: 0.75rem 0; | ||
} | ||
|
||
.small { | ||
font-size: 0.75em; | ||
font-size: var(--step-1); | ||
line-height: $line-height-body; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,10 @@ | |
} | ||
} | ||
|
||
.wide-content .title p { | ||
font-size: var(--step-2); | ||
} | ||
|
||
.definition { | ||
max-width: 47rem; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
|
||
&__title { | ||
font-family: $serif; | ||
font-size: 2.5rem; | ||
font-size: var(--step3); | ||
font-weight: 900; | ||
line-height: 1.25; | ||
margin-bottom: 1rem; | ||
|
@@ -31,17 +31,18 @@ | |
|
||
& > p { | ||
font-family: $sans-serif; | ||
font-size: 1.5rem; | ||
font-size: var(--step0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you changed this here because |
||
grid-column: 1 / -1; | ||
line-height: 1.4; | ||
line-height: $line-height-body; | ||
} | ||
|
||
& h2 { | ||
flex: 0 1 auto; | ||
font-family: $con-sans; | ||
font-size: 0.85rem; | ||
font-size: var(--step-2); | ||
font-weight: normal; | ||
grid-column: 1; | ||
line-height: $line-height-body; | ||
text-transform: uppercase; | ||
transform: translateY(0.4em); | ||
|
||
|
@@ -75,7 +76,7 @@ | |
color: var(--word-signal-color); | ||
display: block; | ||
font-family: $ext-sans; | ||
font-size: 0.75rem; | ||
font-size: var(--step-2); | ||
letter-spacing: 0.15rem; | ||
padding: 0.5rem 0.75rem; | ||
text-transform: uppercase; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We import this in
css/base.scss
, I think you were adding this here because otherwise the SASS variables you are defining in the typography partial would not be accessible?Two ways to mitigate this, both cleaning up the structure a bit:
abstracts/variables
(or inbase/_fonts
where the font weights and families are defined)base/custom-properties