-
Notifications
You must be signed in to change notification settings - Fork 21
/
_warning_text.html.erb
36 lines (32 loc) · 1.16 KB
/
_warning_text.html.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<%
add_gem_component_stylesheet("warning-text")
id ||= "warning-text-#{SecureRandom.hex(4)}"
text_assistive ||= 'Warning'
text_icon ||= '!'
large_font ||= false
highlight_text ||= false
heading_level ||= 0
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
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
text_classes << "gem-c-warning-text__text--highlight" if highlight_text
%>
<%= tag.div id: id, class: "gem-c-warning-text govuk-warning-text" do %>
<% unless text_icon.empty? %>
<%= tag.span text_icon, class: "govuk-warning-text__icon", "aria-hidden": "true" %>
<% end %>
<% inner_text = capture do %>
<%= tag.span text_assistive, class: "govuk-warning-text__assistive" %>
<%= text %>
<% end %>
<% if heading_level > 0 %>
<%= content_tag(shared_helper.get_heading_level, class: text_classes) do %>
<%= inner_text %>
<% end %>
<% else %>
<%= tag.strong class: text_classes do %>
<%= inner_text %>
<% end %>
<% end %>
<% end %>