govuk-design-system-rails 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/app/helpers/govuk_design_system/accordion_helper.rb +7 -0
- data/app/helpers/govuk_design_system/back_link_helper.rb +13 -0
- data/app/helpers/govuk_design_system/breadcrumbs_helper.rb +7 -0
- data/app/helpers/govuk_design_system/button_helper.rb +71 -0
- data/app/helpers/govuk_design_system/checkboxes_helper.rb +8 -0
- data/app/helpers/govuk_design_system/components_helper.rb +13 -0
- data/app/helpers/govuk_design_system/cookie_banner_helper.rb +7 -0
- data/app/helpers/govuk_design_system/date_input_helper.rb +8 -0
- data/app/helpers/govuk_design_system/details_helper.rb +32 -0
- data/app/helpers/govuk_design_system/error_message_helper.rb +7 -0
- data/app/helpers/govuk_design_system/error_summary_helper.rb +20 -0
- data/app/helpers/govuk_design_system/fieldset_helper.rb +9 -0
- data/app/helpers/govuk_design_system/file_upload_helper.rb +59 -0
- data/app/helpers/govuk_design_system/header_helper.rb +7 -0
- data/app/helpers/govuk_design_system/hint_helper.rb +7 -0
- data/app/helpers/govuk_design_system/hmcts_badge_helper.rb +7 -0
- data/app/helpers/govuk_design_system/hmcts_banner_helper.rb +7 -0
- data/app/helpers/govuk_design_system/input_helper.rb +8 -0
- data/app/helpers/govuk_design_system/inset_text_helper.rb +9 -0
- data/app/helpers/govuk_design_system/label_helper.rb +7 -0
- data/app/helpers/govuk_design_system/notification_banner_helper.rb +8 -0
- data/app/helpers/govuk_design_system/phase_banner_helper.rb +21 -0
- data/app/helpers/govuk_design_system/radios_helper.rb +8 -0
- data/app/helpers/govuk_design_system/select_helper.rb +8 -0
- data/app/helpers/govuk_design_system/skip_link_helper.rb +13 -0
- data/app/helpers/govuk_design_system/summary_list_helper.rb +7 -0
- data/app/helpers/govuk_design_system/tabs_helper.rb +7 -0
- data/app/helpers/govuk_design_system/tag_helper.rb +8 -0
- data/app/helpers/govuk_design_system/textarea_helper.rb +8 -0
- data/app/helpers/govuk_design_system/warning_text_helper.rb +20 -0
- data/app/views/components/_govuk_accordion.html.erb +44 -0
- data/app/views/components/_govuk_action_link.html.erb +12 -0
- data/app/views/components/_govuk_breadcrumbs.html.erb +25 -0
- data/app/views/components/_govuk_checkboxes.html.erb +125 -0
- data/app/views/components/_govuk_cookie_banner.html.erb +75 -0
- data/app/views/components/_govuk_date_input.html.erb +94 -0
- data/app/views/components/_govuk_error_message.html.erb +13 -0
- data/app/views/components/_govuk_error_summary.html.erb +32 -0
- data/app/views/components/_govuk_fieldset.html.erb +21 -0
- data/app/views/components/_govuk_header.html.erb +64 -0
- data/app/views/components/_govuk_hint.html.erb +7 -0
- data/app/views/components/_govuk_hr.html.erb +1 -0
- data/app/views/components/_govuk_input.html.erb +97 -0
- data/app/views/components/_govuk_inset_text.html.erb +10 -0
- data/app/views/components/_govuk_label.html.erb +18 -0
- data/app/views/components/_govuk_notification_banner.html.erb +68 -0
- data/app/views/components/_govuk_radios.html.erb +141 -0
- data/app/views/components/_govuk_select.html.erb +105 -0
- data/app/views/components/_govuk_summary_list.html.erb +39 -0
- data/app/views/components/_govuk_tabs.html.erb +46 -0
- data/app/views/components/_govuk_textarea.html.erb +70 -0
- data/app/views/components/_hmcts_banner.html.erb +33 -0
- data/app/views/form_components/_govuk_checkboxes.html.erb +21 -0
- data/app/views/form_components/_govuk_date_input.html.erb +32 -0
- data/app/views/form_components/_govuk_input.html.erb +11 -0
- data/app/views/form_components/_govuk_radios.html.erb +24 -0
- data/app/views/form_components/_govuk_select.html.erb +25 -0
- data/app/views/form_components/_govuk_textarea.html.erb +11 -0
- data/lib/govuk-design-system-rails.rb +1 -0
- data/lib/govuk_design_system/engine.rb +50 -0
- data/lib/govuk_design_system.rb +4 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +2 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/javascript/packs/application.js +15 -0
- data/spec/dummy/app/jobs/application_job.rb +7 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +33 -0
- data/spec/dummy/config/application.rb +38 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +76 -0
- data/spec/dummy/config/environments/production.rb +120 -0
- data/spec/dummy/config/environments/test.rb +59 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/dummy/config/initializers/assets.rb +12 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +8 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +28 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +6 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/permissions_policy.rb +11 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/puma.rb +43 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config/storage.yml +34 -0
- data/spec/dummy/config.ru +6 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/tmp/development_secret.txt +1 -0
- data/spec/helpers/govuk_design_system/accordion_helper_spec.rb +353 -0
- data/spec/helpers/govuk_design_system/breadcrumbs_helper_spec.rb +90 -0
- data/spec/helpers/govuk_design_system/button_helper_spec.rb +34 -0
- data/spec/helpers/govuk_design_system/checkboxes_helper_spec.rb +146 -0
- data/spec/helpers/govuk_design_system/cookie_banner_helper_spec.rb +65 -0
- data/spec/helpers/govuk_design_system/date_input_helper_spec.rb +63 -0
- data/spec/helpers/govuk_design_system/details_helper_spec.rb +42 -0
- data/spec/helpers/govuk_design_system/error_message_helper_spec.rb +18 -0
- data/spec/helpers/govuk_design_system/error_summary_helper_spec.rb +39 -0
- data/spec/helpers/govuk_design_system/header_helper_spec.rb +138 -0
- data/spec/helpers/govuk_design_system/hint_helper_spec.rb +20 -0
- data/spec/helpers/govuk_design_system/hmcts_badge_helper_spec.rb +16 -0
- data/spec/helpers/govuk_design_system/hmcts_banner_helper_spec.rb +59 -0
- data/spec/helpers/govuk_design_system/input_helper_spec.rb +157 -0
- data/spec/helpers/govuk_design_system/inset_text_helper_spec.rb +58 -0
- data/spec/helpers/govuk_design_system/label_helper_spec.rb +21 -0
- data/spec/helpers/govuk_design_system/notification_banner_helper_spec.rb +98 -0
- data/spec/helpers/govuk_design_system/radios_helper_spec.rb +270 -0
- data/spec/helpers/govuk_design_system/select_helper_spec.rb +85 -0
- data/spec/helpers/govuk_design_system/summary_list_helper_spec.rb +138 -0
- data/spec/helpers/govuk_design_system/tabs_helper_spec.rb +129 -0
- data/spec/helpers/govuk_design_system/tag_helper_spec.rb +17 -0
- data/spec/helpers/govuk_design_system/textarea_helper_spec.rb +67 -0
- data/spec/rails_helper.rb +64 -0
- data/spec/spec_helper.rb +116 -0
- metadata +401 -0
@@ -0,0 +1,125 @@
|
|
1
|
+
<%
|
2
|
+
id_prefix = local_assigns[:idPrefix].presence || local_assigns[:name]
|
3
|
+
described_by = local_assigns.dig(:fieldset, :describedBy) || local_assigns[:describedBy]
|
4
|
+
has_fieldset = !local_assigns[:fieldset].nil?
|
5
|
+
inner_html = capture do
|
6
|
+
# NOTE: Start capture
|
7
|
+
%>
|
8
|
+
|
9
|
+
<% if local_assigns[:hint].present? %>
|
10
|
+
<%
|
11
|
+
hint_id = "#{id_prefix}-hint"
|
12
|
+
described_by = described_by.present? ? "#{described_by} #{hint_id}" : hint_id
|
13
|
+
%>
|
14
|
+
<%= govukHint(
|
15
|
+
id: hint_id,
|
16
|
+
classes: local_assigns.dig(:hint, :classes),
|
17
|
+
attributes: local_assigns.dig(:hint, :attributes) || {},
|
18
|
+
html: local_assigns.dig(:hint, :html),
|
19
|
+
text: local_assigns.dig(:hint, :text)
|
20
|
+
) %>
|
21
|
+
<% end %>
|
22
|
+
|
23
|
+
<% if local_assigns[:errorMessage] %>
|
24
|
+
<%
|
25
|
+
error_id = "#{id_prefix}-error"
|
26
|
+
described_by = described_by.present? ? "#{described_by} #{error_id}" : error_id
|
27
|
+
%>
|
28
|
+
<%= govukErrorMessage(
|
29
|
+
id: error_id,
|
30
|
+
classes: local_assigns.dig(:errorMessage, :classes),
|
31
|
+
attributes: local_assigns.dig(:errorMessage, :attributes) || {},
|
32
|
+
html: local_assigns.dig(:errorMessage, :html),
|
33
|
+
text: local_assigns.dig(:errorMessage, :text),
|
34
|
+
visuallyHiddenText: local_assigns.dig(:errorMessage, :visuallyHiddenText)
|
35
|
+
) %>
|
36
|
+
<% end %>
|
37
|
+
|
38
|
+
<%
|
39
|
+
div_attributes = {
|
40
|
+
class: class_names("govuk-checkboxes", local_assigns[:classes]),
|
41
|
+
data: { module: "govuk-checkboxes" }
|
42
|
+
}.merge!(local_assigns[:attributes] || {})
|
43
|
+
%>
|
44
|
+
<%= tag.div **div_attributes do %>
|
45
|
+
<% (local_assigns[:items] || []).each_with_index do |item, index| %>
|
46
|
+
<% if item.present? %>
|
47
|
+
<%
|
48
|
+
item_id = item[:id] || (index.zero? ? id_prefix : "#{id_prefix}-#{index + 1}")
|
49
|
+
name = item[:name].presence || local_assigns[:name]
|
50
|
+
conditional_id = "conditional-#{item_id}"
|
51
|
+
%>
|
52
|
+
<% if item[:divider].present? %>
|
53
|
+
<div class="govuk-checkboxes__divider"><%= item[:divider] %></div>
|
54
|
+
<% else %>
|
55
|
+
<%
|
56
|
+
has_hint = item.dig(:hint, :text).present? || item.dig(:hint, :html).present?
|
57
|
+
item_hint_id = has_hint ? "#{item_id}-item-hint" : ""
|
58
|
+
item_described_by = !has_fieldset ? described_by : ""
|
59
|
+
item_described_by = class_names(item_described_by, item_hint_id)
|
60
|
+
is_checked = item[:checked] || (!item[:value].nil? && item[:values].try(:any?) && item[:values].include?(item[:value]))
|
61
|
+
%>
|
62
|
+
<%= tag.input(type: :hidden, value: (item[:unchecked_value] || "0").to_s, name: name, disabled: item[:disabled]) unless item[:disable_ghost] %>
|
63
|
+
<div class="govuk-checkboxes__item">
|
64
|
+
<%
|
65
|
+
input_attributes = {
|
66
|
+
id: item_id,
|
67
|
+
name: name,
|
68
|
+
type: "checkbox",
|
69
|
+
value: item[:value],
|
70
|
+
data: {}
|
71
|
+
}.merge!(item[:attributes] || {})
|
72
|
+
input_attributes[:class] = class_names("govuk-checkboxes__input", input_attributes[:class])
|
73
|
+
input_attributes[:checked] = true if is_checked
|
74
|
+
input_attributes[:disabled] = true if item[:disabled]
|
75
|
+
input_attributes[:data]["aria-controls"] = conditional_id if item.dig(:conditional, :html).present?
|
76
|
+
input_attributes[:data][:behaviour] = item[:behaviour] if item[:behaviour].present?
|
77
|
+
input_attributes["aria-describedby"] = item_described_by if item_described_by.present?
|
78
|
+
%>
|
79
|
+
<%= tag.input **input_attributes %>
|
80
|
+
<%= govukLabel(
|
81
|
+
html: item[:html],
|
82
|
+
text: item[:text],
|
83
|
+
classes: class_names("govuk-checkboxes__label", item.dig(:label, :classes)),
|
84
|
+
attributes: item.dig(:label, :attributes) || {},
|
85
|
+
for: item_id
|
86
|
+
) %>
|
87
|
+
<% if has_hint %>
|
88
|
+
<%= govukHint(
|
89
|
+
id: item_hint_id,
|
90
|
+
classes: class_names("govuk-checkboxes__hint", item.dig(:hint, :classes)),
|
91
|
+
attributes: item.dig(:hint, :attributes) || {},
|
92
|
+
html: item.dig(:hint, :html),
|
93
|
+
text: item.dig(:hint, :text)
|
94
|
+
) %>
|
95
|
+
<% end %>
|
96
|
+
</div>
|
97
|
+
<% if item.dig(:conditional, :html).present? %>
|
98
|
+
<div class="<%= class_names("govuk-checkboxes__conditional", { "govuk-checkboxes__conditional--hidden" => !is_checked }) %>" id="<%= conditional_id %>">
|
99
|
+
<%= item.dig(:conditional, :html) %>
|
100
|
+
</div>
|
101
|
+
<% end %>
|
102
|
+
<% end %>
|
103
|
+
<% end %>
|
104
|
+
<% end %>
|
105
|
+
<% end %>
|
106
|
+
|
107
|
+
<%
|
108
|
+
# NOTE: End capture
|
109
|
+
end
|
110
|
+
%>
|
111
|
+
|
112
|
+
<%
|
113
|
+
form_group_classes = class_names(
|
114
|
+
"govuk-form-group",
|
115
|
+
local_assigns.dig(:formGroup, :classes),
|
116
|
+
{ "govuk-form-group--error" => local_assigns[:errorMessage] }
|
117
|
+
)
|
118
|
+
%>
|
119
|
+
<%= tag.div class: form_group_classes do %>
|
120
|
+
<% if has_fieldset %>
|
121
|
+
<%= govukFieldset(classes: "", describedBy: described_by.presence, legend: local_assigns[:fieldset][:legend], attributes: local_assigns[:fieldset]) { inner_html } %>
|
122
|
+
<% else %>
|
123
|
+
<%= inner_html %>
|
124
|
+
<% end %>
|
125
|
+
<% end %>
|
@@ -0,0 +1,75 @@
|
|
1
|
+
<%
|
2
|
+
div_attributes = {
|
3
|
+
class: class_names("govuk-cookie-banner", local_assigns[:classes]),
|
4
|
+
"aria-label" => (local_assigns[:ariaLabel].presence || "Cookie banner"),
|
5
|
+
role: "region"
|
6
|
+
}.merge!(local_assigns[:attributes] || {})
|
7
|
+
div_attributes[:data] ||= {}
|
8
|
+
div_attributes[:data]["nosnippet"] = true
|
9
|
+
div_attributes[:hidden] = "hidden" if local_assigns[:hidden]
|
10
|
+
%>
|
11
|
+
<% unless cookies[:seen_cookie_message] %>
|
12
|
+
<%= tag.div **div_attributes do %>
|
13
|
+
<% (local_assigns[:messages] || []).each do |message| %>
|
14
|
+
<%
|
15
|
+
message_attributes = {
|
16
|
+
class: class_names("govuk-cookie-banner__message govuk-width-container", message[:classes]),
|
17
|
+
}.merge!(message[:attributes] || {})
|
18
|
+
message_attributes[:hidden] = "hidden" if message[:hidden]
|
19
|
+
message_attributes[:role] = message[:role] if message[:role]
|
20
|
+
%>
|
21
|
+
<%= tag.div **message_attributes do %>
|
22
|
+
<div class="govuk-grid-row">
|
23
|
+
<div class="govuk-grid-column-two-thirds">
|
24
|
+
<% if message[:headingHtml] || message[:headingText] %>
|
25
|
+
<h2 class="govuk-cookie-banner__heading govuk-heading-m">
|
26
|
+
<%= message[:headingHtml] || message[:headingText] %>
|
27
|
+
</h2>
|
28
|
+
<% end %>
|
29
|
+
<div class="govuk-cookie-banner__content">
|
30
|
+
<% if message[:html] %>
|
31
|
+
<%= message[:html] %>
|
32
|
+
<% elsif message[:text] %>
|
33
|
+
<p class="govuk-body"><%= message[:text] %></p>
|
34
|
+
<% end %>
|
35
|
+
</div>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<% if message[:actions] %>
|
40
|
+
<div class="govuk-button-group">
|
41
|
+
<% (message[:actions] || []).each do |action| %>
|
42
|
+
<% if action[:href].present? %>
|
43
|
+
<% if action[:type] == "button" %>
|
44
|
+
<%= govukButton({
|
45
|
+
"text": action[:text],
|
46
|
+
"type": "button",
|
47
|
+
"classes": action[:classes] || [],
|
48
|
+
"href": action[:href],
|
49
|
+
"attributes": action[:attributes] || {}
|
50
|
+
}) %>
|
51
|
+
<% else %>
|
52
|
+
<%
|
53
|
+
link_attributes = {
|
54
|
+
class: class_names("govuk-link", action[:classes])
|
55
|
+
}.merge!(action[:attributes] || {})
|
56
|
+
%>
|
57
|
+
<%= tag.a action[:text], href: action[:href], **link_attributes %>
|
58
|
+
<% end %>
|
59
|
+
<% else %>
|
60
|
+
<%= govukButton({
|
61
|
+
"text": action[:text],
|
62
|
+
"value": action[:value],
|
63
|
+
"name": action[:name],
|
64
|
+
"type": action[:type],
|
65
|
+
"classes": action[:classes] || [],
|
66
|
+
"attributes": action[:attributes] || {}
|
67
|
+
}) %>
|
68
|
+
<% end %>
|
69
|
+
<% end %>
|
70
|
+
</div>
|
71
|
+
<% end %>
|
72
|
+
<% end %>
|
73
|
+
<% end %>
|
74
|
+
<% end %>
|
75
|
+
<% end %>
|
@@ -0,0 +1,94 @@
|
|
1
|
+
<%
|
2
|
+
described_by = local_assigns[:described_by] || ""
|
3
|
+
date_input_items = local_assigns[:items] ||
|
4
|
+
[
|
5
|
+
{ name: "day", classes: "govuk-input--width-2" },
|
6
|
+
{ name: "month", classes: "govuk-input--width-2" },
|
7
|
+
{ name: "year", classes: "govuk-input--width-4" }
|
8
|
+
]
|
9
|
+
%>
|
10
|
+
<% date_input = capture do %>
|
11
|
+
<% if local_assigns[:hint] %>
|
12
|
+
<%
|
13
|
+
hint_id = local_assigns[:id] + '-hint'
|
14
|
+
described_by = described_by.present? ? described_by + ' ' + hint_id : hint_id
|
15
|
+
%>
|
16
|
+
<%=
|
17
|
+
govukHint(
|
18
|
+
id: hint_id,
|
19
|
+
text: local_assigns[:hint].try(:[], :text)
|
20
|
+
)
|
21
|
+
%>
|
22
|
+
<% end %>
|
23
|
+
<% if local_assigns[:errorMessage] %>
|
24
|
+
<%
|
25
|
+
error_id = local_assigns[:id] + '-error'
|
26
|
+
described_by = described_by.blank? ? error_id : "#{described_by} #{error_id}"
|
27
|
+
error_attributes = (local_assigns[:errorMessage][:attributes] || {}).merge(id: error_id)
|
28
|
+
%>
|
29
|
+
<%=
|
30
|
+
govukErrorMessage({
|
31
|
+
id: error_id,
|
32
|
+
classes: local_assigns[:errorMessage][:classes],
|
33
|
+
attributes: error_attributes,
|
34
|
+
html: local_assigns[:errorMessage][:html],
|
35
|
+
text: local_assigns[:errorMessage][:text],
|
36
|
+
visuallyHiddenText: local_assigns[:errorMessage][:visuallyHiddenText]
|
37
|
+
})
|
38
|
+
%>
|
39
|
+
<% end %>
|
40
|
+
<%
|
41
|
+
input_classes = class_names(
|
42
|
+
"govuk-date-input",
|
43
|
+
local_assigns[:classes]
|
44
|
+
)
|
45
|
+
input_attributes = {
|
46
|
+
class: input_classes,
|
47
|
+
id: local_assigns[:id]
|
48
|
+
}.merge(local_assigns[:attributes] || {})
|
49
|
+
%>
|
50
|
+
<%= tag.div(**input_attributes) do %>
|
51
|
+
<% date_input_items.each do |item| %>
|
52
|
+
<div class="govuk-date-input__item">
|
53
|
+
<%
|
54
|
+
input_mode = item[:inputmode] || "numeric"
|
55
|
+
item_id = item[:id] ? item[:id] : local_assigns[:id] + "-" + item[:name]
|
56
|
+
item_classes = class_names("govuk-date-input__input", item[:classes])
|
57
|
+
name = local_assigns[:namePrefix] ? "#{local_assigns[:namePrefix]}-#{item[:name]}" : item[:name]
|
58
|
+
%>
|
59
|
+
<%=
|
60
|
+
govukInput({
|
61
|
+
label: { text: (item[:label] || item[:name]).capitalize, classes: "govuk-date-input__label" },
|
62
|
+
id: item_id,
|
63
|
+
classes: item_classes,
|
64
|
+
name: name,
|
65
|
+
value: item[:value],
|
66
|
+
type: "text",
|
67
|
+
inputmode: input_mode,
|
68
|
+
autocomplete: item[:autocomplete],
|
69
|
+
pattern: item[:pattern] || "[0-9]*",
|
70
|
+
attributes: item[:attributes]
|
71
|
+
})
|
72
|
+
%>
|
73
|
+
</div>
|
74
|
+
<% end %>
|
75
|
+
<% end %>
|
76
|
+
<% end %>
|
77
|
+
<%
|
78
|
+
form_group_classes = class_names(
|
79
|
+
"govuk-form-group",
|
80
|
+
"govuk-form-group--error" => local_assigns[:errorMessage])
|
81
|
+
%>
|
82
|
+
<%= tag.div(class: form_group_classes) do %>
|
83
|
+
<% if local_assigns[:fieldset] %>
|
84
|
+
<%= govukFieldset({
|
85
|
+
describedBy: described_by,
|
86
|
+
classes: local_assigns[:fieldset].try(:[], :classes),
|
87
|
+
role: 'group',
|
88
|
+
attributes: local_assigns[:fieldset].try(:[], :attributes),
|
89
|
+
legend: local_assigns[:fieldset].try(:[], :legend)
|
90
|
+
}) { date_input } %>
|
91
|
+
<% else %>
|
92
|
+
<%= date_input %>
|
93
|
+
<% end %>
|
94
|
+
<% end %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<%
|
2
|
+
attributes = {
|
3
|
+
class: class_names("govuk-error-message", local_assigns[:classes]),
|
4
|
+
id: local_assigns[:id]
|
5
|
+
}.merge!(local_assigns[:attributes] || {})
|
6
|
+
|
7
|
+
visually_hidden_text = local_assigns[:visuallyHiddenText].nil? ? "Error" : local_assigns[:visuallyHiddenText]
|
8
|
+
%>
|
9
|
+
|
10
|
+
<%= tag.p(**attributes) do %>
|
11
|
+
<span class="govuk-visually-hidden"><%= local_assigns[:visuallyHiddenText].presence || "Error" %>:</span>
|
12
|
+
<%= local_assigns[:html].presence || local_assigns[:text] %>
|
13
|
+
<% end %>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<%
|
2
|
+
div_attributes = {
|
3
|
+
class: class_names("govuk-error-summary", local_assigns[:classes]),
|
4
|
+
"aria-labelledby" => "error-summary-title",
|
5
|
+
role: "alert",
|
6
|
+
data: { module: "govuk-error-summary" }
|
7
|
+
}.merge!(local_assigns[:attributes] || {})
|
8
|
+
div_attributes[:data]["disable-auto-focus"] = true if local_assigns[:disableAutoFocus]
|
9
|
+
%>
|
10
|
+
<%= tag.div **div_attributes do %>
|
11
|
+
<h2 class="govuk-error-summary__title" id="error-summary-title">
|
12
|
+
<%= local_assigns[:titleHtml].presence || local_assigns[:titleText] %>
|
13
|
+
</h2>
|
14
|
+
<div class="govuk-error-summary__body">
|
15
|
+
<% if local_assigns[:descriptionHtml] || local_assigns[:descriptionText] %>
|
16
|
+
<p>
|
17
|
+
<%= local_assigns[:descriptionHtml].presence || local_assigns[:descriptionText] %>
|
18
|
+
</p>
|
19
|
+
<% end %>
|
20
|
+
<ul class="govuk-list govuk-error-summary__list">
|
21
|
+
<% (local_assigns[:errorList] || []).each do |item| %>
|
22
|
+
<li>
|
23
|
+
<% if item[:href].present? %>
|
24
|
+
<%= tag.a (item[:html].presence || item[:text]), href: item[:href], **(item[:attributes] || {}) %>
|
25
|
+
<% else %>
|
26
|
+
<%= item[:html].presence || item[:text] %>
|
27
|
+
<% end %>
|
28
|
+
</li>
|
29
|
+
<% end %>
|
30
|
+
</ul>
|
31
|
+
</div>
|
32
|
+
<% end %>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%
|
2
|
+
fieldset_attributes = {
|
3
|
+
class: class_names("govuk-fieldset", local_assigns[:classes])
|
4
|
+
}
|
5
|
+
fieldset_attributes.merge!(role: local_assigns[:role]) if local_assigns[:role]
|
6
|
+
fieldset_attributes.merge!("aria-describedby" => local_assigns[:describedBy]) if local_assigns[:describedBy]
|
7
|
+
%>
|
8
|
+
<%= tag.fieldset(**fieldset_attributes) do %>
|
9
|
+
<% if local_assigns[:legend].present? %>
|
10
|
+
<%= tag.legend class: "govuk-fieldset__legend #{local_assigns[:legend][:classes]}" do %>
|
11
|
+
<% if local_assigns[:legend][:isPageHeading] %>
|
12
|
+
<%= tag.h1 class: "govuk-fieldset__heading" do %>
|
13
|
+
<%= local_assigns[:legend][:html].presence || local_assigns[:legend][:text] %>
|
14
|
+
<% end %>
|
15
|
+
<% else %>
|
16
|
+
<%= local_assigns[:legend][:html].presence || local_assigns[:legend][:text] %>
|
17
|
+
<% end %>
|
18
|
+
<% end %>
|
19
|
+
<% end %>
|
20
|
+
<%= capture(&block) %>
|
21
|
+
<% end %>
|
@@ -0,0 +1,64 @@
|
|
1
|
+
<%
|
2
|
+
header_classes = class_names(
|
3
|
+
"govuk-header",
|
4
|
+
local_assigns[:classes]
|
5
|
+
)
|
6
|
+
header_attributes = {
|
7
|
+
class: header_classes,
|
8
|
+
role: "banner",
|
9
|
+
"data-module" => "govuk-header"
|
10
|
+
}.merge!(local_assigns[:attributes].presence || {})
|
11
|
+
%>
|
12
|
+
<%
|
13
|
+
container_classes = class_names(
|
14
|
+
"govuk-header__container",
|
15
|
+
{ "govuk-width-container" => local_assigns[:containerClasses].blank? },
|
16
|
+
local_assigns[:containerClasses]
|
17
|
+
)
|
18
|
+
%>
|
19
|
+
|
20
|
+
<%= tag.header(**header_attributes) do %>
|
21
|
+
<%= tag.div(class: container_classes) do %>
|
22
|
+
<div class="govuk-header__logo">
|
23
|
+
<a href="<%=local_assigns[:homepageUrl]%>" class="govuk-header__link govuk-header__link--homepage">
|
24
|
+
<span class="govuk-header__logotype">
|
25
|
+
<svg aria-hidden="true" focusable="false" class="govuk-header__logotype-crown" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 132 97" height="30" width="36">
|
26
|
+
<path fill="currentColor" fill-rule="evenodd" d="M25 30.2c3.5 1.5 7.7-.2 9.1-3.7 1.5-3.6-.2-7.8-3.9-9.2-3.6-1.4-7.6.3-9.1 3.9-1.4 3.5.3 7.5 3.9 9zM9 39.5c3.6 1.5 7.8-.2 9.2-3.7 1.5-3.6-.2-7.8-3.9-9.1-3.6-1.5-7.6.2-9.1 3.8-1.4 3.5.3 7.5 3.8 9zM4.4 57.2c3.5 1.5 7.7-.2 9.1-3.8 1.5-3.6-.2-7.7-3.9-9.1-3.5-1.5-7.6.3-9.1 3.8-1.4 3.5.3 7.6 3.9 9.1zm38.3-21.4c3.5 1.5 7.7-.2 9.1-3.8 1.5-3.6-.2-7.7-3.9-9.1-3.6-1.5-7.6.3-9.1 3.8-1.3 3.6.4 7.7 3.9 9.1zm64.4-5.6c-3.6 1.5-7.8-.2-9.1-3.7-1.5-3.6.2-7.8 3.8-9.2 3.6-1.4 7.7.3 9.2 3.9 1.3 3.5-.4 7.5-3.9 9zm15.9 9.3c-3.6 1.5-7.7-.2-9.1-3.7-1.5-3.6.2-7.8 3.7-9.1 3.6-1.5 7.7.2 9.2 3.8 1.5 3.5-.3 7.5-3.8 9zm4.7 17.7c-3.6 1.5-7.8-.2-9.2-3.8-1.5-3.6.2-7.7 3.9-9.1 3.6-1.5 7.7.3 9.2 3.8 1.3 3.5-.4 7.6-3.9 9.1zM89.3 35.8c-3.6 1.5-7.8-.2-9.2-3.8-1.4-3.6.2-7.7 3.9-9.1 3.6-1.5 7.7.3 9.2 3.8 1.4 3.6-.3 7.7-3.9 9.1zM69.7 17.7l8.9 4.7V9.3l-8.9 2.8c-.2-.3-.5-.6-.9-.9L72.4 0H59.6l3.5 11.2c-.3.3-.6.5-.9.9l-8.8-2.8v13.1l8.8-4.7c.3.3.6.7.9.9l-5 15.4v.1c-.2.8-.4 1.6-.4 2.4 0 4.1 3.1 7.5 7 8.1h.2c.3 0 .7.1 1 .1.4 0 .7 0 1-.1h.2c4-.6 7.1-4.1 7.1-8.1 0-.8-.1-1.7-.4-2.4V34l-5.1-15.4c.4-.2.7-.6 1-.9zM66 92.8c16.9 0 32.8 1.1 47.1 3.2 4-16.9 8.9-26.7 14-33.5l-9.6-3.4c1 4.9 1.1 7.2 0 10.2-1.5-1.4-3-4.3-4.2-8.7L108.6 76c2.8-2 5-3.2 7.5-3.3-4.4 9.4-10 11.9-13.6 11.2-4.3-.8-6.3-4.6-5.6-7.9 1-4.7 5.7-5.9 8-.5 4.3-8.7-3-11.4-7.6-8.8 7.1-7.2 7.9-13.5 2.1-21.1-8 6.1-8.1 12.3-4.5 20.8-4.7-5.4-12.1-2.5-9.5 6.2 3.4-5.2 7.9-2 7.2 3.1-.6 4.3-6.4 7.8-13.5 7.2-10.3-.9-10.9-8-11.2-13.8 2.5-.5 7.1 1.8 11 7.3L80.2 60c-4.1 4.4-8 5.3-12.3 5.4 1.4-4.4 8-11.6 8-11.6H55.5s6.4 7.2 7.9 11.6c-4.2-.1-8-1-12.3-5.4l1.4 16.4c3.9-5.5 8.5-7.7 10.9-7.3-.3 5.8-.9 12.8-11.1 13.8-7.2.6-12.9-2.9-13.5-7.2-.7-5 3.8-8.3 7.1-3.1 2.7-8.7-4.6-11.6-9.4-6.2 3.7-8.5 3.6-14.7-4.6-20.8-5.8 7.6-5 13.9 2.2 21.1-4.7-2.6-11.9.1-7.7 8.8 2.3-5.5 7.1-4.2 8.1.5.7 3.3-1.3 7.1-5.7 7.9-3.5.7-9-1.8-13.5-11.2 2.5.1 4.7 1.3 7.5 3.3l-4.7-15.4c-1.2 4.4-2.7 7.2-4.3 8.7-1.1-3-.9-5.3 0-10.2l-9.5 3.4c5 6.9 9.9 16.7 14 33.5 14.8-2.1 30.8-3.2 47.7-3.2z"></path>
|
27
|
+
</svg>
|
28
|
+
<span class="govuk-header__logotype-text">
|
29
|
+
GOV.UK
|
30
|
+
</span>
|
31
|
+
</span>
|
32
|
+
</a>
|
33
|
+
</div>
|
34
|
+
<% if (local_assigns[:serviceName] || local_assigns[:navigation]) %>
|
35
|
+
<div class="govuk-header__content">
|
36
|
+
<% if local_assigns[:serviceName] %>
|
37
|
+
<% if local_assigns[:serviceUrl] %>
|
38
|
+
<a href="<%=local_assigns[:serviceUrl]%>" class="govuk-header__link govuk-header__link--service-name">
|
39
|
+
<%= local_assigns[:serviceName] %>
|
40
|
+
</a>
|
41
|
+
<% else %>
|
42
|
+
<span class="govuk-header__service-name"><%= local_assigns[:serviceName] %></span>
|
43
|
+
<% end %>
|
44
|
+
<% end %>
|
45
|
+
<% if local_assigns[:navigation] %>
|
46
|
+
<nav aria-label="Menu" class="govuk-header__navigation">
|
47
|
+
<button type="button" class="govuk-header__menu-button govuk-js-header-toggle" aria-controls="navigation" aria-label="Show or hide menu" hidden>Menu</button>
|
48
|
+
<ul id="navigation" class="govuk-header__navigation-list">
|
49
|
+
<% local_assigns[:navigation].each do |item| %>
|
50
|
+
<% item_classes = class_names("govuk-header__navigation-item", "govuk-header__navigation-item--active" => item[:active]) %>
|
51
|
+
<% item_attributes = { class: item_classes }.merge!(item[:attributes].presence || {}) %>
|
52
|
+
<%= tag.li(**item_attributes) do %>
|
53
|
+
<a href="<%= item[:href] %>" class="govuk-header__link">
|
54
|
+
<%= item[:text] %>
|
55
|
+
</a>
|
56
|
+
<% end %>
|
57
|
+
<% end %>
|
58
|
+
</ul>
|
59
|
+
</nav>
|
60
|
+
<% end %>
|
61
|
+
</div>
|
62
|
+
<% end %>
|
63
|
+
<% end %>
|
64
|
+
<% end %>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<%
|
2
|
+
div_attributes = {
|
3
|
+
class: class_names("govuk-hint", local_assigns[:classes]),
|
4
|
+
}.merge!(local_assigns[:attributes].presence || {})
|
5
|
+
div_attributes[:id] = local_assigns[:id] if local_assigns[:id].present?
|
6
|
+
%>
|
7
|
+
<%= tag.div local_assigns[:html] || local_assigns[:text], **div_attributes %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= tag.hr class: class_names("govuk-section-break", classes) %>
|
@@ -0,0 +1,97 @@
|
|
1
|
+
<% described_by = local_assigns[:describedBy] %>
|
2
|
+
<% form_group_classes = class_names(
|
3
|
+
'govuk-form-group',
|
4
|
+
{ 'govuk-form-group--error' => local_assigns[:errorMessage] },
|
5
|
+
local_assigns.dig(:formGroup, :classes)
|
6
|
+
)
|
7
|
+
%>
|
8
|
+
<div class="<%= form_group_classes %>">
|
9
|
+
<%= render('components/govuk_label',
|
10
|
+
html: local_assigns.dig(:label, :html),
|
11
|
+
text: local_assigns.dig(:label, :text),
|
12
|
+
classes: local_assigns.dig(:label, :classes),
|
13
|
+
isPageHeading: local_assigns.dig(:label, :isPageHeading),
|
14
|
+
attributes: local_assigns.dig(:label, :attributes),
|
15
|
+
for: local_assigns.dig(:id)
|
16
|
+
)
|
17
|
+
%>
|
18
|
+
|
19
|
+
<% if local_assigns[:hint] %>
|
20
|
+
<% hint_id = local_assigns[:id] + '-hint' %>
|
21
|
+
<% described_by = described_by ? described_by + ' ' + hint_id : hint_id %>
|
22
|
+
<%= render('components/govuk_hint',
|
23
|
+
id: hint_id,
|
24
|
+
classes: local_assigns.dig(:hint, :classes),
|
25
|
+
attributes: local_assigns.dig(:hint, :attributes),
|
26
|
+
html: local_assigns.dig(:hint, :html),
|
27
|
+
text: local_assigns.dig(:hint, :text)
|
28
|
+
)
|
29
|
+
%>
|
30
|
+
<% end %>
|
31
|
+
|
32
|
+
<% if local_assigns[:errorMessage] %>
|
33
|
+
<% error_id = local_assigns[:id] + '-error' %>
|
34
|
+
<% described_by = described_by ? described_by + ' ' + error_id : error_id %>
|
35
|
+
<%= render('components/govuk_error_message',
|
36
|
+
id: error_id,
|
37
|
+
classes: local_assigns.dig(:errorMessage, :classes),
|
38
|
+
attributes: local_assigns.dig(:errorMessage, :attributes),
|
39
|
+
html: local_assigns.dig(:errorMessage, :html),
|
40
|
+
text: local_assigns.dig(:errorMessage, :text),
|
41
|
+
visuallyHiddenText: local_assigns.dig(:errorMessage, :visuallyHiddenText)
|
42
|
+
)
|
43
|
+
%>
|
44
|
+
<% end %>
|
45
|
+
|
46
|
+
<% if local_assigns[:prefix] || local_assigns[:suffix] %><div class="govuk-input__wrapper"><% end %>
|
47
|
+
|
48
|
+
<% if local_assigns.dig(:prefix, :text) || local_assigns.dig(:prefix, :html) %>
|
49
|
+
<% prefix_attributes = {
|
50
|
+
class: class_names(
|
51
|
+
'govuk-input__prefix',
|
52
|
+
local_assigns.dig(:prefix, :classes)
|
53
|
+
),
|
54
|
+
'aria-hidden': true
|
55
|
+
}
|
56
|
+
prefix_attributes.merge!(local_assigns.dig(:prefix, :attributes)) if local_assigns.dig(:prefix, :attributes)
|
57
|
+
prefix_content = local_assigns.dig(:prefix, :html) || local_assigns.dig(:prefix, :text)
|
58
|
+
%>
|
59
|
+
<%= tag.div prefix_content, **prefix_attributes %>
|
60
|
+
<% end %>
|
61
|
+
|
62
|
+
<% input_attributes = {
|
63
|
+
class: class_names(
|
64
|
+
'govuk-input',
|
65
|
+
local_assigns[:classes],
|
66
|
+
{ 'govuk-input--error' => local_assigns[:errorMessage] }
|
67
|
+
),
|
68
|
+
id: local_assigns[:id],
|
69
|
+
name: local_assigns[:name],
|
70
|
+
type: local_assigns[:type] || "text"
|
71
|
+
}
|
72
|
+
input_attributes[:spellcheck] = local_assigns[:spellcheck] if !local_assigns[:spellcheck].nil?
|
73
|
+
input_attributes[:value] = local_assigns[:value] if local_assigns[:value]
|
74
|
+
input_attributes[:'aria-describedby'] = described_by if described_by.present?
|
75
|
+
input_attributes[:autocomplete] = local_assigns[:autocomplete] if local_assigns[:autocomplete]
|
76
|
+
input_attributes[:pattern] = local_assigns[:pattern] if local_assigns[:pattern]
|
77
|
+
input_attributes[:inputmode] = local_assigns[:inputmode] if local_assigns[:inputmode]
|
78
|
+
input_attributes.merge!(local_assigns[:attributes]) if local_assigns[:attributes]
|
79
|
+
%>
|
80
|
+
<%= tag.input **input_attributes %>
|
81
|
+
|
82
|
+
<% if local_assigns.dig(:suffix, :text) || local_assigns.dig(:suffix, :html) %>
|
83
|
+
<% suffix_attributes = {
|
84
|
+
class: class_names(
|
85
|
+
'govuk-input__suffix',
|
86
|
+
local_assigns.dig(:suffix, :classes)
|
87
|
+
),
|
88
|
+
'aria-hidden': true
|
89
|
+
}
|
90
|
+
suffix_attributes.merge!(local_assigns.dig(:suffix, :attributes)) if local_assigns.dig(:suffix, :attributes)
|
91
|
+
suffix_content = local_assigns.dig(:suffix, :html) || local_assigns.dig(:suffix, :text)
|
92
|
+
%>
|
93
|
+
<%= tag.div suffix_content, **suffix_attributes %>
|
94
|
+
<% end %>
|
95
|
+
|
96
|
+
<% if local_assigns[:prefix] || local_assigns[:suffix] %></div><% end %>
|
97
|
+
</div>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<%
|
2
|
+
div_attributes = {
|
3
|
+
class: class_names("govuk-inset-text", local_assigns[:classes]),
|
4
|
+
}.merge!(local_assigns[:attributes].presence || {})
|
5
|
+
div_attributes[:id] = local_assigns[:id] if local_assigns[:id].present?
|
6
|
+
%>
|
7
|
+
<%= tag.div **div_attributes do %>
|
8
|
+
<%= local_assigns[:html] || local_assigns[:text] %>
|
9
|
+
<%= capture(&block) if block %>
|
10
|
+
<% end %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<%
|
2
|
+
if local_assigns[:html].present? || local_assigns[:text].present?
|
3
|
+
label_attributes = {
|
4
|
+
class: class_names("govuk-label", local_assigns[:classes])
|
5
|
+
}.merge!(local_assigns[:attributes] || {})
|
6
|
+
label_attributes[:for] = local_assigns[:for] if local_assigns[:for].present?
|
7
|
+
label_html = capture do
|
8
|
+
tag.label (local_assigns[:html].presence || local_assigns[:text]), **label_attributes
|
9
|
+
end
|
10
|
+
end
|
11
|
+
%>
|
12
|
+
<% if local_assigns[:isPageHeading] %>
|
13
|
+
<h1 class="govuk-label-wrapper">
|
14
|
+
<%= label_html %>
|
15
|
+
</h1>
|
16
|
+
<% else %>
|
17
|
+
<%= label_html %>
|
18
|
+
<% end %>
|
@@ -0,0 +1,68 @@
|
|
1
|
+
<%
|
2
|
+
banner_type = local_assigns[:type]&.to_s
|
3
|
+
if banner_type == "success"
|
4
|
+
success_banner = true
|
5
|
+
type_class = "govuk-notification-banner--" + banner_type
|
6
|
+
end
|
7
|
+
|
8
|
+
role = if local_assigns[:role]
|
9
|
+
local_assigns[:role]
|
10
|
+
elsif success_banner
|
11
|
+
"alert"
|
12
|
+
else
|
13
|
+
"region"
|
14
|
+
end
|
15
|
+
|
16
|
+
title = if local_assigns[:titleHtml]
|
17
|
+
local_assigns[:titleHtml]
|
18
|
+
elsif local_assigns[:titleText]
|
19
|
+
local_assigns[:titleText]
|
20
|
+
elsif success_banner
|
21
|
+
"Success"
|
22
|
+
else
|
23
|
+
"Important"
|
24
|
+
end
|
25
|
+
|
26
|
+
banner_classes = class_names(
|
27
|
+
"govuk-notification-banner",
|
28
|
+
type_class,
|
29
|
+
local_assigns[:classes]
|
30
|
+
)
|
31
|
+
|
32
|
+
labelled_by = local_assigns[:titleId] || "govuk-notification-banner-title"
|
33
|
+
|
34
|
+
attributes = {
|
35
|
+
role: role,
|
36
|
+
"aria-labelledby" => labelled_by,
|
37
|
+
"data-module" => "govuk-notification-banner",
|
38
|
+
class: banner_classes
|
39
|
+
}.merge(local_assigns[:attributes] || {})
|
40
|
+
|
41
|
+
attributes.merge!({ "data-disable-auto-focus" => true }) if local_assigns[:disableAutoFocus]
|
42
|
+
|
43
|
+
title_heading_level = local_assigns[:title_heading_level] ? "h#{local_assigns[:title_heading_level]}" : "h2"
|
44
|
+
|
45
|
+
header_attributes = {
|
46
|
+
class: "govuk-notification-banner__title",
|
47
|
+
id: labelled_by
|
48
|
+
}
|
49
|
+
%>
|
50
|
+
|
51
|
+
<%= tag.div **attributes do %>
|
52
|
+
<div class="govuk-notification-banner__header">
|
53
|
+
<%= tag.send(title_heading_level, **header_attributes) do %>
|
54
|
+
<%= title %>
|
55
|
+
<% end %>
|
56
|
+
</div>
|
57
|
+
<div class="govuk-notification-banner__content">
|
58
|
+
<% if local_assigns[:block] %>
|
59
|
+
<%= capture &block %>
|
60
|
+
<% elsif local_assigns[:html] %>
|
61
|
+
<%= local_assigns[:html] %>
|
62
|
+
<% elsif local_assigns[:text] %>
|
63
|
+
<p class="govuk-notification-banner__heading">
|
64
|
+
<%= local_assigns[:text] %>
|
65
|
+
</p>
|
66
|
+
<% end %>
|
67
|
+
</div>
|
68
|
+
<% end %>
|