Skip to content

Commit

Permalink
Add option to warning component for larger font
Browse files Browse the repository at this point in the history
  • Loading branch information
andysellick committed Nov 22, 2018
1 parent 2fd3cc4 commit de411a3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
padding-left: 0;
margin-left: 0;
}

.gem-c-warning-text__text--large {
@include govuk-font($size: 24, $weight: bold);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@
classes ||= ''
text_assistive ||= 'Warning'
text_icon ||= '!'
large_font ||= false

css_classes = %w(gem-c-warning-text govuk-warning-text)
css_classes << classes if classes

text_classes = %w(govuk-warning-text__text)
text_classes << "gem-c-warning-text__text--no-indent" if text_icon.empty?
text_classes << "gem-c-warning-text__text--large" if large_font
%>

<%= tag.div id: id, class: css_classes do %>
<% unless text_icon.empty? %>
<%= tag.span text_icon, class: "govuk-warning-text__icon", "aria-hidden": "true" %>
<% end %>
<%= tag.strong class: "govuk-warning-text__text #{'gem-c-warning-text__text--no-indent' if text_icon.empty?}" do %>
<%= tag.strong class: text_classes do %>
<%= tag.span text_assistive, class: "govuk-warning-text__assistive" %>
<%= text %>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ examples:
data:
text_icon: ""
text: "You can be fined up to £320 if you don't register."
with_larger_font:
data:
text: "This content was updated on the 24th of November 2018"
large_font: true
5 changes: 5 additions & 0 deletions spec/components/warning_text_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ def component_name
assert_select(".govuk-warning-text__icon", false)
assert_select(".gem-c-warning-text__text--no-indent", text: /You can be fined up to £5,000 if you don’t register/i)
end

it "renders large warning text" do
render_component(large_font: true, text: "You can be fined up to £5,000 if you don’t register.")
assert_select(".govuk-warning-text__text.gem-c-warning-text__text--large", text: /You can be fined up to £5,000 if you don’t register/i)
end
end

0 comments on commit de411a3

Please sign in to comment.