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

Taxonomy List Component #476

Merged
merged 2 commits into from Aug 14, 2018
Merged

Taxonomy List Component #476

merged 2 commits into from Aug 14, 2018

Conversation

vanitabarrett
Copy link
Contributor

@vanitabarrett vanitabarrett commented Aug 8, 2018

Trello: https://trello.com/c/PFbuMOGm/100-spike-adapt-highlight-box-component-to-work-in-a-list-of-links

We needed to work out a way to display service links (some of which are a list of highlight boxes, some are a document list) so that they are part of one HTML list. I also tried:

  • Adding a flag to remove the <ul> from the highlight box and document list components. However, this would require developers to a) wrap the components they're using in a list tag, and b) require them to copy over styling so the elements were displayed appropriately.

screen shot 2018-08-08 at 13 13 20

screen shot 2018-08-08 at 13 13 26

Link to the component: https://govuk-publishing-compon-pr-476.herokuapp.com/component-guide/taxonomy_list

I think we'd also be able to use this for image cards + document list

@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-476 August 8, 2018 09:20 Inactive
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-476 August 8, 2018 12:21 Inactive
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-476 August 8, 2018 13:13 Inactive
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-476 August 8, 2018 14:32 Inactive
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-476 August 8, 2018 14:35 Inactive
@benthorner benthorner had a problem deploying to govuk-publishing-compon-pr-476 August 8, 2018 16:33 Failure
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-476 August 9, 2018 09:21 Inactive
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-476 August 9, 2018 09:22 Inactive
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-476 August 9, 2018 09:26 Inactive
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-476 August 9, 2018 10:17 Inactive
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-476 August 9, 2018 10:25 Inactive
@vanitabarrett vanitabarrett changed the title [WIP][DO NOT MERGE] Taxonomy List Component [DO NOT MERGE] Taxonomy List Component Aug 9, 2018
@vanitabarrett vanitabarrett changed the title [DO NOT MERGE] Taxonomy List Component Taxonomy List Component Aug 9, 2018
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-476 August 9, 2018 10:30 Inactive
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.

No real problems, but as an outsider I think I have a hard time understanding this. Seems well written though.

Gemfile.lock Outdated
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
govuk_publishing_components (9.12.0)
govuk_publishing_components (9.12.1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Presumably this version bump is required for the changes you're making? Otherwise should it be in a separate PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is so the PR herokuapp built - whoever last versioned the gem didn't bundle and commit the change to the Gemfile.lock so it was failing to build.

@include media(tablet) {
@include box-sizing(border-box);
width: 33%;
display: inline-block;
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure inline-block is needed here?

@@ -8,9 +10,11 @@
brand_helper = GovukPublishingComponents::AppHelpers::BrandHelper.new(brand)
%>
<% if items.any? %>
<ol class="gem-c-document-list<%= margin_bottom_class %><%= margin_top_class %> <%= brand_helper.brand_class %>">
<% unless within_multitype_list %>
<ol class="gem-c-document-list<%= margin_bottom_class %><%= margin_top_class %> <%= brand_helper.brand_class %>">
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this change mean that branding can't be applied to a document list inside a taxonomy list? (I don't know if that would be a problem or not)

@@ -45,5 +49,7 @@
<% end %>
</li>
<% end %>
</ol>
<% unless within_multitype_list %>
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't hugely untidy, so this suggestion may be overkill, but have you considered passing this chunk into content_tag to output or not output this ol?

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'm not sure how this would work, can you please give an example? 🙂

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking you'd wrap up the code in a block somehow and then do an if statement of some kind of either just output the block or do content_tag('ol', block). Thinking about this in more detail it's probably not appropriate for this situation, as you either want the wrapping ol or you don't - this would work better where you would want a choice of wrapping elements.

<% if highlight_box || document_list || image_cards %>
<ul class="gem-c-taxonomy-list" data-module="track-click">
<% if image_cards %>
<% image_cards[:items].in_groups_of(3, false) do |image_group| %>
Copy link
Contributor

Choose a reason for hiding this comment

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

Just seeking clarification here - why is this using in_groups_of(3 ? I can't figure it out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good spot, this was just left over from when I copied this code over from org pages - it's not needed any more 👍

heading_text: image_card[:link][:text],
image_src: image_card[:image][:url],
image_alt: image_card[:image][:alt],
heading_level: image_card[:link][:heading_level],
Copy link
Contributor

Choose a reason for hiding this comment

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

Presumably it's not possible to pass through the parameters cleanly like for highlight_boxes and document_list? Is there anything we could change in the image card component to make that possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As this was just a spike, I didn't look too closely into it - but I'll definitely take a look now 🙂

@@ -0,0 +1,85 @@
name: Taxonomy List
description: Wraps the highlight box and document list component in one list. This is commonly used on topic pages for links to tagged content.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this also mention the image card here?

<% image_cards[:items].in_groups_of(3, false) do |image_group| %>
<% image_group.each do |image_card| %>
<li class="gem-c-taxonomy-list__item">
<%= render "govuk_publishing_components/components/image_card", {
Copy link
Contributor

Choose a reason for hiding this comment

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

Putting highlight boxes and document lists together works and makes sense, particularly when tested using Voiceover, but I'm not sure I'm convinced of the need to be able to do the same with image cards and document lists. What's the thinking behind this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The same as for highlight boxes and document lists - we need both to be the same list for screenreaders. See the "News and Communications" section on /student-finance

screen shot 2018-08-09 at 14 17 58

text: High needs funding
path: /high-needs-funding
metadata:
document_type: Guide
Copy link
Contributor

Choose a reason for hiding this comment

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

Could there be an example of all three together? Also if we wanted to combine one image card, one highlight box, and a document list, what would it look like - would they all stack?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, this doesn't render perfectly at the moment (the highlight boxes end up on the same line as the image cards). I've had a look into this today but it's proving tricky to fix. As we don't need this yet, I'm going to create a separate card so it doesn't block this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Have you tried applying a class to the last element of each component type to provide (whatever is the flex equivalent of) clearing? Although I've had a quick look and can't see what that might be...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@andysellick Yeah, there doesn't seem to be an easy flex equivalent, annoyingly. I got a partial solution, but it then got confusing with different numbers of image cards and on mobile

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough. Maybe add a note to the documentation body to point this out until we can get a fix.

@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-476 August 9, 2018 13:19 Inactive
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-476 August 9, 2018 14:19 Inactive
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-476 August 9, 2018 14:21 Inactive
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-476 August 9, 2018 16:04 Inactive
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-476 August 10, 2018 14:07 Inactive
@benthorner benthorner had a problem deploying to govuk-publishing-compon-pr-476 August 10, 2018 14:57 Failure
@vanitabarrett
Copy link
Contributor Author

@andysellick I think I've addressed all your comments / made changes - can you please re-review?

@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-476 August 10, 2018 14:58 Inactive
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-476 August 10, 2018 15:17 Inactive
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.

Just some small stuff.

body: |
The [highlight box](/component-guide/highlight_boxes), [document list](/component-guide/document_list) and [image card](/component-guide/image_card) components are standalone components.

However, there are some use cases where we want to use both components to render one list of links. This is not possible when using the two components separately.
Copy link
Contributor

Choose a reason for hiding this comment

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

Reword 'both'.

inverse_class = "gem-c-highlight-boxes--inverse" if inverse
highlight_boxes_helper = GovukPublishingComponents::Presenters::HighlightBoxesHelper.new(local_assigns)
%>
<% if items.any? %>
<ol class="gem-c-highlight-boxes" <%= "data-module=track-click" if highlight_boxes_helper.data_tracking? %>>
<% unless within_multitype_list %>
<ol class="gem-c-highlight-boxes" <%= "data-module=track-click" if highlight_boxes_helper.data_tracking? %>>
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't really part of this PR, but is there a way of writing this line that github will like?

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 haven't been able to find much info on this - I tried a few things but nothing seemed to fix it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough. I'll take a look at the rest shortly.

@@ -64,3 +64,7 @@
.gem-c-document-list--top-margin {
margin-top: $gutter-two-thirds;
}

.gem-c-document-list__multi-list {
width: 100%;
Copy link
Contributor

Choose a reason for hiding this comment

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

I've just noticed that the right edge of this (the grey dividing border) seems to overlap the page width (although I'm not sure how this will look in production). See below.

screen shot 2018-08-10 at 16 41 09

Might need to put a margin-right on it of 25px to counter the negative margin on the parent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good spot, I thought it didn't look quite right! 👍

path: /high-needs-funding
metadata:
document_type: Guide
public_updated_at: 2016-06-27 10:29:44
Copy link
Contributor

Choose a reason for hiding this comment

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

Just for testing the layout I'd suggest adding another two link entries in here - so the displayed example has four highlight boxes.

text: High needs funding
path: /high-needs-funding
metadata:
document_type: Guide
Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough. Maybe add a note to the documentation body to point this out until we can get a fix.

@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-476 August 14, 2018 09:23 Inactive
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-476 August 14, 2018 09:30 Inactive
@benthorner benthorner temporarily deployed to govuk-publishing-compon-pr-476 August 14, 2018 09:44 Inactive
Vanita Barrett added 2 commits August 14, 2018 09:46
Wraps the highlight box and document list component in one list. This is commonly used on topic pages for taxonomy-related navigation.
Moves the branding class to the document list item instead of the ul which may not always be rendered.
@vanitabarrett
Copy link
Contributor Author

@andysellick Thanks for your review - I've made all the fixes (apart from the Github error highlighting around data-module which shouldn't block this PR). Are you happy to approve?

@vanitabarrett vanitabarrett merged commit 9da4831 into master Aug 14, 2018
@vanitabarrett vanitabarrett deleted the spike-taxonomy-list branch August 14, 2018 09:59
@vanitabarrett vanitabarrett mentioned this pull request Aug 14, 2018
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.

None yet

3 participants