Skip to content

Commit 819f7c9

Browse files
authored
feat(tailwind): new component and base heading styles (#2483)
1 parent 4ed4344 commit 819f7c9

38 files changed

+184
-255
lines changed

assets/css/_descriptive-link.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
.c-descriptive-link__title {
3131
// Use all aspects of H3 except
3232
// font-family and margin-top
33-
@include h3();
33+
@apply h3;
3434
color: $link-color;
3535
font-family: $font-family-base;
3636
margin-top: 0;

assets/css/_footer.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
}
119119

120120
.m-footer__group-title {
121-
@include h3();
121+
@apply h3;
122122
margin: 0 0 24px;
123123

124124
@include media-breakpoint-only(xs) {

assets/css/_layout-cms.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ $body-columns: ();
146146
}
147147

148148
.c-cms__meta {
149-
@include h4();
149+
@apply h4;
150150
}
151151

152152
.c-cms__content,
@@ -193,7 +193,7 @@ $body-columns: ();
193193

194194
@include media-breakpoint-up(md) {
195195
.c-cms__sidebar-title {
196-
@include h3();
196+
@apply h3;
197197
margin: 0 0 $h1-bottom; // Match the below the h1
198198
padding: $top-adjust 0 $bottom-adjust; // Equalize line-height differences and base-align
199199
}

assets/css/_mixins.scss

Lines changed: 0 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -56,140 +56,6 @@
5656
}
5757
}
5858

59-
/////////////////////////////////////////////////////
60-
// Supporting @mixins for heading typography below //
61-
/////////////////////////////////////////////////////
62-
63-
@mixin base-heading {
64-
font-family: $headings-font-family;
65-
font-weight: $headings-font-weight;
66-
line-height: $headings-line-height;
67-
margin-bottom: $headings-margin-bottom;
68-
margin-top: $headings-margin-top;
69-
}
70-
71-
@mixin h1 {
72-
@include base-heading();
73-
font-size: $font-size-h1;
74-
75-
@include media-breakpoint-down(sm) {
76-
font-size: $font-size-h1-sm;
77-
}
78-
}
79-
80-
@mixin h2 {
81-
@include base-heading();
82-
@include after-heading-space();
83-
font-size: $font-size-h2;
84-
85-
@include media-breakpoint-down(sm) {
86-
font-size: $font-size-h2-sm;
87-
}
88-
}
89-
90-
@mixin h3 {
91-
@include base-heading();
92-
@include after-heading-space();
93-
font-size: $font-size-h3;
94-
95-
+ h4,
96-
+ .h4 {
97-
@include reduce-adjacent-heading-space();
98-
}
99-
}
100-
101-
@mixin h4 {
102-
@include base-heading();
103-
@include after-heading-space();
104-
font-size: $font-size-h4;
105-
font-weight: bold;
106-
107-
+ h5,
108-
+ .h5 {
109-
@include reduce-adjacent-heading-space();
110-
}
111-
}
112-
113-
@mixin h5 {
114-
@include base-heading();
115-
@include after-heading-space();
116-
font-size: $font-size-h5;
117-
118-
+ h6,
119-
+ .h6 {
120-
@include reduce-adjacent-heading-space();
121-
}
122-
}
123-
124-
@mixin h6 {
125-
@include h5();
126-
font-weight: $font-weight-medium;
127-
}
128-
129-
@mixin reduce-adjacent-heading-space {
130-
// Adjacent (sibling) headings should not have additional space
131-
// between them (similar concept to paragraphs following headlines).
132-
//
133-
// This rule helps sub-headings feel "attached" or grouped under
134-
// their parent headings, and not disjointed or ambiguous.
135-
//
136-
// EXCLUSIONS: H1 and H2, as well as H6. H1 usually exists in its
137-
// own space and we want to always have consistent space after it.
138-
// H2 is used to introduce large sections often with tables and other
139-
// non-text content, so it's OK to have the original space under it.
140-
// H6 has no following H7 element, so it's excluded for obvious reasons.
141-
margin-top: -.125em;
142-
}
143-
144-
@mixin after-heading-space {
145-
146-
// Paragraph copy directly following headlines (even if nested in divs) have
147-
// their own built-in spacing (line-heights, em-square), so we undo the
148-
// global after-heading spacing when paragraphs directly follow headings.
149-
+ p,
150-
+ div > p:first-child,
151-
+ div > div > p:first-child,
152-
+ ul,
153-
+ div > ul:first-child,
154-
+ div > div > ul:first-child,
155-
+ ol,
156-
+ div > ol:first-child,
157-
+ div > div > ol:first-child {
158-
margin-top: -$after-heading-adjustment;
159-
}
160-
161-
// When columns break and are ordered vertically only the first should get
162-
// the updated spacing
163-
@include media-breakpoint-down(sm) {
164-
+ div > div ~ div > p:first-child,
165-
+ div > div ~ div > ul:first-child,
166-
+ div > div ~ div > ol:first-child {
167-
margin-top: 0;
168-
}
169-
}
170-
171-
// If an author floats media between a heading and body copy, we lose
172-
// the heading + copy relationship. Add this scenario back here:
173-
@include media-breakpoint-up(sm) {
174-
+ .c-media--half + p {
175-
margin-top: -$after-heading-adjustment;
176-
}
177-
}
178-
179-
// When images are visually directly after a headline, they should get
180-
// the same gap non-paragraphs get by default (undo negative margin above).
181-
+ p > img:first-child,
182-
+ p > a:first-child > img:first-child {
183-
margin-top: $after-heading-adjustment;
184-
}
185-
// Make floated media items align with the top of adjacent wrapped text characters
186-
@include media-breakpoint-up(sm) {
187-
+ .c-media--half .c-media__content {
188-
margin-top: $after-heading-adjustment;
189-
}
190-
}
191-
}
192-
19359
/////////////////////////////////////////////////////
19460
// Supporting @mixins for CMS layout & media below //
19561
/////////////////////////////////////////////////////

assets/css/_project.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Featured project elixir template
22

33
.featured-project-title {
4-
@include h3();
4+
@apply h3;
55

66
@include media-breakpoint-up(sm) {
77
margin-top: 0;

assets/css/_right-rail.scss

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515
// Optical adjustment to top margin of the first direct child
1616
// heading due to presence background color in sidebar paragraphs.
1717
@each $heading in $headings {
18-
> #{$heading}:first-child,
19-
> .#{$heading}:first-child,
20-
.c-multi-column__column:first-child > #{$heading}:first-child,
21-
.c-multi-column__column:first-child > .#{$heading}:first-child {
18+
> :where(#{$heading}, .#{$heading}):first-child,
19+
.c-multi-column__column:first-child > :where(#{$heading}, .#{$heading}):first-child {
2220
margin-top: .125em; // Should be relative to heading font-size
2321
}
2422
}

assets/css/_schedule-page.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@
158158
}
159159

160160
.schedule-finder__heading {
161-
@include h3();
161+
@apply h3;
162162
color: $brand-primary;
163163
margin-top: 0;
164164
}

assets/css/_stop-card.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ $radius: 4px;
227227
}
228228

229229
.departure-card__headsign-name {
230-
@include h4();
230+
@apply h4;
231231
flex-grow: 1;
232232
margin: 0;
233233
max-width: 16.25rem;

assets/css/_transit-near-me.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ $xxl-map-height: map-get($container-max-widths, xxl) * math.div(9, 16);
288288
}
289289

290290
.m-tnm-sidebar__direction-destination {
291-
@include h3();
291+
@apply h3;
292292
margin: 0;
293293
}
294294

@@ -305,7 +305,7 @@ $xxl-map-height: map-get($container-max-widths, xxl) * math.div(9, 16);
305305
}
306306

307307
.m-tnm-sidebar__headsign-name--large {
308-
@include h3();
308+
@apply h3;
309309
margin: 0;
310310
}
311311

@@ -369,7 +369,7 @@ $xxl-map-height: map-get($container-max-widths, xxl) * math.div(9, 16);
369369
}
370370

371371
.m-tnm-sidebar__time-number {
372-
@include h3();
372+
@apply h3;
373373
line-height: 1em;
374374
margin-bottom: 0;
375375
margin-top: calc(#{$base-spacing} / 4);

assets/css/_variables.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ $font-size-h2-sm: 1.625rem;
9494
$font-weight-medium: 500;
9595

9696
$headings-margin-top: 1.075em;
97-
$headings-line-height: 1.275em;
98-
$headings-margin-bottom: .375em;
9997

10098
$pagination-line-height: 1.5rem;
10199

0 commit comments

Comments
 (0)