govuk-components 2.1.5 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +53 -50
- data/app/components/govuk_component/back_link_component.rb +2 -2
- data/app/components/govuk_component/cookie_banner_component.rb +18 -16
- data/app/components/govuk_component/details_component.rb +1 -1
- data/app/components/govuk_component/footer_component.html.erb +3 -1
- data/app/components/govuk_component/header_component.html.erb +5 -5
- data/app/components/govuk_component/phase_banner_component.rb +1 -1
- data/app/components/govuk_component/summary_list_component/action_component.rb +4 -5
- data/app/components/govuk_component/summary_list_component/row_component.rb +8 -4
- data/app/components/govuk_component/summary_list_component.rb +33 -27
- data/app/components/govuk_component/table_component/body_component.rb +1 -1
- data/app/components/govuk_component/table_component/cell_component.rb +6 -6
- data/app/components/govuk_component/table_component/head_component.rb +1 -1
- data/app/components/govuk_component/table_component/row_component.rb +1 -1
- data/app/components/govuk_component/table_component.rb +25 -23
- data/app/components/govuk_component/traits.rb +1 -0
- data/app/components/govuk_component/warning_text_component.rb +4 -4
- data/app/components/govuk_component.rb +1 -0
- data/app/helpers/govuk_link_helper.rb +6 -2
- data/app/helpers/govuk_skip_link_helper.rb +4 -2
- data/lib/govuk/components/engine.rb +2 -0
- data/lib/govuk/components/version.rb +1 -1
- data/lib/govuk/components.rb +2 -1
- metadata +149 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27b0a10c2ac5ff55db6e0728ca288f9e3e93a64a284c92a14314c6aa46997273
|
4
|
+
data.tar.gz: 19db68d4d07e8996a17ceb8f19dbe31635d8b8a88055f8f51614d0a5bee2be0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a00087e5c6851c4061f8128668e6c92ad0b10af024439c5105f78b8a32659c593a48d4e85b450348c3776714fe6da3dea3eb217163da70d3381f67c5470ce5cd
|
7
|
+
data.tar.gz: 63884ab095f6c87054d1bcb6d3b1afeaca1e8a797a4bffd282c45007fff3a0f64b4cbebde4f91299a061fb7f8003c93d984a90ef12608285ef58d7fd5fee307e
|
data/README.md
CHANGED
@@ -2,47 +2,52 @@
|
|
2
2
|
|
3
3
|
[](https://github.com/DFE-Digital/govuk-components/actions?query=workflow%3ATests)
|
4
4
|
[](https://codeclimate.com/github/DFE-Digital/govuk-components/maintainability)
|
5
|
+
[](https://badge.fury.io/rb/govuk-components)
|
6
|
+
[](https://rubygems.org/gems/govuk-components)
|
5
7
|
[](https://codeclimate.com/github/DFE-Digital/govuk-components/test_coverage)
|
6
|
-
[](https://github.com/DFE-Digital/govuk-components/blob/
|
7
|
-
[](https://github.com/DFE-Digital/govuk-components/blob/main/LICENSE)
|
9
|
+
[](https://design-system.service.gov.uk)
|
10
|
+
[](https://weblog.rubyonrails.org/releases/)
|
11
|
+
[](https://www.ruby-lang.org/en/downloads/)
|
8
12
|
|
9
|
-
This gem provides a suite of reusable components for the [GOV.UK Design System](https://design-system.service.gov.uk/). It is intended to provide a lightweight alternative to the [GOV.UK Publishing Components](https://github.com/alphagov/govuk_publishing_components) library and is built with
|
13
|
+
This gem provides a suite of reusable components for the [GOV.UK Design System](https://design-system.service.gov.uk/). It is intended to provide a lightweight alternative to the [GOV.UK Publishing Components](https://github.com/alphagov/govuk_publishing_components) library and is built with GitHub’s [ViewComponent](https://github.com/github/view_component) framework.
|
10
14
|
|
11
15
|
It aims to implement the functionality from the original Nunjucks macros in a way that will feel more familiar to Rails developers. Blocks are preferred over strings of HTML, beneath the surface each component is just a Ruby object, everything is inheritable and overrideable.
|
12
16
|
|
13
|
-
## What
|
17
|
+
## What’s included?
|
14
18
|
|
15
|
-
All of the non-form components from the GOV.UK Design System are
|
19
|
+
All of the non-form components from the GOV.UK Design System are implemented by this library as ViewComponents. Form components are implemented by the [GOV.UK Form Builder](https://govuk-form-builder.netlify.app/).
|
16
20
|
|
17
21
|
The provided components are:
|
18
22
|
|
19
|
-
* [Accordion](https://
|
20
|
-
* [Back link](https://
|
21
|
-
* [Back to top link](https://
|
22
|
-
* [Breadcrumbs](https://
|
23
|
-
* [Cookie banner](https://
|
24
|
-
* [Details](https://
|
25
|
-
* [Footer](https://
|
26
|
-
* [Header](https://
|
27
|
-
* [Inset text](https://
|
28
|
-
* [Notification banner](https://
|
29
|
-
* [Panel](https://
|
30
|
-
* [Phase banner](https://
|
31
|
-
* [Skip link](https://
|
32
|
-
* [Start button](https://
|
33
|
-
* [Summary list](https://
|
34
|
-
* [Tabs](https://
|
35
|
-
* [Tables](https://
|
36
|
-
* [Tags](https://
|
37
|
-
* [Warning text](https://
|
38
|
-
|
39
|
-
This library also provides [
|
23
|
+
* [Accordion](https://govuk-components.netlify.app/components/accordion)
|
24
|
+
* [Back link](https://govuk-components.netlify.app/components/back-links)
|
25
|
+
* [Back to top link](https://govuk-components.netlify.app/components/back-to-top-link)
|
26
|
+
* [Breadcrumbs](https://govuk-components.netlify.app/components/breadcrumbs)
|
27
|
+
* [Cookie banner](https://govuk-components.netlify.app/components/cookie-banner)
|
28
|
+
* [Details](https://govuk-components.netlify.app/components/details)
|
29
|
+
* [Footer](https://govuk-components.netlify.app/components/footer)
|
30
|
+
* [Header](https://govuk-components.netlify.app/components/header)
|
31
|
+
* [Inset text](https://govuk-components.netlify.app/components/inset-text)
|
32
|
+
* [Notification banner](https://govuk-components.netlify.app/components/notification-banner)
|
33
|
+
* [Panel](https://govuk-components.netlify.app/components/panel)
|
34
|
+
* [Phase banner](https://govuk-components.netlify.app/components/phase-banner)
|
35
|
+
* [Skip link](https://govuk-components.netlify.app/components/skip-link)
|
36
|
+
* [Start button](https://govuk-components.netlify.app/components/start-button)
|
37
|
+
* [Summary list](https://govuk-components.netlify.app/components/summary-list)
|
38
|
+
* [Tabs](https://govuk-components.netlify.app/components/tabs)
|
39
|
+
* [Tables](https://govuk-components.netlify.app/components/table)
|
40
|
+
* [Tags](https://govuk-components.netlify.app/components/tags)
|
41
|
+
* [Warning text](https://govuk-components.netlify.app/components/warning-text)
|
42
|
+
|
43
|
+
This library also provides [link](https://govuk-components.netlify.app/helpers/link) and
|
44
|
+
[button](https://govuk-components.netlify.app/helpers/button) helpers.
|
40
45
|
|
41
46
|
## Alternative syntax
|
42
47
|
|
43
48
|
All of the components can be rendered in two ways:
|
44
49
|
|
45
|
-
* directly using Rails
|
50
|
+
* directly using Rails’ `#render` method:
|
46
51
|
|
47
52
|
```erb
|
48
53
|
<%= render GovukComponent::WarningTextComponent.new do %>
|
@@ -58,28 +63,26 @@ All of the components can be rendered in two ways:
|
|
58
63
|
<% end %>
|
59
64
|
```
|
60
65
|
|
61
|
-
The naming convention for helpers is `govuk_` followed by the component
|
62
|
-
see the full list in [GovukComponentsHelper](app/helpers/govuk_components_helper.rb).
|
66
|
+
The naming convention for helpers is `govuk_` followed by the component’s name in snake case. You can see the full list in [GovukComponentsHelper](app/helpers/govuk_components_helper.rb).
|
63
67
|
|
64
68
|
## Example use
|
65
69
|
|
66
|
-
This library allows components to be rendered with Rails
|
70
|
+
This library allows components to be rendered with Rails’ `render` method or via the provided helpers. Here we’ll use the `govuk_tabs` to render three tabbed sections:
|
67
71
|
|
68
72
|
```erb
|
69
73
|
<%= govuk_tabs(title: 'Days of the week') do |component| %>
|
70
74
|
<% component.tab(label: 'Monday') do %>
|
71
|
-
<p>Monday
|
75
|
+
<p>Monday’s child is fair of face</p>
|
72
76
|
<% end %>
|
73
77
|
|
74
78
|
<% component.tab(label: 'Tuesday') do %>
|
75
|
-
<p>Tuesday
|
79
|
+
<p>Tuesday’s child is full of grace</p>
|
76
80
|
<% end %>
|
77
81
|
|
78
82
|
<% component.tab(label: 'Wednesday') do %>
|
79
|
-
<p>Wednesday
|
83
|
+
<p>Wednesday’s child is full of woe</p>
|
80
84
|
<% end %>
|
81
85
|
<% end %>
|
82
|
-
|
83
86
|
```
|
84
87
|
|
85
88
|
Here are the rendered tabs:
|
@@ -107,38 +110,38 @@ require "govuk/components"
|
|
107
110
|
|
108
111
|
## Installation
|
109
112
|
|
110
|
-
Add this line to your application
|
113
|
+
Add this line to your application’s Gemfile:
|
111
114
|
|
112
115
|
```ruby
|
113
116
|
gem 'govuk-components'
|
114
117
|
```
|
115
118
|
|
116
119
|
And then execute:
|
117
|
-
|
118
|
-
|
120
|
+
|
121
|
+
```sh
|
122
|
+
bundle
|
119
123
|
```
|
120
124
|
|
121
125
|
Or install it yourself as:
|
122
|
-
|
123
|
-
|
126
|
+
|
127
|
+
```sh
|
128
|
+
gem install govuk-components
|
124
129
|
```
|
125
130
|
|
126
131
|
## Contributing
|
127
132
|
|
128
|
-
|
133
|
+
Bug reports and feature requests are most welcome, please raise an issue or
|
134
|
+
submit a pull request.
|
129
135
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
`bin/rails db:create`
|
134
|
-
`bin/rails db:migrate`
|
135
|
-
`bin/rails s`
|
136
|
+
Currently we're using [GOVUK Lint](https://github.com/alphagov/govuk-lint) to
|
137
|
+
ensure code meets the GOV.UK guidelines. Please ensure that any PRs also adhere
|
138
|
+
to this standard.
|
136
139
|
|
137
|
-
|
140
|
+
To help keep the logs clean and tidy, please configure git to use your full name:
|
138
141
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
+
```sh
|
143
|
+
git config --global user.name "Julius Hibbert"
|
144
|
+
```
|
142
145
|
|
143
146
|
## License
|
144
147
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class GovukComponent::BackLinkComponent < GovukComponent::Base
|
2
2
|
attr_reader :text, :href
|
3
3
|
|
4
|
-
def initialize(href:, text:
|
4
|
+
def initialize(href:, text: 'Back', classes: nil, html_attributes: {})
|
5
5
|
super(classes: classes, html_attributes: html_attributes)
|
6
6
|
|
7
7
|
@text = text
|
@@ -15,7 +15,7 @@ class GovukComponent::BackLinkComponent < GovukComponent::Base
|
|
15
15
|
private
|
16
16
|
|
17
17
|
def link_content
|
18
|
-
|
18
|
+
content || text || fail(ArgumentError, "no text or content")
|
19
19
|
end
|
20
20
|
|
21
21
|
def default_classes
|
@@ -1,25 +1,27 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module GovukComponent
|
2
|
+
class CookieBannerComponent < GovukComponent::Base
|
3
|
+
renders_many :messages, "GovukComponent::CookieBannerComponent::MessageComponent"
|
3
4
|
|
4
|
-
|
5
|
+
attr_accessor :aria_label, :hidden, :hide_in_print
|
5
6
|
|
6
|
-
|
7
|
-
|
7
|
+
def initialize(aria_label: "Cookie banner", hidden: false, hide_in_print: true, classes: [], html_attributes: {})
|
8
|
+
super(classes: classes, html_attributes: html_attributes)
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
@aria_label = aria_label
|
11
|
+
@hidden = hidden
|
12
|
+
@hide_in_print = hide_in_print
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
def call
|
16
|
+
tag.div(class: classes, role: "region", aria: { label: aria_label }, data: { nosnippet: true }, hidden: hidden, **html_attributes) do
|
17
|
+
safe_join(messages)
|
18
|
+
end
|
17
19
|
end
|
18
|
-
end
|
19
20
|
|
20
|
-
private
|
21
|
+
private
|
21
22
|
|
22
|
-
|
23
|
-
|
23
|
+
def default_classes
|
24
|
+
class_names("govuk-cookie-banner", "govuk-!-display-none-print" => hide_in_print).split
|
25
|
+
end
|
24
26
|
end
|
25
27
|
end
|
@@ -3,7 +3,7 @@ class GovukComponent::DetailsComponent < GovukComponent::Base
|
|
3
3
|
|
4
4
|
renders_one :summary_html
|
5
5
|
|
6
|
-
def initialize(summary_text
|
6
|
+
def initialize(summary_text: nil, text: nil, classes: [], id: nil, open: nil, html_attributes: {})
|
7
7
|
super(classes: classes, html_attributes: html_attributes)
|
8
8
|
|
9
9
|
@summary_text = summary_text
|
@@ -36,14 +36,14 @@
|
|
36
36
|
<% end %>
|
37
37
|
|
38
38
|
<% if navigation_items.any? %>
|
39
|
-
<%= tag.
|
40
|
-
|
41
|
-
|
39
|
+
<%= tag.nav(class: navigation_classes, aria: { label: navigation_label }) do %>
|
40
|
+
<%= tag.button("Menu", type: "button", class: %w(govuk-header__menu-button govuk-js-header-toggle), aria: { controls: "navigation", label: menu_button_label }) %>
|
41
|
+
<ul id="navigation" class="govuk-header__navigation-list">
|
42
42
|
<% navigation_items.each do |item| %>
|
43
43
|
<%= item %>
|
44
44
|
<% end %>
|
45
|
-
|
46
|
-
|
45
|
+
</ul>
|
46
|
+
<% end %>
|
47
47
|
<% end %>
|
48
48
|
</div>
|
49
49
|
<% end %>
|
@@ -9,7 +9,7 @@ class GovukComponent::PhaseBannerComponent < GovukComponent::Base
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def phase_tag_component
|
12
|
-
GovukComponent::TagComponent.new(classes: "govuk-phase-banner__content__tag"
|
12
|
+
GovukComponent::TagComponent.new(**phase_tag.deep_merge(classes: "govuk-phase-banner__content__tag"))
|
13
13
|
end
|
14
14
|
|
15
15
|
private
|
@@ -9,12 +9,11 @@ class GovukComponent::SummaryListComponent::ActionComponent < GovukComponent::Ba
|
|
9
9
|
@visually_hidden_text = visually_hidden_text
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
|
14
|
-
|
15
|
-
# and others don't
|
16
|
-
return "" if href.blank?
|
12
|
+
def render?
|
13
|
+
href.present?
|
14
|
+
end
|
17
15
|
|
16
|
+
def call
|
18
17
|
link_classes = govuk_link_classes.append(classes).flatten
|
19
18
|
|
20
19
|
link_to(href, class: link_classes, **html_attributes) do
|
@@ -1,12 +1,14 @@
|
|
1
1
|
class GovukComponent::SummaryListComponent::RowComponent < GovukComponent::Base
|
2
|
-
attr_reader :href, :visually_hidden_text
|
2
|
+
attr_reader :href, :visually_hidden_text, :show_actions_column
|
3
3
|
|
4
4
|
renders_one :key, GovukComponent::SummaryListComponent::KeyComponent
|
5
5
|
renders_one :value, GovukComponent::SummaryListComponent::ValueComponent
|
6
6
|
renders_many :actions, GovukComponent::SummaryListComponent::ActionComponent
|
7
7
|
|
8
|
-
def initialize(classes: [], html_attributes: {})
|
8
|
+
def initialize(show_actions_column: nil, classes: [], html_attributes: {})
|
9
9
|
super(classes: classes, html_attributes: html_attributes)
|
10
|
+
|
11
|
+
@show_actions_column = show_actions_column
|
10
12
|
end
|
11
13
|
|
12
14
|
def call
|
@@ -18,7 +20,7 @@ class GovukComponent::SummaryListComponent::RowComponent < GovukComponent::Base
|
|
18
20
|
private
|
19
21
|
|
20
22
|
def actions_content
|
21
|
-
return
|
23
|
+
return unless show_actions_column && actions.any?
|
22
24
|
|
23
25
|
(actions.one?) ? single_action : actions_list
|
24
26
|
end
|
@@ -36,7 +38,9 @@ private
|
|
36
38
|
end
|
37
39
|
|
38
40
|
def default_classes
|
39
|
-
%w(govuk-summary-list__row)
|
41
|
+
%w(govuk-summary-list__row).tap do |c|
|
42
|
+
c << "govuk-summary-list__row--no-actions" if show_actions_column && actions.none?
|
43
|
+
end
|
40
44
|
end
|
41
45
|
|
42
46
|
def actions_class
|
@@ -1,29 +1,35 @@
|
|
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
|
-
|
1
|
+
module GovukComponent
|
2
|
+
class SummaryListComponent < GovukComponent::Base
|
3
|
+
attr_reader :borders, :actions
|
4
|
+
|
5
|
+
renders_many :rows, ->(classes: [], html_attributes: {}, &block) do
|
6
|
+
GovukComponent::SummaryListComponent::RowComponent.new(
|
7
|
+
show_actions_column: @show_actions_column,
|
8
|
+
classes: classes,
|
9
|
+
html_attributes: html_attributes,
|
10
|
+
&block
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(actions: true, borders: true, classes: [], html_attributes: {})
|
15
|
+
super(classes: classes, html_attributes: html_attributes)
|
16
|
+
|
17
|
+
@borders = borders
|
18
|
+
@show_actions_column = actions
|
19
|
+
end
|
20
|
+
|
21
|
+
def classes
|
22
|
+
super.append(borders_class).compact
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def borders_class
|
28
|
+
%(govuk-summary-list--no-border) unless borders
|
29
|
+
end
|
30
|
+
|
31
|
+
def default_classes
|
32
|
+
%w(govuk-summary-list)
|
33
|
+
end
|
28
34
|
end
|
29
35
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class GovukComponent::TableComponent::BodyComponent < GovukComponent::Base
|
2
|
-
renders_many :rows, GovukComponent::TableComponent::RowComponent
|
2
|
+
renders_many :rows, "GovukComponent::TableComponent::RowComponent"
|
3
3
|
|
4
4
|
def initialize(rows: nil, first_cell_is_header: false, classes: [], html_attributes: {})
|
5
5
|
super(classes: classes, html_attributes: html_attributes)
|
@@ -4,12 +4,12 @@ class GovukComponent::TableComponent::CellComponent < GovukComponent::Base
|
|
4
4
|
alias_method :numeric?, :numeric
|
5
5
|
|
6
6
|
WIDTHS = {
|
7
|
-
"full" => "govuk
|
8
|
-
"three-quarters" => "govuk
|
9
|
-
"two-thirds" => "govuk
|
10
|
-
"one-half" => "govuk
|
11
|
-
"one-third" => "govuk
|
12
|
-
"one-quarter" => "govuk
|
7
|
+
"full" => "govuk-!-width-full",
|
8
|
+
"three-quarters" => "govuk-!-width-three-quarters",
|
9
|
+
"two-thirds" => "govuk-!-width-two-thirds",
|
10
|
+
"one-half" => "govuk-!-width-one-half",
|
11
|
+
"one-third" => "govuk-!-width-one-third",
|
12
|
+
"one-quarter" => "govuk-!-width-one-quarter",
|
13
13
|
}.freeze
|
14
14
|
|
15
15
|
def initialize(header: false, text: nil, numeric: false, width: nil, classes: [], html_attributes: {})
|
@@ -1,33 +1,35 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module GovukComponent
|
2
|
+
class TableComponent < GovukComponent::Base
|
3
|
+
renders_one :caption, "GovukComponent::TableComponent::CaptionComponent"
|
4
|
+
renders_one :head, "GovukComponent::TableComponent::HeadComponent"
|
5
|
+
renders_many :bodies, "GovukComponent::TableComponent::BodyComponent"
|
5
6
|
|
6
|
-
|
7
|
+
attr_accessor :id, :first_cell_is_header, :caption_text
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
def initialize(id: nil, rows: nil, head: nil, caption: nil, first_cell_is_header: false, classes: [], html_attributes: {})
|
10
|
+
super(classes: classes, html_attributes: html_attributes)
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
@id = id
|
13
|
+
@first_cell_is_header = first_cell_is_header
|
14
|
+
@caption_text = caption
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
# when no rows are passed in it's likely we're taking the slot approach
|
17
|
+
return unless rows.presence
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
# if no head is passed in,use the first row for headers
|
20
|
+
build(*(head ? [head, rows] : [rows[0], rows[1..]]), caption_text)
|
21
|
+
end
|
21
22
|
|
22
|
-
private
|
23
|
+
private
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
def build(head_data, body_data, caption_text)
|
26
|
+
caption(text: caption_text)
|
27
|
+
head(rows: [head_data])
|
28
|
+
body(rows: body_data, first_cell_is_header: first_cell_is_header)
|
29
|
+
end
|
29
30
|
|
30
|
-
|
31
|
-
|
31
|
+
def default_classes
|
32
|
+
%w(govuk-table)
|
33
|
+
end
|
32
34
|
end
|
33
35
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
module GovukComponent::Traits; end
|
@@ -3,7 +3,7 @@ class GovukComponent::WarningTextComponent < GovukComponent::Base
|
|
3
3
|
|
4
4
|
ICON = '!'.freeze
|
5
5
|
|
6
|
-
def initialize(text
|
6
|
+
def initialize(text: nil, icon_fallback_text: 'Warning', classes: [], html_attributes: {})
|
7
7
|
super(classes: classes, html_attributes: html_attributes)
|
8
8
|
|
9
9
|
@text = text
|
@@ -12,7 +12,7 @@ class GovukComponent::WarningTextComponent < GovukComponent::Base
|
|
12
12
|
|
13
13
|
def call
|
14
14
|
tag.div(class: classes, **html_attributes) do
|
15
|
-
safe_join([icon,
|
15
|
+
safe_join([icon, warning_text])
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -22,9 +22,9 @@ private
|
|
22
22
|
tag.span(ICON, class: 'govuk-warning-text__icon', aria: { hidden: true })
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
25
|
+
def warning_text
|
26
26
|
tag.strong(class: 'govuk-warning-text__text') do
|
27
|
-
safe_join([assistive, text])
|
27
|
+
safe_join([assistive, (content || text)])
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -0,0 +1 @@
|
|
1
|
+
module GovukComponent; end
|
@@ -56,7 +56,11 @@ module GovukLinkHelper
|
|
56
56
|
html_options = build_html_options(extra_options, style: :button)
|
57
57
|
|
58
58
|
if block_given?
|
59
|
-
|
59
|
+
if Rails.version >= "7.0.0" && name.is_a?(Hash)
|
60
|
+
button_to(name.merge(html_options), &block)
|
61
|
+
else
|
62
|
+
button_to(name, html_options, &block)
|
63
|
+
end
|
60
64
|
else
|
61
65
|
button_to(name, options, html_options)
|
62
66
|
end
|
@@ -114,7 +118,7 @@ private
|
|
114
118
|
attributes ||= {}
|
115
119
|
|
116
120
|
attributes.with_indifferent_access.tap do |attrs|
|
117
|
-
attrs[:class] = Array.wrap(attrs[:class]).prepend(class_name).flatten
|
121
|
+
attrs[:class] = Array.wrap(attrs[:class]).prepend(class_name).flatten.join(" ")
|
118
122
|
end
|
119
123
|
end
|
120
124
|
end
|
@@ -2,9 +2,11 @@ module GovukSkipLinkHelper
|
|
2
2
|
def govuk_skip_link(text: 'Skip to main content', href: '#main-content', classes: [], **html_attributes, &block)
|
3
3
|
link_classes = Array.wrap(classes).append('govuk-skip-link')
|
4
4
|
|
5
|
-
|
5
|
+
html_attributes_with_data_module = { data: { module: "govuk-skip-link" } }.deep_merge(html_attributes)
|
6
6
|
|
7
|
-
link_to(
|
7
|
+
return link_to(href, class: link_classes, **html_attributes_with_data_module, &block) if block_given?
|
8
|
+
|
9
|
+
link_to(text, href, class: link_classes, **html_attributes_with_data_module)
|
8
10
|
end
|
9
11
|
end
|
10
12
|
|
data/lib/govuk/components.rb
CHANGED
metadata
CHANGED
@@ -1,57 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk-components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DfE developers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 6.1.4.4
|
17
20
|
- - ">="
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version: '6.
|
22
|
+
version: '6.1'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 6.1.4.4
|
24
30
|
- - ">="
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version: '6.
|
32
|
+
version: '6.1'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: railties
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 6.1.4.4
|
31
40
|
- - ">="
|
32
41
|
- !ruby/object:Gem::Version
|
33
|
-
version: '6.
|
42
|
+
version: '6.1'
|
34
43
|
type: :runtime
|
35
44
|
prerelease: false
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
37
46
|
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 6.1.4.4
|
38
50
|
- - ">="
|
39
51
|
- !ruby/object:Gem::Version
|
40
|
-
version: '6.
|
52
|
+
version: '6.1'
|
41
53
|
- !ruby/object:Gem::Dependency
|
42
54
|
name: view_component
|
43
55
|
requirement: !ruby/object:Gem::Requirement
|
44
56
|
requirements:
|
45
57
|
- - "~>"
|
46
58
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.
|
59
|
+
version: 2.47.0
|
48
60
|
type: :runtime
|
49
61
|
prerelease: false
|
50
62
|
version_requirements: !ruby/object:Gem::Requirement
|
51
63
|
requirements:
|
52
64
|
- - "~>"
|
53
65
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.
|
66
|
+
version: 2.47.0
|
55
67
|
- !ruby/object:Gem::Dependency
|
56
68
|
name: pry-byebug
|
57
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,6 +162,132 @@ dependencies:
|
|
150
162
|
- - ">="
|
151
163
|
- !ruby/object:Gem::Version
|
152
164
|
version: '0'
|
165
|
+
- !ruby/object:Gem::Dependency
|
166
|
+
name: htmlbeautifier
|
167
|
+
requirement: !ruby/object:Gem::Requirement
|
168
|
+
requirements:
|
169
|
+
- - "~>"
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
version: 1.4.1
|
172
|
+
type: :development
|
173
|
+
prerelease: false
|
174
|
+
version_requirements: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - "~>"
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: 1.4.1
|
179
|
+
- !ruby/object:Gem::Dependency
|
180
|
+
name: nanoc
|
181
|
+
requirement: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - "~>"
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: '4.11'
|
186
|
+
type: :development
|
187
|
+
prerelease: false
|
188
|
+
version_requirements: !ruby/object:Gem::Requirement
|
189
|
+
requirements:
|
190
|
+
- - "~>"
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: '4.11'
|
193
|
+
- !ruby/object:Gem::Dependency
|
194
|
+
name: rouge
|
195
|
+
requirement: !ruby/object:Gem::Requirement
|
196
|
+
requirements:
|
197
|
+
- - "~>"
|
198
|
+
- !ruby/object:Gem::Version
|
199
|
+
version: 3.27.0
|
200
|
+
type: :development
|
201
|
+
prerelease: false
|
202
|
+
version_requirements: !ruby/object:Gem::Requirement
|
203
|
+
requirements:
|
204
|
+
- - "~>"
|
205
|
+
- !ruby/object:Gem::Version
|
206
|
+
version: 3.27.0
|
207
|
+
- !ruby/object:Gem::Dependency
|
208
|
+
name: rubypants
|
209
|
+
requirement: !ruby/object:Gem::Requirement
|
210
|
+
requirements:
|
211
|
+
- - "~>"
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: 0.7.0
|
214
|
+
type: :development
|
215
|
+
prerelease: false
|
216
|
+
version_requirements: !ruby/object:Gem::Requirement
|
217
|
+
requirements:
|
218
|
+
- - "~>"
|
219
|
+
- !ruby/object:Gem::Version
|
220
|
+
version: 0.7.0
|
221
|
+
- !ruby/object:Gem::Dependency
|
222
|
+
name: sass
|
223
|
+
requirement: !ruby/object:Gem::Requirement
|
224
|
+
requirements:
|
225
|
+
- - ">="
|
226
|
+
- !ruby/object:Gem::Version
|
227
|
+
version: '0'
|
228
|
+
type: :development
|
229
|
+
prerelease: false
|
230
|
+
version_requirements: !ruby/object:Gem::Requirement
|
231
|
+
requirements:
|
232
|
+
- - ">="
|
233
|
+
- !ruby/object:Gem::Version
|
234
|
+
version: '0'
|
235
|
+
- !ruby/object:Gem::Dependency
|
236
|
+
name: sassc
|
237
|
+
requirement: !ruby/object:Gem::Requirement
|
238
|
+
requirements:
|
239
|
+
- - "~>"
|
240
|
+
- !ruby/object:Gem::Version
|
241
|
+
version: 2.4.0
|
242
|
+
type: :development
|
243
|
+
prerelease: false
|
244
|
+
version_requirements: !ruby/object:Gem::Requirement
|
245
|
+
requirements:
|
246
|
+
- - "~>"
|
247
|
+
- !ruby/object:Gem::Version
|
248
|
+
version: 2.4.0
|
249
|
+
- !ruby/object:Gem::Dependency
|
250
|
+
name: slim
|
251
|
+
requirement: !ruby/object:Gem::Requirement
|
252
|
+
requirements:
|
253
|
+
- - "~>"
|
254
|
+
- !ruby/object:Gem::Version
|
255
|
+
version: 4.1.0
|
256
|
+
type: :development
|
257
|
+
prerelease: false
|
258
|
+
version_requirements: !ruby/object:Gem::Requirement
|
259
|
+
requirements:
|
260
|
+
- - "~>"
|
261
|
+
- !ruby/object:Gem::Version
|
262
|
+
version: 4.1.0
|
263
|
+
- !ruby/object:Gem::Dependency
|
264
|
+
name: slim_lint
|
265
|
+
requirement: !ruby/object:Gem::Requirement
|
266
|
+
requirements:
|
267
|
+
- - "~>"
|
268
|
+
- !ruby/object:Gem::Version
|
269
|
+
version: 0.22.0
|
270
|
+
type: :development
|
271
|
+
prerelease: false
|
272
|
+
version_requirements: !ruby/object:Gem::Requirement
|
273
|
+
requirements:
|
274
|
+
- - "~>"
|
275
|
+
- !ruby/object:Gem::Version
|
276
|
+
version: 0.22.0
|
277
|
+
- !ruby/object:Gem::Dependency
|
278
|
+
name: webrick
|
279
|
+
requirement: !ruby/object:Gem::Requirement
|
280
|
+
requirements:
|
281
|
+
- - "~>"
|
282
|
+
- !ruby/object:Gem::Version
|
283
|
+
version: 1.7.0
|
284
|
+
type: :development
|
285
|
+
prerelease: false
|
286
|
+
version_requirements: !ruby/object:Gem::Requirement
|
287
|
+
requirements:
|
288
|
+
- - "~>"
|
289
|
+
- !ruby/object:Gem::Version
|
290
|
+
version: 1.7.0
|
153
291
|
description: A collection of components intended to ease the building of GOV.UK Design
|
154
292
|
System web applications
|
155
293
|
email:
|
@@ -161,6 +299,7 @@ files:
|
|
161
299
|
- MIT-LICENSE
|
162
300
|
- README.md
|
163
301
|
- Rakefile
|
302
|
+
- app/components/govuk_component.rb
|
164
303
|
- app/components/govuk_component/accordion_component.html.erb
|
165
304
|
- app/components/govuk_component/accordion_component.rb
|
166
305
|
- app/components/govuk_component/accordion_component/section_component.html.erb
|
@@ -203,6 +342,7 @@ files:
|
|
203
342
|
- app/components/govuk_component/table_component/row_component.html.erb
|
204
343
|
- app/components/govuk_component/table_component/row_component.rb
|
205
344
|
- app/components/govuk_component/tag_component.rb
|
345
|
+
- app/components/govuk_component/traits.rb
|
206
346
|
- app/components/govuk_component/traits/custom_classes.rb
|
207
347
|
- app/components/govuk_component/traits/custom_html_attributes.rb
|
208
348
|
- app/components/govuk_component/warning_text_component.rb
|
@@ -235,7 +375,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
235
375
|
- !ruby/object:Gem::Version
|
236
376
|
version: '0'
|
237
377
|
requirements: []
|
238
|
-
rubygems_version: 3.2.
|
378
|
+
rubygems_version: 3.2.32
|
239
379
|
signing_key:
|
240
380
|
specification_version: 4
|
241
381
|
summary: Lightweight set of reusable GOV.UK Design System components
|