Skip to content

Commit df4007c

Browse files
author
castastrophe
committed
Proposed optimization
1 parent e9b67eb commit df4007c

File tree

2 files changed

+481
-495
lines changed

2 files changed

+481
-495
lines changed

elements/pfe-band/src/pfe-band.scss

Lines changed: 32 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
$LOCAL: band;
44

5+
%flex-fallback {
6+
display: flex;
7+
flex-flow: column nowrap;
8+
align-items: flex-start;
9+
margin-bottom: #{pfe-local(gutter--vertical)};
10+
}
11+
12+
%grid-layout {
13+
display: grid;
14+
grid-row-gap: #{pfe-local(gutter--vertical)};
15+
grid-column-gap: #{pfe-local(gutter--horizontal)};
16+
margin-bottom: 0;
17+
}
18+
519
:host {
620
display: block;
721

@@ -55,9 +69,7 @@ $LOCAL: band;
5569

5670
// Wrapper sets padding and background visuals
5771
position: relative;
58-
display: flex;
59-
flex-direction: column;
60-
justify-items: flex-start;
72+
@extend %flex-fallback;
6173

6274
// Padding
6375
padding: calc(#{pfe-local(Padding--vertical)} / 2) #{pfe-local(Padding--horizontal)};
@@ -99,45 +111,6 @@ $LOCAL: band;
99111
--pfe-band--Padding: calc(#{pfe-local(Padding--vertical)} / 4) #{pfe-local(Padding--horizontal)};
100112
}
101113

102-
.pfe-band__header,
103-
.pfe-band__body,
104-
.pfe-band__aside,
105-
.pfe-band__footer {
106-
display: flex;
107-
flex-flow: column nowrap;
108-
align-items: flex-start;
109-
margin-bottom: #{pfe-local(gutter--vertical)};
110-
}
111-
112-
@supports (display: grid) {
113-
.pfe-band__header,
114-
.pfe-band__body,
115-
.pfe-band__aside,
116-
.pfe-band__footer {
117-
display: grid;
118-
grid-row-gap: var(--pfe-band--gutter--vertical);
119-
grid-column-gap: var(--pfe-band--gutter--horizontal);
120-
margin-bottom: 0;
121-
}
122-
.pfe-band__header {
123-
grid-area: header;
124-
grid-template-columns: var(--pfe-band__header--layout);
125-
}
126-
.pfe-band__footer {
127-
grid-area: footer;
128-
grid-template-columns: var(--pfe-band__footer--layout);
129-
}
130-
.pfe-band__aside {
131-
grid-area: aside;
132-
grid-template-columns: var(--pfe-band__aside--layout);
133-
}
134-
.pfe-band__body {
135-
grid-area: body;
136-
grid-template-columns: var(--pfe-band__body--layout);
137-
margin-bottom: 0;
138-
}
139-
}
140-
141114
.pfe-band {
142115
&__container {
143116
// Does not need to be wrapped in @supports because it updates variables
@@ -227,12 +200,11 @@ $LOCAL: band;
227200
position: relative;
228201
margin: 0 auto;
229202
width: #{pfe-local(Width)};
230-
203+
@extend %flex-fallback;
204+
231205
// Grid support styles
232206
@supports (display: grid) {
233-
display: grid;
234-
grid-row-gap: #{pfe-local(gutter--vertical)};
235-
grid-column-gap: #{pfe-local(gutter--horizontal)};
207+
@extend %grid-layout;
236208
grid-template-columns: #{pfe-local(layout)};
237209
grid-template-rows: max-content;
238210
grid-template-areas: var(--pfe-band--gridTemplateArea_mobile);
@@ -241,4 +213,18 @@ $LOCAL: band;
241213
}
242214
}
243215
}
216+
// For each section in the band layout
217+
@each $section in (header, body, aside, footer) {
218+
&__#{$section} { // i.e., pfe-band__header
219+
@extend %flex-fallback; // Add the flex fallback styles
220+
// Apply the standard grid
221+
@supports (display: grid) {
222+
@extend %grid-layout;
223+
// Apply the section as a named grid-area
224+
grid-area: #{$section};
225+
// Allow users to hook into the layout with custom columns
226+
grid-template-columns: var(--pfe-band__#{$section}--layout);
227+
}
228+
}
229+
}
244230
}

0 commit comments

Comments
 (0)