-
Notifications
You must be signed in to change notification settings - Fork 171
/
_patterns_grid-8.scss
167 lines (141 loc) · 4.35 KB
/
_patterns_grid-8.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
@import 'settings';
// CSS grid implementation of columns for all screens sizes
@mixin vf-grid-8-column($col) {
@supports (display: grid) {
grid-column-end: span #{$col};
//nesting
@if $col > 1 {
& .grid-row {
grid-template-columns: repeat($col, minmax(0, 1fr));
}
}
}
}
@mixin vf-grid-8-column-reordering($label, $col-count, $reset: false) {
@for $i from 1 through $col-count {
.grid-row [class*='#{$grid-8-column-prefix}'].#{$grid-8-column-prefix}start-#{$label}-#{$i} {
@if $reset {
grid-column-start: initial;
} @else {
grid-column-start: #{$i};
}
}
.#{$grid-8-column-prefix}order-#{$label}-#{$i} {
@if $reset {
order: initial;
} @else {
order: #{$i};
}
}
}
}
@mixin vf-p-grid-8 {
// FIXME: this should be removed from framework SCSS
// (see https://github.com/canonical/vanilla-framework/issues/3199)
.grid-demo .grid-col,
.grid-demo [class*='#{$grid-8-column-prefix}'] {
background: $colors--theme--background-negative-default;
margin-bottom: $spv--small;
}
.grid-row {
@extend %vf-grid-row;
}
// mobile grid
// by default medium and large screen col classes should span full width on mobile (to match block level element behaviour)
%grid-8-span-on-mobile {
grid-column: auto / span $grid-8-columns-small;
}
@for $i from 1 through $grid-8-columns-medium {
.#{$grid-8-medium-col-prefix}#{$i} {
@extend %grid-8-span-on-mobile;
@extend %display-block;
}
}
@for $i from 1 through $grid-8-columns {
.#{$grid-8-large-col-prefix}#{$i} {
@extend %grid-8-span-on-mobile;
@extend %display-block;
}
}
// col-small-X classes define grid for small screen
@for $i from $grid-8-columns-small through 1 {
.#{$grid-8-small-col-prefix}#{$i} {
@extend %display-block;
@include vf-grid-8-column($i);
width: 100%;
}
}
// tablet grid
// on medium/tablet screens, small and large grid class names span full width (to match block level element behaviour)
%grid-8-span-on-tablet {
@media (min-width: $threshold-4-6-col) {
grid-column: auto / span $grid-8-columns-medium;
}
}
@for $i from 1 through $grid-8-columns-small {
.#{$grid-8-small-col-prefix}#{$i} {
@extend %grid-8-span-on-tablet;
}
}
@for $i from 1 through $grid-8-columns {
.#{$grid-8-large-col-prefix}#{$i} {
@extend %grid-8-span-on-tablet;
}
}
// col-medium-X classes define grid for medium screens
@media (min-width: $threshold-4-6-col) {
@for $i from $grid-8-columns-medium through 1 {
.#{$grid-8-medium-col-prefix}#{$i} {
@include vf-grid-8-column($i);
width: 100%;
}
}
}
// desktop grid
// on desktop screens small and medium grid class names span full width (to match block level element behaviour)
%grid-8-span-on-desktop {
@media (min-width: $threshold-6-12-col) {
grid-column: auto / span $grid-8-columns;
}
}
@for $i from 1 through $grid-8-columns-small {
.#{$grid-8-small-col-prefix}#{$i} {
@extend %grid-8-span-on-desktop;
}
}
@for $i from 1 through $grid-8-columns-medium {
.#{$grid-8-medium-col-prefix}#{$i} {
@extend %grid-8-span-on-desktop;
}
}
// col-X class names define grid on large/desktop screens
@media (min-width: $threshold-6-12-col) {
@for $i from $grid-8-columns through 1 {
// set col-* to span respective number of columns on desktop
.#{$grid-8-large-col-prefix}#{$i} {
// on smaller screens let them display full width one under another
@include vf-grid-8-column($i);
}
}
}
// column reordering
$offsets: (
(small, 0, $threshold-4-6-col, $grid-8-columns-small),
(medium, $threshold-4-6-col, $threshold-6-12-col, $grid-8-columns-medium),
(large, $threshold-6-12-col, false, $grid-8-columns)
);
@each $label, $breakpoint-min, $breakpoint-reset, $col-count in $offsets {
@if $breakpoint-min == 0 {
@include vf-grid-8-column-reordering($label, $col-count);
} @else {
@media (min-width: #{$breakpoint-min}) {
@include vf-grid-8-column-reordering($label, $col-count);
}
}
@if $breakpoint-reset {
@media (min-width: #{$breakpoint-reset}) {
@include vf-grid-8-column-reordering($label, $col-count, $reset: true);
}
}
}
}