diff --git a/README.md b/README.md index 7062cd8..4a2e8b4 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This includes a selection form macros from [GOV.UK elements](http://govuk-elemen This is a mirror of [govuk-elelemt-marko](https://github.com/gunjam/govuk-elements-marko) in nunjucks. -This currently is to work with old style radio buttons and checkboxes. (GOV.UK elements v2.1.2 or GOV.UK Frontend Toolkit pre 4.17.0) +Old style radio and checkboxes can be found under **retired** these can be used with GOV.UK elements v2.1.2 or GOV.UK Frontend Toolkit pre 4.17.0. ## Tests @@ -29,7 +29,6 @@ Current components: Things to add/improve - common approach to data-attributes -- update radios to be new style ## Examples @@ -63,6 +62,10 @@ This will need to be exposed in the nunjuck render and can be called like this: - [gov-select](./components/gov-select/README.md) - [gov-textarea](./components/gov-textarea/README.md) +## UI Graveyard + +- [gov-checkboxes](./components/retired/gov-checkboxes/README.md) +- [gov-radios](./components/retired/gov-radios/README.md) ## Contributing diff --git a/components/gov-checkboxes/__tests__/__snapshots__/gov-checkboxes.spec.js.snap b/components/gov-checkboxes/__tests__/__snapshots__/gov-checkboxes.spec.js.snap index 5bf1395..adc8eab 100644 --- a/components/gov-checkboxes/__tests__/__snapshots__/gov-checkboxes.spec.js.snap +++ b/components/gov-checkboxes/__tests__/__snapshots__/gov-checkboxes.spec.js.snap @@ -6,8 +6,10 @@ exports[`gov-checkBoxes checkbox options should add data fields when supplied 1` Select a check box - +
+ + +
`; @@ -18,10 +20,14 @@ exports[`gov-checkBoxes class options should add classes to legend span 1`] = ` Select a check box - - +
+ + +
+
+ + +
`; @@ -33,10 +39,14 @@ exports[`gov-checkBoxes should add a form hint using the hint attribute 1`] = ` Select a checkbox select as many or as few as you like - - +
+ + +
+
+ + +
`; @@ -48,10 +58,14 @@ exports[`gov-checkBoxes should add error message and classes when passed an erro Select a checkbox Select an checkbox - - +
+ + +
+
+ + +
`; @@ -62,10 +76,16 @@ exports[`gov-checkBoxes should set the ID as input-{name} if ID attr not supplie Select a checkbox - - +
+ + +
+
+ + +
`; @@ -76,10 +96,15 @@ exports[`gov-checkBoxes should set the check box to selected if value is set 1`] Select a checkbox - - +
+ + +
+
+ + +
`; @@ -90,10 +115,14 @@ exports[`gov-checkBoxes should use ID attribute value over generated input-{name Select a checkbox - - +
+ + +
+
+ + +
`; diff --git a/components/gov-checkboxes/__tests__/gov-checkboxes.spec.js b/components/gov-checkboxes/__tests__/gov-checkboxes.spec.js index 22ac42b..1994e07 100644 --- a/components/gov-checkboxes/__tests__/gov-checkboxes.spec.js +++ b/components/gov-checkboxes/__tests__/gov-checkboxes.spec.js @@ -113,16 +113,18 @@ describe('gov-checkBoxes', () => { }); const $ = cheerio.load(output); + + const firstDivContainer = $('div.multiple-choice'); + expect(firstDivContainer.get(0).attribs['data-target']).toBe('data-target'); + expect(firstDivContainer.get(0).attribs['data-journey-click']).toBe('data-target-click'); + const firstLabel = $('label'); const oneCheck = expect.stringContaining('One'); expect(firstLabel.text()).toEqual(oneCheck); - expect(firstLabel.get(0).attribs['data-target']).toBe('data-target'); - const firstRadio = $('input').get(0).attribs; expect(firstRadio.id).toBe('my-id-one'); expect(firstRadio.name).toBe('selection'); expect(firstRadio.value).toBe('one'); - expect(firstRadio['data-journey-click']).toBe('data-target-click'); expect(output).toMatchSnapshot(); }); }); diff --git a/components/gov-checkboxes/template.njk b/components/gov-checkboxes/template.njk index 1a1a60b..0e773eb 100644 --- a/components/gov-checkboxes/template.njk +++ b/components/gov-checkboxes/template.njk @@ -11,12 +11,10 @@ {% for checkBox in checkBoxes %} - +
+ + +
{% endfor %} diff --git a/components/gov-radios/__tests__/__snapshots__/gov-radios.spec.js.snap b/components/gov-radios/__tests__/__snapshots__/gov-radios.spec.js.snap index 92577c7..099dedd 100644 --- a/components/gov-radios/__tests__/__snapshots__/gov-radios.spec.js.snap +++ b/components/gov-radios/__tests__/__snapshots__/gov-radios.spec.js.snap @@ -6,10 +6,14 @@ exports[`gov-radios class options should add classes to legend span 1`] = ` Select a radio button - - +
+ + +
+
+ + +
`; @@ -20,10 +24,14 @@ exports[`gov-radios class options should add inline class to form to fieldset wh Select a radio button - - +
+ + +
+
+ + +
`; @@ -34,12 +42,18 @@ exports[`gov-radios class options should have no classes on fieldset when two or Select a radio button - - - +
+ + +
+
+ + +
+
+ + +
`; @@ -50,8 +64,10 @@ exports[`gov-radios radio button options should add data fields when supplied 1` Select a radio button - +
+ + +
`; @@ -63,10 +79,14 @@ exports[`gov-radios should add a form hint using the hint attribute 1`] = ` Select a radio button Select one of the below - - +
+ + +
+
+ + +
`; @@ -78,10 +98,14 @@ exports[`gov-radios should add error message and classes when passed an error ob Select a radio button Select an option - - +
+ + +
+
+ + +
`; @@ -92,10 +116,16 @@ exports[`gov-radios should set the ID as input-{name} if ID attr not supplied an Select a radio button - - +
+ + +
+
+ + +
`; @@ -106,10 +136,15 @@ exports[`gov-radios should set the radio button to checked if the value matches Select a radio button - - +
+ + +
+
+ + +
`; @@ -120,10 +155,14 @@ exports[`gov-radios should use ID attribute value over generated input-{name} ID Select a radio button - - +
+ + +
+
+ + +
`; diff --git a/components/gov-radios/__tests__/gov-radios.spec.js b/components/gov-radios/__tests__/gov-radios.spec.js index ade6592..af86ce7 100644 --- a/components/gov-radios/__tests__/gov-radios.spec.js +++ b/components/gov-radios/__tests__/gov-radios.spec.js @@ -115,18 +115,19 @@ describe('gov-radios', () => { id: 'my-id', name: 'selection' }); - const $ = cheerio.load(output); + + const firstDivContainer = $('div.multiple-choice'); + expect(firstDivContainer.get(0).attribs['data-target']).toBe('data-target'); + expect(firstDivContainer.get(0).attribs['data-journey-click']).toBe('data-target-click'); + const firstLabel = $('label'); const labelCheck = expect.stringContaining('label-id'); expect(firstLabel.text()).toEqual(labelCheck); - expect(firstLabel.get(0).attribs['data-target']).toBe('data-target'); - const firstRadio = $('input').get(0).attribs; expect(firstRadio.id).toBe('my-id-id'); expect(firstRadio.name).toBe('selection'); expect(firstRadio.value).toBe('value-id'); - expect(firstRadio['data-journey-click']).toBe('data-target-click'); expect(output).toMatchSnapshot(); }); }); diff --git a/components/gov-radios/template.njk b/components/gov-radios/template.njk index 62ab416..f583c06 100644 --- a/components/gov-radios/template.njk +++ b/components/gov-radios/template.njk @@ -11,12 +11,10 @@ {% for radio in radioButtons %} - +
+ + +
{% endfor %} diff --git a/components/retired/gov-checkboxes/README.md b/components/retired/gov-checkboxes/README.md new file mode 100644 index 0000000..97f6406 --- /dev/null +++ b/components/retired/gov-checkboxes/README.md @@ -0,0 +1,104 @@ +# GOV-CHECKBOXES Documentation + +This macro generates a selection of `` with `