-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4442 from alphagov/show-hide-password-component
Create password input component
- Loading branch information
Showing
26 changed files
with
1,529 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/govuk-frontend-review/src/views/full-page-examples/sign-in/confirm.njk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{% extends "layouts/full-page-example.njk" %} | ||
|
||
{% from "govuk/components/panel/macro.njk" import govukPanel %} | ||
|
||
{% set pageTitle = "Logged in successfully" %} | ||
{% block pageTitle %}{{ pageTitle }} - GOV.UK{% endblock %} | ||
|
||
{% block content %} | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
{{ govukPanel({ | ||
titleText: pageTitle | ||
}) }} | ||
</div> | ||
</div> | ||
{% endblock %} |
39 changes: 39 additions & 0 deletions
39
packages/govuk-frontend-review/src/views/full-page-examples/sign-in/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import express from 'express' | ||
import { body, matchedData, validationResult } from 'express-validator' | ||
|
||
import { formatValidationErrors } from '../../../utils.mjs' | ||
|
||
const router = express.Router() | ||
|
||
router.post( | ||
'/sign-in', | ||
|
||
body('email') | ||
.notEmpty() | ||
.withMessage('Enter your email address') | ||
.isEmail() | ||
.withMessage( | ||
'Enter an email address in the correct format, like name@example.com' | ||
), | ||
|
||
body('password').notEmpty().withMessage('Enter your password'), | ||
|
||
(req, res) => { | ||
const { example } = res.locals | ||
|
||
const viewPath = `./full-page-examples/${example.path}` | ||
const errors = formatValidationErrors(validationResult(req)) | ||
|
||
if (!errors) { | ||
return res.redirect(303, `./${example.path}/confirm`) | ||
} | ||
|
||
res.render(`${viewPath}/index`, { | ||
errors, | ||
errorSummary: Object.values(errors), | ||
values: matchedData(req, { onlyValidData: false }) // In production this should sanitized. | ||
}) | ||
} | ||
) | ||
|
||
export default router |
90 changes: 90 additions & 0 deletions
90
packages/govuk-frontend-review/src/views/full-page-examples/sign-in/index.njk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
--- | ||
title: Sign in to a service | ||
name: Sign in to a service | ||
scenario: | | ||
As part of an online service, you have to sign in before accessing it. | ||
|
||
Things to try: | ||
|
||
1. Intentionally avoid answering the questions before continuing to the next page. | ||
--- | ||
|
||
{% extends "layouts/full-page-example.njk" %} | ||
|
||
{% from "govuk/components/back-link/macro.njk" import govukBackLink %} | ||
{% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %} | ||
{% from "govuk/components/input/macro.njk" import govukInput %} | ||
{% from "govuk/components/password-input/macro.njk" import govukPasswordInput %} | ||
{% from "govuk/components/checkboxes/macro.njk" import govukCheckboxes %} | ||
{% from "govuk/components/button/macro.njk" import govukButton %} | ||
|
||
{% set pageTitle = example.title %} | ||
{% block pageTitle %}{{ "Error: " if errorSummary | length }}{{ pageTitle }} - GOV.UK{% endblock %} | ||
|
||
{% block beforeContent %} | ||
{{ govukBackLink({ | ||
text: "Back" | ||
}) }} | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
{% if errorSummary | length %} | ||
{{ govukErrorSummary({ | ||
titleText: "There is a problem", | ||
errorList: errorSummary | ||
}) }} | ||
{% endif %} | ||
|
||
<h1 class="govuk-heading-xl">{{ pageTitle }}</h1> | ||
|
||
<p class="govuk-body">You'll first need to <a class="govuk-link" href="#">create an account</a> if you haven't already. You can also <a class="govuk-link" href="#">reset your password</a> if you can't remember it.</p> | ||
|
||
<form method="post" novalidate> | ||
|
||
{{ govukInput({ | ||
label: { | ||
text: "Email address", | ||
classes: "govuk-label--m" | ||
}, | ||
type: "email", | ||
id: "email", | ||
name: "email", | ||
value: values["email"], | ||
errorMessage: errors["email"], | ||
autocomplete: "email", | ||
spellcheck: false | ||
}) }} | ||
|
||
{{ govukPasswordInput({ | ||
label: { | ||
text: "Password", | ||
classes: "govuk-label--m" | ||
}, | ||
id: "password", | ||
name: "password", | ||
value: values["password"], | ||
errorMessage: errors["password"], | ||
autocomplete: "current-password" | ||
}) }} | ||
|
||
{{ govukCheckboxes({ | ||
name: "remember-me", | ||
classes: "govuk-checkboxes--small", | ||
items: [ | ||
{ | ||
value: "true", | ||
text: "Keep me signed in on this device" | ||
} | ||
] | ||
}) }} | ||
|
||
{{ govukButton({ | ||
text: "Sign in" | ||
}) }} | ||
|
||
</form> | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.