govuk-components 3.0.0b2 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae11984437c0a4e6631d19c4db1211886178b8a70498f3d2592175cb7ba466e9
4
- data.tar.gz: 6cfbbf6933643393abf51f6dc6c8b6d6c62c36b5a93e62dbfdd955f3ab845fe1
3
+ metadata.gz: 057cf421a74d24cf1dcfa796a3fb058ca4fff573eb3d8095d04f83b4891f09da
4
+ data.tar.gz: 77ab1008878c995b46ff439fb5fbb396190b85b1a48978e8bffc6d2197156994
5
5
  SHA512:
6
- metadata.gz: 82da69e1477bd8e07b7c778aff87da77886eb2008bbe470996635445b73de841b03b3fb91b0000d7067072b98a6998ccaafa204447e2ed284b8411204e1ff435
7
- data.tar.gz: eb1ce8afdb5562b9de0eeda99bb62122101ac42656ab0a5999f10372ed343c153f8769cc8ab420e06c790c21407e94fb79932c7448c7a36da41a3d02629e62e1
6
+ metadata.gz: 32c6f43b3b590706e8e545afe71fe158cb33590433aa454ad84be3a20f907588097febd5890fb26d8fadbfb2d4e8332c36bafbf62394beab9d8167f83b473f84
7
+ data.tar.gz: 7def35bb74e158cc480d8fa7e6df578a2b4a17db10198139e64833569d6b038f67a061dc3f83bc70c49ee60aa4096e139d15a8bb68f18e981c6bc09c12bb6340
data/README.md CHANGED
@@ -2,9 +2,13 @@
2
2
 
3
3
  [![Tests](https://github.com/DFE-Digital/govuk-components/workflows/Tests/badge.svg)](https://github.com/DFE-Digital/govuk-components/actions?query=workflow%3ATests)
4
4
  [![Maintainability](https://api.codeclimate.com/v1/badges/cbcbc140f300b920d833/maintainability)](https://codeclimate.com/github/DFE-Digital/govuk-components/maintainability)
5
+ [![Gem Version](https://badge.fury.io/rb/govuk-components.svg)](https://badge.fury.io/rb/govuk-components)
6
+ [![Gem](https://img.shields.io/gem/dt/govuk-components?logo=rubygems)](https://rubygems.org/gems/govuk-components)
5
7
  [![Test Coverage](https://api.codeclimate.com/v1/badges/cbcbc140f300b920d833/test_coverage)](https://codeclimate.com/github/DFE-Digital/govuk-components/test_coverage)
6
- [![GitHub license](https://img.shields.io/github/license/DFE-Digital/govuk-components)](https://github.com/DFE-Digital/govuk-components/blob/master/LICENSE)
7
- [![GOV.UK Design System Version](https://img.shields.io/badge/GOV.UK%20Design%20System-3.13.1-brightgreen)](https://design-system.service.gov.uk)
8
+ [![GitHub license](https://img.shields.io/github/license/DFE-Digital/govuk-components)](https://github.com/DFE-Digital/govuk-components/blob/main/LICENSE)
9
+ [![GOV.UK Design System Version](https://img.shields.io/badge/GOV.UK%20Design%20System-4.0.0-brightgreen)](https://design-system.service.gov.uk)
10
+ [![Rails](https://img.shields.io/badge/Rails-6.1.4.4%20%E2%95%B1%207.0.1-E16D6D)](https://weblog.rubyonrails.org/releases/)
11
+ [![Ruby](https://img.shields.io/badge/Ruby-2.7.5%20%20%E2%95%B1%203.0.3%20%20%E2%95%B1%203.1.0-E16D6D)](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 [button](https://govuk-components.netlify.app/helpers/button) helpers.
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
- To setup the dummy app:
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
- After changing a component or adding a new one:
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
- * add or update the corresponding specs, and check they pass by running `bundle exec rspec`.
140
+ To help keep the logs clean and tidy, please configure git to use your full name:
141
141
 
142
- * update the examples page by cd-ing into the dummy app `cd spec/dummy` and running the rake task `bin/rake generate_examples_page`.
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 call
13
- # when no href is provided return an empty string so the dd container
14
- # will render, it's useful in lists where some rows have actions
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 if actions.blank?
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, "GovukComponent::SummaryListComponent::RowComponent"
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 = borders
11
- end
17
+ @borders = borders
18
+ @show_actions_column = actions
19
+
20
+ return unless rows.presence
12
21
 
13
- def any_row_has_actions?
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
- return link_to(href, class: link_classes, **html_attributes, &block) if block_given?
5
+ html_attributes_with_data_module = { data: { module: "govuk-skip-link" } }.deep_merge(html_attributes)
6
6
 
7
- link_to(text, href, class: link_classes, **html_attributes)
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
 
@@ -1,3 +1,5 @@
1
+ require "rails/engine"
2
+
1
3
  module Govuk
2
4
  module Components
3
5
  class Engine < ::Rails::Engine
@@ -1,5 +1,5 @@
1
1
  module Govuk
2
2
  module Components
3
- VERSION = '3.0.0b2'.freeze
3
+ VERSION = '3.0.1'.freeze
4
4
  end
5
5
  end
@@ -1,3 +1,4 @@
1
- require "view_component/engine"
1
+ require "rails/engine"
2
+ require "view_component"
2
3
  require "govuk/components/helpers/css_utilities"
3
4
  require "govuk/components/engine"
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.0b2
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-03 00:00:00.000000000 Z
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.39.0
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.39.0
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: 1.3.1
364
+ version: '0'
377
365
  requirements: []
378
- rubygems_version: 3.2.32
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: []