-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
_index.scss
228 lines (205 loc) · 5.14 KB
/
_index.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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/* ==========================================================================
objects.layout
Fluid and nestable layout system based on flexbox.
/ =========================================================================== */
/**
* Forward the variables to the parent stylesheet
*/
@forward './variables';
/**
* Use the settings & tools in this sheet
*/
@use './variables';
@use '../../settings/defaults';
@use '../../tools/space';
@use '../../tools/responsive';
/* --------------------------------------------------------------------------
Internal variables
/ --------------------------------------------------------------------------- */
$selector: '> *';
@if defaults.$css-modules {
$selector: ':global(#{$selector})';
}
/* --------------------------------------------------------------------------
Module code
/ --------------------------------------------------------------------------- */
/**
* Block: layout
*
* 1. Account for browser defaults of elements that might be the root node of
* the component.
* 2. Negative margin for the gap
*/
.o-layout {
--columns: #{variables.$columns};
--gap: 0px; // stylelint-disable-line
--layout-gap: var(--gap);
--layout-block-gap: var(--layout-gap);
--layout-inline-gap: var(--layout-gap);
display: flex;
flex-flow: row wrap;
align-items: flex-start;
padding: 0; /* [1] */
row-gap: var(--layout-block-gap);
column-gap: var(--layout-inline-gap);
list-style: none; /* [1] */
/**
* Flex item
* No explicit width by default. Rely on combining the item with a
* dimension utility or a component class that extends 'layout'.
*
* 1. Set flex items to full width by default, minus the gap
* 2. Fix issue where elements with overflow extend past the
* item's container. As per:
* http://weblog.west-wind.com/posts/2016/Feb/15/Flexbox-Containers-PRE-tags-and-managing-Overflow
* 3. To fix the "percentage-based flex-basis & gap" based issues we need to
* set a max-width with a ratio to negate the `gap`.
* 4. Calculate offset
*/
#{$selector} {
--colspan: var(--columns);
--offset: 0;
flex-basis: calc(
(100% / var(--columns) * var(--colspan)) - var(--layout-inline-gap)
); /* [1] */
flex-grow: 1;
min-inline-size: 0; /* [2] */
// stylelint-disable
max-inline-size: calc(
(100% / var(--columns) * var(--colspan)) - var(--layout-inline-gap) *
(100 - 100 / var(--columns) * var(--colspan)) / 100
); /* [3] */
// stylelint-enable
margin-inline-start: calc(100% / var(--columns) * var(--offset)); /* [4] */
}
}
/**
* Modifier: inline-center
* center align all layout items over the inline axis
*/
.o-layout--align-inline-center {
justify-content: center;
}
/**
* Modifier: align-inline-end
* align all layout items to the end of the inline axis
*/
.o-layout--align-inline-end {
justify-content: flex-end;
}
/**
* Modifier: align-inline-between
* align layout items by creating an even space between
*/
.o-layout--align-inline-between {
justify-content: space-between;
}
/**
* Modifier: align-block-center
* center-align layout items on the block axis
*/
.o-layout--align-block-center {
align-items: center;
}
/**
* Modifier: align-block-end
* end-align layout items on the block axis
*/
.o-layout--align-block-end {
align-items: flex-end;
}
/**
* Modifier: stretch
* All items match the size of tallest item in a row
*/
.o-layout--stretch {
align-items: stretch;
}
/**
* Modifier: reverse
* reverse all items
*/
.o-layout--reverse {
flex-direction: row-reverse;
}
/**
* Modifier: fill
* allow items to equal distribute width
*/
.o-layout--fill {
#{$selector} {
flex: 1;
max-inline-size: none;
}
}
/**
* Modifier: fit
* fit all items to their content
*/
.o-layout--fit {
#{$selector} {
flex-basis: auto;
flex-grow: 0;
max-inline-size: none;
}
}
/**
* Modifier: gap-X
*/
@each $gap in variables.$gaps {
.o-layout--gap-#{$gap} {
--layout-gap: #{space.get($gap)};
}
}
/**
* Modifier: gap-block-X
*/
@each $gap in variables.$gaps {
.o-layout--gap-block-#{$gap} {
--layout-block-gap: #{space.get($gap)};
}
}
/**
* Modifier: gap-inline-X
*/
@each $gap in variables.$gaps {
.o-layout--gap-inline-#{$gap} {
--layout-inline-gap: #{space.get($gap)};
}
}
/* --------------------------------------------------------------------------
Elements
/ --------------------------------------------------------------------------- */
/**
* Element: fill
* Make an item fill the remaining space.
*
* 1. Fixes issue where a element doesn’t fill the remaining space when the
* container has no explicit width.
*/
.o-layout__fill {
@include responsive.in-query(variables.$fill-in-query) {
flex: auto;
inline-size: 0%; /* [1] */
max-inline-size: none;
}
}
/**
* Element: fit
* Make an item shrink wrap its content.
*/
.o-layout__fit {
@include responsive.in-query(variables.$fit-in-query) {
flex-basis: auto;
flex-grow: 0;
max-inline-size: none;
}
}
/**
* Element: align-inline-center
* Center one flex item on the inline axis
*/
.o-layout__align-inline-center {
margin-inline-start: auto;
margin-inline-end: auto;
}