@ministryofjustice/frontend 3.3.0 → 3.4.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/README.md +4 -10
- package/govuk-prototype-kit.config.json +5 -16
- package/moj/all.jquery.min.js +77 -3
- package/moj/all.js +2022 -1444
- package/moj/all.scss +2 -0
- package/moj/all.spec.js +15 -13
- package/moj/components/_all.scss +1 -0
- package/moj/components/action-bar/_action-bar.scss +4 -6
- package/moj/components/add-another/_add-another.scss +9 -7
- package/moj/components/add-another/add-another.js +90 -69
- package/moj/components/add-another/add-another.spec.js +165 -0
- package/moj/components/alert/README.md +0 -0
- package/moj/components/alert/_alert.scss +142 -0
- package/moj/components/alert/alert.js +247 -0
- package/moj/components/alert/alert.spec.helper.js +67 -0
- package/moj/components/alert/alert.spec.js +229 -0
- package/moj/components/alert/macro.njk +3 -0
- package/moj/components/alert/template.njk +83 -0
- package/moj/components/badge/_badge.scss +3 -4
- package/moj/components/banner/_banner.scss +5 -10
- package/moj/components/button-menu/_button-menu.scss +10 -9
- package/moj/components/button-menu/button-menu.js +139 -136
- package/moj/components/button-menu/button-menu.spec.js +295 -296
- package/moj/components/cookie-banner/_cookie-banner.scss +6 -5
- package/moj/components/currency-input/_currency-input.scss +4 -4
- package/moj/components/date-picker/README.md +14 -17
- package/moj/components/date-picker/_date-picker.scss +122 -106
- package/moj/components/date-picker/date-picker.js +473 -471
- package/moj/components/date-picker/date-picker.spec.js +962 -914
- package/moj/components/filter/README.md +1 -1
- package/moj/components/filter/_filter.scss +53 -75
- package/moj/components/filter-toggle-button/filter-toggle-button.js +71 -67
- package/moj/components/filter-toggle-button/filter-toggle-button.spec.js +203 -205
- package/moj/components/form-validator/form-validator.js +117 -109
- package/moj/components/header/_header.scss +17 -19
- package/moj/components/identity-bar/_identity-bar.scss +5 -5
- package/moj/components/interruption-card/_interruption-card.scss +9 -2
- package/moj/components/messages/_messages.scss +12 -19
- package/moj/components/multi-file-upload/README.md +1 -1
- package/moj/components/multi-file-upload/_multi-file-upload.scss +34 -30
- package/moj/components/multi-file-upload/multi-file-upload.js +188 -152
- package/moj/components/multi-file-upload/multi-file-upload.spec.js +510 -0
- package/moj/components/multi-select/_multi-select.scss +4 -3
- package/moj/components/multi-select/multi-select.js +55 -50
- package/moj/components/multi-select/multi-select.spec.js +128 -0
- package/moj/components/notification-badge/_notification-badge.scss +12 -12
- package/moj/components/organisation-switcher/_organisation-switcher.scss +1 -1
- package/moj/components/page-header-actions/_page-header-actions.scss +3 -2
- package/moj/components/pagination/_pagination.scss +26 -31
- package/moj/components/password-reveal/_password-reveal.scss +1 -2
- package/moj/components/password-reveal/password-reveal.js +22 -21
- package/moj/components/password-reveal/password-reveal.spec.js +39 -37
- package/moj/components/primary-navigation/_primary-navigation.scss +26 -29
- package/moj/components/progress-bar/_progress-bar.scss +21 -26
- package/moj/components/rich-text-editor/_rich-text-editor.scss +17 -16
- package/moj/components/rich-text-editor/rich-text-editor.js +117 -103
- package/moj/components/search/_search.scss +6 -4
- package/moj/components/search-toggle/search-toggle.js +29 -30
- package/moj/components/search-toggle/search-toggle.scss +21 -15
- package/moj/components/search-toggle/search-toggle.spec.js +129 -0
- package/moj/components/side-navigation/_side-navigation.scss +12 -21
- package/moj/components/sortable-table/_sortable-table.scss +25 -23
- package/moj/components/sortable-table/sortable-table.js +139 -117
- package/moj/components/sortable-table/sortable-table.spec.js +362 -0
- package/moj/components/sub-navigation/_sub-navigation.scss +24 -28
- package/moj/components/tag/_tag.scss +8 -9
- package/moj/components/task-list/_task-list.scss +8 -7
- package/moj/components/ticket-panel/_ticket-panel.scss +14 -6
- package/moj/components/timeline/_timeline.scss +18 -20
- package/moj/filters/all.js +28 -30
- package/moj/filters/prototype-kit-13-filters.js +2 -1
- package/moj/helpers/_all.scss +1 -0
- package/moj/helpers/_hidden.scss +1 -1
- package/moj/helpers/_links.scss +20 -0
- package/moj/helpers.js +160 -31
- package/moj/helpers.spec.js +235 -0
- package/moj/init.js +2 -2
- package/moj/moj-frontend.min.css +2 -2
- package/moj/moj-frontend.min.js +77 -3
- package/moj/namespace.js +2 -1
- package/moj/objects/_filter-layout.scss +11 -10
- package/moj/objects/_scrollable-pane.scss +11 -14
- package/moj/settings/_colours.scss +5 -0
- package/moj/settings/_measurements.scss +0 -2
- package/moj/utilities/_hidden.scss +3 -3
- package/moj/utilities/_width-container.scss +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/* eslint-disable no-new */
|
|
2
|
+
|
|
3
|
+
const { queryByRole, queryAllByRole } = require('@testing-library/dom')
|
|
4
|
+
const { userEvent } = require('@testing-library/user-event')
|
|
5
|
+
|
|
6
|
+
require('./multi-select.js')
|
|
7
|
+
|
|
8
|
+
const user = userEvent.setup()
|
|
9
|
+
|
|
10
|
+
const createComponent = (id = 'multi-select', idprefix = false) => {
|
|
11
|
+
const html = `
|
|
12
|
+
<table id="${id}" class="govuk-table" data-module="moj-multi-select" data-multi-select-checkbox="#${id}-select-all" ${idprefix ? `data-multi-select-idprefix="${idprefix}-"` : ''}>
|
|
13
|
+
<thead class="govuk-table__head">
|
|
14
|
+
<tr class="govuk-table__row">
|
|
15
|
+
<th class="govuk-table__header" scope="col" id="${id}-select-all"></th>
|
|
16
|
+
<th class="govuk-table__header" scope="col">Name</th>
|
|
17
|
+
</tr>
|
|
18
|
+
</thead>
|
|
19
|
+
<tbody class="govuk-table__body">
|
|
20
|
+
<tr class="govuk-table__row govuk-table__row--selected">
|
|
21
|
+
<td class="govuk-table__cell">
|
|
22
|
+
<div class="govuk-checkboxes__item govuk-checkboxes--small moj-multi-select__checkbox">
|
|
23
|
+
<input type="checkbox" class="govuk-checkboxes__input" id="mountain-aconcagua">
|
|
24
|
+
<label class="govuk-label govuk-checkboxes__label" for="mountain-aconcagua">
|
|
25
|
+
<span class="govuk-visually-hidden">Select Aconcagua</span>
|
|
26
|
+
</label>
|
|
27
|
+
</div>
|
|
28
|
+
</td>
|
|
29
|
+
<td class="govuk-table__cell">Aconcagua</td>
|
|
30
|
+
</tr>
|
|
31
|
+
<tr class="govuk-table__row">
|
|
32
|
+
<td class="govuk-table__cell">
|
|
33
|
+
<div class="govuk-checkboxes__item govuk-checkboxes--small moj-multi-select__checkbox">
|
|
34
|
+
<input type="checkbox" class="govuk-checkboxes__input" id="mountain-denali" value="denali">
|
|
35
|
+
<label class="govuk-label govuk-checkboxes__label" for="mountain-denali">
|
|
36
|
+
<span class="govuk-visually-hidden">Select Denali</span>
|
|
37
|
+
</label>
|
|
38
|
+
</div>
|
|
39
|
+
</td>
|
|
40
|
+
</td>
|
|
41
|
+
<td class="govuk-table__cell">Denali</td>
|
|
42
|
+
</tr>
|
|
43
|
+
</tbody>
|
|
44
|
+
</table>
|
|
45
|
+
`
|
|
46
|
+
document.body.insertAdjacentHTML('afterbegin', html)
|
|
47
|
+
const component = document.querySelector(`#${id}`)
|
|
48
|
+
return component
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
describe('multi select', () => {
|
|
52
|
+
let component
|
|
53
|
+
let container
|
|
54
|
+
let checkboxes
|
|
55
|
+
|
|
56
|
+
beforeEach(() => {
|
|
57
|
+
component = createComponent()
|
|
58
|
+
container = component.querySelector('#multi-select-select-all')
|
|
59
|
+
checkboxes = component.querySelectorAll('tbody input[type=checkbox]')
|
|
60
|
+
|
|
61
|
+
new MOJFrontend.MultiSelect({
|
|
62
|
+
container,
|
|
63
|
+
checkboxes
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
afterEach(() => {
|
|
68
|
+
document.body.innerHTML = ''
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
test('initialises component', () => {
|
|
72
|
+
const selectToggle = queryByRole(container, 'checkbox')
|
|
73
|
+
|
|
74
|
+
expect(selectToggle).toBeInTheDocument()
|
|
75
|
+
expect(selectToggle).toHaveAccessibleName('Select all')
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
test('toggles all checkboxes', async () => {
|
|
79
|
+
const selectToggle = queryByRole(container, 'checkbox')
|
|
80
|
+
const tbody = component.querySelector('tbody')
|
|
81
|
+
const checkboxes = queryAllByRole(tbody, 'checkbox')
|
|
82
|
+
|
|
83
|
+
expect(checkboxes).toHaveLength(2)
|
|
84
|
+
checkboxes.forEach((checkbox) => {
|
|
85
|
+
expect(checkbox).not.toBeChecked()
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
await user.click(selectToggle)
|
|
89
|
+
expect(selectToggle).toBeChecked()
|
|
90
|
+
|
|
91
|
+
checkboxes.forEach((checkbox) => {
|
|
92
|
+
expect(checkbox).toBeChecked()
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
await user.click(selectToggle)
|
|
96
|
+
expect(selectToggle).not.toBeChecked()
|
|
97
|
+
|
|
98
|
+
checkboxes.forEach((checkbox) => {
|
|
99
|
+
expect(checkbox).not.toBeChecked()
|
|
100
|
+
})
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
test('deselcting single checkbox unchecks all checkbox', async () => {
|
|
104
|
+
const selectToggle = queryByRole(container, 'checkbox')
|
|
105
|
+
const tbody = component.querySelector('tbody')
|
|
106
|
+
const checkboxes = queryAllByRole(tbody, 'checkbox')
|
|
107
|
+
|
|
108
|
+
expect(checkboxes).toHaveLength(2)
|
|
109
|
+
checkboxes.forEach((checkbox) => {
|
|
110
|
+
expect(checkbox).not.toBeChecked()
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
await user.click(selectToggle)
|
|
114
|
+
expect(selectToggle).toBeChecked()
|
|
115
|
+
|
|
116
|
+
checkboxes.forEach((checkbox) => {
|
|
117
|
+
expect(checkbox).toBeChecked()
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
await user.click(checkboxes[0])
|
|
121
|
+
expect(checkboxes[0]).not.toBeChecked()
|
|
122
|
+
expect(selectToggle).not.toBeChecked()
|
|
123
|
+
|
|
124
|
+
await user.click(checkboxes[0])
|
|
125
|
+
expect(checkboxes[0]).toBeChecked()
|
|
126
|
+
expect(selectToggle).toBeChecked()
|
|
127
|
+
})
|
|
128
|
+
})
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
========================================================================== */
|
|
4
4
|
|
|
5
5
|
.moj-notification-badge {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
6
|
+
@include govuk-font($size: 16, $weight: "bold");
|
|
7
|
+
display: inline-block;
|
|
8
|
+
min-width: 15px;
|
|
9
|
+
padding: 5px 8px 2px;
|
|
10
|
+
border-radius: 75px;
|
|
11
|
+
color: govuk-colour("white");
|
|
12
|
+
background-color: govuk-colour("red");
|
|
13
|
+
font-size: 16px;
|
|
14
|
+
font-weight: 600;
|
|
15
|
+
text-align: center;
|
|
16
|
+
white-space: nowrap;
|
|
17
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
.moj-page-header-actions {
|
|
2
2
|
display: flex;
|
|
3
|
+
min-height: govuk-spacing(7); // Match button height
|
|
4
|
+
margin-bottom: govuk-spacing(7);
|
|
3
5
|
flex-wrap: wrap;
|
|
4
6
|
justify-content: space-between;
|
|
5
7
|
align-items: center;
|
|
6
8
|
gap: govuk-spacing(2);
|
|
7
|
-
margin-bottom: govuk-spacing(7);
|
|
8
|
-
min-height: govuk-spacing(7); // Match button height
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
.moj-page-header-actions__title {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
.moj-button-group {
|
|
19
19
|
margin-bottom: 0;
|
|
20
20
|
}
|
|
21
|
+
|
|
21
22
|
.govuk-button {
|
|
22
23
|
margin-bottom: 0;
|
|
23
24
|
}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// text-align: center;
|
|
3
3
|
|
|
4
4
|
@include govuk-media-query($from: desktop) {
|
|
5
|
+
margin-right: - govuk-spacing(1);
|
|
5
6
|
|
|
6
7
|
// Alignment adjustments
|
|
7
8
|
margin-left: - govuk-spacing(1);
|
|
8
|
-
margin-right: - govuk-spacing(1);
|
|
9
9
|
|
|
10
10
|
// Hide whitespace between elements
|
|
11
11
|
font-size: 0;
|
|
@@ -13,19 +13,18 @@
|
|
|
13
13
|
// Trick to remove the need for floats
|
|
14
14
|
text-align: justify;
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
content:
|
|
16
|
+
&::after {
|
|
17
|
+
content: "";
|
|
18
18
|
display: inline-block;
|
|
19
19
|
width: 100%;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
.moj-pagination__list {
|
|
26
|
-
list-style: none;
|
|
27
25
|
margin: 0;
|
|
28
26
|
padding: 0;
|
|
27
|
+
list-style: none;
|
|
29
28
|
@include govuk-media-query($from: desktop) {
|
|
30
29
|
display: inline-block;
|
|
31
30
|
margin-bottom: 0;
|
|
@@ -36,6 +35,7 @@
|
|
|
36
35
|
.moj-pagination__results {
|
|
37
36
|
@include govuk-font(19);
|
|
38
37
|
margin-top: 0;
|
|
38
|
+
padding: govuk-spacing(1);
|
|
39
39
|
@include govuk-media-query($from: desktop) {
|
|
40
40
|
display: inline-block;
|
|
41
41
|
margin-bottom: 0;
|
|
@@ -50,49 +50,49 @@
|
|
|
50
50
|
|
|
51
51
|
.moj-pagination__item--active,
|
|
52
52
|
.moj-pagination__item--dots {
|
|
53
|
-
font-weight: bold;
|
|
54
53
|
height: 25px;
|
|
55
54
|
padding: govuk-spacing(1) govuk-spacing(2);
|
|
55
|
+
font-weight: bold;
|
|
56
56
|
text-align: center;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
.moj-pagination__item--dots {
|
|
60
|
-
padding-left: 0;
|
|
61
60
|
padding-right: 0;
|
|
61
|
+
padding-left: 0;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
.moj-pagination__item--prev .moj-pagination__link
|
|
65
|
-
.moj-pagination__item--next .moj-pagination__link
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
64
|
+
.moj-pagination__item--prev .moj-pagination__link::before,
|
|
65
|
+
.moj-pagination__item--next .moj-pagination__link::after {
|
|
66
|
+
content: "";
|
|
67
|
+
display: inline-block;
|
|
68
|
+
width: 10px;
|
|
69
|
+
height: 10px;
|
|
70
|
+
-webkit-transform: rotate(-45deg);
|
|
71
|
+
-ms-transform: rotate(-45deg);
|
|
72
|
+
transform: rotate(-45deg);
|
|
73
|
+
border-style: solid;
|
|
74
|
+
color: govuk-colour("black");
|
|
75
|
+
background: transparent;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
.moj-pagination__item--prev .moj-pagination__link
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
.moj-pagination__item--prev .moj-pagination__link::before {
|
|
79
|
+
margin-right: govuk-spacing(1);
|
|
80
|
+
border-width: 3px 0 0 3px;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
.moj-pagination__item--next .moj-pagination__link
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
.moj-pagination__item--next .moj-pagination__link::after {
|
|
84
|
+
margin-left: govuk-spacing(1);
|
|
85
|
+
border-width: 0 3px 3px 0;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
.moj-pagination__link {
|
|
89
89
|
@include govuk-link-common;
|
|
90
90
|
@include govuk-link-style-default;
|
|
91
91
|
display: block;
|
|
92
|
+
min-width: 25px;
|
|
92
93
|
padding: govuk-spacing(1);
|
|
93
94
|
text-align: center;
|
|
94
95
|
text-decoration: none;
|
|
95
|
-
min-width: 25px;
|
|
96
96
|
|
|
97
97
|
&:link,
|
|
98
98
|
&:visited {
|
|
@@ -106,9 +106,4 @@
|
|
|
106
106
|
&:focus {
|
|
107
107
|
color: govuk-colour("black");
|
|
108
108
|
}
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
.moj-pagination__results {
|
|
113
|
-
padding: govuk-spacing(1);
|
|
114
109
|
}
|
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
MOJFrontend.PasswordReveal = function(element) {
|
|
2
|
-
this.el = element
|
|
3
|
-
|
|
1
|
+
MOJFrontend.PasswordReveal = function (element) {
|
|
2
|
+
this.el = element
|
|
3
|
+
const $el = $(this.el)
|
|
4
4
|
|
|
5
5
|
if ($el.data('moj-password-reveal-initialised')) {
|
|
6
6
|
return
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
$el.data('moj-password-reveal-initialised', true)
|
|
10
|
-
$el.attr('spellcheck', 'false')
|
|
9
|
+
$el.data('moj-password-reveal-initialised', true)
|
|
10
|
+
$el.attr('spellcheck', 'false')
|
|
11
11
|
|
|
12
|
-
$el.wrap('<div class="moj-password-reveal"></div>')
|
|
13
|
-
this.container = $(this.el).parent()
|
|
14
|
-
this.createButton()
|
|
15
|
-
}
|
|
12
|
+
$el.wrap('<div class="moj-password-reveal"></div>')
|
|
13
|
+
this.container = $(this.el).parent()
|
|
14
|
+
this.createButton()
|
|
15
|
+
}
|
|
16
16
|
|
|
17
|
-
MOJFrontend.PasswordReveal.prototype.createButton = function() {
|
|
18
|
-
this.button = $(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
MOJFrontend.PasswordReveal.prototype.createButton = function () {
|
|
18
|
+
this.button = $(
|
|
19
|
+
'<button type="button" class="govuk-button govuk-button--secondary moj-password-reveal__button">Show <span class="govuk-visually-hidden">password</span></button>'
|
|
20
|
+
)
|
|
21
|
+
this.container.append(this.button)
|
|
22
|
+
this.button.on('click', $.proxy(this, 'onButtonClick'))
|
|
23
|
+
}
|
|
22
24
|
|
|
23
|
-
MOJFrontend.PasswordReveal.prototype.onButtonClick = function() {
|
|
25
|
+
MOJFrontend.PasswordReveal.prototype.onButtonClick = function () {
|
|
24
26
|
if (this.el.type === 'password') {
|
|
25
|
-
this.el.type = 'text'
|
|
26
|
-
this.button.html('Hide <span class="govuk-visually-hidden">password</span>')
|
|
27
|
+
this.el.type = 'text'
|
|
28
|
+
this.button.html('Hide <span class="govuk-visually-hidden">password</span>')
|
|
27
29
|
} else {
|
|
28
|
-
this.el.type = 'password'
|
|
29
|
-
this.button.html('Show <span class="govuk-visually-hidden">password</span>')
|
|
30
|
+
this.el.type = 'password'
|
|
31
|
+
this.button.html('Show <span class="govuk-visually-hidden">password</span>')
|
|
30
32
|
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
+
}
|
|
@@ -1,55 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
const { userEvent } = require("@testing-library/user-event");
|
|
3
|
-
const { configureAxe } = require("jest-axe");
|
|
1
|
+
/* eslint-disable no-new */
|
|
4
2
|
|
|
5
|
-
require(
|
|
3
|
+
const { getByDisplayValue, getByText } = require('@testing-library/dom')
|
|
4
|
+
const { userEvent } = require('@testing-library/user-event')
|
|
5
|
+
const { configureAxe } = require('jest-axe')
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
require('./password-reveal.js')
|
|
8
|
+
|
|
9
|
+
const user = userEvent.setup()
|
|
8
10
|
const axe = configureAxe({
|
|
9
11
|
rules: {
|
|
10
12
|
// disable landmark rules when testing isolated components.
|
|
11
|
-
region: { enabled: false }
|
|
12
|
-
}
|
|
13
|
-
})
|
|
13
|
+
region: { enabled: false }
|
|
14
|
+
}
|
|
15
|
+
})
|
|
14
16
|
|
|
15
|
-
describe(
|
|
16
|
-
let container
|
|
17
|
+
describe('Password reveal', () => {
|
|
18
|
+
let container
|
|
17
19
|
|
|
18
20
|
beforeEach(() => {
|
|
19
|
-
const input = document.createElement(
|
|
20
|
-
input.type =
|
|
21
|
-
input.value =
|
|
21
|
+
const input = document.createElement('input')
|
|
22
|
+
input.type = 'password'
|
|
23
|
+
input.value = 'password'
|
|
22
24
|
|
|
23
|
-
new MOJFrontend.PasswordReveal(input)
|
|
25
|
+
new MOJFrontend.PasswordReveal(input)
|
|
24
26
|
|
|
25
|
-
container = input.parentNode
|
|
26
|
-
})
|
|
27
|
+
container = input.parentNode
|
|
28
|
+
})
|
|
27
29
|
|
|
28
|
-
test(
|
|
29
|
-
expect(container).toHaveClass(
|
|
30
|
-
expect(container).toContainElement(getByText(container,
|
|
31
|
-
})
|
|
30
|
+
test('initialises container', () => {
|
|
31
|
+
expect(container).toHaveClass('moj-password-reveal')
|
|
32
|
+
expect(container).toContainElement(getByText(container, 'Show'))
|
|
33
|
+
})
|
|
32
34
|
|
|
33
|
-
test(
|
|
34
|
-
const input = getByDisplayValue(container,
|
|
35
|
-
const button = getByText(container,
|
|
35
|
+
test('toggle reveal', async () => {
|
|
36
|
+
const input = getByDisplayValue(container, 'password')
|
|
37
|
+
const button = getByText(container, 'Show')
|
|
36
38
|
|
|
37
|
-
await user.click(button)
|
|
39
|
+
await user.click(button)
|
|
38
40
|
|
|
39
|
-
expect(input).toHaveAttribute(
|
|
40
|
-
expect(button).toHaveTextContent(
|
|
41
|
+
expect(input).toHaveAttribute('type', 'text')
|
|
42
|
+
expect(button).toHaveTextContent('Hide')
|
|
41
43
|
|
|
42
|
-
await user.click(button)
|
|
44
|
+
await user.click(button)
|
|
43
45
|
|
|
44
|
-
expect(input).toHaveAttribute(
|
|
45
|
-
expect(button).toHaveTextContent(
|
|
46
|
-
})
|
|
46
|
+
expect(input).toHaveAttribute('type', 'password')
|
|
47
|
+
expect(button).toHaveTextContent('Show')
|
|
48
|
+
})
|
|
47
49
|
|
|
48
|
-
test(
|
|
49
|
-
const button = getByText(container,
|
|
50
|
+
test('accessibility', async () => {
|
|
51
|
+
const button = getByText(container, 'Show')
|
|
50
52
|
|
|
51
|
-
expect(await axe(document.body)).toHaveNoViolations()
|
|
52
|
-
await user.click(button)
|
|
53
|
-
expect(await axe(document.body)).toHaveNoViolations()
|
|
54
|
-
})
|
|
55
|
-
})
|
|
53
|
+
expect(await axe(document.body)).toHaveNoViolations()
|
|
54
|
+
await user.click(button)
|
|
55
|
+
expect(await axe(document.body)).toHaveNoViolations()
|
|
56
|
+
})
|
|
57
|
+
})
|
|
@@ -11,12 +11,11 @@
|
|
|
11
11
|
font-size: 0; // Hide whitespace between elements
|
|
12
12
|
text-align: justify; // Trick to remove the need for floats
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
content:
|
|
14
|
+
&::after {
|
|
15
|
+
content: "";
|
|
16
16
|
display: inline-block;
|
|
17
17
|
width: 100%;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
.moj-primary-navigation__nav {
|
|
@@ -25,36 +24,34 @@
|
|
|
25
24
|
display: inline-block;
|
|
26
25
|
vertical-align: middle;
|
|
27
26
|
}
|
|
28
|
-
|
|
29
27
|
}
|
|
30
28
|
|
|
31
29
|
.moj-primary-navigation__list {
|
|
32
|
-
font-size: 0; // Removes white space when using inline-block on child element.
|
|
33
|
-
list-style: none;
|
|
34
30
|
margin: 0;
|
|
35
31
|
padding: 0;
|
|
32
|
+
font-size: 0; // Removes white space when using inline-block on child element.
|
|
33
|
+
list-style: none;
|
|
36
34
|
}
|
|
37
35
|
|
|
38
36
|
.moj-primary-navigation__item {
|
|
39
37
|
@include govuk-font($size: 19);
|
|
40
38
|
display: inline-block;
|
|
41
|
-
margin-right: govuk-spacing(4);
|
|
42
39
|
margin-top: 0;
|
|
40
|
+
margin-right: govuk-spacing(4);
|
|
43
41
|
|
|
44
42
|
&:last-child {
|
|
45
43
|
margin-right: 0;
|
|
46
44
|
}
|
|
47
|
-
|
|
48
45
|
}
|
|
49
46
|
|
|
50
47
|
.moj-primary-navigation__link {
|
|
51
48
|
@include govuk-link-common;
|
|
52
49
|
@include govuk-link-style-default;
|
|
53
50
|
display: block;
|
|
54
|
-
padding-bottom: 15px;
|
|
55
51
|
padding-top: 15px;
|
|
56
|
-
|
|
52
|
+
padding-bottom: 15px;
|
|
57
53
|
font-weight: bold;
|
|
54
|
+
text-decoration: none;
|
|
58
55
|
|
|
59
56
|
&:link,
|
|
60
57
|
&:visited {
|
|
@@ -66,63 +63,63 @@
|
|
|
66
63
|
}
|
|
67
64
|
|
|
68
65
|
&:focus {
|
|
69
|
-
color: govuk-colour("black"); // Focus colour on yellow should really be black.
|
|
70
66
|
position: relative; // Ensure focus sits above everything else.
|
|
71
67
|
z-index: 1;
|
|
68
|
+
color: govuk-colour("black"); // Focus colour on yellow should really be black.
|
|
72
69
|
box-shadow: none;
|
|
73
70
|
}
|
|
74
71
|
|
|
75
|
-
&:focus
|
|
76
|
-
background-color: govuk-colour("black");
|
|
72
|
+
&:focus::before {
|
|
77
73
|
content: "";
|
|
78
74
|
display: block;
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
position: absolute;
|
|
76
|
+
bottom: 0;
|
|
77
|
+
left: 0;
|
|
81
78
|
width: 100%;
|
|
79
|
+
height: 5px;
|
|
80
|
+
background-color: govuk-colour("black");
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
&[aria-current] {
|
|
85
|
-
color: $govuk-link-colour;
|
|
86
84
|
position: relative;
|
|
87
|
-
|
|
85
|
+
color: $govuk-link-colour;
|
|
88
86
|
font-weight: bold;
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
text-decoration: none;
|
|
88
|
+
|
|
89
|
+
&::before {
|
|
91
90
|
content: "";
|
|
92
91
|
display: block;
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
position: absolute;
|
|
93
|
+
bottom: 0;
|
|
94
|
+
left: 0;
|
|
95
95
|
width: 100%;
|
|
96
|
+
height: 5px;
|
|
97
|
+
background-color: $govuk-link-colour;
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
&:hover {
|
|
99
101
|
color: $govuk-link-hover-colour;
|
|
100
102
|
|
|
101
|
-
|
|
103
|
+
&::before {
|
|
102
104
|
background-color: $govuk-link-hover-colour;
|
|
103
105
|
}
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
&:focus {
|
|
107
|
-
color: govuk-colour("black"); // Focus colour on yellow should really be black.
|
|
108
109
|
position: relative; // Ensure focus sits above everything else.
|
|
109
110
|
border: none;
|
|
111
|
+
color: govuk-colour("black"); // Focus colour on yellow should really be black.
|
|
110
112
|
|
|
111
|
-
|
|
113
|
+
&::before {
|
|
112
114
|
background-color: govuk-colour("black");
|
|
113
115
|
}
|
|
114
|
-
|
|
115
116
|
}
|
|
116
|
-
|
|
117
117
|
}
|
|
118
|
-
|
|
119
118
|
}
|
|
120
119
|
|
|
121
120
|
.moj-primary-navigation__search {
|
|
122
|
-
|
|
123
121
|
@include govuk-media-query($from: desktop) {
|
|
124
122
|
display: inline-block;
|
|
125
123
|
vertical-align: middle;
|
|
126
124
|
}
|
|
127
|
-
|
|
128
125
|
}
|