Skip to content

Commit

Permalink
Modify how branding works
Browse files Browse the repository at this point in the history
- rename get_brand method
- have explicit methods for color and border-color instead of one with a parameter
  • Loading branch information
andysellick committed May 9, 2018
1 parent 8f9ed42 commit c06106e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions docs/component_branding.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ To add colours to a component, modify the component to follow the example below.
brand_helper = GovukPublishingComponents::Presenters::BrandHelper.new(brand)
%>
<div class="gem-c-component <%= brand_helper.get_brand %>">
<div class="gem-c-component__title <%= brand_helper.get_brand_element("border-color") %>">
<div class="gem-c-component <%= brand_helper.brand_class %>">
<div class="gem-c-component__title <%= brand_helper.brand_border_color %>">
Example element that requires a coloured border
</div>
<a href="#" class="<%= brand_helper.get_brand_element("color") %>">
<a href="#" class="<%= brand_helper.brand_color %>">
Example element that requires coloured text
</a>
</div>
Expand Down
10 changes: 7 additions & 3 deletions lib/govuk_publishing_components/presenters/brand_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ def initialize(brand)
@brand = brand if brand
end

def get_brand
def brand_class
"brand--#{@brand}" if @brand
end

def get_brand_element(attribute)
"brand__#{attribute}" if @brand
def border_color_class
"brand__border-color" if @brand
end

def color_class
"brand__color" if @brand
end
end
end
Expand Down

0 comments on commit c06106e

Please sign in to comment.