@nice-digital/nds-core 1.3.4-alpha.0 → 2.0.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/scss/colours/_index.scss +1 -0
- package/scss/colours/tokens/_alias.scss +163 -0
- package/scss/colours/tokens/_global.scss +47 -0
- package/scss/{helpers/_helpers-focus.scss → focus/_index.scss} +15 -11
- package/scss/{helpers/_helpers-glyphs.scss → glyphs/_index.scss} +12 -10
- package/scss/layout/_index.scss +43 -0
- package/scss/media-queries/_index.scss +29 -0
- package/scss/media-queries/vendor/_mq.scss +307 -0
- package/scss/{settings/_settings-modular-scale.scss → modular-scale/_index.scss} +9 -7
- package/scss/spacing/_index.scss +31 -0
- package/scss/typography/{_typography-headings.scss → _headings.scss} +20 -19
- package/scss/typography/_helpers.scss +172 -0
- package/scss/typography/_index.scss +4 -0
- package/scss/typography/_links.scss +78 -0
- package/scss/{settings/_settings-typography.scss → typography/_settings.scss} +38 -34
- package/scss/{helpers/_helpers-utils.scss → utils/_index.scss} +22 -19
- package/scss/{vendor/_vendor-is.scss → utils/vendor/_is.scss} +8 -6
- package/scss/visibility/_index.scss +65 -0
- package/scss/core.scss +0 -4
- package/scss/helpers/_helpers-clearfix.scss +0 -23
- package/scss/helpers/_helpers-lists.scss +0 -45
- package/scss/helpers/_helpers-print.scss +0 -35
- package/scss/helpers/_helpers-text.scss +0 -21
- package/scss/helpers/_helpers-visibility.scss +0 -37
- package/scss/helpers/_helpers.scss +0 -2
- package/scss/layout/_layout-container.scss +0 -12
- package/scss/layout/_layout.scss +0 -1
- package/scss/settings/_settings-breakpoints.scss +0 -25
- package/scss/settings/_settings-colour-global.scss +0 -27
- package/scss/settings/_settings-colours-nice.scss +0 -80
- package/scss/settings/_settings-colours-semantic.scss +0 -247
- package/scss/settings/_settings-glyphs.scss +0 -3
- package/scss/settings/_settings-layout.scss +0 -15
- package/scss/settings/_settings-mq.scss +0 -17
- package/scss/settings/_settings-print.scss +0 -5
- package/scss/settings/_settings-spacing.scss +0 -43
- package/scss/settings/_settings.scss +0 -4
- package/scss/typography/_typography-helpers.scss +0 -148
- package/scss/typography/_typography-links.scss +0 -73
- package/scss/typography/_typography.scss +0 -1
- package/scss/vendor/_vendor-math.scss +0 -79
- package/scss/vendor/_vendor.scss +0 -2
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
// v6.0.0
|
|
2
|
+
// Vendored in much the same way as https://github.com/nhsuk/nhsuk-frontend/pull/601 and https://github.com/alphagov/govuk-frontend/pull/657
|
|
3
|
+
|
|
4
|
+
@use 'sass:math';
|
|
5
|
+
@use 'sass:map';
|
|
6
|
+
@use 'sass:list';
|
|
7
|
+
|
|
8
|
+
/// Breakpoint list
|
|
9
|
+
///
|
|
10
|
+
/// Name your breakpoints in a way that creates a ubiquitous language
|
|
11
|
+
/// across team members. It will improve communication between
|
|
12
|
+
/// stakeholders, designers, developers, and testers.
|
|
13
|
+
///
|
|
14
|
+
/// @type Map
|
|
15
|
+
/// @link https://github.com/sass-mq/sass-mq#seeing-the-currently-active-breakpoint Full documentation and examples
|
|
16
|
+
$breakpoints: (
|
|
17
|
+
mobile: 320px,
|
|
18
|
+
tablet: 740px,
|
|
19
|
+
desktop: 980px,
|
|
20
|
+
wide: 1300px
|
|
21
|
+
) !default;
|
|
22
|
+
|
|
23
|
+
/// Show breakpoints in the top right corner
|
|
24
|
+
///
|
|
25
|
+
/// If you want to display the currently active breakpoint in the top
|
|
26
|
+
/// right corner of your site during development, add the breakpoints
|
|
27
|
+
/// to this list, ordered by width. For example: (mobile, tablet, desktop).
|
|
28
|
+
///
|
|
29
|
+
/// @example scss
|
|
30
|
+
/// @use 'path/to/mq' with ($show-breakpoints: ('mobile', 'tablet', 'desktop'));
|
|
31
|
+
///
|
|
32
|
+
///
|
|
33
|
+
/// @type map
|
|
34
|
+
$show-breakpoints: () !default;
|
|
35
|
+
|
|
36
|
+
/// Customize the media type (for example: `@media screen` or `@media print`)
|
|
37
|
+
/// By default sass-mq uses an "all" media type (`@media all and …`)
|
|
38
|
+
///
|
|
39
|
+
/// If you want to overried the media type, you can use this option.
|
|
40
|
+
/// @example scss
|
|
41
|
+
/// @use 'path/to/mq' with ($media-type: 'screen');
|
|
42
|
+
///
|
|
43
|
+
/// @type String
|
|
44
|
+
/// @link https://github.com/sass-mq/sass-mq#changing-media-type Full documentation and example
|
|
45
|
+
$media-type: all !default;
|
|
46
|
+
|
|
47
|
+
/// Convert pixels to ems
|
|
48
|
+
///
|
|
49
|
+
/// @param {Number} $px - value to convert
|
|
50
|
+
///
|
|
51
|
+
/// @example scss
|
|
52
|
+
/// $font-size-in-ems: px2em(16px);
|
|
53
|
+
/// p { font-size: px2em(16px); }
|
|
54
|
+
///
|
|
55
|
+
/// @returns {Number}
|
|
56
|
+
|
|
57
|
+
@function px2em($px) {
|
|
58
|
+
@if math.is-unitless($px) {
|
|
59
|
+
@warn "Assuming #{$px} to be in pixels, attempting to convert it into pixels.";
|
|
60
|
+
@return px2em($px * 1px);
|
|
61
|
+
}
|
|
62
|
+
// if $px is compatible with em units, then return value unchanged
|
|
63
|
+
@if math.compatible($px, 1em) {
|
|
64
|
+
@return $px;
|
|
65
|
+
}
|
|
66
|
+
@return math.div($px, 16px) * 1em;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/// Get a breakpoint's width
|
|
70
|
+
///
|
|
71
|
+
/// @param {String} $name - Name of the breakpoint. One of $breakpoints
|
|
72
|
+
///
|
|
73
|
+
/// @example scss
|
|
74
|
+
/// $tablet-width: get-breakpoint-width(tablet);
|
|
75
|
+
/// @media (min-width: get-breakpoint-width(tablet)) {}
|
|
76
|
+
///
|
|
77
|
+
/// @requires {Variable} $breakpoints
|
|
78
|
+
///
|
|
79
|
+
/// @returns {Number} Value in pixels
|
|
80
|
+
@function get-breakpoint-width($name, $breakpoints: $breakpoints) {
|
|
81
|
+
@if map.has-key($breakpoints, $name) {
|
|
82
|
+
@return map.get($breakpoints, $name);
|
|
83
|
+
} @else {
|
|
84
|
+
@warn "Breakpoint #{$name} wasn't found in $breakpoints.";
|
|
85
|
+
@return null;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/// Media Query mixin
|
|
90
|
+
///
|
|
91
|
+
/// @param {String | Boolean} $from [false] - One of $breakpoints
|
|
92
|
+
/// @param {String | Boolean} $until [false] - One of $breakpoints
|
|
93
|
+
/// @param {String | Boolean} $and [false] - Additional media query parameters
|
|
94
|
+
/// @param {String} $media-type [$media-type] - Media type: screen, print…
|
|
95
|
+
///
|
|
96
|
+
/// @ignore Undocumented API, for advanced use only:
|
|
97
|
+
/// @ignore @param {Map} $breakpoints [$breakpoints]
|
|
98
|
+
///
|
|
99
|
+
/// @content styling rules, wrapped into a @media query when $responsive is true
|
|
100
|
+
///
|
|
101
|
+
/// @requires {Variable} $media-type
|
|
102
|
+
/// @requires {Variable} $breakpoints
|
|
103
|
+
/// @requires {function} px2em
|
|
104
|
+
/// @requires {function} get-breakpoint-width
|
|
105
|
+
///
|
|
106
|
+
/// @link https://github.com/sass-mq/sass-mq#responsive-mode-on-default Full documentation and examples
|
|
107
|
+
///
|
|
108
|
+
/// @example scss
|
|
109
|
+
/// @use 'path/to/mq' as *;
|
|
110
|
+
/// .element {
|
|
111
|
+
/// @include mq($from: mobile) {
|
|
112
|
+
/// color: red;
|
|
113
|
+
/// }
|
|
114
|
+
/// @include mq($until: tablet) {
|
|
115
|
+
/// color: blue;
|
|
116
|
+
/// }
|
|
117
|
+
/// @include mq(mobile, tablet) {
|
|
118
|
+
/// color: green;
|
|
119
|
+
/// }
|
|
120
|
+
/// @include mq($from: tablet, $and: '(orientation: landscape)') {
|
|
121
|
+
/// color: teal;
|
|
122
|
+
/// }
|
|
123
|
+
/// @include mq(950px) {
|
|
124
|
+
/// color: hotpink;
|
|
125
|
+
/// }
|
|
126
|
+
/// @include mq(tablet, $media-type: screen) {
|
|
127
|
+
/// color: hotpink;
|
|
128
|
+
/// }
|
|
129
|
+
/// // Advanced use:
|
|
130
|
+
/// $my-breakpoints: (L: 900px, XL: 1200px);
|
|
131
|
+
/// @include mq(L, $breakpoints: $my-breakpoints) {
|
|
132
|
+
/// color: hotpink;
|
|
133
|
+
/// }
|
|
134
|
+
/// }
|
|
135
|
+
@mixin mq(
|
|
136
|
+
$from: false,
|
|
137
|
+
$until: false,
|
|
138
|
+
$and: false,
|
|
139
|
+
$media-type: $media-type,
|
|
140
|
+
$breakpoints: $breakpoints
|
|
141
|
+
) {
|
|
142
|
+
$min-width: 0;
|
|
143
|
+
$max-width: 0;
|
|
144
|
+
$media-query: '';
|
|
145
|
+
|
|
146
|
+
// From: this breakpoint (inclusive)
|
|
147
|
+
@if $from {
|
|
148
|
+
@if type-of($from) == number {
|
|
149
|
+
$min-width: px2em($from);
|
|
150
|
+
} @else {
|
|
151
|
+
$min-width: px2em(get-breakpoint-width($from, $breakpoints));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Until: that breakpoint (exclusive)
|
|
156
|
+
@if $until {
|
|
157
|
+
@if type-of($until) == number {
|
|
158
|
+
$max-width: px2em($until);
|
|
159
|
+
} @else {
|
|
160
|
+
$max-width: px2em(get-breakpoint-width($until, $breakpoints)) - 0.01em;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@if $min-width != 0 {
|
|
165
|
+
$media-query: '#{$media-query} and (min-width: #{$min-width})';
|
|
166
|
+
}
|
|
167
|
+
@if $max-width != 0 {
|
|
168
|
+
$media-query: '#{$media-query} and (max-width: #{$max-width})';
|
|
169
|
+
}
|
|
170
|
+
@if $and {
|
|
171
|
+
$media-query: '#{$media-query} and #{$and}';
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Remove unnecessary media query prefix 'all and '
|
|
175
|
+
@if ($media-type == 'all' and $media-query != '') {
|
|
176
|
+
$media-type: '';
|
|
177
|
+
$media-query: str-slice(unquote($media-query), 6);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
@media #{$media-type + $media-query} {
|
|
181
|
+
@content;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/// Quick sort
|
|
186
|
+
///
|
|
187
|
+
/// @author Sam Richards
|
|
188
|
+
/// @access private
|
|
189
|
+
/// @param {List} $list - List to sort
|
|
190
|
+
/// @returns {List} Sorted List
|
|
191
|
+
@function _quick-sort($list) {
|
|
192
|
+
$less: ();
|
|
193
|
+
$equal: ();
|
|
194
|
+
$large: ();
|
|
195
|
+
|
|
196
|
+
@if length($list) > 1 {
|
|
197
|
+
$seed: list.nth($list, math.ceil(math.div(length($list), 2)));
|
|
198
|
+
|
|
199
|
+
@each $item in $list {
|
|
200
|
+
@if ($item == $seed) {
|
|
201
|
+
$equal: list.append($equal, $item);
|
|
202
|
+
} @else if ($item < $seed) {
|
|
203
|
+
$less: list.append($less, $item);
|
|
204
|
+
} @else if ($item > $seed) {
|
|
205
|
+
$large: list.append($large, $item);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
@return join(join(_quick-sort($less), $equal), _quick-sort($large));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
@return $list;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/// Sort a map by values (works with numbers only)
|
|
216
|
+
///
|
|
217
|
+
/// @access private
|
|
218
|
+
/// @param {Map} $map - Map to sort
|
|
219
|
+
/// @returns {Map} Map sorted by value
|
|
220
|
+
@function _map-sort-by-value($map) {
|
|
221
|
+
$map-sorted: ();
|
|
222
|
+
$map-keys: map.keys($map);
|
|
223
|
+
$map-values: map.values($map);
|
|
224
|
+
$map-values-sorted: _quick-sort($map-values);
|
|
225
|
+
|
|
226
|
+
// Reorder key/value pairs based on key values
|
|
227
|
+
@each $value in $map-values-sorted {
|
|
228
|
+
$index: index($map-values, $value);
|
|
229
|
+
$key: list.nth($map-keys, $index);
|
|
230
|
+
$map-sorted: map.merge(
|
|
231
|
+
$map-sorted,
|
|
232
|
+
(
|
|
233
|
+
$key: $value
|
|
234
|
+
)
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
// Unset the value in $map-values to prevent the loop
|
|
238
|
+
// from finding the same index twice
|
|
239
|
+
$map-values: list.set-nth($map-values, $index, 0);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
@return $map-sorted;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/// Add a breakpoint
|
|
246
|
+
///
|
|
247
|
+
/// @param {String} $name - Name of the breakpoint
|
|
248
|
+
/// @param {Number} $width - Width of the breakpoint
|
|
249
|
+
///
|
|
250
|
+
/// @requires {Variable} $breakpoints
|
|
251
|
+
///
|
|
252
|
+
/// @example scss
|
|
253
|
+
/// @include add-breakpoint(tvscreen, 1920px);
|
|
254
|
+
/// @include mq(tvscreen) {}
|
|
255
|
+
@mixin add-breakpoint($name, $width) {
|
|
256
|
+
$new-breakpoint: (
|
|
257
|
+
$name: $width
|
|
258
|
+
);
|
|
259
|
+
$breakpoints: map.merge($breakpoints, $new-breakpoint) !global;
|
|
260
|
+
$breakpoints: _map-sort-by-value($breakpoints) !global;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/// Show the active breakpoint in the top right corner of the viewport
|
|
264
|
+
/// @link https://github.com/sass-mq/sass-mq#seeing-the-currently-active-breakpoint
|
|
265
|
+
///
|
|
266
|
+
/// @param {List} $show-breakpoints [$show-breakpoints] - List of breakpoints to show in the top right corner
|
|
267
|
+
/// @param {Map} $breakpoints [$breakpoints] - Breakpoint names and sizes
|
|
268
|
+
///
|
|
269
|
+
/// @requires {Variable} $breakpoints
|
|
270
|
+
/// @requires {Variable} $show-breakpoints
|
|
271
|
+
///
|
|
272
|
+
/// @example scss
|
|
273
|
+
/// // Show breakpoints using global settings
|
|
274
|
+
/// @include show-breakpoints;
|
|
275
|
+
///
|
|
276
|
+
/// // Show breakpoints using custom settings
|
|
277
|
+
/// @include show-breakpoints((L, XL), (S: 300px, L: 800px, XL: 1200px));
|
|
278
|
+
@mixin show-breakpoints(
|
|
279
|
+
$show-breakpoints: $show-breakpoints,
|
|
280
|
+
$breakpoints: $breakpoints
|
|
281
|
+
) {
|
|
282
|
+
body:before {
|
|
283
|
+
background-color: #fcf8e3;
|
|
284
|
+
border-bottom: 1px solid #fbeed5;
|
|
285
|
+
border-left: 1px solid #fbeed5;
|
|
286
|
+
color: #c09853;
|
|
287
|
+
font: small-caption;
|
|
288
|
+
padding: 3px 6px;
|
|
289
|
+
pointer-events: none;
|
|
290
|
+
position: fixed;
|
|
291
|
+
right: 0;
|
|
292
|
+
top: 0;
|
|
293
|
+
z-index: 100;
|
|
294
|
+
|
|
295
|
+
// Loop through the breakpoints that should be shown
|
|
296
|
+
@each $show-breakpoint in $show-breakpoints {
|
|
297
|
+
$width: get-breakpoint-width($show-breakpoint, $breakpoints);
|
|
298
|
+
@include mq($show-breakpoint, $breakpoints: $breakpoints) {
|
|
299
|
+
content: '#{$show-breakpoint} ≥ #{$width} (#{px2em($width)})';
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
@if list.length($show-breakpoints) > 0 {
|
|
306
|
+
@include show-breakpoints;
|
|
307
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
@use
|
|
1
|
+
@use 'sass:math';
|
|
2
|
+
|
|
3
|
+
// stylelint-disable number-max-precision
|
|
2
4
|
|
|
3
5
|
/// Modular scale values
|
|
4
6
|
/// @link http://www.modularscale.com/
|
|
@@ -19,7 +21,7 @@
|
|
|
19
21
|
/// @prop {Number} major-second[1.125]
|
|
20
22
|
/// @prop {Number} minor-second[1.066666667]
|
|
21
23
|
/// @since 0.1.0
|
|
22
|
-
$
|
|
24
|
+
$scales: (
|
|
23
25
|
golden: 1.618034,
|
|
24
26
|
double-octave: 4,
|
|
25
27
|
major-twelfth: 3,
|
|
@@ -40,14 +42,14 @@ $nds-scales: (
|
|
|
40
42
|
);
|
|
41
43
|
|
|
42
44
|
/// Gets a module scale ratio with the given name. Looks
|
|
43
|
-
/// inside the $
|
|
45
|
+
/// inside the $scales map to find a ratio.
|
|
44
46
|
/// @param $scale The name of the scale
|
|
45
47
|
/// @returns {Number} The numeric scale ratio for the given name
|
|
46
48
|
/// @since 0.1.0
|
|
47
|
-
@function
|
|
48
|
-
@if map-has-key($
|
|
49
|
-
@return map-get($
|
|
49
|
+
@function get-ratio($scale) {
|
|
50
|
+
@if map-has-key($scales, $scale) {
|
|
51
|
+
@return map-get($scales, $scale);
|
|
50
52
|
} @else {
|
|
51
|
-
@error 'Scale with name #{$scale} could not be found in the $
|
|
53
|
+
@error 'Scale with name #{$scale} could not be found in the $scales map';
|
|
52
54
|
}
|
|
53
55
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
////
|
|
2
|
+
/// @group spacing
|
|
3
|
+
////
|
|
4
|
+
|
|
5
|
+
/// Extra extra small spacing
|
|
6
|
+
/// @since 0.2.0
|
|
7
|
+
$xx-small: 2;
|
|
8
|
+
|
|
9
|
+
/// Extra small spacing
|
|
10
|
+
/// @since 0.2.0
|
|
11
|
+
$x-small: 4;
|
|
12
|
+
|
|
13
|
+
/// Small spacing
|
|
14
|
+
/// @since 0.2.0
|
|
15
|
+
$small: 8;
|
|
16
|
+
|
|
17
|
+
/// Medium spacing
|
|
18
|
+
/// @since 0.2.0
|
|
19
|
+
$medium: 16;
|
|
20
|
+
|
|
21
|
+
/// Large spacing
|
|
22
|
+
/// @since 0.2.0
|
|
23
|
+
$large: 32;
|
|
24
|
+
|
|
25
|
+
/// Extra large spacing
|
|
26
|
+
/// @since 0.2.0
|
|
27
|
+
$x-large: 48;
|
|
28
|
+
|
|
29
|
+
/// Extra extra large spacing
|
|
30
|
+
/// @since 0.2.0
|
|
31
|
+
$xx-large: 64;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@use 'helpers';
|
|
2
|
+
|
|
1
3
|
////
|
|
2
4
|
/// @group Typography
|
|
3
5
|
////
|
|
@@ -5,24 +7,21 @@
|
|
|
5
7
|
/// Primary heading. Used for h1 tag but can be used directly
|
|
6
8
|
/// for semantic classes for visual styling.
|
|
7
9
|
/// @since 0.1.0
|
|
8
|
-
@mixin
|
|
9
|
-
@include
|
|
10
|
+
@mixin h1 {
|
|
11
|
+
@include helpers.font(h1);
|
|
10
12
|
clear: both;
|
|
11
|
-
font-family:
|
|
13
|
+
font-family: helpers.get-font-family(serif);
|
|
12
14
|
font-weight: 600;
|
|
13
|
-
// Letter spacing and text shadow to mimic 900 weight, see https://github.com/nice-digital/nice-design-system/issues/240
|
|
14
|
-
letter-spacing: 0.5px;
|
|
15
15
|
max-width: 66ch;
|
|
16
|
-
text-shadow: 1.5px 0 0 currentColor;
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
/// Secondary heading. Used for h2 tag but can be used directly
|
|
20
19
|
/// for semantic classes for visual styling.
|
|
21
20
|
/// @since 0.1.0
|
|
22
|
-
@mixin
|
|
23
|
-
@include
|
|
21
|
+
@mixin h2 {
|
|
22
|
+
@include helpers.font(h2);
|
|
24
23
|
clear: both;
|
|
25
|
-
font-family:
|
|
24
|
+
font-family: helpers.get-font-family(serif);
|
|
26
25
|
font-weight: 600;
|
|
27
26
|
max-width: 66ch;
|
|
28
27
|
}
|
|
@@ -30,10 +29,10 @@
|
|
|
30
29
|
/// Tertiary heading. Used for h3 tag but can be used directly
|
|
31
30
|
/// for semantic classes for visual styling.
|
|
32
31
|
/// @since 0.1.0
|
|
33
|
-
@mixin
|
|
34
|
-
@include
|
|
32
|
+
@mixin h3 {
|
|
33
|
+
@include helpers.font(h3);
|
|
35
34
|
clear: both;
|
|
36
|
-
font-family:
|
|
35
|
+
font-family: helpers.get-font-family(serif);
|
|
37
36
|
font-weight: 600;
|
|
38
37
|
max-width: 66ch;
|
|
39
38
|
}
|
|
@@ -41,10 +40,10 @@
|
|
|
41
40
|
/// Fourth level heading. Used for h4 tag but can be used directly
|
|
42
41
|
/// for semantic classes for visual styling.
|
|
43
42
|
/// @since 0.1.0
|
|
44
|
-
@mixin
|
|
45
|
-
@include
|
|
43
|
+
@mixin h4 {
|
|
44
|
+
@include helpers.font(h4);
|
|
46
45
|
clear: both;
|
|
47
|
-
font-family:
|
|
46
|
+
font-family: helpers.get-font-family(serif);
|
|
48
47
|
font-weight: 600;
|
|
49
48
|
max-width: 66ch;
|
|
50
49
|
}
|
|
@@ -52,9 +51,10 @@
|
|
|
52
51
|
/// Fifth level heading. Used for h5 tag but can be used directly
|
|
53
52
|
/// for semantic classes for visual styling.
|
|
54
53
|
/// @since 0.1.0
|
|
55
|
-
@mixin
|
|
56
|
-
@include
|
|
54
|
+
@mixin h5 {
|
|
55
|
+
@include helpers.font(h5);
|
|
57
56
|
clear: both;
|
|
57
|
+
font-family: helpers.get-font-family(sans);
|
|
58
58
|
font-weight: 700;
|
|
59
59
|
max-width: 66ch;
|
|
60
60
|
}
|
|
@@ -62,9 +62,10 @@
|
|
|
62
62
|
/// Sixth level heading. Used for h6 tag but can be used directly
|
|
63
63
|
/// for semantic classes for visual styling.
|
|
64
64
|
/// @since 0.1.0
|
|
65
|
-
@mixin
|
|
66
|
-
@include
|
|
65
|
+
@mixin h6 {
|
|
66
|
+
@include helpers.font(h6);
|
|
67
67
|
clear: both;
|
|
68
|
+
font-family: helpers.get-font-family(sans);
|
|
68
69
|
font-weight: 700;
|
|
69
70
|
max-width: 66ch;
|
|
70
71
|
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
@use 'sass:map';
|
|
2
|
+
@use 'settings' as typography-settings;
|
|
3
|
+
@use '../spacing';
|
|
4
|
+
@use '../colours';
|
|
5
|
+
@use '../utils';
|
|
6
|
+
|
|
7
|
+
////
|
|
8
|
+
/// @group Typography
|
|
9
|
+
////
|
|
10
|
+
|
|
11
|
+
/// Gets a font family from the `$font-families` map, given a name
|
|
12
|
+
/// @param {String} $stack The stack name e.g. sans, serif or mono
|
|
13
|
+
/// @since 0.1.0
|
|
14
|
+
@function get-font-family($stack) {
|
|
15
|
+
$result: map.get(typography-settings.$font-families, $stack);
|
|
16
|
+
@return unquote($result);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/// Gets a numeric scale
|
|
20
|
+
/// @param $scale {Integer|Name} The integer ratio or named font-size.
|
|
21
|
+
/// @since 0.1.0
|
|
22
|
+
@function get-scale-integer($scale) {
|
|
23
|
+
@if map-has-key(typography-settings.$named-font-sizes, $scale) {
|
|
24
|
+
@return map.get(typography-settings.$named-font-sizes, $scale);
|
|
25
|
+
} @else if is-integer($scale) {
|
|
26
|
+
@return $scale;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@error '`$scale` must either be an integer or exist as a named font size in `$named-font-sizes`';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/// Gets a numeric font size (in px) from a given scale multiplier.
|
|
33
|
+
/// Usually not used directly - the font-size or font mixin is usually used instead.
|
|
34
|
+
/// @param $scale {Integer|Name} The integer ratio or named font-size.
|
|
35
|
+
/// @return {Number} Numeric font size (in px)
|
|
36
|
+
/// @example
|
|
37
|
+
/// $font-size: get-font-size(2)
|
|
38
|
+
/// @example
|
|
39
|
+
/// $font-size: get-font-size(h1)
|
|
40
|
+
/// @since 0.1.0
|
|
41
|
+
@function get-font-size($scale) {
|
|
42
|
+
$scale-integer: get-scale-integer($scale);
|
|
43
|
+
$font-map: map.get(typography-settings.$font-sizes, $scale-integer);
|
|
44
|
+
@return map.get($font-map, fs);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/// Gets a numeric line height (in px) from a given scale multiplier.
|
|
48
|
+
/// Usually not used directly - the font-size or font mixin is usually used instead.
|
|
49
|
+
/// @param $scale {Integer|Name} The integer ratio or named font-size.
|
|
50
|
+
/// @return {Number} Numeric line-height (in px)
|
|
51
|
+
/// @example
|
|
52
|
+
/// $line-height: get-line-height(2)
|
|
53
|
+
/// @example
|
|
54
|
+
/// $line-height: get-line-height(h1)
|
|
55
|
+
/// @since 0.1.0
|
|
56
|
+
@function get-line-height($scale) {
|
|
57
|
+
$scale-integer: get-scale-integer($scale);
|
|
58
|
+
$font-map: map.get(typography-settings.$font-sizes, $scale-integer);
|
|
59
|
+
@return map.get($font-map, lh);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/// Applies font size and line-height for the given scale.
|
|
63
|
+
/// @param $scale {Integer|Name} The integer ratio or named font-size.
|
|
64
|
+
/// @param $important {Boolean} Whether to add an important declaration to the CSS rules.
|
|
65
|
+
/// @example
|
|
66
|
+
/// .test {
|
|
67
|
+
/// @include font-size(-2);
|
|
68
|
+
/// }
|
|
69
|
+
/// @example
|
|
70
|
+
/// .test {
|
|
71
|
+
/// @include font-size(h1, true);
|
|
72
|
+
/// }
|
|
73
|
+
/// @since 0.1.0
|
|
74
|
+
@mixin font-size($scale: 0, $important: false) {
|
|
75
|
+
$font-size: get-font-size($scale);
|
|
76
|
+
$line-height: get-line-height($scale);
|
|
77
|
+
|
|
78
|
+
@if $important {
|
|
79
|
+
font-size: utils.rem($font-size) !important;
|
|
80
|
+
line-height: utils.rem($line-height) !important;
|
|
81
|
+
} @else {
|
|
82
|
+
font-size: utils.rem($font-size);
|
|
83
|
+
line-height: utils.rem($line-height);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/// Nice font: includes font size, line height, and margins.
|
|
88
|
+
/// @param $scale {Integer|Name} The integer ratio or named font-size.
|
|
89
|
+
/// @param $important {Boolean} Whether to add an important declaration to the CSS rules.
|
|
90
|
+
/// @example
|
|
91
|
+
/// .test {
|
|
92
|
+
/// @include font(3);
|
|
93
|
+
/// }
|
|
94
|
+
/// @example
|
|
95
|
+
/// .test {
|
|
96
|
+
/// @include font(h1, true);
|
|
97
|
+
/// }
|
|
98
|
+
/// @since 0.1.0
|
|
99
|
+
@mixin font($scale, $important: false) {
|
|
100
|
+
$scale-integer: get-scale-integer($scale);
|
|
101
|
+
$font-map: map.get(typography-settings.$font-sizes, $scale-integer);
|
|
102
|
+
@include font-size($scale, $important);
|
|
103
|
+
|
|
104
|
+
@if $important {
|
|
105
|
+
margin-bottom: utils.rem(map.get($font-map, mb)) !important;
|
|
106
|
+
margin-top: utils.rem(map.get($font-map, mt)) !important;
|
|
107
|
+
} @else {
|
|
108
|
+
margin-bottom: utils.rem(map.get($font-map, mb));
|
|
109
|
+
margin-top: utils.rem(map.get($font-map, mt));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/// Default paragraph style
|
|
114
|
+
/// @since 0.5.2
|
|
115
|
+
@mixin p {
|
|
116
|
+
@include font(p);
|
|
117
|
+
font-feature-settings: 'kern', 'onum', 'liga';
|
|
118
|
+
font-weight: normal;
|
|
119
|
+
max-width: 66ch;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/// Lead paragraph style
|
|
123
|
+
/// @since 0.2.12
|
|
124
|
+
@mixin lead {
|
|
125
|
+
@include font(lead);
|
|
126
|
+
font-weight: normal;
|
|
127
|
+
max-width: 66ch;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/// Base list style
|
|
131
|
+
/// @since 0.1.0
|
|
132
|
+
@mixin list {
|
|
133
|
+
font-feature-settings: 'kern', 'onum', 'liga';
|
|
134
|
+
margin-left: utils.rem(spacing.$medium);
|
|
135
|
+
max-width: 66ch;
|
|
136
|
+
padding: 0;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/// Text truncate
|
|
140
|
+
/// Requires inline-block or block for proper styling
|
|
141
|
+
/// @since 0.1.0
|
|
142
|
+
@mixin text-truncate {
|
|
143
|
+
overflow: hidden;
|
|
144
|
+
text-overflow: ellipsis;
|
|
145
|
+
white-space: nowrap;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/// Set and element to display as block and align
|
|
149
|
+
/// centrally via auto left/right margins
|
|
150
|
+
/// @since 0.1.0
|
|
151
|
+
@mixin center-block {
|
|
152
|
+
display: block;
|
|
153
|
+
margin-left: auto;
|
|
154
|
+
margin-right: auto;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// TODO: default-error-style probably belongs elsewhere?
|
|
158
|
+
|
|
159
|
+
/// The highlight style used for elements like inputs and textareas
|
|
160
|
+
/// if there's an error on the field
|
|
161
|
+
/// @param {Boolean} $rounded whether to use box shadow for border (outline can't be styled to have radius corners)
|
|
162
|
+
/// @output default styling for form elements in an errored state
|
|
163
|
+
/// @since 1.0
|
|
164
|
+
@mixin default-error-style($rounded: false) {
|
|
165
|
+
@if $rounded {
|
|
166
|
+
box-shadow: 0 0 0 utils.rem(spacing.$x-small) colours.$error;
|
|
167
|
+
outline: spacing.$x-small solid transparent;
|
|
168
|
+
outline-offset: spacing.$x-small;
|
|
169
|
+
} @else {
|
|
170
|
+
outline: utils.rem(spacing.$x-small) solid colours.$error;
|
|
171
|
+
}
|
|
172
|
+
}
|