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

Suppress subscription components heading #804

Merged
merged 2 commits into from
Mar 28, 2019

Conversation

aliuk2012
Copy link
Contributor

@aliuk2012 aliuk2012 commented Mar 27, 2019

For some unknown reason this component includes a h2 heading by default.
This means that if a service uses it unexpectedly it will include the heading.
It also stops a team from using this component anywhere else on a page.

By using the 'hide_heading' option, it will suppress the heading when
the component is being rendered.

Component: https://govuk-publishing-compon-pr-804.herokuapp.com/component-guide/subscription-links

Demo: https://govuk-publishing-compon-pr-804.herokuapp.com/component-guide/subscription-links/without_heading

Ticket: https://trello.com/c/nMB9EUx0/581-update-top-section-of-results-layout

@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-804 March 27, 2019 15:53 Inactive
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-804 March 27, 2019 15:54 Inactive
@aliuk2012 aliuk2012 marked this pull request as ready for review March 27, 2019 16:21
@aliuk2012 aliuk2012 force-pushed the suppress-subscription-heading branch from ad02897 to ead4098 Compare March 28, 2019 07:32
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-804 March 28, 2019 07:32 Inactive
@aliuk2012
Copy link
Contributor Author

I plan to do a release once this has been approved & merged

Copy link
Contributor

@andysellick andysellick left a comment

Choose a reason for hiding this comment

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

Looks good. Would it be worth adding a small note in the yml file's body (there currently isn't one) explaining that the component includes a hidden h2? It's clearly non-obvious, so worth pointing out.

For some unknown reason this component includes a h2 heading by default.
This means that if a service uses it unexpectly it will include the heading.
It also stops a team from using this component anywhere else on a page.

By using the 'hide_heading' option, it will suppress the heading when
the component is being rendered.
@@ -11,10 +11,13 @@
css_classes << (shared_helper.get_margin_bottom) unless local_assigns[:margin_bottom] == 0
css_classes << brand_helper.brand_class
data = {"module": "gem-toggle"} if sl_helper.feed_link_box_value
hide_heading ||= false
Copy link
Contributor

@alex-ju alex-ju Mar 28, 2019

Choose a reason for hiding this comment

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

I was wondering if we could turn this into a positive flag show_heading ||= true which can be turned off. It's a matter of flavour, but I always find confusing setting things to true to disable something. Especially because we don't know why we set this <h2> implicitly on this component and we may consider dropping it at some point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've tried using positive flags before but it doesn't work with the way we set the defaults using ||= operator.

TBH, I would have liked to have simply remove the h2 but I just don't have time to update and test the other repos.

Copy link
Contributor

Choose a reason for hiding this comment

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

It could be a positive flag, but we'd have to go and change every existing use of the component.

Copy link
Contributor

@alex-ju alex-ju Mar 28, 2019

Choose a reason for hiding this comment

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

@andysellick: I don't think so if we're setting the default to true.
I'm not very opinionated, whatever does the job 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

@alex-ju that's the problem Al was talking about. If you set the default to true, like this: show_heading ||= true when you pass through 'false' it defaults to true.

Copy link
Contributor

Choose a reason for hiding this comment

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

yep, familiar with this situation, but we dealt with it in other components with a conditional statement.

@aliuk2012
Copy link
Contributor Author

@andysellick Good idea, I've added a some copy. I'll merge it now.

@alex-ju
Copy link
Contributor

alex-ju commented Mar 28, 2019

@aliuk2012 would be great if we can get #805 in the same release

@aliuk2012 aliuk2012 merged commit 60fb415 into master Mar 28, 2019
@aliuk2012 aliuk2012 deleted the suppress-subscription-heading branch March 28, 2019 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants