-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added equal height grid row pattern with full screen sized dividers Signed-off-by: Mason Hu <mason.hu@canonical.com>
- Loading branch information
Showing
11 changed files
with
674 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
@import 'settings'; | ||
|
||
@mixin divider-position($divider-order, $large-screen: false) { | ||
@if $large-screen { | ||
@if $divider-order == 1 { | ||
&.p-equal-height-row--has-1st-divider::before { | ||
@content; | ||
} | ||
} | ||
|
||
@if $divider-order == 2 { | ||
&.p-equal-height-row--has-2nd-divider::after { | ||
@content; | ||
} | ||
} | ||
|
||
@if $divider-order == 3 { | ||
&.p-equal-height-row--has-3rd-divider:not(.p-equal-height-row--has-1st-divider)::before, | ||
&.p-equal-height-row--has-3rd-divider:not(.p-equal-height-row--has-2nd-divider)::after { | ||
@content; | ||
} | ||
} | ||
} @else { | ||
@if $divider-order == 1 { | ||
&.p-equal-height-row--has-1st-divider .p-equal-height-row__col::before { | ||
@content; | ||
} | ||
} | ||
|
||
@if $divider-order == 2 { | ||
&.p-equal-height-row--has-2nd-divider .p-equal-height-row__col::after { | ||
@content; | ||
} | ||
} | ||
|
||
@if $divider-order == 3 { | ||
&.p-equal-height-row--has-3rd-divider:not(.p-equal-height-row--has-1st-divider) .p-equal-height-row__col::before, | ||
&.p-equal-height-row--has-3rd-divider:not(.p-equal-height-row--has-2nd-divider) .p-equal-height-row__col::after { | ||
@content; | ||
} | ||
} | ||
} | ||
} | ||
|
||
@mixin divider-styles($large-screen: false) { | ||
// For each row or column grid we only have access to two pseudo elements | ||
// if 1st-divider (::before) is present, assume 2nd-divider (::after) isn't, then 3rd-divider must be (::after) | ||
// if 2nd-divider (::after) is present, assume 1st-divider (::before) isn't, then 3rd-divider must be (::before) | ||
@if $large-screen { | ||
&.p-equal-height-row--has-1st-divider::before, | ||
&.p-equal-height-row--has-2nd-divider::after, | ||
&.p-equal-height-row--has-3rd-divider:not(.p-equal-height-row--has-1st-divider)::before, | ||
&.p-equal-height-row--has-3rd-divider:not(.p-equal-height-row--has-2nd-divider)::after { | ||
@content; | ||
} | ||
} @else { | ||
// For smaller screens, the divider pseudo elements are inserted at the column level | ||
&.p-equal-height-row--has-1st-divider .p-equal-height-row__col::before, | ||
&.p-equal-height-row--has-2nd-divider .p-equal-height-row__col::after, | ||
&.p-equal-height-row--has-3rd-divider:not(.p-equal-height-row--has-1st-divider) .p-equal-height-row__col::before, | ||
&.p-equal-height-row--has-3rd-divider:not(.p-equal-height-row--has-2nd-divider) .p-equal-height-row__col::after { | ||
@content; | ||
} | ||
} | ||
} | ||
|
||
@mixin vf-p-equal-height-row { | ||
.p-equal-height-row { | ||
display: grid; | ||
grid-template-columns: subgrid; | ||
position: relative; | ||
|
||
.p-equal-height-row__col { | ||
// smaller screens each column will have border top by default | ||
border-top-color: $colors--theme--border-default; | ||
border-top-style: solid; | ||
border-top-width: 1px; | ||
display: grid; | ||
grid-column: span $grid-columns-small; | ||
grid-row: span 4; | ||
grid-template-rows: subgrid; | ||
margin-top: -1px; | ||
position: relative; | ||
|
||
@media screen and ($breakpoint-small <=width < $breakpoint-large) { | ||
grid-column: span $grid-columns-medium; | ||
grid-template-columns: subgrid; | ||
|
||
// for medium screen, each column item will take half of the available cols from the parent grid | ||
.p-equal-height-row__item { | ||
grid-column: span calc($grid-columns-medium / 2); | ||
} | ||
|
||
// for medium screen, position the first column item on the left of the grid | ||
.p-equal-height-row__item:first-child { | ||
grid-row: span 100; | ||
} | ||
} | ||
|
||
@media screen and (width >=$breakpoint-large) { | ||
border: none; | ||
grid-column: span calc($grid-columns / 4); | ||
} | ||
} | ||
|
||
// divider styles | ||
// remove row level dividers for small screen | ||
&[class*='p-equal-height-row--has-']::before, | ||
&[class*='p-equal-height-row--has-']::after { | ||
@extend %vf-pseudo-border; | ||
display: none; | ||
width: 100%; | ||
} | ||
|
||
@include divider-styles { | ||
@extend %vf-pseudo-border; | ||
grid-column: span $grid-columns-small; | ||
width: 100%; | ||
} | ||
|
||
@include divider-position(1) { | ||
grid-row: 2; | ||
} | ||
|
||
@include divider-position(2) { | ||
grid-row: 3; | ||
} | ||
|
||
@include divider-position(3) { | ||
grid-row: 4; | ||
} | ||
|
||
@media screen and ($breakpoint-small <=width < $breakpoint-large) { | ||
// We don't need to insert divider below item-1 for medium screen size since item-1 gets positioned on the left | ||
@include divider-position(1) { | ||
display: none; | ||
} | ||
|
||
@include divider-position(2) { | ||
grid-column: 4 / 7; | ||
grid-row: 2; | ||
} | ||
|
||
@include divider-position(3) { | ||
grid-column: 4 / 7; | ||
grid-row: 3; | ||
} | ||
} | ||
|
||
@media screen and (width >=$breakpoint-large) { | ||
@include divider-styles { | ||
display: none; | ||
} | ||
|
||
@include divider-styles($large-screen: true) { | ||
display: block; | ||
} | ||
|
||
@include divider-position(1, $large-screen: true) { | ||
grid-row: 2; | ||
} | ||
|
||
@include divider-position(2, $large-screen: true) { | ||
grid-row: 3; | ||
} | ||
|
||
@include divider-position(3, $large-screen: true) { | ||
grid-row: 4; | ||
} | ||
} | ||
} | ||
|
||
// support for 25-75 split on large screen size for this pattern | ||
.row--25-75-on-large > .col, | ||
.row > .col-9 { | ||
& .p-equal-height-row { | ||
grid-gap: 0 map-get($grid-gutter-widths, small); | ||
grid-template-columns: repeat($grid-columns-small, minmax(0, 1fr)); | ||
|
||
@media screen and ($breakpoint-small <=width < $breakpoint-large) { | ||
grid-gap: 0 map-get($grid-gutter-widths, default); | ||
grid-template-columns: repeat($grid-columns-medium, minmax(0, 1fr)); | ||
} | ||
|
||
@media screen and (width >=$breakpoint-large) { | ||
grid-template-columns: repeat(9, minmax(0, 1fr)); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@import '../vanilla'; | ||
@include vf-base; | ||
|
||
// dependencies needed for examples | ||
@include vf-p-buttons; | ||
@include vf-p-media-container; | ||
@include vf-p-headings; | ||
|
||
// vf-p-grid is needed for this pattern to work | ||
@include vf-p-grid; | ||
@include vf-p-equal-height-row; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.