">
+
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/app_helpers/brand_helper.rb b/lib/govuk_publishing_components/app_helpers/brand_helper.rb
new file mode 100644
index 0000000000..30132234df
--- /dev/null
+++ b/lib/govuk_publishing_components/app_helpers/brand_helper.rb
@@ -0,0 +1,25 @@
+module GovukPublishingComponents
+ 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
+
+ def border_color_class
+ "brand__border-color" if @brand
+ end
+
+ def color_class
+ "brand__color" if @brand
+ end
+ end
+ end
+end
diff --git a/lib/govuk_publishing_components/presenters/brand_helper.rb b/lib/govuk_publishing_components/presenters/brand_helper.rb
deleted file mode 100644
index 479e335883..0000000000
--- a/lib/govuk_publishing_components/presenters/brand_helper.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-module GovukPublishingComponents
- module Presenters
- class BrandHelper
- def initialize(brand)
- @brand = brand if brand
- end
-
- def get_brand
- "brand--#{@brand}" if @brand
- end
-
- def get_brand_element(attribute)
- "brand__#{attribute}" if @brand
- end
- end
- end
-end
diff --git a/spec/components/document_list_spec.rb b/spec/components/document_list_spec.rb
index e4b85e96c9..86b9b8fe8a 100644
--- a/spec/components/document_list_spec.rb
+++ b/spec/components/document_list_spec.rb
@@ -131,4 +131,25 @@ def component_name
assert_select "#{li} a[data-track-label='/link2']", text: "Link 2"
assert_select "#{li} a[data-track-options='{\"dimension28\":\"2\",\"dimension29\":\"Link 2\"}']", text: "Link 2"
end
+
+ it "adds branding correctly" do
+ render_component(
+ brand: 'attorney-generals-office',
+ items: [
+ {
+ link: {
+ text: "School behaviour and attendance: parental responsibility measures",
+ path: "/government/publications/parental-responsibility-measures-for-behaviour-and-attendance",
+ },
+ metadata: {
+ public_updated_at: Time.zone.parse("2017-01-05 14:50:33 +0000"),
+ document_type: "Statutory guidance"
+ }
+ }
+ ]
+ )
+
+ assert_select '.gem-c-document-list.brand--attorney-generals-office'
+ assert_select '.gem-c-document-list .gem-c-document-list__item-title .brand__color'
+ end
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