govuk-components 3.0.0b2 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -15
- 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 +30 -8
- 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 +10 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 057cf421a74d24cf1dcfa796a3fb058ca4fff573eb3d8095d04f83b4891f09da
|
4
|
+
data.tar.gz: 77ab1008878c995b46ff439fb5fbb396190b85b1a48978e8bffc6d2197156994
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32c6f43b3b590706e8e545afe71fe158cb33590433aa454ad84be3a20f907588097febd5890fb26d8fadbfb2d4e8332c36bafbf62394beab9d8167f83b473f84
|
7
|
+
data.tar.gz: 7def35bb74e158cc480d8fa7e6df578a2b4a17db10198139e64833569d6b038f67a061dc3f83bc70c49ee60aa4096e139d15a8bb68f18e981c6bc09c12bb6340
|
data/README.md
CHANGED
@@ -2,9 +2,13 @@
|
|
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
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
|
|
@@ -36,7 +40,8 @@ The provided components are:
|
|
36
40
|
* [Tags](https://govuk-components.netlify.app/components/tags)
|
37
41
|
* [Warning text](https://govuk-components.netlify.app/components/warning-text)
|
38
42
|
|
39
|
-
This library also provides [link](https://govuk-components.netlify.app/helpers/link) and
|
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
|
|
@@ -78,7 +83,6 @@ This library allows components to be rendered with Rails’ `render` method or v
|
|
78
83
|
<p>Wednesday’s child is full of woe</p>
|
79
84
|
<% end %>
|
80
85
|
<% end %>
|
81
|
-
|
82
86
|
```
|
83
87
|
|
84
88
|
Here are the rendered tabs:
|
@@ -126,20 +130,18 @@ gem install govuk-components
|
|
126
130
|
|
127
131
|
## Contributing
|
128
132
|
|
129
|
-
|
130
|
-
|
131
|
-
`cd spec/dummy`
|
132
|
-
`yarn install`
|
133
|
-
`bundle install`
|
134
|
-
`bin/rails db:create`
|
135
|
-
`bin/rails db:migrate`
|
136
|
-
`bin/rails s`
|
133
|
+
Bug reports and feature requests are most welcome, please raise an issue or
|
134
|
+
submit a pull request.
|
137
135
|
|
138
|
-
|
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.
|
139
139
|
|
140
|
-
|
140
|
+
To help keep the logs clean and tidy, please configure git to use your full name:
|
141
141
|
|
142
|
-
|
142
|
+
```sh
|
143
|
+
git config --global user.name "Julius Hibbert"
|
144
|
+
```
|
143
145
|
|
144
146
|
## License
|
145
147
|
|
@@ -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,17 +1,25 @@
|
|
1
1
|
module GovukComponent
|
2
2
|
class SummaryListComponent < GovukComponent::Base
|
3
|
-
attr_reader :borders
|
4
|
-
|
5
|
-
renders_many :rows,
|
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
|
6
13
|
|
7
|
-
def initialize(borders: true, classes: [], html_attributes: {})
|
14
|
+
def initialize(rows: nil, actions: true, borders: true, classes: [], html_attributes: {})
|
8
15
|
super(classes: classes, html_attributes: html_attributes)
|
9
16
|
|
10
|
-
@borders
|
11
|
-
|
17
|
+
@borders = borders
|
18
|
+
@show_actions_column = actions
|
19
|
+
|
20
|
+
return unless rows.presence
|
12
21
|
|
13
|
-
|
14
|
-
rows.any? { |row| row.href.present? }
|
22
|
+
build(rows)
|
15
23
|
end
|
16
24
|
|
17
25
|
def classes
|
@@ -27,5 +35,19 @@ module GovukComponent
|
|
27
35
|
def default_classes
|
28
36
|
%w(govuk-summary-list)
|
29
37
|
end
|
38
|
+
|
39
|
+
def build(rows)
|
40
|
+
@show_actions_column = rows.any? { |r| r.key?(:actions) }
|
41
|
+
|
42
|
+
rows.each do |data|
|
43
|
+
k, v, a = data.values_at(:key, :value, :actions)
|
44
|
+
|
45
|
+
row(**data.slice(:classes, :html_attributes)) do |r|
|
46
|
+
r.key(**k)
|
47
|
+
r.value(**v)
|
48
|
+
Array.wrap(a).each { |ad| r.action(**ad) }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
30
52
|
end
|
31
53
|
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,22 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk-components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DfE developers
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-10 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
|
20
17
|
- - ">="
|
21
18
|
- !ruby/object:Gem::Version
|
22
19
|
version: '6.1'
|
@@ -24,9 +21,6 @@ dependencies:
|
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 6.1.4.4
|
30
24
|
- - ">="
|
31
25
|
- !ruby/object:Gem::Version
|
32
26
|
version: '6.1'
|
@@ -34,9 +28,6 @@ dependencies:
|
|
34
28
|
name: railties
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: 6.1.4.4
|
40
31
|
- - ">="
|
41
32
|
- !ruby/object:Gem::Version
|
42
33
|
version: '6.1'
|
@@ -44,9 +35,6 @@ dependencies:
|
|
44
35
|
prerelease: false
|
45
36
|
version_requirements: !ruby/object:Gem::Requirement
|
46
37
|
requirements:
|
47
|
-
- - "~>"
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: 6.1.4.4
|
50
38
|
- - ">="
|
51
39
|
- !ruby/object:Gem::Version
|
52
40
|
version: '6.1'
|
@@ -56,14 +44,14 @@ dependencies:
|
|
56
44
|
requirements:
|
57
45
|
- - "~>"
|
58
46
|
- !ruby/object:Gem::Version
|
59
|
-
version: 2.
|
47
|
+
version: 2.47.0
|
60
48
|
type: :runtime
|
61
49
|
prerelease: false
|
62
50
|
version_requirements: !ruby/object:Gem::Requirement
|
63
51
|
requirements:
|
64
52
|
- - "~>"
|
65
53
|
- !ruby/object:Gem::Version
|
66
|
-
version: 2.
|
54
|
+
version: 2.47.0
|
67
55
|
- !ruby/object:Gem::Dependency
|
68
56
|
name: pry-byebug
|
69
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -360,7 +348,7 @@ homepage: https://github.com/DFE-Digital/govuk-components
|
|
360
348
|
licenses:
|
361
349
|
- MIT
|
362
350
|
metadata: {}
|
363
|
-
post_install_message:
|
351
|
+
post_install_message:
|
364
352
|
rdoc_options: []
|
365
353
|
require_paths:
|
366
354
|
- lib
|
@@ -371,12 +359,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
371
359
|
version: '0'
|
372
360
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
373
361
|
requirements:
|
374
|
-
- - "
|
362
|
+
- - ">="
|
375
363
|
- !ruby/object:Gem::Version
|
376
|
-
version:
|
364
|
+
version: '0'
|
377
365
|
requirements: []
|
378
|
-
rubygems_version: 3.
|
379
|
-
signing_key:
|
366
|
+
rubygems_version: 3.1.6
|
367
|
+
signing_key:
|
380
368
|
specification_version: 4
|
381
369
|
summary: Lightweight set of reusable GOV.UK Design System components
|
382
370
|
test_files: []
|