-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #476 from alphagov/spike-taxonomy-list
Taxonomy List Component
- Loading branch information
Showing
12 changed files
with
327 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
app/assets/stylesheets/govuk_publishing_components/components/_taxonomy-list.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.gem-c-taxonomy-list { | ||
display: flex; | ||
flex-wrap: wrap; | ||
margin-top: $gutter-half; | ||
|
||
@include media(tablet) { | ||
margin-right: -25px; | ||
} | ||
} | ||
|
||
.gem-c-taxonomy-list__item { | ||
list-style: none; | ||
|
||
@include media(tablet) { | ||
@include box-sizing(border-box); | ||
width: 33%; | ||
padding-right: $gutter-one-third; | ||
vertical-align: top; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
app/views/govuk_publishing_components/components/_taxonomy_list.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<% | ||
highlight_box ||= false | ||
document_list ||= false | ||
image_cards ||= false | ||
|
||
highlight_box.merge!({within_multitype_list: true}) if highlight_box | ||
document_list.merge!({within_multitype_list: true}) if document_list | ||
|
||
taxonomy_list_helper = GovukPublishingComponents::Presenters::TaxonomyListHelper.new(image_cards) | ||
%> | ||
<% if highlight_box || document_list || image_cards %> | ||
<ul class="gem-c-taxonomy-list" data-module="track-click"> | ||
<% if image_cards %> | ||
<% taxonomy_list_helper.image_card_data.each do |image_card| %> | ||
<li class="gem-c-taxonomy-list__item"> | ||
<%= render "govuk_publishing_components/components/image_card", image_card %> | ||
</li> | ||
<% end %> | ||
<% end %> | ||
|
||
<% if highlight_box %> | ||
<%= render "govuk_publishing_components/components/highlight_boxes", highlight_box %> | ||
<% end %> | ||
|
||
<% if document_list %> | ||
<%= render "govuk_publishing_components/components/document_list", document_list %> | ||
<% end %> | ||
</ul> | ||
<% end %> |
107 changes: 107 additions & 0 deletions
107
app/views/govuk_publishing_components/components/docs/taxonomy_list.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
name: Taxonomy list | ||
description: Wraps the highlight box, document list and image card components in one list. This is commonly used on topic pages for links to tagged content. | ||
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 these components together to render one list of links. This is not possible when using the components separately. | ||
This component wraps these components in one list, and applies relevant styling to get them to display appropriately together. | ||
**Note:** At the moment, this component only works when displaying either highlight box + document list **or** image cards + document list. The layout for combining all three together hasn't been fixed. | ||
accessibility_criteria: | | ||
The taxonomy list should: | ||
- Wrap all links in one list | ||
- Should not be used to display links that don't belong together in one list | ||
shared_accessibility_criteria: | ||
- link | ||
examples: | ||
default: | ||
data: | ||
highlight_box: | ||
inverse: true | ||
items: | ||
- link: | ||
text: If your child is taken into care | ||
path: /child-into-care | ||
description: Information on what to do if your child is taken into care | ||
metadata: | ||
document_type: Detailed guide | ||
- link: | ||
text: High needs funding | ||
path: /high-needs-funding | ||
metadata: | ||
document_type: Guide | ||
public_updated_at: 2016-06-27 10:29:44 | ||
- link: | ||
text: Student Finance | ||
path: /student-finance | ||
description: Student loan information | ||
metadata: | ||
document_type: Detailed guide | ||
- link: | ||
text: If your child is taken into care | ||
path: /child-into-care | ||
description: Information on what to do if your child is taken into care | ||
metadata: | ||
document_type: Detailed guide | ||
document_list: | ||
items: | ||
- link: | ||
text: If your child is taken into care | ||
path: /child-into-care | ||
metadata: | ||
document_type: Detailed guide | ||
- link: | ||
text: High needs funding | ||
path: /high-needs-funding | ||
metadata: | ||
document_type: Guide | ||
with_image_cards: | ||
data: | ||
image_cards: | ||
items: | ||
- link: | ||
path: /not-a-page | ||
text: News headline | ||
heading_level: 0 | ||
image: | ||
url: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/feature/image/62756/s300_courts-of-justice.JPG | ||
alt: some meaningful alt text please | ||
context: The Rt Hon | ||
- link: | ||
path: /not-a-page | ||
text: News headline | ||
heading_level: 0 | ||
image: | ||
url: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/feature/image/62756/s300_courts-of-justice.JPG | ||
alt: some meaningful alt text please | ||
context: The Rt Hon | ||
- link: | ||
path: /not-a-page | ||
text: News headline | ||
heading_level: 0 | ||
image: | ||
url: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/feature/image/62756/s300_courts-of-justice.JPG | ||
alt: some meaningful alt text please | ||
context: The Rt Hon | ||
- link: | ||
path: /not-a-page | ||
text: News headline | ||
heading_level: 0 | ||
image: | ||
url: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/feature/image/62756/s300_courts-of-justice.JPG | ||
alt: some meaningful alt text please | ||
context: The Rt Hon | ||
document_list: | ||
items: | ||
- link: | ||
text: If your child is taken into care | ||
path: /child-into-care | ||
description: What happens if your child is taken into care | ||
metadata: | ||
document_type: Detailed guide | ||
- link: | ||
text: High needs funding | ||
path: /high-needs-funding | ||
metadata: | ||
document_type: Guide |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
lib/govuk_publishing_components/presenters/taxonomy_list_helper.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module GovukPublishingComponents | ||
module Presenters | ||
class TaxonomyListHelper | ||
def initialize(image_cards) | ||
@image_cards = image_cards | ||
end | ||
|
||
def image_card_data | ||
@image_cards[:items].map do |image_card| | ||
{ | ||
context: image_card[:image][:context], | ||
href: image_card[:link][:path], | ||
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], | ||
href_data_attributes: (image_card[:link][:data_attributes] if image_card[:link][:data_attributes]) | ||
} | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.