Skip to content

Commit

Permalink
Remove is_page_heading param from radio component
Browse files Browse the repository at this point in the history
Recently, the ability to pass a custom heading level to the radio
component was introduced.
Since a custom heading level is now an option, the is_page_heading
parameter became redundant. This parameter simply dictates that the
radio component legend heading should be a h1 of size xl by default.
It is possible to achieve the same result using heading_level and/or
heading_size instead.

This removes all mentions of is_page_heading from the radio component.
Whenever we need this component to have a h1 in the future we can simply
use the heading_level option (in combination with heading_size, if
necessary)
  • Loading branch information
danacotoran committed Jul 28, 2021
1 parent bce33ec commit 8694e7e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 23 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
## Unreleased

* BREAKING: Remove ability to link contextual text on titles ([PR #2192](https://github.com/alphagov/govuk_publishing_components/pull/2192))

* Delete empty print stylesheets ([PR #2225](https://github.com/alphagov/govuk_publishing_components/pull/2225))
* BREAKING: Remove is_page_heading parameter from radio component ([PR #2061](https://github.com/alphagov/govuk_publishing_components/pull/2061))


## 24.21.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
heading_size ||= nil
small ||= false
inline ||= false
is_page_heading ||= false
heading_level = is_page_heading ? 'h1' : shared_helper.get_heading_level
heading_level = shared_helper.get_heading_level
heading_classes = %w(govuk-fieldset__heading)
heading_classes << "gem-c-radio__heading-text" if heading_level == 'h1'

if ['s', 'm', 'l', 'xl'].include?(heading_size)
size = heading_size
elsif is_page_heading
elsif heading_level == 'h1'
size = 'xl'
else
size = 'm'
Expand Down
19 changes: 4 additions & 15 deletions app/views/govuk_publishing_components/components/docs/radio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,6 @@ examples:
text: "Green"
- value: "blue"
text: "Blue"
with_page_heading:
description: This adds a H1 element containing the text supplied.
data:
name: "radio-group-heading"
heading: "Is it raining?"
is_page_heading: true
items:
- value: "yes"
text: "Yes"
- value: "no"
text: "No"
with_page_header_and_caption:
description: |
If a caption text is provided with a page heading, it will be displayed above the heading.
Expand All @@ -127,7 +116,7 @@ examples:
name: "radio-group-heading"
heading: "Is it snowing?"
heading_caption: "Question 3 of 9"
is_page_heading: true
heading_level: 1
items:
- value: "yes"
text: "Yes"
Expand All @@ -137,7 +126,7 @@ examples:
data:
name: "radio-group-heading"
heading: "Is it snowing?"
is_page_heading: true
heading_level: 1
hint: "Sleet or hail doesn’t count."
items:
- value: "yes"
Expand Down Expand Up @@ -179,7 +168,7 @@ examples:
data:
name: "radio-group-description"
heading: "What is your favourite colour?"
is_page_heading: true
heading_level: 1
description: |
Skittles consist of hard sugar shells imprinted with the letter "S".
The interior consists mainly of sugar, corn syrup, and hydrogenated
Expand All @@ -196,7 +185,7 @@ examples:
description: |
This allows the size of the legend to be changed. Valid options are s, m, l, xl, defaulting to m if no option is passed.
If the is_page_heading option is true and heading_size is not set, the text size will be xl.
If heading_level is 1 and heading_size is not set, the text size will be xl.
data:
name: "radio-group-description"
heading: "What is your favourite colour?"
Expand Down
8 changes: 4 additions & 4 deletions spec/components/radio_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def component_name
render_component(
name: "favourite-skittle",
heading: "What is your favourite skittle?",
is_page_heading: true,
heading_level: 1,
items: [
{ label: "Red", value: "red" },
{ label: "Blue", value: "blue" },
Expand All @@ -153,7 +153,7 @@ def component_name
name: "favourite-skittle",
heading: "What is your favourite skittle?",
heading_caption: "Question 3 of 9",
is_page_heading: true,
heading_level: 1,
items: [
{ label: "Red", value: "red" },
{ label: "Blue", value: "blue" },
Expand Down Expand Up @@ -184,7 +184,7 @@ def component_name
heading: "What is your favourite skittle?",
heading_caption: "Question 3 of 9",
heading_size: "l",
is_page_heading: true,
heading_level: 1,
items: [
{ label: "Red", value: "red" },
{ label: "Blue", value: "blue" },
Expand All @@ -200,7 +200,7 @@ def component_name
name: "favourite-skittle",
heading: "What is your favourite skittle?",
heading_caption: "Question 3 of 9",
is_page_heading: true,
heading_level: 1,
items: [
{ label: "Red", value: "red" },
{ label: "Blue", value: "blue" },
Expand Down

0 comments on commit 8694e7e

Please sign in to comment.