From d5f0ac3ba571d9b6e75b3d0cd4a5db1442099cd0 Mon Sep 17 00:00:00 2001 From: Vanita Barrett Date: Thu, 8 Aug 2019 01:32:02 +0000 Subject: [PATCH] Add inverse flag to contents list component We have a need to use the contents list component within a topic page header, which has a blue background. --- .../components/_contents-list.scss | 19 +++++++++++++++++++ .../components/_contents_list.html.erb | 6 +++++- .../components/docs/contents_list.yml | 12 ++++++++++++ spec/components/contents_list_spec.rb | 5 +++++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/govuk_publishing_components/components/_contents-list.scss b/app/assets/stylesheets/govuk_publishing_components/components/_contents-list.scss index ad0daa1b0e..2059636ab9 100644 --- a/app/assets/stylesheets/govuk_publishing_components/components/_contents-list.scss +++ b/app/assets/stylesheets/govuk_publishing_components/components/_contents-list.scss @@ -10,12 +10,27 @@ box-shadow: 0 20px 15px -10px govuk-colour("white"); } +.gem-c-contents-list--inverse { + background: transparent; + box-shadow: none; +} + .gem-c-contents-list__title { @include govuk-text-colour; @include govuk-font($size: 16, $weight: regular, $line-height: 1.5); margin: 0; } +.gem-c-contents-list--inverse .gem-c-contents-list__title, +.gem-c-contents-list--inverse .gem-c-contents-list__link:link, +.gem-c-contents-list--inverse .gem-c-contents-list__link:visited { + color: govuk-colour("white"); +} + +.gem-c-contents-list--inverse .gem-c-contents-list__link:focus { + color: $govuk-focus-text-colour; +} + .gem-c-contents-list__list, .gem-c-contents-list__nested-list { @include govuk-text-colour; @@ -76,6 +91,10 @@ } } + .gem-c-contents-list--inverse &:before { + color: govuk-colour("white"); + } + // Focus styles on IE8 and older include the // left margin, creating an odd white box with // orange border around the em dash. diff --git a/app/views/govuk_publishing_components/components/_contents_list.html.erb b/app/views/govuk_publishing_components/components/_contents_list.html.erb index 19b667862c..a119458c97 100644 --- a/app/views/govuk_publishing_components/components/_contents_list.html.erb +++ b/app/views/govuk_publishing_components/components/_contents_list.html.erb @@ -2,6 +2,7 @@ cl_helper = GovukPublishingComponents::Presenters::ContentsListHelper.new format_numbers ||= false underline_links ||= false + inverse ||= false contents ||= [] aria_label ||= '' nested = !!contents.find { |c| c[:items] && c[:items].any? } @@ -19,7 +20,10 @@ <% if contents.any? %>