Skip to content
This repository has been archived by the owner on Aug 13, 2023. It is now read-only.

adds prop to override h2 element #3585

Merged
merged 10 commits into from
Jul 10, 2020
Merged

adds prop to override h2 element #3585

merged 10 commits into from
Jul 10, 2020

Conversation

rhenshaw56
Copy link
Contributor

@rhenshaw56 rhenshaw56 commented Jul 7, 2020

Resolves #3574

Overall change: Optionally render any element instead of an h2.

Code changes:

  • Adds an overrideHeadingAs prop to override the default h2.

  • I have assigned myself to this PR and the corresponding issues
  • Automated jest tests added (for new features) or updated (for existing features)
  • This PR requires manual testing

@rhenshaw56 rhenshaw56 added ws-articles Tasks for the WS Articles Team a11y Accessibility-related task labels Jul 7, 2020
@rhenshaw56 rhenshaw56 self-assigned this Jul 7, 2020
dir="ltr"
id="test-section-label"
>
This is text in a SectionLabel.
</span>
<span
aria-hidden="true"
class="c6"
class="c7"
dir="ltr"
>
See All
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the journalist inputs a link - we won't want this in the recommendations component... will it be possible for a journalist to input a link?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@greenc05 in the recommendations container in simorgh, it will be hard coded to not have a link text or an href, so we never have this outputted as a link

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rhenshaw56 maybe we don't need tests for this scenario then?

@rhenshaw56 rhenshaw56 marked this pull request as ready for review July 7, 2020 14:09
@@ -133,6 +135,7 @@ SectionLabel.propTypes = {
service: string.isRequired,
visuallyHidden: bool,
backgroundColor: string,
overrideHeadingAs: string,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we restrict the allowed value for this to be only null or strong at this time, just to discourage misuse and encourage people to choose the correct element type in the future?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that is possible, definately

Copy link
Contributor Author

@rhenshaw56 rhenshaw56 Jul 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrewscfc would a prop validation warning suffice? or should it be strictly enforced?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just say prop validation personally, just to guide people in the right direction. Enforcing is a bit pointless because anyone can edit the code, it's just to encourage people to pause and think really.

@@ -81,11 +81,12 @@ const SectionLabel = ({
service,
visuallyHidden,
backgroundColor,
overrideHeadingAs,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this is used in Simorgh could we summarise why we are overriding to strong in a comment I don't think this will be very obvious when people come to this in the future #3574 (comment)

I was considering suggesting adding a supplementary prop, this trying to express the reason for using strong, the section label being inside supplementary content rather than being used in the main content of the page; this could then be used inside the component to switch to use a strong. I'm still not sure this is clear enough though, so I'd personally just suggest adding a comment as above.

Copy link
Contributor

@andrewscfc andrewscfc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing my comment apologies for the slow reply.

Copy link
Contributor

@HarveyPeachey HarveyPeachey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job Rowland, LGTM 👍

</div>
`;

exports[`SectionLabel With heading overriden to be a strong element should render correctly as a plain title with no bar 1`] = `
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats the difference in this to the example above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@greenc05 none actually, just a change in the test description title.

@paruchurisilpa paruchurisilpa self-assigned this Jul 9, 2020
@paruchurisilpa
Copy link
Contributor

Looks good to me. Looked at Storybook and we have an option under sectionlabel for 'with heading overriden to be a strong element'

@amywalkerdev amywalkerdev deleted the strong-section-label branch September 28, 2020 12:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a11y Accessibility-related task ws-articles Tasks for the WS Articles Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow section-label heading optionally use a strong element
5 participants