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

Set panel component's title heading level to 1 as default #967

Merged
merged 2 commits into from
Aug 31, 2018
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
11 changes: 7 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@

💥 Breaking changes:

- Pull Request Title goes here
- Set panel component's title heading level to 1 as default

Description goes here (optional)
We think the panel title should be the h1 in the majority of cases,
so we made it the default.

To migrate you need to change: X
If you have need to change the Panel component heading to something
other than h1, you can do so by specifying `headingLevel: <number>`
in the Nunjucks macro.

([PR #N](https://github.com/alphagov/govuk-frontend/pull/N))
([PR #967](https://github.com/alphagov/govuk-frontend/pull/967))

🆕 New features:

Expand Down
10 changes: 5 additions & 5 deletions src/components/panel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Find out when to use the panel component in your service in the [GOV.UK Design S
#### Markup

<div class="govuk-panel govuk-panel--confirmation">
<h2 class="govuk-panel__title">
<h1 class="govuk-panel__title">
Application complete
</h2>
</h1>

<div class="govuk-panel__body">
Your reference number: HDJ2123F
Expand All @@ -43,9 +43,9 @@ Find out when to use the panel component in your service in the [GOV.UK Design S
#### Markup

<div class="govuk-panel govuk-panel--confirmation">
<h1 class="govuk-panel__title">
<h2 class="govuk-panel__title">
Application complete
</h1>
</h2>

<div class="govuk-panel__body">
Your reference number: HDJ2123F
Expand All @@ -59,7 +59,7 @@ Find out when to use the panel component in your service in the [GOV.UK Design S

{{ govukPanel({
"titleText": "Application complete",
"headingLevel": 1,
"headingLevel": 2,
"text": "Your reference number: HDJ2123F"
}) }}

Expand Down
2 changes: 1 addition & 1 deletion src/components/panel/panel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ examples:
- name: custom heading level
data:
titleText: Application complete
headingLevel: 1
headingLevel: 2
text: 'Your reference number: HDJ2123F'
3 changes: 1 addition & 2 deletions src/components/panel/template.njk
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{#- TODO: Change default title heading level to 1 - https://github.com/alphagov/govuk-frontend/issues/864 -#}
{% set headingLevel = params.headingLevel if params.headingLevel else 2 %}
{% set headingLevel = params.headingLevel if params.headingLevel else 1 %}
<div class="govuk-panel govuk-panel--confirmation
{%- if params.classes %} {{ params.classes }}{% endif %}"
{%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %}>
Expand Down
4 changes: 2 additions & 2 deletions src/components/panel/template.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ describe('Panel', () => {
expect(panelTitle).toEqual('Application &lt;strong&gt;not&lt;/strong&gt; complete')
})

it('renders title as h2 (as the default heading level)', () => {
it('renders title as h1 (as the default heading level)', () => {
const $ = render('panel', examples.default)
const panelTitleHeadingLevel = $('.govuk-panel__title')[0].name

expect(panelTitleHeadingLevel).toEqual('h2')
expect(panelTitleHeadingLevel).toEqual('h1')
})

it('renders title as specified heading level', () => {
Expand Down