Skip to content

Commit

Permalink
Add html parameter to Exit this Page button
Browse files Browse the repository at this point in the history
  • Loading branch information
querkmachine committed Jun 30, 2023
1 parent 6b14436 commit 10dd4c0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
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

0 comments on commit 10dd4c0

Please sign in to comment.