Skip to content

Commit 73d8649

Browse files
author
castastrophe
committed
Merge branch 'master' of github.com:patternfly/patternfly-elements into issue-310/band-layout
2 parents 12e5cfa + 6b6685f commit 73d8649

File tree

5 files changed

+514
-532
lines changed

5 files changed

+514
-532
lines changed

elements/pfe-band/README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,35 @@ This container element provides a set of slots in which to render banded content
77
All slots other than `pfe-band--body` are optional. If the slot is not defined, the container tag for it will not be rendered in the template.
88

99
- `pfe-band--header`: This slot renders at the top of the container and generally contains the title, headline, and or subheadline content. Other possible candidates include a set of social sharing links or tags that describe the content below. The recommended tag for this slot is the `header` tag with h-level or p tags contained within it.
10-
- **Default slot**: This is the default slot and contains the bulk of the content in this element. Paragraph text or a grid of cards or images might be rendered in this region. Recommended tag for this slot is the `article` tag. Any content not assigned to a slot will be rendered here.
10+
- **Default slot**: This unnamed slot should contain the bulk of the content in this element. The recommended wrapper within this slot is the `article` tag, but a `div` could also work to contain text elements like paragraphs. If you are rendering non-text components such as cards or images, no wrapper is necessary, and these items will make use of the grid layout. Any content not assigned to a named slot will be rendered here.
1111
- `pfe-band--footer`: This slot is typically used for calls-to-action or footnotes and is pushed to the bottom of the container. Recommended tags include `pfe-cta` or `footer`.
1212
- `pfe-band--aside`: This slot is for content that should be rendered to the right or left of the default slot on desktop. Asides often contain `pfe-card` or interest forms which provide users a little more information or context for the band.
1313

14+
### Example markup
15+
```
16+
<pfe-band>
17+
<header slot="pfe-band--header">
18+
<h2>Lighter band; no footer</h2>
19+
</header>
20+
21+
<article>
22+
<p>Consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata dolor sit amet.</p>
23+
</article>
24+
25+
<pfe-card slot="pfe-band--aside">
26+
<h3 slot="header">Aside: left body bottom</h3>
27+
<p>Ut wisi enim ad minim veniam.</p>
28+
</pfe-card>
29+
30+
<footer slot="pfe-band--footer">
31+
<pfe-cta slot="footer" priority="tertiary">
32+
<a href="#">Learn more</a>
33+
</pfe-cta>
34+
</footer>
35+
</pfe-band>
36+
```
37+
38+
1439
## Attributes
1540

1641
<style>

elements/pfe-band/demo/index.html

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<noscript>
1010
<link href="../../pfelement/pfelement-noscript.min.css" rel="stylesheet">
1111
</noscript>
12+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap-reboot.css">
1213

1314
<link href="../../pfelement/pfelement.min.css" rel="stylesheet">
1415
<link href="../../pfe-layouts/pfe-layouts.css" rel="stylesheet">
@@ -46,19 +47,6 @@
4647
margin: 0;
4748
}
4849

49-
p,
50-
h1,
51-
h2,
52-
h3 {
53-
margin-top: 0;
54-
}
55-
56-
p:last-child,
57-
h1:last-child,
58-
h2:last-child,
59-
h3:last-child {
60-
margin-bottom: 0;
61-
}
6250
/* Example CSS variable overrides
6351
:root {
6452
--pfe-theme--container-spacer: 4px;
@@ -120,10 +108,12 @@ <h3 slot="header">Aside: right body bottom</h3>
120108
<h2>Lighter band; no footer</h2>
121109
<p class="custom-band-summary">Header region, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</p>
122110
</header>
123-
<p>Consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
124-
<pfe-cta priority="tertiary">
125-
<a href="#">Learn more</a>
126-
</pfe-cta>
111+
<article>
112+
<p>Consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
113+
<pfe-cta priority="tertiary">
114+
<a href="#">Learn more</a>
115+
</pfe-cta>
116+
</article>
127117
<pfe-card color="complement" slot="pfe-band--aside">
128118
<h3 slot="header">Aside: left body bottom</h3>
129119
<p>Ut wisi enim ad minim veniam.</p>

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

Lines changed: 32 additions & 49 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,48 +111,6 @@ $LOCAL: band;
99111
--pfe-band--Padding: calc(#{pfe-local(Padding--vertical)} / 4) #{pfe-local(Padding--horizontal)};
100112
}
101113

102-
@each $slot in (default, header, footer, aside) {
103-
$slot-name: $slot;
104-
$grid-area: "body";
105-
@if $slot != default {
106-
$slot-name: "pfe-band--#{$slot-name}";
107-
$grid-area: $slot;
108-
}
109-
.pfe-band__#{$grid-area} {
110-
// Set up the flex styles for each region
111-
display: flex;
112-
flex-flow: column nowrap;
113-
align-items: flex-start;
114-
// Grid support styles
115-
@supports (display: grid) {
116-
grid-area: #{$grid-area};
117-
// Set up the internal grid system for each slot
118-
display: grid;
119-
grid-row-gap: #{pfe-local(gutter--vertical)};
120-
grid-column-gap: #{pfe-local(gutter--horizontal)};
121-
grid-template-columns: #{pfe-local(
122-
$cssvar: layout,
123-
$region: $grid-area
124-
)};
125-
}
126-
}
127-
@include pfe-slot($slot-name, ":not(:last-child)") {
128-
margin-bottom: #{pfe-local(gutter--vertical)};
129-
@supports (display: grid) {
130-
margin-bottom: 0;
131-
}
132-
}
133-
@include pfe-slot($slot-name, "> *") {
134-
margin: 0;
135-
}
136-
@include pfe-slot($slot-name, "> *:not(:last-child)") {
137-
margin-bottom: #{pfe-local(gutter--vertical)};
138-
@supports (display: grid) {
139-
margin-bottom: 0;
140-
}
141-
}
142-
}
143-
144114
.pfe-band {
145115
&__container {
146116
// Does not need to be wrapped in @supports because it updates variables
@@ -288,12 +258,11 @@ $LOCAL: band;
288258
margin: 0 auto;
289259
width: 100%;
290260
max-width: #{pfe-local(Width)};
291-
261+
@extend %flex-fallback;
262+
292263
// Grid support styles
293264
@supports (display: grid) {
294-
display: grid;
295-
grid-row-gap: #{pfe-local(gutter--vertical)};
296-
grid-column-gap: #{pfe-local(gutter--horizontal)};
265+
@extend %grid-layout;
297266
grid-template-columns: #{pfe-local(layout)};
298267
grid-template-rows: max-content;
299268
grid-template-areas: var(--pfe-band--gridTemplateArea_mobile);
@@ -302,4 +271,18 @@ $LOCAL: band;
302271
}
303272
}
304273
}
274+
// For each section in the band layout
275+
@each $section in (header, body, aside, footer) {
276+
&__#{$section} { // i.e., pfe-band__header
277+
@extend %flex-fallback; // Add the flex fallback styles
278+
// Apply the standard grid
279+
@supports (display: grid) {
280+
@extend %grid-layout;
281+
// Apply the section as a named grid-area
282+
grid-area: #{$section};
283+
// Allow users to hook into the layout with custom columns
284+
grid-template-columns: var(--pfe-band__#{$section}--layout);
285+
}
286+
}
287+
}
305288
}

elements/pfe-sass/mixins/_mixins.scss

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -142,19 +142,3 @@
142142
@mixin pfe-define-vars($this-component-var, $this-theme-var, $this-fallback) {
143143
--pfe-local-#{$this-component-var}: var(--pfe-#{$this-component-var}, var(--pfe-theme--#{$this-theme-var}, #{$this-fallback}));
144144
}
145-
146-
// Mixin for building slot selectors
147-
@mixin pfe-slot($slot-name, $selector: "") {
148-
// This logic makes it much easier to style default slots in a loop
149-
// with named slots
150-
@if $slot-name != default {
151-
::slotted([slot="#{$slot-name}"]#{$selector}) {
152-
@content;
153-
}
154-
}
155-
@else {
156-
::slotted(*) {
157-
@content;
158-
}
159-
}
160-
}

0 commit comments

Comments
 (0)