-
Notifications
You must be signed in to change notification settings - Fork 106
/
_mixins.scss
276 lines (236 loc) · 5.9 KB
/
_mixins.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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
// ==========================================================================
// TOOLS / #MIXINS
// ==========================================================================
//
// Clearfix mixin
//
// Usage: @include clearfix();
// See utilities/clearfix
//
@mixin clearfix() {
&:after {
clear: both;
content: "";
display: block;
}
}
//
// Reading width mixin, add a maximum width
// to large pieces of content
//
// Usage: @include reading-width();
// See utilities/reading-width
//
@mixin reading-width() {
max-width: 44em;
}
//
// Visually hidden mixin, used for hiding
// content visually but keeping it in the DOM
//
// Usage: @include visually-hidden();
// See utilities/visually-hidden
//
@mixin visually-hidden() {
border: 0;
clip: rect(0 0 0 0);
-webkit-clip-path: inset(50%);
clip-path: inset(50%);
height: 1px;
margin: 0;
overflow: hidden;
padding: 0;
position: absolute;
white-space: nowrap;
width: 1px;
}
//
// Visually shown mixin, used for displaying
// content visually that has previously been hidden
// by visually-hidden
// Differences between mobile and desktop views
// Use $display-property to assign display
//
// Usage: @include visually-shown(table-header-group);
//
@mixin visually-shown($display-property) {
clip: auto;
-webkit-clip-path: initial;
clip-path: initial;
display: $display-property;
height: auto;
overflow: auto;
position: relative;
width: auto;
}
//
// Top and bottom margin mixin, remove
// the top and bottom margin spacing
//
// Usage: @include top-and-bottom();
// See utilities/top-and-bottom
//
@mixin top-and-bottom() {
& > *:first-child {
margin-top: 0;
}
& > *:last-child {
margin-bottom: 0;
}
}
//
// Panel mixin
//
// Usage: @include panel-with-label($color_nhsuk-blue, $color_nhsuk-white);
// See components/_panel
//
@mixin panel($panel-background-color, $panel-text-color) {
@include top-and-bottom();
@include nhsuk-responsive-margin(7, "bottom");
@include nhsuk-responsive-margin(7, "top");
@include nhsuk-responsive-padding(5);
background-color: $panel-background-color;
color: $panel-text-color;
@include mq($media-type: print) {
border: 1px solid $nhsuk-print-text-color;
page-break-inside: avoid;
}
}
//
// Panel with label mixin, inherits panel styling
// and removes padding top for the label positioning.
//
// Used in-conjunction with @mixin heading-label
//
// Usage: @include panel-with-label($color_nhsuk-blue, $color_nhsuk-white);
// See components/_warning-component
//
@mixin panel-with-label($panel-background-color, $panel-text-color, $panel-border-color) {
@include panel($panel-background-color, $panel-text-color);
border: 1px solid $panel-border-color;
padding-top: 0 !important; /* stylelint-disable-line declaration-no-important */
}
//
// Heading label mixin, adds a tab heading to
// warning callout, do and don't lists and panel.
//
// Used in-conjunction with @mixin panel-with-label
//
// Usage: @include heading-label($color_nhsuk-blue, $color_nhsuk-white);
// See components/_warning-component
//
// 1. Background colour to be set on the @include.
// 2. Text colour to be set on the @include.
// 3. Display inline-block so it does not take up the full width.
// 4. Margin -24px left and right aligns the heading to the box.
// 5. Top positioning set to minus to make the heading
// sit just outside the box.
//
@mixin heading-label($heading-background-color, $heading-text-color) {
@include nhsuk-typography-responsive(24);
background-color: $heading-background-color; // [1] //
color: $heading-text-color; // [2] //
display: inline-block; // [3] //
margin: nhsuk-spacing(0) nhsuk-spacing(0) nhsuk-spacing(2) -33px;
padding: nhsuk-spacing(2) nhsuk-spacing(5);
position: relative;
top: -16px; // [5] //
@include mq($until: tablet) {
margin-left: -25px;
margin-right: 0;
padding: nhsuk-spacing(2) nhsuk-spacing(4);
top: -8px; // [5] //
}
@include mq($media-type: print) {
background: none;
color: $color_nhsuk-black;
top: 0;
}
}
//
// Care card mixin, used for creating
// different coloured care cards.
//
// Usage: @include care-card($color_nhsuk-blue, $color_nhsuk-white, 4px);
// See components/card/card
//
@mixin care-card($heading-background-color, $heading-text-color, $print-border-size) {
.nhsuk-card--care__heading-container {
background-color: $heading-background-color;
color: $heading-text-color;
}
@include mq($media-type: print) {
border: $print-border-size solid $nhsuk-print-text-color;
color: $nhsuk-print-text-color;
page-break-inside: avoid;
}
}
//
// Print colour mixin, sets the text print colour
// warning callout, do and don't lists and panels.
//
// Usage: @include print-color($nhsuk-print-text-color);
// See components/_care-card
//
@mixin print-color($print-color) {
@include mq($media-type: print) {
color: $print-color;
fill: $print-color;
&:active,
&:focus,
&:visited {
color: $nhsuk-print-text-color;
}
}
}
//
// Print hide mixin, hides the element from print.
//
// Usage: @include print-hide();
// See components/_care-card
//
@mixin print-hide() {
@include mq($media-type: print) {
display: none;
}
}
//
// Flex mixin
// Usage: @include flex();
//
@mixin flex() {
display: flex;
flex-wrap: wrap;
}
//
// Flex item mixin
// Usage: @include flex-item();
//
@mixin flex-item() {
display: flex;
@include mq($until: desktop) {
flex: 0 0 100%;
}
}
//
// Remove margin mobile mixin, removes left and right
// margin at tablet breakpoint.
//
@mixin remove-margin-mobile() {
@include mq($until: tablet) {
margin-left: -$nhsuk-gutter-half;
margin-right: -$nhsuk-gutter-half;
}
}
/// NHS logo size helper
///
/// Saves duplicating the code for when using the logo as a link.
/// Used in the header and footer.
@mixin nhsuk-logo-size {
height: 40px;
width: 100px;
}
@mixin nhsuk-logo-size-small {
height: 32px;
width: 80px;
}