Skip to content

Commit

Permalink
add font sizes and fluid spacers
Browse files Browse the repository at this point in the history
  • Loading branch information
pkd2512 committed Aug 4, 2023
1 parent 8b527e9 commit addf8e0
Show file tree
Hide file tree
Showing 13 changed files with 642 additions and 164 deletions.
2 changes: 1 addition & 1 deletion src/components/GraphicBlock/GraphicBlock.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
@include text-sm;
@include text-primary;
&:last-of-type {
@extend %fmb-1;
@include fmb-1;
}
}
// Notes text...
Expand Down
6 changes: 3 additions & 3 deletions src/components/Headline/Headline.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@
header.headline {
:global {
h1 {
@extend %fmy-1;
@extend %fmx-auto;
@include fmy-1;
@include fmx-auto;
}
p {
Expand All @@ -129,7 +129,7 @@
}
.article-metadata {
.byline-container {
@extend %fmb-1;
@include fmb-1;
}
.byline {
Expand Down
2 changes: 1 addition & 1 deletion src/components/SimpleTimeline/SimpleTimeline.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
}
}
:global(p) {
@extend %fmb-2;
@include fmb-2;
@include leading-normal;
@include font-light;
@include text-sm;
Expand Down
40 changes: 30 additions & 10 deletions src/components/SiteHeadline/SiteHeadline.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,6 @@
let hedClass;
$: {
switch (hedSize) {
// case 'biggest':
// hedClass = 'text-6xl';
// break;
// case 'bigger':
// hedClass = 'text-5xl';
// break;
case 'big':
hedClass = 'text-4xl';
break;
Expand All @@ -100,7 +94,7 @@
<div class="title">
{#if section}
<p
class="section-title mb-2 font-subhed text-sm text-secondary font-bold"
class="section-title mb-0 font-subhed text-xxs text-secondary font-bold uppercase whitespace-nowrap tracking-wider"
>
{#if sectionUrl}
<a class="no-underline !text-secondary" href="{sectionUrl}"
Expand All @@ -112,14 +106,18 @@
</p>
{/if}
{#if hed}
<h1 class="my-0 font-hed text-primary leading-none {hedClass}">
<h1
class="font-hed text-primary leading-none font-medium fmt-1 fmb-3 {hedClass}"
>
{hed}
</h1>
{/if}
</div>
<aside class="article-metadata mt-2 font-subhed">
<div class="byline-container">
<div class="byline text-sm text-primary font-bold leading-tight">
<div
class="byline text-xs text-primary font-bold leading-tighter fmb-1"
>
By
{#if authors.length > 0}
{#each authors as author, i}
Expand All @@ -140,7 +138,7 @@
</div>
</div>
<div
class="dateline-container mt-1.5 text-secondary text-xxs uppercase leading-normal tracking-normal"
class="dateline-container fmt-0 text-secondary text-xs leading-tighter"
>
{#if isValidDate(publishTime)}
<div>
Expand Down Expand Up @@ -176,10 +174,32 @@
</Block>

<style lang="scss">
@use '../../scss/mixins' as *;
.byline a {
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
@media (max-width: $column-width-narrow) {
h1 {
@include font-semibold;
}
}
@media (min-width: $column-width-narrower) {
.dateline-container {
display: flex;
flex-flow: wrap;
div {
&:not(:last-child) {
&:after {
content: '·';
@include fmx-1;
}
}
}
}
}
</style>
23 changes: 12 additions & 11 deletions src/components/Theme/themes/common.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @type {Omit<import('../@types/component').Theme, "colour">} */
// Generated from https://www.fluid-type-scale.com/calculate?minFontSize=18&minWidth=320&minRatio=1.125&maxFontSize=22&maxWidth=1280&maxRatio=1.25&steps=xxs%2Cxs%2Csm%2Cbase%2Clg%2Cxl%2C2xl%2C3xl%2C4xl%2C5xl%2C6xl&baseStep=base&prefix=+fs&decimals=2&useRems=on&remValue=16&previewFont=Noto+Sans&previewText=Almost+before+we+knew+it%2C+we+had+left+the+ground&previewWidth=0
export default {
font: {
family: {
Expand All @@ -12,17 +13,17 @@ export default {
note: 'var(--theme-font-family-sans-serif)',
},
size: {
xxs: 'clamp(0.79rem, -0.2vw + 0.83rem, 0.67rem)',
xs: 'clamp(0.89rem, -0.08vw + 0.91rem, 0.84rem)',
sm: 'clamp(1rem, 0.08vw + 0.98rem, 1.05rem)',
base: 'clamp(1.13rem, 0.31vw + 1.06rem, 1.31rem)',
lg: 'clamp(1.27rem, 0.63vw + 1.14rem, 1.64rem)',
xl: 'clamp(1.42rem, 1.04vw + 1.21rem, 2.05rem)',
'2xl': 'clamp(1.6rem, 1.6vw + 1.28rem, 2.56rem)',
'3xl': 'clamp(1.8rem, 2.34vw + 1.33rem, 3.2rem)',
'4xl': 'clamp(2.03rem, 3.3vw + 1.37rem, 4.01rem)',
'5xl': 'clamp(2.28rem, 4.54vw + 1.37rem, 5.01rem)',
'6xl': 'clamp(2.57rem, 6.15vw + 1.33rem, 6.26rem)',
xxs: 'clamp(0.79rem, -0.14vw + 0.82rem, 0.7rem)',
xs: 'clamp(0.89rem, -0.01vw + 0.89rem, 0.88rem)',
sm: 'clamp(1rem, 0.17vw + 0.97rem, 1.1rem)',
base: 'clamp(1.13rem, 0.42vw + 1.04rem, 1.38rem)',
lg: 'clamp(1.27rem, 0.76vw + 1.11rem, 1.72rem)',
xl: 'clamp(1.42rem, 1.21vw + 1.18rem, 2.15rem)',
'2xl': 'clamp(1.6rem, 1.81vw + 1.24rem, 2.69rem)',
'3xl': 'clamp(1.8rem, 2.59vw + 1.28rem, 3.36rem)',
'4xl': 'clamp(2.03rem, 3.61vw + 1.3rem, 4.2rem)',
'5xl': 'clamp(2.28rem, 4.94vw + 1.29rem, 5.25rem)',
'6xl': 'clamp(2.57rem, 6.65vw + 1.24rem, 6.56rem)',
},
},
};
8 changes: 4 additions & 4 deletions src/docs/styles/tokens/layout/spacers.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ As a rule of thumb, if you're setting space between or adjacent to _text element
<CopyTable
title="Fluid margin"
mdnLink="margin"
header={['Class', 'Extend', 'Properties']}
header={['Class', 'Include', 'Properties']}
body={cssStringToTableArray(fluidMargin, true)}
copyable={[true, (t) => `@extend %${t};`, false]}
copyable={[true, (t) => `@include ${t};`, false]}
/>

<CopyTable
title="Fluid padding"
mdnLink="margin"
header={['Class', 'Extend', 'Properties']}
header={['Class', 'Include', 'Properties']}
body={cssStringToTableArray(fluidPadding, true)}
copyable={[true, (t) => `@extend %${t};`, false]}
copyable={[true, (t) => `@include ${t};`, false]}
/>
26 changes: 20 additions & 6 deletions src/scss/reset/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,26 @@
body {
font-size: 1rem;
@include font-sans;
@include font-normal;
@include font-regular;
@include leading-normal;
// Font-smoothing
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

// SIZE RANGE REFERENCE //
// xxs: 12.64px
// xs: 14.22px
// sm: 16.00px → 17.60px
// base: 18.00px → 22.00px
// lg: 20.25px → 27.50px
// xl: 22.78px → 34.38px
// 2xl: 25.63px → 42.97px
// 3xl: 28.83px → 53.71px
// 4xl: 32.44px → 67.14px
// 5xl: 36.49px → 83.92px
// 6xl: 41.05px → 104.90px

/////////////
// HEADINGS
/////////////
Expand All @@ -25,6 +38,7 @@ h1 {
@include font-hed;
@include text-3xl;
@include leading-none;

margin-block-start: calc(var(--theme-font-size-base) * 1.5);
margin-block-end: calc(var(--theme-font-size-base) * 0.75);
}
Expand Down Expand Up @@ -58,7 +72,7 @@ h5 {
}
h6 {
@include text-sm;
@include font-normal;
@include font-regular;
text-transform: uppercase;
margin-block-end: calc(var(--theme-font-size-base) * 0.375);
}
Expand All @@ -75,7 +89,7 @@ h6 {
margin-inline-end: 0px;
@include font-body;
@include text-base;
@include font-normal;
@include font-regular;
@include leading-normal;
@include text-primary;
}
Expand Down Expand Up @@ -108,7 +122,7 @@ strong {

figcaption {
@include text-sm;
@include font-normal;
@include font-regular;
@include leading-normal;
@include text-secondary;
@include font-note;
Expand All @@ -118,12 +132,12 @@ blockquote {
margin-inline: 0;
padding-left: 1rem;
border-left: 1px solid $theme-colour-brand-rules;
@extend %fmy-6;
@include fmy-6;
p {
@include font-body;
@include text-lg;
&:last-of-type {
@extend %fmb-2;
@include fmb-2;
}
}
blockquote {
Expand Down
62 changes: 56 additions & 6 deletions src/scss/tokens/spacers/_fluid-margin.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,55 @@
@use 'mixins/fluid-margin' as *;

@each $level, $value in $fluid-margin-levels {
%fm-#{$level} {
margin: $value;
}
%fmt-#{$level} {
margin-top: $value;
}
%fmr-#{$level} {
margin-right: $value;
}
%fmb-#{$level} {
margin-bottom: $value;
}
%fml-#{$level} {
margin-left: $value;
}
%fmx-#{$level} {
margin-right: $value;
margin-left: $value;
}
%fmy-#{$level} {
margin-top: $value;
margin-bottom: $value;
}

%\!fm-#{$level} {
margin: $value !important;
}
%\!fmt-#{$level} {
margin-top: $value !important;
}
%\!fmr-#{$level} {
margin-right: $value !important;
}
%\!fmb-#{$level} {
margin-bottom: $value !important;
}
%\!fml-#{$level} {
margin-left: $value !important;
}
%\!fmx-#{$level} {
margin-right: $value !important;
margin-left: $value !important;
}
%\!fmy-#{$level} {
margin-top: $value !important;
margin-bottom: $value !important;
}
}

$fluid-margin-placeholder-levels: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9;

@each $level, $value in $fluid-margin-placeholder-levels {
Expand Down Expand Up @@ -49,20 +99,20 @@ $fluid-margin-placeholder-levels: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9;
}

.fm-auto {
@extend %fm-auto;
@include fm-auto;
}
.fmx-auto {
@extend %fmx-auto;
@include fmx-auto;
}
.fmy-auto {
@extend %fmy-auto;
@include fmy-auto;
}
.\!fm-auto {
@extend %\!fm-auto;
@include \!fm-auto;
}
.\!fmx-auto {
@extend %\!fmx-auto;
@include \!fmx-auto;
}
.\!fmy-auto {
@extend %\!fmy-auto;
@include \!fmy-auto;
}
50 changes: 50 additions & 0 deletions src/scss/tokens/spacers/_fluid-padding.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,55 @@
@use 'mixins/fluid-padding' as *;

@each $level, $value in $fluid-padding-levels {
%fp-#{$level} {
padding: $value;
}
%fpt-#{$level} {
padding-top: $value;
}
%fpr-#{$level} {
padding-right: $value;
}
%fpb-#{$level} {
padding-bottom: $value;
}
%fpl-#{$level} {
padding-left: $value;
}
%fpx-#{$level} {
padding-right: $value;
padding-left: $value;
}
%fpy-#{$level} {
padding-top: $value;
padding-bottom: $value;
}

%\!fp-#{$level} {
padding: $value !important;
}
%\!fpt-#{$level} {
padding-top: $value !important;
}
%\!fpr-#{$level} {
padding-right: $value !important;
}
%\!fpb-#{$level} {
padding-bottom: $value !important;
}
%\!fpl-#{$level} {
padding-left: $value !important;
}
%\!fpx-#{$level} {
padding-right: $value !important;
padding-left: $value !important;
}
%\!fpy-#{$level} {
padding-top: $value !important;
padding-bottom: $value !important;
}
}

$fluid-padding-placeholder-levels: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9;

@each $level, $value in $fluid-padding-placeholder-levels {
Expand Down
Loading

0 comments on commit addf8e0

Please sign in to comment.