diff --git a/CHANGELOG.md b/CHANGELOG.md index a58b0db50b..b188b2caa7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Unreleased -* Add an optional `canonical` meta tag. +* Add an optional `canonical` meta tag (PR #302) +* Iterate branding model (PR #300) # 7.2.0 diff --git a/lib/govuk_publishing_components.rb b/lib/govuk_publishing_components.rb index ac0185bc1b..0282d537cb 100644 --- a/lib/govuk_publishing_components.rb +++ b/lib/govuk_publishing_components.rb @@ -1,6 +1,5 @@ require "govuk_publishing_components/config" require "govuk_publishing_components/engine" -require "govuk_publishing_components/presenters/brand_helper" require "govuk_publishing_components/presenters/contextual_navigation" require "govuk_publishing_components/presenters/related_navigation_helper" require "govuk_publishing_components/presenters/step_by_step_nav_helper" @@ -15,6 +14,7 @@ require "govuk_publishing_components/presenters/content_item" require "govuk_publishing_components/app_helpers/taxon_breadcrumbs" +require "govuk_publishing_components/app_helpers/brand_helper" module GovukPublishingComponents end diff --git a/lib/govuk_publishing_components/presenters/brand_helper.rb b/lib/govuk_publishing_components/app_helpers/brand_helper.rb similarity index 58% rename from lib/govuk_publishing_components/presenters/brand_helper.rb rename to lib/govuk_publishing_components/app_helpers/brand_helper.rb index 7c02a7f34d..30132234df 100644 --- a/lib/govuk_publishing_components/presenters/brand_helper.rb +++ b/lib/govuk_publishing_components/app_helpers/brand_helper.rb @@ -1,10 +1,14 @@ module GovukPublishingComponents - module Presenters + module AppHelpers class BrandHelper def initialize(brand) @brand = brand if brand end + # Apply government organisation branding to individual components, specifically + # link colour and border colour + # see https://github.com/alphagov/govuk_publishing_components/blob/master/docs/component_branding.md + def brand_class "brand--#{@brand}" if @brand end diff --git a/spec/lib/app_helpers/brand_helper_spec.rb b/spec/lib/app_helpers/brand_helper_spec.rb new file mode 100644 index 0000000000..c64636c9d9 --- /dev/null +++ b/spec/lib/app_helpers/brand_helper_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +RSpec.describe GovukPublishingComponents::AppHelpers::BrandHelper do + describe "Brand helper" do + it "returns nothing if no brand is specified" do + brand = GovukPublishingComponents::AppHelpers::BrandHelper.new(nil) + + expect(brand.brand_class).to eql(nil) + expect(brand.border_color_class).to eql(nil) + expect(brand.color_class).to eql(nil) + end + + it "returns the expected brand" do + brand = GovukPublishingComponents::AppHelpers::BrandHelper.new('attorney-generals-office') + + expect(brand.brand_class).to eql('brand--attorney-generals-office') + expect(brand.border_color_class).to eql('brand__border-color') + expect(brand.color_class).to eql('brand__color') + end + end +end