content_block_tools 0.6.5 → 0.7.0

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: 89f5c3789ea13016159db057ef191cbe1f977e08606c3948ad557da24cf2cb77
4
- data.tar.gz: 6bc53e5cb65fc6260aabc7805c354984486749ed15a787ccf0d23f21e6796e73
3
+ metadata.gz: 55ffab3c548b42f43db5e9ea658b4fc6cdd13e0d51eaef12c1c7b60a72f00bb7
4
+ data.tar.gz: e6ca9db8eddd145974c49edb2a57b4f6b1b327b1f94a855a9ae2e61dc2765261
5
5
  SHA512:
6
- metadata.gz: e2e8c3ac13d8581aadbfd45a12d5426607efc7531e3057c61f3c80d5e4a6cb62396ac4db7494e8c66baf9160e4a430738c4e038f89349d65867ed57352a3925c
7
- data.tar.gz: 1c001f490fcecb3df158d3cd17fa5ff66d184df33225fe9781a20a7c5ab34043c237dd5fc8413430bf5a4eeba766af7913662784f3d6aa898f90e7c2ce43f74d
6
+ metadata.gz: 6ce195b0111b12dcf83b791f3702e75e2d4edeb2abb1bb8caa827257780eb1f858b8a1f78bbdd4c7ae439968eed27d360d59026ad0a46bfb170930bbe67fd6bd
7
+ data.tar.gz: a33e0a2898e36fd0c73245e115f9eac3732bf183c59c4836621b20ac89138a69d87ee234714b201c92421f49d035a8ee8c9dc35ad14601fdfb782d417c1a2612
data/CHANGELOG.md CHANGED
@@ -7,6 +7,11 @@
7
7
  useful summary for people upgrading their application, not a replication
8
8
  of the commit log.
9
9
 
10
+ ## 0.7.0
11
+
12
+ - Alter markup of contact ([55](https://github.com/alphagov/govuk_content_block_tools/pull/55))
13
+ - Handle when opening hours are missing ([55](https://github.com/alphagov/govuk_content_block_tools/pull/55))
14
+
10
15
  ## 0.6.5
11
16
 
12
17
  - Add opening hours to a contact block ([52](https://github.com/alphagov/govuk_content_block_tools/pull/52))
@@ -12,10 +12,6 @@ module ContentBlockTools
12
12
  @item = item
13
13
  end
14
14
 
15
- def title_content
16
- "#{item[:title]}: "
17
- end
18
-
19
15
  def render; end
20
16
  end
21
17
  end
@@ -4,16 +4,24 @@ module ContentBlockTools
4
4
  module Contact
5
5
  class AddressPresenter < ContentBlockTools::Presenters::BlockPresenters::BasePresenter
6
6
  def render
7
- content_tag(:p, class: "govuk-body govuk-!-margin-bottom-4") do
8
- [
9
- item[:street_address],
10
- item[:locality],
11
- item[:region],
12
- item[:postal_code],
13
- item[:country],
14
- ].compact_blank.join(",<br/>").html_safe
7
+ content_tag(:p, class: "adr") do
8
+ %i[street_address locality region postal_code country].map { |field|
9
+ next if item[field].blank?
10
+
11
+ content_tag(:span, item[field], { class: class_for_field_name(field) })
12
+ }.compact_blank.join(",<br/>").html_safe
15
13
  end
16
14
  end
15
+
16
+ def class_for_field_name(field_name)
17
+ {
18
+ street_address: "street-address",
19
+ locality: "locality",
20
+ region: "region",
21
+ postal_code: "postal-code",
22
+ country: "country-name",
23
+ }[field_name]
24
+ end
17
25
  end
18
26
  end
19
27
  end
@@ -4,12 +4,14 @@ module ContentBlockTools
4
4
  module Contact
5
5
  class ContactFormPresenter < ContentBlockTools::Presenters::BlockPresenters::BasePresenter
6
6
  def render
7
- content_tag(:p, class: "govuk-body govuk-!-margin-bottom-4") do
8
- concat content_tag(:span, title_content)
9
- concat content_tag(:a,
10
- item[:url],
11
- class: "govuk-link",
12
- href: item[:url])
7
+ content_tag(:div, class: "email-url-number") do
8
+ content_tag(:p) do
9
+ concat content_tag(:span, item[:title])
10
+ concat content_tag(:a,
11
+ item[:url],
12
+ class: "url",
13
+ href: item[:url])
14
+ end
13
15
  end
14
16
  end
15
17
  end
@@ -4,12 +4,14 @@ module ContentBlockTools
4
4
  module Contact
5
5
  class EmailAddressPresenter < ContentBlockTools::Presenters::BlockPresenters::BasePresenter
6
6
  def render
7
- content_tag(:p, class: "govuk-body govuk-!-margin-bottom-4") do
8
- concat content_tag(:span, title_content)
9
- concat content_tag(:a,
10
- item[:email_address],
11
- class: "govuk-link",
12
- href: "mailto:#{item[:email_address]}")
7
+ content_tag(:div, class: "email-url-number") do
8
+ content_tag(:p) do
9
+ concat content_tag(:span, item[:title])
10
+ concat content_tag(:a,
11
+ item[:email_address],
12
+ class: "email",
13
+ href: "mailto:#{item[:email_address]}")
14
+ end
13
15
  end
14
16
  end
15
17
  end
@@ -6,15 +6,15 @@ module ContentBlockTools
6
6
  BASE_TAG_TYPE = :div
7
7
 
8
8
  def render
9
- content_tag(:div, class: "govuk-body") do
9
+ content_tag(:div, class: "email-url-number") do
10
10
  concat number_list
11
- concat opening_hours_list if item[:opening_hours].any?
11
+ concat opening_hours_list if item[:opening_hours].present?
12
12
  concat call_charges_link
13
13
  end
14
14
  end
15
15
 
16
16
  def number_list
17
- content_tag(:ul, class: "govuk-!-padding-0 govuk-!-margin-0 govuk-list") do
17
+ content_tag(:ul) do
18
18
  item[:telephone_numbers].each do |number|
19
19
  concat number_list_item(number)
20
20
  end
@@ -22,11 +22,14 @@ module ContentBlockTools
22
22
  end
23
23
 
24
24
  def number_list_item(number)
25
- content_tag(:li, "#{number[:label]}: #{number[:telephone_number]}", class: "govuk-!-margin-bottom-0")
25
+ content_tag(:li) do
26
+ concat content_tag(:span, number[:label])
27
+ concat content_tag(:span, number[:telephone_number], { class: "tel" })
28
+ end
26
29
  end
27
30
 
28
31
  def opening_hours_list
29
- content_tag(:ul, class: "govuk-!-padding-0 govuk-!-margin-0 govuk-list") do
32
+ content_tag(:ul) do
30
33
  item[:opening_hours].each do |item|
31
34
  concat opening_hours_list_item(item)
32
35
  end
@@ -34,12 +37,12 @@ module ContentBlockTools
34
37
  end
35
38
 
36
39
  def opening_hours_list_item(item)
37
- content_tag(:li, "#{item[:day_from]} to #{item[:day_to]}, #{item[:time_from]} to #{item[:time_to]}", class: "govuk-!-margin-bottom-0")
40
+ content_tag(:li, "#{item[:day_from]} to #{item[:day_to]}, #{item[:time_from]} to #{item[:time_to]}")
38
41
  end
39
42
 
40
43
  def call_charges_link
41
44
  if item[:show_uk_call_charges] == "true"
42
- content_tag(:p, class: "govuk-!-margin-0") do
45
+ content_tag(:p) do
43
46
  concat content_tag(:a,
44
47
  "Find out about call charges",
45
48
  class: "govuk-link",
@@ -20,10 +20,14 @@ module ContentBlockTools
20
20
 
21
21
  def default_content
22
22
  content_tag(:div, class: "contact") do
23
- concat content_tag(:p, content_block.title, class: "govuk-body")
24
- embedded_objects.each do |object|
25
- items = send(object)
26
- concat(items.map { |item| presenter_for_object_type(object).new(item).render }.join.html_safe)
23
+ content_tag(:div, class: "content") do
24
+ content_tag(:div, class: "vcard contact-inner") do
25
+ concat content_tag(:p, content_block.title, class: "fn org")
26
+ embedded_objects.each do |object|
27
+ items = send(object)
28
+ concat(items.map { |item| presenter_for_object_type(object).new(item).render }.join.html_safe)
29
+ end
30
+ end
27
31
  end
28
32
  end
29
33
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ContentBlockTools
4
- VERSION = "0.6.5"
4
+ VERSION = "0.7.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: content_block_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev