Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve dividers and allow sidebar positioning when Layout is flowing as row. #1422

Merged
merged 9 commits into from May 27, 2021
5 changes: 5 additions & 0 deletions .changeset/large-masks-walk.md
@@ -0,0 +1,5 @@
---
'@primer/css': patch
---

Improve dividers and allow sidebar positioning when `Layout` is flowing as row.
38 changes: 37 additions & 1 deletion docs/content/components/layout.md
Expand Up @@ -40,7 +40,12 @@ of the sidebar position.

### Dividers

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


```html live
<div class="Layout Layout--divided">
Expand All @@ -53,6 +58,16 @@ Add `Layout--divided` to the `Layout` to show the dividers.
<div class="Layout-divider"></div>
<div class="Layout-sidebar border">divider hidden</div>
</div>
<div class="Layout Layout--divided">
<div class="Layout-main border">main content</div>
<div class="Layout-divider Layout-divider--flowRow-shallow"></div>
<div class="Layout-sidebar border">flowRow shallow divider</div>
</div>
<div class="Layout Layout--divided">
<div class="Layout-main border">main content</div>
<div class="Layout-divider Layout-divider--flowRow-hidden"></div>
<div class="Layout-sidebar border">flowRow hidden divider</div>
</div>
```

### Centered content
Expand Down Expand Up @@ -181,6 +196,27 @@ Add `Layout--divided` to the `Layout` to show the dividers.
</div>
```

### Sidebar positioning as rows

- `Layout--sidebarPosition-flowRow-start` (default): when stacked, render the sidebar first
- `Layout--sidebarPosition-flowRow-end`: when stacked, render the sidebar last
- `Layout--sidebarPosition-flowRow-none`: when stacked, hide the sidebar

```html live
<div class="Layout Layout--sidebarPosition-flowRow-start">
<div class="Layout-main border">main</div>
<div class="Layout-sidebar border">sidebar</div>
</div>
<div class="Layout Layout--sidebarPosition-flowRow-end">
<div class="Layout-main border">main</div>
<div class="Layout-sidebar border">sidebar</div>
</div>
<div class="Layout Layout--sidebarPosition-flowRow-none">
<div class="Layout-main border">main</div>
<div class="Layout-sidebar border">sidebar</div>
</div>
```

### Layout stacking

- Default: stacks when container is `sm`.
Expand Down
2 changes: 2 additions & 0 deletions src/layout/index.scss
@@ -1,4 +1,6 @@
@import "../support/index.scss";
@import "./mixins.scss";

@import "./container.scss";
@import "./grid.scss";
@import "./grid-offset.scss";
Expand Down
30 changes: 3 additions & 27 deletions src/layout/layout.scss
Expand Up @@ -6,42 +6,18 @@
--Layout-gutter: 16px;

@media (max-width: calc(#{$width-sm} - 1px)) {
grid-auto-flow: row;
grid-template-columns: 1fr !important;

.Layout-sidebar,
.Layout-divider,
.Layout-main {
width: 100% !important;
grid-column: 1 !important;
}
@include flow-as-row;
}

&.Layout--flowRow-until-md {
@media (max-width: calc(#{$width-md} - 1px)) {
grid-auto-flow: row;
grid-template-columns: 1fr !important;

.Layout-sidebar,
.Layout-divider,
.Layout-main {
width: 100% !important;
grid-column: 1 !important;
}
@include flow-as-row;
}
}

&.Layout--flowRow-until-lg {
@media (max-width: calc(#{$width-lg} - 1px)) {
grid-auto-flow: row;
grid-template-columns: 1fr !important;

.Layout-sidebar,
.Layout-divider,
.Layout-main {
width: 100% !important;
grid-column: 1 !important;
}
@include flow-as-row;
}
}

Expand Down
64 changes: 64 additions & 0 deletions src/layout/mixins.scss
@@ -0,0 +1,64 @@
// Layout mixins

@mixin flow-as-row {
grid-auto-flow: row;
grid-template-columns: 1fr !important;

.Layout-sidebar,
.Layout-divider,
.Layout-main {
width: 100% !important;
grid-column: 1 !important;
}

&.Layout--divided {
@include flow-as-row-divider;
}

&.Layout--sidebarPosition-flowRow-start {
.Layout-sidebar {
grid-row: 1;
}

.Layout-main {
grid-row: 2 / span 2;
}
}

&.Layout--sidebarPosition-flowRow-end {
.Layout-sidebar {
grid-row: 2 / span 2;
}

.Layout-main {
grid-row: 1;
}
}

&.Layout--sidebarPosition-flowRow-none {
.Layout-sidebar {
display: none;
}
}
}

@mixin flow-as-row-divider {
--Layout-gutter: 0;

.Layout-divider {
height: 1px;

&.Layout-divider--flowRow-hidden {
display: none;
}

&.Layout-divider--flowRow-shallow {
height: 8px;
margin-right: 0;
background: var(--color-bg-canvas-inset);
border-color: var(--color-border-primary);
border-style: solid;
border-width: $border-width 0;
}
}
}