Skip to content

Commit

Permalink
Merge pull request #583 from alphagov/add-error-summary-examples
Browse files Browse the repository at this point in the history
Add error summary examples, add margin to error summary
  • Loading branch information
36degrees authored Mar 8, 2018
2 parents 0bca6b9 + 2652c8e commit 0fea0ec
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Note: We're not following semantic versioning yet, we are going to talk about th

## Unreleased

Breaking changes:

- The error summary component now has a default bottom margin
(PR [#583](https://github.com/alphagov/govuk-frontend/pull/583))

Internal:

- Update pre-release step to check for new components
Expand Down
79 changes: 79 additions & 0 deletions app/views/examples/error-summary-with-messages/index.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{% from "back-link/macro.njk" import govukBackLink %}
{% from "button/macro.njk" import govukButton %}
{% from "date-input/macro.njk" import govukDateInput %}
{% from "error-summary/macro.njk" import govukErrorSummary %}
{% from "input/macro.njk" import govukInput %}

{% extends "layout.njk" %}

{% block content %}

{{ govukBackLink({
"href": "/",
"text": "Back"
}) }}

<main class="govuk-o-main-wrapper">

<form action="/" method="post">

{{ govukErrorSummary({
"titleText": "Message to alert the user to a problem goes here",
"descriptionText": "Optional description of the errors and how to correct them",
"classes": "optional-extra-class",
"errorList": [
{
"text": "Descriptive link to the question with an error",
"href": "#example-error-1"
},
{
"text": "Descriptive link to the question with an error",
"href": "#example-error-1"
}
]
}) }}

<h1 class="govuk-heading-xl">Passport details</h1>

{{ govukInput({
label: {
"html": '<h3 class="govuk-heading-m govuk-!-mb-r1">Passport number</h3>',
"hintText": "For example, 502135326"
},
id: "passport-number",
name: "passport-number",
errorMessage: {
"text": "You must provide your passport number"
}
}) }}

{{ govukDateInput({
fieldset: {
legendHtml: '<h3 class="govuk-heading-m">Expiry date</h3>',
legendHintText: 'For example, 08 2014'
},
id: 'expiry',
name: 'expiry',
items:[
{
name: 'month'
},
{
name: 'year'
}
],
errorMessage: {
"text": "You must provide your expiry date"
}
})
}}

{{ govukButton({
"text": "Continue"
}) }}

</form>

</main>

{% endblock %}
67 changes: 67 additions & 0 deletions app/views/examples/error-summary-with-one-thing-per-page/index.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{% from "back-link/macro.njk" import govukBackLink %}
{% from "button/macro.njk" import govukButton %}
{% from "date-input/macro.njk" import govukDateInput %}
{% from "error-summary/macro.njk" import govukErrorSummary %}

{% extends "layout.njk" %}

{% block content %}

{{ govukBackLink({
"href": "/",
"text": "Back"
}) }}

<main class="govuk-o-main-wrapper">

<form action="/" method="post">

{{ govukErrorSummary({
"titleText": "Message to alert the user to a problem goes here",
"descriptionText": "Optional description of the errors and how to correct them",
"classes": "optional-extra-class",
"errorList": [
{
"text": "Descriptive link to the question with an error",
"href": "#example-error-1"
},
{
"text": "Descriptive link to the question with an error",
"href": "#example-error-1"
}
]
}) }}

{{ govukDateInput({
fieldset: {
legendHtml: '<h1 class="govuk-heading-xl">What is your date of birth?</h1>',
legendHintText: 'For example, 31 3 1980'
},
id: 'dob',
name: 'dob',
items:[
{
name: 'day'
},
{
name: 'month'
},
{
name: 'year'
}
],
errorMessage: {
text: "You must provide your date of birth"
}
})
}}

{{ govukButton({
"text": "Continue"
}) }}

</form>

</main>

{% endblock %}
1 change: 1 addition & 0 deletions src/error-summary/_error-summary.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
.govuk-c-error-summary {
@include govuk-text-colour;
@include govuk-responsive-padding($govuk-spacing-responsive-4);
@include govuk-responsive-margin($govuk-spacing-responsive-8, "bottom");
@include govuk-focusable;

border: $govuk-border-width-mobile solid $govuk-error-colour;
Expand Down

0 comments on commit 0fea0ec

Please sign in to comment.