govuk-components 3.0.0b2 → 3.0.0b3

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: 07ed020fcee80322b4d5d89f39eab0fc2ee474916f94359a80ca9801a08a24aa
4
+ data.tar.gz: fe4a45acd08735f21c6b465b956d7372c7e3b8843016284a010aac7a080b6619
5
5
  SHA512:
6
- metadata.gz: 82da69e1477bd8e07b7c778aff87da77886eb2008bbe470996635445b73de841b03b3fb91b0000d7067072b98a6998ccaafa204447e2ed284b8411204e1ff435
7
- data.tar.gz: eb1ce8afdb5562b9de0eeda99bb62122101ac42656ab0a5999f10372ed343c153f8769cc8ab420e06c790c21407e94fb79932c7448c7a36da41a3d02629e62e1
6
+ metadata.gz: f7892945af9393cac946f328fe0262da01ecd2c0a489f00a002e2599b03d94d48fef1e1c1e5e679270fdd9c15f8448f7a3835858db34487219eb1c671cbd6ca3
7
+ data.tar.gz: 39dee312be4c324de08d94077d53b05af472a33773f0c1187aaa9986e13ccbaa4d33f4ae7665b666e4a35fd680c1224a6c536666f544f9d17dff8cfa1e322552
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
8
  [![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)
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.0-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-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,21 @@
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(actions: true, borders: true, classes: [], html_attributes: {})
8
15
  super(classes: classes, html_attributes: html_attributes)
9
16
 
10
- @borders = borders
11
- end
12
-
13
- def any_row_has_actions?
14
- rows.any? { |row| row.href.present? }
17
+ @borders = borders
18
+ @show_actions_column = actions
15
19
  end
16
20
 
17
21
  def classes
@@ -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.0b3'.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,14 +1,14 @@
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.0b3
5
5
  platform: ruby
6
6
  authors:
7
7
  - DfE developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-03 00:00:00.000000000 Z
11
+ date: 2022-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -56,14 +56,14 @@ dependencies:
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: 2.39.0
59
+ version: 2.47.0
60
60
  type: :runtime
61
61
  prerelease: false
62
62
  version_requirements: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
- version: 2.39.0
66
+ version: 2.47.0
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: pry-byebug
69
69
  requirement: !ruby/object:Gem::Requirement