govuk-components 3.1.2 → 3.1.5

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: 6b5dce8d53f4985c84480f5c770bb75727ab288ee938d0d4fabfbbad2a08b34a
4
- data.tar.gz: a48fee01465a83dd33bbc6047d0c90599cc05574645d68c8b2cd2f6cba2f9078
3
+ metadata.gz: 632ec1fef8b22693d71008152c6adb25bde2cd400895618b41d14056466cd055
4
+ data.tar.gz: 4ccf73c83e598e6419c8e82e700870861c338a19e1d083bc2820f6433d19f549
5
5
  SHA512:
6
- metadata.gz: 807a2be466fa64f2c124c1b2e39468e73b0f7bac592221aa222fc9a640a30b5a19ffd2d88a8ef77735537c0b3ee8cf7d70db61b3e04da766c6e3b6f4d493a898
7
- data.tar.gz: fc0da82704eca9c674aa646836db4fefbab450258866c3b05de6767202808eea87fc7346dbf2d90af5c6040edf2b479ed9ff197ff6d891b65f455e399e741ab0
6
+ metadata.gz: cba06bc11666a450af21e78aa2e0516ee3d270172200e2ea0fa5256a53468535081bcf42a72827e456bbdf948bed9a629734b36534a27dcef8728ed652d6de1e
7
+ data.tar.gz: f967118acba6ea0c32304ac8af943bcf8a7a63dfa62ae28b004413f1dedf4ad70bd994cb8b3df144c294250929951deb927f008208144aaa7aed33fadca43022
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  [![Gem](https://img.shields.io/gem/dt/govuk-components?logo=rubygems)](https://rubygems.org/gems/govuk-components)
7
7
  [![Test Coverage](https://api.codeclimate.com/v1/badges/cbcbc140f300b920d833/test_coverage)](https://codeclimate.com/github/DFE-Digital/govuk-components/test_coverage)
8
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.2.0-brightgreen)](https://design-system.service.gov.uk)
9
+ [![GOV.UK Design System Version](https://img.shields.io/badge/GOV.UK%20Design%20System-4.3.0-brightgreen)](https://design-system.service.gov.uk)
10
10
  [![Rails](https://img.shields.io/badge/Rails-6.1.5%20%E2%95%B1%207.0.3-E16D6D)](https://weblog.rubyonrails.org/releases/)
11
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.2-E16D6D)](https://www.ruby-lang.org/en/downloads/)
12
12
 
@@ -14,6 +14,15 @@ This gem provides a suite of reusable components for the [GOV.UK Design System](
14
14
 
15
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.
16
16
 
17
+ ## Documentation
18
+
19
+ The gem comes with [a full guide](https://govuk-components.netlify.app/) that
20
+ covers most aspects of day-to-day use, along with code and output examples. The
21
+ examples in the guide (and the guide itself) are built using the components,
22
+ so it will always be up to date.
23
+
24
+ [![Netlify Status](https://api.netlify.com/api/v1/badges/d40a5a0a-b086-4c35-b046-97fbcbf9f219/deploy-status)](https://app.netlify.com/sites/govuk-components/deploys)
25
+
17
26
  ## What’s included?
18
27
 
19
28
  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/).
@@ -28,7 +28,7 @@ private
28
28
  when Hash
29
29
  breadcrumbs.map { |text, link| build_list_item(text, link) }
30
30
  else
31
- fail(ArgumentError, "breadcrumb must be an array or hash")
31
+ fail(ArgumentError, "breadcrumbs must be an array or hash")
32
32
  end
33
33
  end
34
34
 
@@ -65,9 +65,14 @@ private
65
65
  def build_meta_links(links)
66
66
  return [] if links.blank?
67
67
 
68
- fail(ArgumentError, 'meta links must be a hash') unless links.is_a?(Hash)
69
-
70
- links.map { |text, href| raw(link_to(text, href, class: %w(govuk-footer__link))) }
68
+ case links
69
+ when Array
70
+ links.map { |link| raw(link_to(link[:text], link[:href], class: %w(govuk-footer__link), **link.fetch(:attr, {}))) }
71
+ when Hash
72
+ links.map { |text, href| raw(link_to(text, href, class: %w(govuk-footer__link))) }
73
+ else
74
+ fail(ArgumentError, 'meta links must be a hash or array of hashes') unless links.is_a?(Hash)
75
+ end
71
76
  end
72
77
 
73
78
  def default_licence
@@ -37,7 +37,7 @@
37
37
 
38
38
  <% if navigation_items.any? %>
39
39
  <%= tag.nav(**navigation_html_attributes) do %>
40
- <%= tag.button("Menu", type: "button", class: %w(govuk-header__menu-button govuk-js-header-toggle), aria: { controls: "navigation", label: menu_button_label }) %>
40
+ <%= tag.button("Menu", type: "button", class: %w(govuk-header__menu-button govuk-js-header-toggle), hidden: true, aria: { controls: "navigation", label: menu_button_label }) %>
41
41
  <ul id="navigation" class="govuk-header__navigation-list">
42
42
  <% navigation_items.each do |item| %>
43
43
  <%= item %>
@@ -105,6 +105,7 @@ private
105
105
 
106
106
  def active?
107
107
  return @active_override unless @active_override.nil?
108
+ return false if href.blank?
108
109
 
109
110
  current_page?(href)
110
111
  end
@@ -1,29 +1,38 @@
1
1
  class GovukComponent::StartButtonComponent < GovukComponent::Base
2
2
  BUTTON_ATTRIBUTES = {
3
- role: 'button',
4
3
  draggable: 'false',
5
4
  data: { module: 'govuk-button' }
6
5
  }.freeze
7
6
 
8
- attr_reader :text, :href
7
+ LINK_ATTRIBUTES = BUTTON_ATTRIBUTES.merge({ role: 'button' }).freeze
9
8
 
10
- def initialize(text:, href:, classes: [], html_attributes: {})
9
+ attr_reader :text, :href, :as_button
10
+
11
+ def initialize(text:, href:, as_button: false, classes: [], html_attributes: {})
11
12
  @text = text
12
13
  @href = href
14
+ @as_button = as_button
13
15
 
14
16
  super(classes: classes, html_attributes: html_attributes)
15
17
  end
16
18
 
17
19
  def call
18
- link_to(href, **html_attributes) do
19
- safe_join([text, icon])
20
+ if as_button
21
+ button_to(href, **html_attributes) do
22
+ safe_join([text, icon])
23
+ end
24
+ else
25
+ link_to(href, **html_attributes) do
26
+ safe_join([text, icon])
27
+ end
20
28
  end
21
29
  end
22
30
 
23
31
  private
24
32
 
25
33
  def default_attributes
26
- BUTTON_ATTRIBUTES.merge({ class: %w(govuk-button govuk-button--start) })
34
+ (as_button ? BUTTON_ATTRIBUTES : LINK_ATTRIBUTES)
35
+ .merge({ class: %w(govuk-button govuk-button--start) })
27
36
  end
28
37
 
29
38
  def icon
@@ -68,7 +68,7 @@ module GovukLinkHelper
68
68
 
69
69
  def govuk_button_link_to(name = nil, options = nil, extra_options = {}, &block)
70
70
  extra_options = options if block_given?
71
- html_options = GovukComponent::StartButtonComponent::BUTTON_ATTRIBUTES
71
+ html_options = GovukComponent::StartButtonComponent::LINK_ATTRIBUTES
72
72
  .merge build_html_options(extra_options, style: :button)
73
73
 
74
74
  if block_given?
@@ -1,5 +1,5 @@
1
1
  module Govuk
2
2
  module Components
3
- VERSION = '3.1.2'.freeze
3
+ VERSION = '3.1.5'.freeze
4
4
  end
5
5
  end
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.1.2
4
+ version: 3.1.5
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-06-27 00:00:00.000000000 Z
11
+ date: 2022-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -260,14 +260,14 @@ dependencies:
260
260
  requirements:
261
261
  - - "~>"
262
262
  - !ruby/object:Gem::Version
263
- version: 3.29.0
263
+ version: 3.30.0
264
264
  type: :development
265
265
  prerelease: false
266
266
  version_requirements: !ruby/object:Gem::Requirement
267
267
  requirements:
268
268
  - - "~>"
269
269
  - !ruby/object:Gem::Version
270
- version: 3.29.0
270
+ version: 3.30.0
271
271
  - !ruby/object:Gem::Dependency
272
272
  name: rubypants
273
273
  requirement: !ruby/object:Gem::Requirement
@@ -360,7 +360,6 @@ executables: []
360
360
  extensions: []
361
361
  extra_rdoc_files: []
362
362
  files:
363
- - MIT-LICENSE
364
363
  - README.md
365
364
  - Rakefile
366
365
  - app/components/govuk_component.rb
@@ -428,7 +427,7 @@ homepage: https://github.com/DFE-Digital/govuk-components
428
427
  licenses:
429
428
  - MIT
430
429
  metadata: {}
431
- post_install_message:
430
+ post_install_message:
432
431
  rdoc_options: []
433
432
  require_paths:
434
433
  - lib
@@ -444,7 +443,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
444
443
  version: '0'
445
444
  requirements: []
446
445
  rubygems_version: 3.1.6
447
- signing_key:
446
+ signing_key:
448
447
  specification_version: 4
449
448
  summary: Lightweight set of reusable GOV.UK Design System components
450
449
  test_files: []
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright 2020 Peter Yates
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.