@moduk/frontend 1.0.9 → 1.1.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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moduk/frontend",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "The MOD.UK Frontend contains the code you need to start building a user interface for Ministry of Defence platforms and services.",
|
|
5
5
|
"main": "dist/lib/index.js",
|
|
6
6
|
"sass": "src/css/index.scss",
|
|
@@ -111,6 +111,7 @@
|
|
|
111
111
|
"postcss-fail-on-warn": "^0.2.1",
|
|
112
112
|
"release-it": "^15.7.0",
|
|
113
113
|
"sass": "^1.59.3",
|
|
114
|
+
"sass-true": "^7.0.0",
|
|
114
115
|
"shx": "^0.3.4",
|
|
115
116
|
"ts-node": "^10.9.1",
|
|
116
117
|
"typescript": "^4.9.5",
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
@use 'sass-true' as test;
|
|
2
|
+
@use '../colour-palette' as moduk;
|
|
3
|
+
|
|
4
|
+
@include test.describe('moduk-colour') {
|
|
5
|
+
@include test.it('returns untinted colours') {
|
|
6
|
+
@include test.assert-equal(moduk.moduk-colour('dark-purple'), #532a45);
|
|
7
|
+
@include test.assert-equal(moduk.moduk-colour('dark-grey'), #323e48);
|
|
8
|
+
@include test.assert-equal(moduk.moduk-colour('dark-blue'), #13284c);
|
|
9
|
+
@include test.assert-equal(moduk.moduk-colour('dark-green'), #153e35);
|
|
10
|
+
@include test.assert-equal(moduk.moduk-colour('dark-yellow'), #f6a800);
|
|
11
|
+
@include test.assert-equal(moduk.moduk-colour('dark-orange'), #e0592b);
|
|
12
|
+
@include test.assert-equal(moduk.moduk-colour('dark-pink'), #8e1537);
|
|
13
|
+
@include test.assert-equal(moduk.moduk-colour('muted-purple'), #94368d);
|
|
14
|
+
@include test.assert-equal(moduk.moduk-colour('muted-grey'), #7b98ac);
|
|
15
|
+
@include test.assert-equal(moduk.moduk-colour('muted-blue'), #4298cc);
|
|
16
|
+
@include test.assert-equal(moduk.moduk-colour('muted-green'), #00945f);
|
|
17
|
+
@include test.assert-equal(moduk.moduk-colour('muted-yellow'), #ffc845);
|
|
18
|
+
@include test.assert-equal(moduk.moduk-colour('muted-orange'), #f28b00);
|
|
19
|
+
@include test.assert-equal(moduk.moduk-colour('muted-pink'), #fa7699);
|
|
20
|
+
@include test.assert-equal(moduk.moduk-colour('bright-purple'), #ab92e1);
|
|
21
|
+
@include test.assert-equal(moduk.moduk-colour('bright-grey'), #becdd6);
|
|
22
|
+
@include test.assert-equal(moduk.moduk-colour('bright-blue'), #3db5e6);
|
|
23
|
+
@include test.assert-equal(moduk.moduk-colour('bright-green'), #00ce7d);
|
|
24
|
+
@include test.assert-equal(moduk.moduk-colour('bright-yellow'), #ffc600);
|
|
25
|
+
@include test.assert-equal(moduk.moduk-colour('bright-orange'), #ff8200);
|
|
26
|
+
@include test.assert-equal(moduk.moduk-colour('bright-pink'), #f087cf);
|
|
27
|
+
@include test.assert-equal(moduk.moduk-colour('light-maroon'), #643f58);
|
|
28
|
+
@include test.assert-equal(moduk.moduk-colour('maroon'), #532a45);
|
|
29
|
+
@include test.assert-equal(moduk.moduk-colour('dark-maroon'), #4b263e);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@include test.it('returns tinted colours') {
|
|
33
|
+
@include test.assert-equal(moduk.moduk-colour('dark-purple', 80), #75556a);
|
|
34
|
+
@include test.assert-equal(moduk.moduk-colour('dark-purple', 60), #987f8f);
|
|
35
|
+
@include test.assert-equal(moduk.moduk-colour('dark-purple', 40), #baaab5);
|
|
36
|
+
@include test.assert-equal(moduk.moduk-colour('dark-purple', 20), #ddd4da);
|
|
37
|
+
@include test.assert-equal(moduk.moduk-colour('dark-grey', 80), #5b656d);
|
|
38
|
+
@include test.assert-equal(moduk.moduk-colour('dark-grey', 60), #848b91);
|
|
39
|
+
@include test.assert-equal(moduk.moduk-colour('dark-grey', 40), #adb2b6);
|
|
40
|
+
@include test.assert-equal(moduk.moduk-colour('dark-grey', 20), #d6d8da);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
|
|
3
|
+
import { globSync } from 'glob'
|
|
4
|
+
import { join } from 'node:path'
|
|
5
|
+
import sassTrue from 'sass-true'
|
|
6
|
+
import { describe, it } from 'vitest'
|
|
7
|
+
|
|
8
|
+
globSync(join(__dirname, '**/*.test.scss'), { windowsPathsNoEscape: true }).forEach((filePath) => {
|
|
9
|
+
sassTrue.runSass(
|
|
10
|
+
{ describe, it },
|
|
11
|
+
filePath,
|
|
12
|
+
{
|
|
13
|
+
loadPaths: ['node_modules'],
|
|
14
|
+
quietDeps: true,
|
|
15
|
+
},
|
|
16
|
+
)
|
|
17
|
+
})
|
|
@@ -1,15 +1,67 @@
|
|
|
1
|
+
@use 'sass:color';
|
|
2
|
+
@use 'sass:list';
|
|
3
|
+
@use 'sass:map';
|
|
4
|
+
|
|
5
|
+
@use 'govuk-frontend/govuk/helpers/colour';
|
|
6
|
+
|
|
1
7
|
$moduk-colours: (
|
|
2
|
-
'
|
|
8
|
+
'dark-purple': #532a45,
|
|
9
|
+
'dark-grey': #323e48,
|
|
10
|
+
'dark-blue': #13284c,
|
|
11
|
+
'dark-green': #153e35,
|
|
12
|
+
'dark-yellow': #f6a800,
|
|
13
|
+
'dark-orange': #e0592b,
|
|
14
|
+
'dark-pink': #8e1537,
|
|
15
|
+
'muted-purple': #94368d,
|
|
16
|
+
'muted-grey': #7b98ac,
|
|
17
|
+
'muted-blue': #4298cc,
|
|
18
|
+
'muted-green': #00945f,
|
|
19
|
+
'muted-yellow': #ffc845,
|
|
20
|
+
'muted-orange': #f28b00,
|
|
21
|
+
'muted-pink': #fa7699,
|
|
22
|
+
'bright-purple': #ab92e1,
|
|
23
|
+
'bright-grey': #becdd6,
|
|
24
|
+
'bright-blue': #3db5e6,
|
|
25
|
+
'bright-green': #00ce7d,
|
|
26
|
+
'bright-yellow': #ffc600,
|
|
27
|
+
'bright-orange': #ff8200,
|
|
28
|
+
'bright-pink': #f087cf,
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
$legacy-moduk-colours: (
|
|
32
|
+
'maroon': map-get($moduk-colours, 'dark-purple'),
|
|
3
33
|
'dark-maroon': #4b263e,
|
|
4
34
|
'light-maroon': #643f58,
|
|
5
35
|
);
|
|
6
36
|
|
|
7
|
-
|
|
37
|
+
// Get a colour from the MOD.UK colour palette.
|
|
38
|
+
//
|
|
39
|
+
// @param $colour-name {String} the name of the colour (e.g. dark-purple, muted-blue)
|
|
40
|
+
// @param $tint {Number} Optional colour tint (80, 60, 40 or 20)
|
|
41
|
+
//
|
|
42
|
+
// @return {String}
|
|
43
|
+
@function moduk-colour($colour-name, $tint: null) {
|
|
44
|
+
$valid_tints: [20, 40, 60, 80];
|
|
8
45
|
$quoted-colour-name: quote($colour-name);
|
|
46
|
+
$all_colours: map.merge($legacy-moduk-colours, $moduk-colours);
|
|
47
|
+
|
|
48
|
+
@if $tint and not list.index($valid_tints, $tint) {
|
|
49
|
+
@error "Invalid tint `#{$tint}`";
|
|
50
|
+
}
|
|
9
51
|
|
|
10
|
-
@if not map
|
|
52
|
+
@if not map.has-key($all_colours, $quoted-colour-name) {
|
|
11
53
|
@error "Unknown colour `#{$quoted-colour-name}`";
|
|
12
54
|
}
|
|
13
55
|
|
|
14
|
-
@
|
|
56
|
+
@if $tint and map.has-key($legacy-moduk-colours, $quoted-colour-name) {
|
|
57
|
+
@error "Invalid tint `#{$tint}` for colour `#{$quoted-colour-name}`";
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
$resolved_colour: map.get($all_colours, $quoted-colour-name);
|
|
61
|
+
|
|
62
|
+
@if $tint {
|
|
63
|
+
@return colour.govuk-tint($resolved_colour, 100 - $tint);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@return $resolved_colour;
|
|
15
67
|
}
|