-
Notifications
You must be signed in to change notification settings - Fork 171
/
Copy path_patterns_equal-height-row.scss
153 lines (131 loc) · 4.63 KB
/
_patterns_equal-height-row.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
@classreference
equal-height-row:
Equal height row:
.p-equal-height-row:
Main element of the equal height row component.
"&.has-divider-1":
Cross-column divider shown between the first and second grid rows.
"&.has-divider-2":
Cross-column divider shown between the second and third grid rows.
"&.has-divider-3":
Cross-column divider shown between the third and fourth grid rows.
.p-equal-height-row--wrap:
Wraps contents such that two items appear per row on medium screen sizes.
Column:
.p-equal-height-row__col:
Column element within an equal height row.
Item:
.p-equal-height-row__item:
Item element within an equal height row column.
*/
@import 'settings';
@mixin vf-p-equal-height-row {
.p-equal-height-row,
.p-equal-height-row--wrap {
// TODO use new 4/4/8 grid (`%vf-grid-row`)
@extend %vf-row;
position: relative;
.p-equal-height-row__col {
// At smaller sizes, each column will have top border by default
border-top-color: $colors--theme--border-low-contrast;
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-bottom: $spv--small;
position: relative;
@media screen and ($breakpoint-small <= width < $breakpoint-large) {
grid-column: span $grid-columns-medium;
grid-template-columns: subgrid;
// At medium size, 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);
}
// At medium size, position the first column item on the left of the
// grid
.p-equal-height-row__item:first-child {
// This needs to be sufficiently large so remaining column items won't
// get stretched
grid-row: span 100;
}
}
@media screen and (width >= $breakpoint-large) {
border: none;
grid-column: span calc($grid-columns / 4);
margin-bottom: 0;
}
}
// DIVIDERS
// 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)
&.has-divider-1::before,
&.has-divider-2::after,
&.has-divider-3:not(.has-divider-1)::before,
&.has-divider-3:not(.has-divider-2)::after {
@extend %vf-pseudo-border;
// Override border color to be low contrast
background-color: $colors--theme--border-low-contrast;
// Row-level dividers are not visible on smaller screen sizes
display: none;
grid-column-end: span 12;
grid-column-start: 1;
margin: auto;
@media screen and (width >= $breakpoint-large) {
display: block;
}
}
&.has-divider-1::before {
grid-row: 2;
}
&.has-divider-2::after {
grid-row: 3;
}
// When 3rd-divider is present and 1st-divider is not present
&.has-divider-3:not(.has-divider-1)::before,
// When 3rd-divider is present and 2nd-divider is not present
&.has-divider-3:not(.has-divider-2)::after,
// When only 3rd-divider is present
&.has-divider-3:not(.has-divider-1):not(.has-divider-2)::before {
grid-row: 4;
}
&.has-divider-3:not(.has-divider-1):not(.has-divider-2)::after {
display: none;
}
}
// WRAP VARIANT
// This variant displays multiple columns side-by-side and wraps them at
// medium size; we have to unset some grid properties from the default
// variant to enable this functionality
.p-equal-height-row--wrap {
.p-equal-height-row__col {
@media screen and ($breakpoint-small <= width < $breakpoint-large) {
// Fit 2 columns onto each row at medium size
grid-column: span calc($grid-columns-medium / 2);
grid-template-columns: none;
.p-equal-height-row__item {
grid-column: auto;
}
.p-equal-height-row__item:first-child {
grid-row: auto;
}
}
}
}
// ADVANCED GRID SUPPORT
// Support for 25-75 split on large screen size
// TODO implement with new 4/4/8 grid (.grid-row)
.row--25-75-on-large > .col,
.row > .col-9 {
& .p-equal-height-row,
& .p-equal-height-row--wrap {
@media screen and (width >= $breakpoint-large) {
grid-template-columns: repeat(9, minmax(0, 1fr));
}
}
}
}