Skip to content

Commit

Permalink
Merge pull request #3312 from alphagov/default-warning-text-icon-fall…
Browse files Browse the repository at this point in the history
…back

Add default value for warning text icon fallback attribute
  • Loading branch information
owenatgov authored Feb 21, 2023
2 parents 7a3df8e + e29aa85 commit 1920d9a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ We’ve made fixes to GOV.UK Frontend in the following pull requests:

- [#3272: Add empty alt attribute to logo IE8 fallback PNG](https://github.com/alphagov/govuk-frontend/pull/3272)
- [#3306: Re-enable complete hover link styles on the footer](https://github.com/alphagov/govuk-frontend/pull/3306)
- [#3312: Add default value for warning text icon fallback attribute](https://github.com/alphagov/govuk-frontend/pull/3312)

## 4.5.0 (Feature release)

Expand Down
2 changes: 1 addition & 1 deletion src/govuk/components/warning-text/template.njk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
>
<span class="govuk-warning-text__icon" aria-hidden="true">!</span>
<strong class="govuk-warning-text__text">
<span class="govuk-warning-text__assistive">{{ params.iconFallbackText }}</span>
<span class="govuk-warning-text__assistive">{{ params.iconFallbackText | default("Warning") }}</span>
{{ params.html | safe if params.html else params.text }}
</strong>
</div>
2 changes: 1 addition & 1 deletion src/govuk/components/warning-text/template.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('Warning text', () => {
expect($component.text()).toContain('You can be fined up to £5,000 if you don’t register.')
})

it('renders with assistive text', () => {
it('renders with default assistive text', () => {
const $ = render('warning-text', examples.default)

const $assistiveText = $('.govuk-warning-text__assistive')
Expand Down
12 changes: 6 additions & 6 deletions src/govuk/components/warning-text/warning-text.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ params:
description: If `text` is set, this is not required. HTML to use within the warning text component. If `html` is provided, the `text` option will be ignored.
- name: iconFallbackText
type: string
required: true
description: The fallback text for the icon.
required: false
description: The fallback text for the icon. Defaults to 'Warning'
- name: classes
type: string
required: false
Expand All @@ -35,28 +35,28 @@ examples:
hidden: true
data:
text: You can be fined up to £5,000 if you don’t register.
iconFallbackText: Warning
attributes:
id: my-warning-text
data-test: attribute
- name: classes
hidden: true
data:
text: Warning text
iconFallbackText: Warning
classes: govuk-warning-text--custom-class
- name: html
hidden: true
data:
text: You can be fined up to £5,000 if you don’t register.
iconFallbackText: Warning
html: <span>Some custom warning text</span>
- name: html as text
hidden: true
data:
iconFallbackText: Warning
text: <span>Some custom warning text</span>
- name: icon fallback text only
hidden: true
data:
iconFallbackText: Some custom fallback text
- name: no icon fallback text
hidden: true
data:
text: This is a warning

0 comments on commit 1920d9a

Please sign in to comment.