@moduk/frontend 0.2.0-alpha.1 → 0.2.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/dist/lib/nunjucks/moduk/components/error-summary/__examples__/default.njk +16 -0
- package/dist/lib/nunjucks/moduk/components/error-summary/__examples__/with-error-linked-to-checkbox.njk +54 -0
- package/dist/lib/nunjucks/moduk/components/error-summary/__examples__/with-error-linked-to-date-part.njk +45 -0
- package/dist/lib/nunjucks/moduk/components/error-summary/__tests__/macro.test.ts +55 -0
- package/dist/lib/nunjucks/moduk/components/error-summary/macro.njk +11 -0
- package/dist/lib/nunjucks/moduk/components/summary-list/__examples__/default.njk +74 -0
- package/dist/lib/nunjucks/moduk/components/summary-list/__examples__/with-no-actions.njk +38 -0
- package/dist/lib/nunjucks/moduk/components/summary-list/__examples__/with-no-border.njk +39 -0
- package/dist/lib/nunjucks/moduk/components/summary-list/__tests__/macro.test.ts +9 -0
- package/dist/lib/nunjucks/moduk/components/summary-list/macro.njk +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{% from "moduk/components/error-summary/macro.njk" import modukErrorSummary %}
|
|
2
|
+
|
|
3
|
+
{{ modukErrorSummary({
|
|
4
|
+
titleText: "There is a problem",
|
|
5
|
+
descriptionText: "There have been some errors when trying to submit your application.",
|
|
6
|
+
errorList: [
|
|
7
|
+
{
|
|
8
|
+
text: "The start date of the contract must include a year",
|
|
9
|
+
href: "#incorect-date-format"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
text: "Enter your full name",
|
|
13
|
+
href: "#full-name-input"
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}) }}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{% from "moduk/components/error-summary/macro.njk" import modukErrorSummary %}
|
|
2
|
+
{% from "moduk/components/checkboxes/macro.njk" import modukCheckboxes %}
|
|
3
|
+
|
|
4
|
+
<div>
|
|
5
|
+
{{ modukErrorSummary({
|
|
6
|
+
titleText: "There is a problem",
|
|
7
|
+
errorList: [
|
|
8
|
+
{
|
|
9
|
+
text: "Select which technologies you use in your role",
|
|
10
|
+
href: "#technologies"
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
}) }}
|
|
14
|
+
|
|
15
|
+
{{ modukCheckboxes({
|
|
16
|
+
name: "technologies",
|
|
17
|
+
fieldset: {
|
|
18
|
+
legend: {
|
|
19
|
+
text: "Which technologies do you use in your role?",
|
|
20
|
+
isPageHeading: true,
|
|
21
|
+
classes: "govuk-fieldset__legend--l"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
hint: {
|
|
25
|
+
text: "Select all that apply."
|
|
26
|
+
},
|
|
27
|
+
errorMessage: {
|
|
28
|
+
text: "Select which technologies you use in your role"
|
|
29
|
+
},
|
|
30
|
+
items: [
|
|
31
|
+
{
|
|
32
|
+
value: "angular",
|
|
33
|
+
text: "Angular"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
value: "nunjucks",
|
|
37
|
+
text: "Nunjucks"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
value: "react",
|
|
41
|
+
text: "React"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
value: "web-components",
|
|
45
|
+
text: "Web components"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
value: "another-technology",
|
|
49
|
+
text: "Another technology"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}) }}
|
|
53
|
+
|
|
54
|
+
</div>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{% from "moduk/components/error-summary/macro.njk" import modukErrorSummary %}
|
|
2
|
+
{% from "moduk/components/date-input/macro.njk" import modukDateInput %}
|
|
3
|
+
|
|
4
|
+
<div>
|
|
5
|
+
{{ modukErrorSummary({
|
|
6
|
+
titleText: "There is a problem",
|
|
7
|
+
errorList: [
|
|
8
|
+
{
|
|
9
|
+
text: "The start date of the contract must include a year",
|
|
10
|
+
href: "#incorect-date-format-year"
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
}) }}
|
|
14
|
+
|
|
15
|
+
{{ modukDateInput({
|
|
16
|
+
id: "incorect-date-format",
|
|
17
|
+
namePrefix: "incorect-date-format",
|
|
18
|
+
fieldset: {
|
|
19
|
+
legend: {
|
|
20
|
+
isPageHeading: true,
|
|
21
|
+
text: "When will the contract start?",
|
|
22
|
+
classes: 'govuk-fieldset__legend--l'
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
errorMessage: {
|
|
26
|
+
text: "The start date of the contract must include a year"
|
|
27
|
+
},
|
|
28
|
+
items: [
|
|
29
|
+
{
|
|
30
|
+
classes: "govuk-input--width-2",
|
|
31
|
+
name: "day",
|
|
32
|
+
value: "6"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
classes: "govuk-input--width-2",
|
|
36
|
+
name: "month",
|
|
37
|
+
value: "3"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
classes: "govuk-input--width-4 govuk-input--error",
|
|
41
|
+
name: "year"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}) }}
|
|
45
|
+
</div>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import { render, renderFile } from '../../../../../test-utils'
|
|
4
|
+
|
|
5
|
+
describe('error summary', async () => {
|
|
6
|
+
it('renders the content when using the text property', () => {
|
|
7
|
+
const element = renderFile('moduk/components/error-summary/__examples__/default.njk')
|
|
8
|
+
expect(element).toHaveTextContent('There is a problem')
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it('renders the error description when using the descriptionHtml property', () => {
|
|
12
|
+
const element = render(`
|
|
13
|
+
{% from "moduk/components/error-summary/macro.njk" import modukErrorSummary %}
|
|
14
|
+
|
|
15
|
+
{{ modukErrorSummary({
|
|
16
|
+
titleText: "There is a problem",
|
|
17
|
+
descriptionHtml: "There have been some errors when trying to submit your application.",
|
|
18
|
+
errorList: [
|
|
19
|
+
{
|
|
20
|
+
text: "The start date of the contract must include a year",
|
|
21
|
+
href: "#incorect-date-format"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
text: "Enter your full name",
|
|
25
|
+
href: "#full-name-input"
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}) }}
|
|
29
|
+
`)
|
|
30
|
+
expect(element).toHaveTextContent('There have been some errors when trying to submit your application.')
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('renders the content when using a call block', () => {
|
|
34
|
+
const element = render(`
|
|
35
|
+
{% from "moduk/components/error-summary/macro.njk" import modukErrorSummary %}
|
|
36
|
+
|
|
37
|
+
{% call modukErrorSummary({
|
|
38
|
+
titleText: "There is a problem",
|
|
39
|
+
errorList: [
|
|
40
|
+
{
|
|
41
|
+
text: "The start date of the contract must include a year",
|
|
42
|
+
href: "#incorect-date-format"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
text: "Enter your full name",
|
|
46
|
+
href: "#full-name-input"
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}) %}
|
|
50
|
+
There have been some errors<br> when trying to submit your application.
|
|
51
|
+
{% endcall %}
|
|
52
|
+
`)
|
|
53
|
+
expect(element).toContainHTML('There have been some errors<br> when')
|
|
54
|
+
})
|
|
55
|
+
})
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %}
|
|
2
|
+
|
|
3
|
+
{% macro modukErrorSummary(params) %}
|
|
4
|
+
{% if caller -%}
|
|
5
|
+
{% call govukErrorSummary(params) -%}
|
|
6
|
+
{{ caller() }}
|
|
7
|
+
{%- endcall %}
|
|
8
|
+
{%- else -%}
|
|
9
|
+
{{ govukErrorSummary(params) }}
|
|
10
|
+
{%- endif %}
|
|
11
|
+
{% endmacro %}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{% from "moduk/components/summary-list/macro.njk" import modukSummaryList %}
|
|
2
|
+
|
|
3
|
+
{{ modukSummaryList({
|
|
4
|
+
rows: [
|
|
5
|
+
{
|
|
6
|
+
key: {
|
|
7
|
+
text: "Name"
|
|
8
|
+
},
|
|
9
|
+
value: {
|
|
10
|
+
text: "Sarah Philips"
|
|
11
|
+
},
|
|
12
|
+
actions: {
|
|
13
|
+
items: [
|
|
14
|
+
{
|
|
15
|
+
href: "#",
|
|
16
|
+
text: "Change",
|
|
17
|
+
visuallyHiddenText: "name"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
key: {
|
|
24
|
+
text: "Date of birth"
|
|
25
|
+
},
|
|
26
|
+
value: {
|
|
27
|
+
text: "5 January 1978"
|
|
28
|
+
},
|
|
29
|
+
actions: {
|
|
30
|
+
items: [
|
|
31
|
+
{
|
|
32
|
+
href: "#",
|
|
33
|
+
text: "Change",
|
|
34
|
+
visuallyHiddenText: "date of birth"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
key: {
|
|
41
|
+
text: "Address"
|
|
42
|
+
},
|
|
43
|
+
value: {
|
|
44
|
+
html: "72 Guild Street<br>London<br>SE23 6FH"
|
|
45
|
+
},
|
|
46
|
+
actions: {
|
|
47
|
+
items: [
|
|
48
|
+
{
|
|
49
|
+
href: "#",
|
|
50
|
+
text: "Change",
|
|
51
|
+
visuallyHiddenText: "address"
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
key: {
|
|
58
|
+
text: "Contact details"
|
|
59
|
+
},
|
|
60
|
+
value: {
|
|
61
|
+
html: '<p class="govuk-body">07700 900457</p><p class="govuk-body">sarah.phillips@example.com</p>'
|
|
62
|
+
},
|
|
63
|
+
actions: {
|
|
64
|
+
items: [
|
|
65
|
+
{
|
|
66
|
+
href: "#",
|
|
67
|
+
text: "Change",
|
|
68
|
+
visuallyHiddenText: "contact details"
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
}) }}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{% from "moduk/components/summary-list/macro.njk" import modukSummaryList %}
|
|
2
|
+
|
|
3
|
+
{{ modukSummaryList({
|
|
4
|
+
rows: [
|
|
5
|
+
{
|
|
6
|
+
key: {
|
|
7
|
+
text: "Name"
|
|
8
|
+
},
|
|
9
|
+
value: {
|
|
10
|
+
text: "Sarah Philips"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
key: {
|
|
15
|
+
text: "Date of birth"
|
|
16
|
+
},
|
|
17
|
+
value: {
|
|
18
|
+
text: "5 January 1978"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
key: {
|
|
23
|
+
text: "Address"
|
|
24
|
+
},
|
|
25
|
+
value: {
|
|
26
|
+
html: "72 Guild Street<br>London<br>SE23 6FH"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
key: {
|
|
31
|
+
text: "Contact details"
|
|
32
|
+
},
|
|
33
|
+
value: {
|
|
34
|
+
html: '<p class="govuk-body">07700 900457</p><p class="govuk-body">sarah.phillips@example.com</p>'
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}) }}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{% from "moduk/components/summary-list/macro.njk" import modukSummaryList %}
|
|
2
|
+
|
|
3
|
+
{{ modukSummaryList({
|
|
4
|
+
classes: 'govuk-summary-list--no-border',
|
|
5
|
+
rows: [
|
|
6
|
+
{
|
|
7
|
+
key: {
|
|
8
|
+
text: "Name"
|
|
9
|
+
},
|
|
10
|
+
value: {
|
|
11
|
+
text: "Sarah Philips"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
key: {
|
|
16
|
+
text: "Date of birth"
|
|
17
|
+
},
|
|
18
|
+
value: {
|
|
19
|
+
text: "5 January 1978"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
key: {
|
|
24
|
+
text: "Address"
|
|
25
|
+
},
|
|
26
|
+
value: {
|
|
27
|
+
html: "72 Guild Street<br>London<br>SE23 6FH"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
key: {
|
|
32
|
+
text: "Contact details"
|
|
33
|
+
},
|
|
34
|
+
value: {
|
|
35
|
+
html: '<p class="govuk-body">07700 900457</p><p class="govuk-body">sarah.phillips@example.com</p>'
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}) }}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import { renderFile } from '../../../../../test-utils'
|
|
4
|
+
|
|
5
|
+
describe('Summary list', async () => {
|
|
6
|
+
it('renders the content', () => {
|
|
7
|
+
expect(() => renderFile('moduk/components/summary-list/__examples__/default.njk')).not.toThrowError()
|
|
8
|
+
})
|
|
9
|
+
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moduk/frontend",
|
|
3
|
-
"version": "0.2.0
|
|
3
|
+
"version": "0.2.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",
|