Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add html parameter to Exit this Page button #3878

Merged
merged 1 commit into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/govuk/components/exit-this-page/exit-this-page.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ params:
- name: text
type: string
required: false
description: Text for the link. Defaults to `Exit this page`.
description: Text for the link. If `html` is provided, the `text` option will be ignored. Defaults to 'Exit this page'.
- name: html
type: string
required: false
description: HTML for the link. If `html` is provided, the `text` option will be ignored.
- name: redirectUrl
type: string
required: false
Expand Down Expand Up @@ -62,3 +66,7 @@ examples:
classes: 'test-class'
attributes:
test-attribute: true
- name: testing-html
hidden: true
data:
html: 'Exit <em>this</em> test'
1 change: 1 addition & 0 deletions src/govuk/components/exit-this-page/template.njk
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
{%- if params.pressOneMoreTimeText %} data-i18n.press-one-more-time="{{ params.pressOneMoreTimeText | escape }}"{% endif %}
>
{{- govukButton({
html: params.html,
text: params.text | default("Exit this page"),
classes: "govuk-button--warning govuk-exit-this-page__button govuk-js-exit-this-page-button",
href: params.redirectUrl | default("https://www.bbc.co.uk/weather")
Expand Down
7 changes: 7 additions & 0 deletions src/govuk/components/exit-this-page/template.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ describe('Exit this page', () => {
expect($button.text()).toContain('Exit this test')
})

it('renders with custom HTML', () => {
const $ = render('exit-this-page', examples['testing-html'])
const $button = $('.govuk-exit-this-page').find('.govuk-button')

expect($button.html()).toContain('Exit <em>this</em> test')
})

it('renders with a custom URL', () => {
const $ = render('exit-this-page', examples.testing)
const $button = $('.govuk-exit-this-page').find('.govuk-button')
Expand Down