This repository was archived by the owner on Mar 13, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_utilities.widths.scss
More file actions
162 lines (135 loc) · 4.39 KB
/
Copy path_utilities.widths.scss
File metadata and controls
162 lines (135 loc) · 4.39 KB
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
//--------------------------------------------------------------------------------------------------------------------------------------
// WIDTHS
//--------------------------------------------------------------------------------------------------------------------------------------
/*
Utility classes to provide fluid widths to whichever element they're applied to. Most commonly used in
conjunction with the grid system object 'o-layout', but can be used with anything.
*/
/*
<div class="o-layout__item u-1/2">CONTENT</div>
*/
// WIDTHS MIXIN
//--------------------------------------------------------------------------------------------------------------------------------------
@mixin create-widths($width-sets, $breakpoint-suffix: null) {
@each $denominator in $width-sets {
@for $numerator from 1 through $denominator {
/*
[1] Reset margin-left to disabled any previous offsets
*/
// Width class, eg 'u-1/2'
.u-#{$numerator}\/#{$denominator}#{$breakpoint-suffix} {
width:($numerator / $denominator) * 100% !important;
margin-left:0 !important;
}
}
}
}
// OFFSETS MIXIN
//--------------------------------------------------------------------------------------------------------------------------------------
@mixin create-offsets($width-sets, $breakpoint-suffix: null) {
@each $denominator in $width-sets {
@for $numerator from 1 through $denominator {
// Offset class, eg 'u-offset-1/2'
.u-offset-#{$numerator}\/#{$denominator}#{$breakpoint-suffix} {
margin-left:($numerator / $denominator) * 100% !important;
}
}
}
}
// GENERATE STANDARD WIDTHS
//--------------------------------------------------------------------------------------------------------------------------------------
@include create-widths($width-sets);
@include create-offsets($width-sets);
// GENERATE RESPONSIVE WIDTHS
//--------------------------------------------------------------------------------------------------------------------------------------
// Create responsive variants using settings.breakpoints
// Changes width when breakpoint is hit
// Example: .u-1/3@md
@each $bp-name, $bp-value in $mq-breakpoints {
@include mq(#{$bp-name}) {
@include create-widths($width-sets, \@#{$bp-name});
@include create-offsets($width-sets, \@#{$bp-name});
}
}
// Create responsive variants using settings.breakpoints
// Changes width until breakpoint is hit
// Example: .u-1/3@max-md
@each $bp-name, $bp-value in $mq-breakpoints {
@include mq($until: #{$bp-name}) {
@include create-widths($width-sets, \@max-#{$bp-name});
@include create-offsets($width-sets, \@max-#{$bp-name});
}
}
// FULL & MAX WIDTH UTILITIES
//--------------------------------------------------------------------------------------------------------------------------------------
/*
Fixed & 100% max-width sizings for control the widths of groups of elements, images etc.
Numbers are based on values in settings.spacing
*/
// Example: u-max-width-small
@each $sp-name, $sp-value in $spacing {
.u-max-width-#{$sp-name} {
max-width:rem($sp-value * 10) !important;
}
}
.u-full-width {
width:100% !important;
max-width:100% !important;
}
// Breaks out of containers with to go full width
.u-breakout {
width: 100vw;
position: relative;
left: 50%;
right: 50%;
margin-left: -50vw;
margin-right: -50vw;
}
// Changes max-width when breakpoint is hit
// Example: u-max-width-small@md
// Example: u-full-width@md
@each $bp-name, $bp-value in $mq-breakpoints {
@include mq(#{$bp-name}) {
@each $sp-name, $sp-value in $spacing {
.u-max-width-#{$sp-name}\@#{$bp-name} {
max-width:rem($sp-value * 10) !important;
}
}
.u-full-width\@#{$bp-name} {
width:100% !important;
max-width:100% !important;
}
.u-breakout\@#{$bp-name} {
width: 100vw;
position: relative;
left: 50%;
right: 50%;
margin-left: -50vw;
margin-right: -50vw;
}
}
}
// Changes max-width until breakpoint is hit
// Example: u-max-width-small@max-md
// Example: u-full-width@md
@each $bp-name, $bp-value in $mq-breakpoints {
@include mq($until: #{$bp-name}) {
@each $sp-name, $sp-value in $spacing {
.u-max-width-#{$sp-name}\@max-#{$bp-name} {
max-width:rem($sp-value * 10) !important;
}
}
.u-full-width\@max-#{$bp-name} {
width:100% !important;
max-width:100% !important;
}
.u-breakout\@max-#{$bp-name} {
width: 100vw;
position: relative;
left: 50%;
right: 50%;
margin-left: -50vw;
margin-right: -50vw;
}
}
}