govuk-components 1.2.0 → 2.0.0b5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/components/govuk_component/{accordion.html.erb → accordion_component.html.erb} +1 -1
- data/app/components/govuk_component/{accordion.rb → accordion_component.rb} +13 -14
- data/app/components/govuk_component/{back_link.rb → back_link_component.rb} +6 -2
- data/app/components/govuk_component/base.rb +9 -7
- data/app/components/govuk_component/{breadcrumbs.html.erb → breadcrumbs_component.html.erb} +3 -6
- data/app/components/govuk_component/{breadcrumbs.rb → breadcrumbs_component.rb} +4 -4
- data/app/components/govuk_component/{cookie_banner.html.erb → cookie_banner_component.html.erb} +2 -6
- data/app/components/govuk_component/{cookie_banner.rb → cookie_banner_component.rb} +1 -1
- data/app/components/govuk_component/details_component.rb +40 -0
- data/app/components/govuk_component/{footer.html.erb → footer_component.html.erb} +3 -5
- data/app/components/govuk_component/{footer.rb → footer_component.rb} +4 -9
- data/app/components/govuk_component/header_component.html.erb +49 -0
- data/app/components/govuk_component/header_component.rb +112 -0
- data/app/components/govuk_component/{inset_text.rb → inset_text_component.rb} +4 -4
- data/app/components/govuk_component/notification_banner_component.html.erb +14 -0
- data/app/components/govuk_component/{notification_banner.rb → notification_banner_component.rb} +30 -16
- data/app/components/govuk_component/panel_component.rb +46 -0
- data/app/components/govuk_component/phase_banner_component.html.erb +6 -0
- data/app/components/govuk_component/phase_banner_component.rb +20 -0
- data/app/components/govuk_component/start_button_component.rb +47 -0
- data/app/components/govuk_component/summary_list_component.html.erb +11 -0
- data/app/components/govuk_component/summary_list_component.rb +64 -0
- data/app/components/govuk_component/tab_component.html.erb +11 -0
- data/app/components/govuk_component/{tabs.rb → tab_component.rb} +23 -12
- data/app/components/govuk_component/tag_component.rb +48 -0
- data/app/components/govuk_component/warning_text_component.rb +38 -0
- data/app/helpers/govuk_components_helper.rb +16 -16
- data/app/helpers/govuk_link_helper.rb +39 -4
- data/lib/govuk/components.rb +1 -0
- data/lib/govuk/components/helpers/css_utilities.rb +22 -0
- data/lib/govuk/components/version.rb +1 -1
- metadata +48 -53
- data/app/components/govuk_component/back_link.html.erb +0 -1
- data/app/components/govuk_component/details.html.erb +0 -10
- data/app/components/govuk_component/details.rb +0 -16
- data/app/components/govuk_component/header.html.erb +0 -50
- data/app/components/govuk_component/header.rb +0 -66
- data/app/components/govuk_component/notification_banner.html.erb +0 -23
- data/app/components/govuk_component/panel.html.erb +0 -13
- data/app/components/govuk_component/panel.rb +0 -28
- data/app/components/govuk_component/phase_banner.html.erb +0 -8
- data/app/components/govuk_component/phase_banner.rb +0 -16
- data/app/components/govuk_component/slot.rb +0 -9
- data/app/components/govuk_component/start_now_button.html.erb +0 -6
- data/app/components/govuk_component/start_now_button.rb +0 -16
- data/app/components/govuk_component/summary_list.html.erb +0 -19
- data/app/components/govuk_component/summary_list.rb +0 -34
- data/app/components/govuk_component/tabs.html.erb +0 -19
- data/app/components/govuk_component/tag.rb +0 -30
- data/app/components/govuk_component/warning.html.erb +0 -7
- data/app/components/govuk_component/warning.rb +0 -14
@@ -1,23 +0,0 @@
|
|
1
|
-
<%= tag.div(class: classes.append(success_class).compact, role: "region", aria: { labelledby: title_id }, data: data_params, **html_attributes) do %>
|
2
|
-
<div class="govuk-notification-banner__header">
|
3
|
-
<%= content_tag(title_tag, class: "govuk-notification-banner__title", id: title_id) do %>
|
4
|
-
<%= title %>
|
5
|
-
<% end %>
|
6
|
-
</div>
|
7
|
-
<div class="govuk-notification-banner__content">
|
8
|
-
<% headings.each do |heading| %>
|
9
|
-
<p class="govuk-notification-banner__heading">
|
10
|
-
<% if heading.text.present? %>
|
11
|
-
<%= heading.text %>
|
12
|
-
<% if heading.link_target && heading.link_text %>
|
13
|
-
<%= link_to(heading.link_text, heading.link_target, class: "govuk-notification-banner__link") %>.
|
14
|
-
<% end %>
|
15
|
-
<% else %>
|
16
|
-
<%= heading.content %>
|
17
|
-
<% end %>
|
18
|
-
</p>
|
19
|
-
<% end %>
|
20
|
-
|
21
|
-
<%= content %>
|
22
|
-
</div>
|
23
|
-
<% end %>
|
@@ -1,13 +0,0 @@
|
|
1
|
-
<%= tag.div(class: classes, **html_attributes) do %>
|
2
|
-
<% if display_title? %>
|
3
|
-
<h1 class="govuk-panel__title">
|
4
|
-
<%= @title %>
|
5
|
-
</h1>
|
6
|
-
<% end %>
|
7
|
-
|
8
|
-
<% if display_body? %>
|
9
|
-
<div class="govuk-panel__body">
|
10
|
-
<%= content.presence || @body %>
|
11
|
-
</div>
|
12
|
-
<% end %>
|
13
|
-
<% end %>
|
@@ -1,28 +0,0 @@
|
|
1
|
-
class GovukComponent::Panel < GovukComponent::Base
|
2
|
-
attr_accessor :title, :body
|
3
|
-
|
4
|
-
def initialize(title: nil, body: nil, classes: [], html_attributes: {})
|
5
|
-
super(classes: classes, html_attributes: html_attributes)
|
6
|
-
|
7
|
-
@title = title
|
8
|
-
@body = body
|
9
|
-
end
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def default_classes
|
14
|
-
%w(govuk-panel govuk-panel--confirmation)
|
15
|
-
end
|
16
|
-
|
17
|
-
def display_title?
|
18
|
-
@title.present?
|
19
|
-
end
|
20
|
-
|
21
|
-
def display_body?
|
22
|
-
[@body, content].any?(&:present?)
|
23
|
-
end
|
24
|
-
|
25
|
-
def render?
|
26
|
-
display_title? || display_body?
|
27
|
-
end
|
28
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
class GovukComponent::PhaseBanner < GovukComponent::Base
|
2
|
-
attr_accessor :phase_tag, :text
|
3
|
-
|
4
|
-
def initialize(phase_tag: nil, text: nil, classes: [], html_attributes: {})
|
5
|
-
super(classes: classes, html_attributes: html_attributes)
|
6
|
-
|
7
|
-
@phase_tag = GovukComponent::Tag.new(classes: "govuk-phase-banner__content__tag", **phase_tag)
|
8
|
-
@text = text
|
9
|
-
end
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def default_classes
|
14
|
-
%w(govuk-phase-banner)
|
15
|
-
end
|
16
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
class GovukComponent::Slot < ViewComponent::Slot
|
2
|
-
include GovukComponent::Traits::CustomClasses
|
3
|
-
include GovukComponent::Traits::CustomHtmlAttributes
|
4
|
-
|
5
|
-
def initialize(classes: [], html_attributes: {})
|
6
|
-
@classes = parse_classes(classes)
|
7
|
-
@html_attributes = html_attributes
|
8
|
-
end
|
9
|
-
end
|
@@ -1,6 +0,0 @@
|
|
1
|
-
<%= link_to(@href, role: 'button', draggable: 'false', class: classes, data: { module: 'govuk-button' }, **html_attributes) do %>
|
2
|
-
<%= @text %>
|
3
|
-
<svg class="govuk-button__start-icon" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19" viewBox="0 0 33 40" aria-hidden="true" focusable="false">
|
4
|
-
<path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z" />
|
5
|
-
</svg>
|
6
|
-
<% end %>
|
@@ -1,16 +0,0 @@
|
|
1
|
-
class GovukComponent::StartNowButton < GovukComponent::Base
|
2
|
-
attr_accessor :text, :href
|
3
|
-
|
4
|
-
def initialize(text:, href:, classes: [], html_attributes: {})
|
5
|
-
super(classes: classes, html_attributes: html_attributes)
|
6
|
-
|
7
|
-
@text = text
|
8
|
-
@href = href
|
9
|
-
end
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def default_classes
|
14
|
-
%w(govuk-button govuk-button--start)
|
15
|
-
end
|
16
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
<%= tag.dl(class: classes, **html_attributes) do %>
|
2
|
-
<% rows.each do |row| %>
|
3
|
-
<%= tag.div(class: row.classes, **row.html_attributes) do %>
|
4
|
-
<dt class="govuk-summary-list__key">
|
5
|
-
<%= row.key %>
|
6
|
-
</dt>
|
7
|
-
|
8
|
-
<dd class="govuk-summary-list__value">
|
9
|
-
<%= row.value %>
|
10
|
-
</dd>
|
11
|
-
|
12
|
-
<% if any_row_has_actions? %>
|
13
|
-
<dd class="govuk-summary-list__actions">
|
14
|
-
<%= row.action %>
|
15
|
-
</dd>
|
16
|
-
<% end %>
|
17
|
-
<% end %>
|
18
|
-
<% end %>
|
19
|
-
<% end %>
|
@@ -1,34 +0,0 @@
|
|
1
|
-
class GovukComponent::SummaryList < GovukComponent::Base
|
2
|
-
include ViewComponent::Slotable
|
3
|
-
|
4
|
-
with_slot :row, collection: true, class_name: 'Row'
|
5
|
-
wrap_slot :row
|
6
|
-
|
7
|
-
def any_row_has_actions?
|
8
|
-
rows.any? { |r| r.action.present? }
|
9
|
-
end
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def default_classes
|
14
|
-
%w(govuk-summary-list)
|
15
|
-
end
|
16
|
-
|
17
|
-
class Row < GovukComponent::Slot
|
18
|
-
attr_accessor :key, :value, :action
|
19
|
-
|
20
|
-
def initialize(key:, value:, action: nil, classes: [], html_attributes: {})
|
21
|
-
super(classes: classes, html_attributes: html_attributes)
|
22
|
-
|
23
|
-
self.key = key
|
24
|
-
self.value = value
|
25
|
-
self.action = action
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def default_classes
|
31
|
-
%w(govuk-summary-list__row)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
<%= tag.div(class: classes, data: { module: 'govuk-tabs' }, **html_attributes) do %>
|
2
|
-
<h2 class="govuk-tabs__title">
|
3
|
-
<%= title %>
|
4
|
-
</h2>
|
5
|
-
<ul class="govuk-tabs__list">
|
6
|
-
<% tabs.each.with_index do |tab, i| %>
|
7
|
-
<li class="govuk-tabs__list-item <%= 'govuk-tabs__list-item--selected' if i.zero? %>">
|
8
|
-
<a class="govuk-tabs__tab" href="<%= tab.id(prefix: '#') %>">
|
9
|
-
<%= tab.title %>
|
10
|
-
</a>
|
11
|
-
</li>
|
12
|
-
<% end %>
|
13
|
-
</ul>
|
14
|
-
<% tabs.each.with_index do |tab, i| %>
|
15
|
-
<%= tag.div(class: tab.classes.append(tab.hidden_class(i)), id: tab.id, **tab.html_attributes) do %>
|
16
|
-
<%= tab.content %>
|
17
|
-
<% end %>
|
18
|
-
<% end %>
|
19
|
-
<% end %>
|
@@ -1,30 +0,0 @@
|
|
1
|
-
class GovukComponent::Tag < GovukComponent::Base
|
2
|
-
attr_reader :text
|
3
|
-
|
4
|
-
COLOURS = %w(grey green turquoise blue red purple pink orange yellow).freeze
|
5
|
-
|
6
|
-
def initialize(text:, colour: nil, classes: [], html_attributes: {})
|
7
|
-
super(classes: classes, html_attributes: html_attributes)
|
8
|
-
|
9
|
-
@text = text
|
10
|
-
@colour = colour
|
11
|
-
end
|
12
|
-
|
13
|
-
def call
|
14
|
-
tag.strong(@text, class: classes.append(colour_class), **html_attributes)
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def default_classes
|
20
|
-
%w(govuk-tag)
|
21
|
-
end
|
22
|
-
|
23
|
-
def colour_class
|
24
|
-
return nil if @colour.blank?
|
25
|
-
|
26
|
-
fail("invalid tag colour #{@colour}, supported colours are #{COLOURS.to_sentence}") unless @colour.in?(COLOURS)
|
27
|
-
|
28
|
-
%(govuk-tag--#{@colour})
|
29
|
-
end
|
30
|
-
end
|
@@ -1,7 +0,0 @@
|
|
1
|
-
<%= content_tag('div', class: classes, **html_attributes) do %>
|
2
|
-
<span class="govuk-warning-text__icon" aria-hidden="true">!</span>
|
3
|
-
<strong class="govuk-warning-text__text">
|
4
|
-
<span class="govuk-warning-text__assistive"><%= @icon_fallback_text %></span>
|
5
|
-
<%= @text %>
|
6
|
-
</strong>
|
7
|
-
<% end %>
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class GovukComponent::Warning < GovukComponent::Base
|
2
|
-
def initialize(text:, icon_fallback_text: 'Warning', classes: [], html_attributes: {})
|
3
|
-
super(classes: classes, html_attributes: html_attributes)
|
4
|
-
|
5
|
-
@text = text
|
6
|
-
@icon_fallback_text = icon_fallback_text
|
7
|
-
end
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
def default_classes
|
12
|
-
%w(govuk-warning-text)
|
13
|
-
end
|
14
|
-
end
|