Skip to content

Commit

Permalink
Merge pull request #1382 from primer/tobiasahlin/optimize-marketing-b…
Browse files Browse the repository at this point in the history
…ody-inheritence

Marketing: optimize body typography inheritance
  • Loading branch information
simurai authored May 6, 2021
2 parents d7209ce + e092c25 commit 7dce045
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/selfish-moose-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/css": patch
---

Marketing: optimize body typography inheritance
5 changes: 5 additions & 0 deletions src/marketing/support/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ $mktg-headers: (
6: [10, 9, 9]
) !default;

// Body content
$mktg-body-spacing-threshold: 28px !default;
$mktg-body-weight-threshold: 24px !default;
$mktg-body-spacing-large: -0.01em !default;

// Body size steps
$mktg-body-size-0: 48px !default;
$mktg-body-size-1: 40px !default;
Expand Down
33 changes: 21 additions & 12 deletions src/marketing/type/typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,37 @@
@each $body, $sizes in $mktg-bodies {
.f#{$body}-mktg {
$pairing: map-get($mktg-body-pairings, nth($sizes, 1));
$pairing-md: map-get($mktg-body-pairings, nth($sizes, 2));
$pairing-lg: map-get($mktg-body-pairings, nth($sizes, 3));

font-size: map-get($pairing, "size") !important;
line-height: map-get($pairing, "lh") !important;
@if (map-get($pairing, "size") >= 28px) { letter-spacing: $mktg-header-spacing-default !important; }
@if (map-get($pairing, "size") >= 24px) { font-weight: $font-weight-semibold !important; }
@if (map-get($pairing, "size") >= $mktg-body-spacing-threshold) { letter-spacing: $mktg-body-spacing-large !important; }
@if (map-get($pairing, "size") >= $mktg-body-weight-threshold) { font-weight: $font-weight-semibold !important; }

@if (nth($sizes, 1) != nth($sizes, 2)) {
@include breakpoint(md) {
$pairing: map-get($mktg-body-pairings, nth($sizes, 2));
font-size: map-get($pairing, "size") !important;
line-height: map-get($pairing, "lh") !important;
@if (map-get($pairing, "size") >= 28px) { letter-spacing: $mktg-header-spacing-default !important; }
@if (map-get($pairing, "size") >= 24px) { font-weight: $font-weight-semibold !important; }
font-size: map-get($pairing-md, "size") !important;
line-height: map-get($pairing-md, "lh") !important;
@if (map-get($pairing-md, "size") >= $mktg-body-spacing-threshold and map-get($pairing, "size") < $mktg-body-spacing-threshold) {
letter-spacing: $mktg-body-spacing-large !important;
}
@if (map-get($pairing-md, "size") >= $mktg-body-weight-threshold and map-get($pairing, "size") < $mktg-body-weight-threshold) {
font-weight: $font-weight-semibold !important;
}
}
}

@if (nth($sizes, 2) != nth($sizes, 3)) {
@include breakpoint(lg) {
$pairing: map-get($mktg-body-pairings, nth($sizes, 3));
font-size: map-get($pairing, "size") !important;
line-height: map-get($pairing, "lh") !important;
@if (map-get($pairing, "size") >= 28px) { letter-spacing: $mktg-header-spacing-default !important; }
@if (map-get($pairing, "size") >= 24px) { font-weight: $font-weight-semibold !important; }
font-size: map-get($pairing-lg, "size") !important;
line-height: map-get($pairing-lg, "lh") !important;
@if (map-get($pairing-lg, "size") >= $mktg-body-spacing-threshold and map-get($pairing-md, "size") < $mktg-body-spacing-threshold) {
letter-spacing: $mktg-body-spacing-large !important;
}
@if (map-get($pairing-lg, "size") >= $mktg-body-weight-threshold and map-get($pairing-md, "size") < $mktg-body-weight-threshold) {
font-weight: $font-weight-semibold !important;
}
}
}
}
Expand Down

0 comments on commit 7dce045

Please sign in to comment.