govuk_publishing_components 16.1.0 → 16.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1c43a8de608bcadb260cb50450159ed9a1afb2629bf108bc3d21897cea0531e
4
- data.tar.gz: 9a1bf967473efb25ee611861a94d8084a430d095ca3fb39f27008863b2481da8
3
+ metadata.gz: c8194e57a52a4ba7a9d41fb80f0dd76903f299fac60f35e2b45fa8d2803c51d5
4
+ data.tar.gz: 130f165b192cbc3a54d1c87d0cabd5ab0b17f2e6c1907fb43735c028f9bf387d
5
5
  SHA512:
6
- metadata.gz: bd69d01ebf621bc839d7ff47c1eaa47c7ea721d47971958cb9172d9be7e604d5633301fede44e60f6f9b9bfb0d95da24b023d756effbc3e2a18071af3e7e81e0
7
- data.tar.gz: 6e8add99822a200e2f2652c6735bc44e211e302e6fd1b28ebf2926f6c7c0e0a2b14f072c6304a3e5a6d12b8ec073058953eea2d3b9dcf632c716b3410b9d6d93
6
+ metadata.gz: 2de1d21a69fb4a855c07d06e241abdc570c182933c84c3af06889e8978742d74f9bbae3596ff9fb6382239b9f2b9ae433186f23ea2df267d479359e9ac776a84
7
+ data.tar.gz: bd1673a83c3b7acfd8d95d1d6922c2ace5336fe7d31adefb6b9401caef5a43321632a3b48221bdd6dc0db0ba3069172512a1a011919bdf936c4cbec2ce052a9c
@@ -1 +1,5 @@
1
1
  @import "govuk-frontend/components/textarea/textarea";
2
+
3
+ .gem-c-textarea .govuk-textarea {
4
+ margin-bottom: 0;
5
+ }
@@ -1,5 +1,5 @@
1
1
  <%
2
- heading_helper = GovukPublishingComponents::Presenters::AccordionHelper.new(local_assigns)
2
+ shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
3
3
 
4
4
  id ||= "default-id-#{SecureRandom.hex(4)}"
5
5
  items ||= []
@@ -31,7 +31,7 @@
31
31
  <div class="govuk-accordion__section-header">
32
32
  <%=
33
33
  content_tag(
34
- heading_helper.heading_tag,
34
+ shared_helper.get_heading_level,
35
35
  content_tag('span', item[:heading][:text], class: "govuk-accordion__section-button", id: "#{id}-heading-#{index}", data: item[:data_attributes]),
36
36
  class: 'govuk-accordion__section-heading'
37
37
  )
@@ -1,10 +1,10 @@
1
1
  <%
2
2
  text ||= t('components.back_link.back')
3
+ data_attributes ||= nil
3
4
  %>
4
- <%= link_to text,
5
+ <%= link_to(
6
+ text,
5
7
  href,
6
- class: %w(
7
- gem-c-back-link
8
- govuk-back-link
9
- )
10
- %>
8
+ class: %w(gem-c-back-link govuk-back-link),
9
+ data: data_attributes
10
+ ) %>
@@ -1,6 +1,13 @@
1
- <% data_attributes ||= nil %>
2
- <% open ||= nil %>
3
- <%= tag.details class: "gem-c-details govuk-details", data: data_attributes, open: open do %>
1
+ <%
2
+ shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
3
+
4
+ data_attributes ||= nil
5
+ open ||= nil
6
+ margin_bottom ||= 3
7
+ css_classes = %w(gem-c-details govuk-details)
8
+ css_classes << (shared_helper.get_margin_bottom)
9
+ %>
10
+ <%= tag.details class: css_classes, data: data_attributes, open: open do %>
4
11
  <summary class="govuk-details__summary">
5
12
  <span class="govuk-details__summary-text">
6
13
  <%= title %>
@@ -2,8 +2,9 @@
2
2
  brand ||= false
3
3
  brand_helper = GovukPublishingComponents::AppHelpers::BrandHelper.new(brand)
4
4
  heading_helper = GovukPublishingComponents::Presenters::HeadingHelper.new(local_assigns)
5
+ shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
5
6
  %>
6
- <%= content_tag(heading_helper.heading_tag, text,
7
+ <%= content_tag(shared_helper.get_heading_level, text,
7
8
  class: "gem-c-heading #{heading_helper.classes} #{brand_helper.brand_class} #{brand_helper.border_color_class}",
8
9
  id: heading_helper.id
9
10
  ) %>
@@ -1,9 +1,9 @@
1
1
  <%
2
2
  id ||= "hint-#{SecureRandom.hex(4)}"
3
- margin_bottom ||= 3
3
+ shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
4
4
 
5
5
  css_classes = %w( gem-c-hint govuk-hint )
6
- css_classes << ([*0..9].include?(margin_bottom) ? "govuk-!-margin-bottom-#{margin_bottom}" : "govuk-!-margin-bottom-3")
6
+ css_classes << (shared_helper.get_margin_bottom)
7
7
  %>
8
8
 
9
9
  <%= tag.span id: id, class: css_classes do %>
@@ -2,6 +2,7 @@
2
2
  brand ||= false
3
3
  brand_helper = GovukPublishingComponents::AppHelpers::BrandHelper.new(brand)
4
4
  card_helper = GovukPublishingComponents::Presenters::ImageCardHelper.new(local_assigns)
5
+ shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
5
6
  %>
6
7
  <% if card_helper.href || card_helper.extra_links.any? %>
7
8
  <div class="gem-c-image-card <%= "gem-c-image-card--large" if card_helper.large %> <%= brand_helper.brand_class %>"
@@ -13,7 +14,7 @@
13
14
  <%= card_helper.context %>
14
15
 
15
16
  <% if card_helper.heading_text %>
16
- <%= content_tag(card_helper.heading_tag,
17
+ <%= content_tag(shared_helper.get_heading_level,
17
18
  class: "gem-c-image-card__title") do %>
18
19
  <% if card_helper.href %>
19
20
  <%= link_to card_helper.heading_text, card_helper.href,
@@ -1,11 +1,14 @@
1
1
  <%
2
2
  brand ||= false
3
- margin_bottom ||= 0
4
3
  brand_helper = GovukPublishingComponents::AppHelpers::BrandHelper.new(brand)
5
4
  sl_helper = GovukPublishingComponents::Presenters::SubscriptionLinksHelper.new(local_assigns)
5
+ shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
6
+
7
+ local_assigns[:margin_bottom] ||= 0
8
+ local_assigns[:margin_bottom] = 0 if local_assigns[:margin_bottom] > 9
6
9
 
7
10
  css_classes = %w( gem-c-subscription-links )
8
- css_classes << ([*0..9].include?(margin_bottom) ? "govuk-!-margin-bottom-#{margin_bottom}" : "govuk-!-margin-bottom-0")
11
+ css_classes << (shared_helper.get_margin_bottom) unless local_assigns[:margin_bottom] == 0
9
12
  css_classes << brand_helper.brand_class
10
13
  data = {"module": "gem-toggle"} if sl_helper.feed_link_box_value
11
14
  %>
@@ -7,7 +7,8 @@
7
7
 
8
8
  label ||= nil
9
9
  hint ||= nil
10
- margin_bottom ||= 3
10
+ local_assigns[:margin_bottom] ||= 6
11
+ local_assigns[:margin_bottom] = 6 if local_assigns[:margin_bottom] > 9
11
12
  error_message ||= nil
12
13
  error_items ||= nil
13
14
  character_count ||= nil
@@ -16,12 +17,14 @@
16
17
  has_error ||= error_message || error_items&.any?
17
18
  error_id = "error-#{SecureRandom.hex(4)}"
18
19
 
19
- css_classes = %w(gem-c-textarea govuk-textarea)
20
+ shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
21
+
22
+ css_classes = %w(govuk-textarea)
20
23
  css_classes << "js-character-count" if character_count
21
24
  css_classes << "govuk-textarea--error" if has_error
22
- css_classes << ([*0..9].include?(margin_bottom) ? "govuk-!-margin-bottom-#{margin_bottom}" : "govuk-!-margin-bottom-3")
23
- form_group_css_classes = %w(govuk-form-group)
25
+ form_group_css_classes = %w(gem-c-textarea govuk-form-group)
24
26
  form_group_css_classes << "govuk-form-group--error" if has_error
27
+ form_group_css_classes << (shared_helper.get_margin_bottom)
25
28
 
26
29
  aria_described_by ||= nil
27
30
  if hint || has_error
@@ -14,3 +14,8 @@ examples:
14
14
  data:
15
15
  text: 'Back to document list'
16
16
  href: '#'
17
+ with_data_attributes:
18
+ data:
19
+ href: '#'
20
+ data_attributes:
21
+ tracking: GT-1234
@@ -20,6 +20,13 @@ examples:
20
20
  label:
21
21
  text: "Can you provide more detail?"
22
22
  name: "more-detail"
23
+ with_margin_bottom:
24
+ description: The component accepts a number for margin bottom from 0 to 9 (0px to 60px) using the [GOV.UK Frontend spacing scale](http://govuk-frontend-review.herokuapp.com/docs/#settings/spacing-variable-govuk-spacing-points). It defaults to a margin bottom of 6 (30px).
25
+ data:
26
+ margin_bottom: 9
27
+ label:
28
+ text: "Can you provide more detail?"
29
+ name: "more-detail"
23
30
  specific_rows:
24
31
  description: Textarea with 10 rows
25
32
  data:
@@ -1,6 +1,6 @@
1
1
  require "govuk_publishing_components/config"
2
2
  require "govuk_publishing_components/engine"
3
- require "govuk_publishing_components/presenters/accordion_helper"
3
+ require "govuk_publishing_components/presenters/shared_helper"
4
4
  require "govuk_publishing_components/presenters/breadcrumbs"
5
5
  require "govuk_publishing_components/presenters/button_helper"
6
6
  require "govuk_publishing_components/presenters/contextual_navigation"
@@ -4,8 +4,6 @@ module GovukPublishingComponents
4
4
  attr_reader :heading_tag, :id, :classes
5
5
 
6
6
  def initialize(options)
7
- @heading_tag = "h2"
8
- @heading_tag = "h#{options[:heading_level]}" if [1, 2, 3, 4, 5, 6].include? options[:heading_level]
9
7
  @id = options[:id]
10
8
 
11
9
  @classes = ""
@@ -16,7 +16,6 @@ module GovukPublishingComponents
16
16
  @description = local_assigns[:description]
17
17
  @large = local_assigns[:large]
18
18
  @heading_text = local_assigns[:heading_text]
19
- @heading_level = local_assigns[:heading_level] || 2
20
19
  @extra_links_no_indent = local_assigns[:extra_links_no_indent]
21
20
  @metadata = local_assigns[:metadata]
22
21
  end
@@ -59,11 +58,6 @@ module GovukPublishingComponents
59
58
  end
60
59
  end
61
60
 
62
- def heading_tag
63
- return "h#{@heading_level}" if [1, 2, 3, 4, 5, 6].include? @heading_level
64
- return "span" if @heading_level.zero?
65
- end
66
-
67
61
  def description
68
62
  content_tag(:div, @description, class: "gem-c-image-card__description") if @description
69
63
  end
@@ -0,0 +1,23 @@
1
+ module GovukPublishingComponents
2
+ module Presenters
3
+ class SharedHelper
4
+ attr_reader :options, :margin_bottom, :heading_level
5
+
6
+ def initialize(local_assigns)
7
+ @options = local_assigns
8
+ @margin_bottom = @options[:margin_bottom] || 3
9
+ @heading_level = @options[:heading_level] || 2
10
+ end
11
+
12
+ def get_margin_bottom
13
+ [*0..9].include?(@margin_bottom) ? "govuk-!-margin-bottom-#{margin_bottom}" : "govuk-!-margin-bottom-3"
14
+ end
15
+
16
+ def get_heading_level
17
+ return [*1..6].include?(@heading_level) ? "h#{@heading_level}" : "h2" unless @heading_level.zero?
18
+
19
+ "span"
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '16.1.0'.freeze
2
+ VERSION = '16.2.0'.freeze
3
3
  end
@@ -49,7 +49,7 @@
49
49
  "/"
50
50
  ],
51
51
  "_resolved": "git://github.com/alphagov/accessible-autocomplete.git#0c518b4fa79b9a95b544410858486ed9e6403c84",
52
- "_shasum": "81318b920b7ddddd526e2a9a6dc935344ebdd964",
52
+ "_shasum": "3766842c6201eea1fb4369b0494b7539e51bb988",
53
53
  "_shrinkwrap": null,
54
54
  "_spec": "accessible-autocomplete@git://github.com/alphagov/accessible-autocomplete.git#add-multiselect-support",
55
55
  "_where": "/var/lib/jenkins/workspace/ublishing_components_master-N4FWJIUY4CIFHKGZOAAEVVXODRY3YBORQOPIBBXWX72VUPSGJRRQ",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 16.1.0
4
+ version: 16.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-26 00:00:00.000000000 Z
11
+ date: 2019-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govspeak
@@ -594,7 +594,6 @@ files:
594
594
  - lib/govuk_publishing_components/config.rb
595
595
  - lib/govuk_publishing_components/engine.rb
596
596
  - lib/govuk_publishing_components/minitest/component_guide_test.rb
597
- - lib/govuk_publishing_components/presenters/accordion_helper.rb
598
597
  - lib/govuk_publishing_components/presenters/breadcrumbs.rb
599
598
  - lib/govuk_publishing_components/presenters/button_helper.rb
600
599
  - lib/govuk_publishing_components/presenters/checkboxes_helper.rb
@@ -622,6 +621,7 @@ files:
622
621
  - lib/govuk_publishing_components/presenters/schema_org.rb
623
622
  - lib/govuk_publishing_components/presenters/select.rb
624
623
  - lib/govuk_publishing_components/presenters/services.rb
624
+ - lib/govuk_publishing_components/presenters/shared_helper.rb
625
625
  - lib/govuk_publishing_components/presenters/step_by_step_nav_helper.rb
626
626
  - lib/govuk_publishing_components/presenters/subscription_links_helper.rb
627
627
  - lib/govuk_publishing_components/presenters/taxonomy_list_helper.rb
@@ -1,12 +0,0 @@
1
- module GovukPublishingComponents
2
- module Presenters
3
- class AccordionHelper
4
- attr_reader :heading_tag
5
-
6
- def initialize(options)
7
- @heading_tag = "h2"
8
- @heading_tag = "h#{options[:heading_level]}" if [1, 2, 3, 4, 5, 6].include? options[:heading_level]
9
- end
10
- end
11
- end
12
- end