Skip to content

Commit f780741

Browse files
authored
Merge pull request primer#1422 from primer/layout-flow-as-row
Improve dividers and allow sidebar positioning when `Layout` is flowing as row.
2 parents fe5b245 + 3955254 commit f780741

File tree

5 files changed

+111
-28
lines changed

5 files changed

+111
-28
lines changed

.changeset/large-masks-walk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/css': patch
3+
---
4+
5+
Improve dividers and allow sidebar positioning when `Layout` is flowing as row.

docs/content/components/layout.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ of the sidebar position.
4040

4141
### Dividers
4242

43-
Add `Layout--divided` to the `Layout` to show the dividers.
43+
Use `Layout--divided` in conjuction with a `Layout-divider` to show a divider between the main content and the sidebar.
44+
Flowing as row:
45+
- default: shows a `1px` line between main and sidebar
46+
- `Layout-divider--flowRow-shallow`: shows a filled `8px` divider.
47+
- `Layout-divider--flowRow-hidden`: hides the divider
48+
4449

4550
```html live
4651
<div class="Layout Layout--divided">
@@ -53,6 +58,16 @@ Add `Layout--divided` to the `Layout` to show the dividers.
5358
<div class="Layout-divider"></div>
5459
<div class="Layout-sidebar border">divider hidden</div>
5560
</div>
61+
<div class="Layout Layout--divided">
62+
<div class="Layout-main border">main content</div>
63+
<div class="Layout-divider Layout-divider--flowRow-shallow"></div>
64+
<div class="Layout-sidebar border">flowRow shallow divider</div>
65+
</div>
66+
<div class="Layout Layout--divided">
67+
<div class="Layout-main border">main content</div>
68+
<div class="Layout-divider Layout-divider--flowRow-hidden"></div>
69+
<div class="Layout-sidebar border">flowRow hidden divider</div>
70+
</div>
5671
```
5772

5873
### Centered content
@@ -181,6 +196,27 @@ Add `Layout--divided` to the `Layout` to show the dividers.
181196
</div>
182197
```
183198

199+
### Sidebar positioning as rows
200+
201+
- `Layout--sidebarPosition-flowRow-start` (default): when stacked, render the sidebar first
202+
- `Layout--sidebarPosition-flowRow-end`: when stacked, render the sidebar last
203+
- `Layout--sidebarPosition-flowRow-none`: when stacked, hide the sidebar
204+
205+
```html live
206+
<div class="Layout Layout--sidebarPosition-flowRow-start">
207+
<div class="Layout-main border">main</div>
208+
<div class="Layout-sidebar border">sidebar</div>
209+
</div>
210+
<div class="Layout Layout--sidebarPosition-flowRow-end">
211+
<div class="Layout-main border">main</div>
212+
<div class="Layout-sidebar border">sidebar</div>
213+
</div>
214+
<div class="Layout Layout--sidebarPosition-flowRow-none">
215+
<div class="Layout-main border">main</div>
216+
<div class="Layout-sidebar border">sidebar</div>
217+
</div>
218+
```
219+
184220
### Layout stacking
185221

186222
- Default: stacks when container is `sm`.

src/layout/index.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
@import "../support/index.scss";
2+
@import "./mixins.scss";
3+
24
@import "./container.scss";
35
@import "./grid.scss";
46
@import "./grid-offset.scss";

src/layout/layout.scss

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,18 @@
66
--Layout-gutter: 16px;
77

88
@media (max-width: calc(#{$width-sm} - 1px)) {
9-
grid-auto-flow: row;
10-
grid-template-columns: 1fr !important;
11-
12-
.Layout-sidebar,
13-
.Layout-divider,
14-
.Layout-main {
15-
width: 100% !important;
16-
grid-column: 1 !important;
17-
}
9+
@include flow-as-row;
1810
}
1911

2012
&.Layout--flowRow-until-md {
2113
@media (max-width: calc(#{$width-md} - 1px)) {
22-
grid-auto-flow: row;
23-
grid-template-columns: 1fr !important;
24-
25-
.Layout-sidebar,
26-
.Layout-divider,
27-
.Layout-main {
28-
width: 100% !important;
29-
grid-column: 1 !important;
30-
}
14+
@include flow-as-row;
3115
}
3216
}
3317

3418
&.Layout--flowRow-until-lg {
3519
@media (max-width: calc(#{$width-lg} - 1px)) {
36-
grid-auto-flow: row;
37-
grid-template-columns: 1fr !important;
38-
39-
.Layout-sidebar,
40-
.Layout-divider,
41-
.Layout-main {
42-
width: 100% !important;
43-
grid-column: 1 !important;
44-
}
20+
@include flow-as-row;
4521
}
4622
}
4723

src/layout/mixins.scss

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Layout mixins
2+
3+
@mixin flow-as-row {
4+
grid-auto-flow: row;
5+
grid-template-columns: 1fr !important;
6+
7+
.Layout-sidebar,
8+
.Layout-divider,
9+
.Layout-main {
10+
width: 100% !important;
11+
grid-column: 1 !important;
12+
}
13+
14+
&.Layout--divided {
15+
@include flow-as-row-divider;
16+
}
17+
18+
&.Layout--sidebarPosition-flowRow-start {
19+
.Layout-sidebar {
20+
grid-row: 1;
21+
}
22+
23+
.Layout-main {
24+
grid-row: 2 / span 2;
25+
}
26+
}
27+
28+
&.Layout--sidebarPosition-flowRow-end {
29+
.Layout-sidebar {
30+
grid-row: 2 / span 2;
31+
}
32+
33+
.Layout-main {
34+
grid-row: 1;
35+
}
36+
}
37+
38+
&.Layout--sidebarPosition-flowRow-none {
39+
.Layout-sidebar {
40+
display: none;
41+
}
42+
}
43+
}
44+
45+
@mixin flow-as-row-divider {
46+
--Layout-gutter: 0;
47+
48+
.Layout-divider {
49+
height: 1px;
50+
51+
&.Layout-divider--flowRow-hidden {
52+
display: none;
53+
}
54+
55+
&.Layout-divider--flowRow-shallow {
56+
height: 8px;
57+
margin-right: 0;
58+
background: var(--color-bg-canvas-inset);
59+
border-color: var(--color-border-primary);
60+
border-style: solid;
61+
border-width: $border-width 0;
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)