content_block_tools 0.16.0 → 1.0.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 +4 -4
- data/.github/workflows/ci.yml +26 -6
- data/.gitignore +1 -0
- data/CHANGELOG.md +9 -0
- data/app/assets/stylesheets/blocks/_contact.scss +13 -0
- data/app/assets/stylesheets/content_block_tools.scss +24 -0
- data/lib/content_block_tools/engine.rb +16 -0
- data/lib/content_block_tools/presenters/block_presenters/contact/address_presenter.rb +3 -8
- data/lib/content_block_tools/presenters/block_presenters/contact/block_level_contact_item.rb +10 -16
- data/lib/content_block_tools/presenters/block_presenters/contact/contact_link_presenter.rb +6 -4
- data/lib/content_block_tools/presenters/block_presenters/contact/email_address_presenter.rb +10 -4
- data/lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb +9 -26
- data/lib/content_block_tools/presenters/contact_presenter.rb +6 -10
- data/lib/content_block_tools/version.rb +1 -1
- data/lib/content_block_tools.rb +2 -8
- data/package-lock.json +22 -0
- data/package.json +9 -0
- metadata +6 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a56c786b7424a15facf7bd8f34bfb17922418c109b10fb6fd1854b48c713252
|
4
|
+
data.tar.gz: 83a46bcfcb4e77e05dd1a245bbe009defc1f09225a877fce535b7a9a703cd8b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a407aa51ec57374cecef4f1c057b3cbcb99a248670509ea210cf453734d7343a1518513631fbc93050aa727576f3d9aa70a693151ca48c1e36379df0dcca324f
|
7
|
+
data.tar.gz: 9176b9453c70a7cc1a30e06463b47a97e787c0de25206300c662bcfb8329f1a7bec6244c0243944ed10307a7e81b78fc7050e51c92b7cb550d179cdafee042b4
|
data/.github/workflows/ci.yml
CHANGED
@@ -44,12 +44,32 @@ jobs:
|
|
44
44
|
- run: echo "All matrix tests have passed 🚀"
|
45
45
|
|
46
46
|
publish:
|
47
|
-
needs:
|
47
|
+
needs: test
|
48
|
+
runs-on: ubuntu-latest
|
48
49
|
if: ${{ github.ref == 'refs/heads/main' }}
|
49
50
|
permissions:
|
50
51
|
contents: write
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
52
|
+
steps:
|
53
|
+
- uses: actions/checkout@v4
|
54
|
+
- uses: ruby/setup-ruby@v1
|
55
|
+
with:
|
56
|
+
rubygems: latest
|
57
|
+
- uses: actions/setup-node@v4.4.0
|
58
|
+
with:
|
59
|
+
node-version: lts/* # use the latest LTS release
|
60
|
+
- run: yarn install
|
61
|
+
- env:
|
62
|
+
GEM_HOST_API_KEY: ${{ secrets.ALPHAGOV_RUBYGEMS_API_KEY }}
|
63
|
+
run: |
|
64
|
+
VERSION=$(ruby -r rubygems -e "puts Gem::Specification::load('content_block_tools.gemspec').version")
|
65
|
+
GEM_VERSION=$(gem list --exact --remote content_block_tools)
|
66
|
+
|
67
|
+
if [ "${GEM_VERSION}" != "content_block_tools (${VERSION})" ]; then
|
68
|
+
gem build content_block_tools.gemspec
|
69
|
+
gem push "content_block_tools-${VERSION}.gem"
|
70
|
+
fi
|
71
|
+
|
72
|
+
if ! git ls-remote --tags --exit-code origin v"${VERSION}"; then
|
73
|
+
git tag v"${VERSION}"
|
74
|
+
git push --tags
|
75
|
+
fi
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,15 @@
|
|
7
7
|
useful summary for people upgrading their application, not a replication
|
8
8
|
of the commit log.
|
9
9
|
|
10
|
+
## 1.0.0
|
11
|
+
|
12
|
+
- Add portable styling to the gem ([76](https://github.com/alphagov/govuk_content_block_tools/pull/76))
|
13
|
+
- Update contact blocks to match design system ([76](https://github.com/alphagov/govuk_content_block_tools/pull/76))
|
14
|
+
|
15
|
+
## 0.17.0
|
16
|
+
|
17
|
+
- Use recipient field in address ([75](https://github.com/alphagov/govuk_content_block_tools/pull/75))
|
18
|
+
|
10
19
|
## 0.16.0
|
11
20
|
|
12
21
|
- Use label as link text for contact link ([74](https://github.com/alphagov/govuk_content_block_tools/pull/74))
|
@@ -0,0 +1,24 @@
|
|
1
|
+
@import "govuk/core/lists";
|
2
|
+
@import "govuk/core/typography";
|
3
|
+
|
4
|
+
@import "blocks/contact";
|
5
|
+
|
6
|
+
.content-block {
|
7
|
+
&__body {
|
8
|
+
@extend %govuk-body-m;
|
9
|
+
}
|
10
|
+
|
11
|
+
ul#{&}__list {
|
12
|
+
@extend %govuk-list;
|
13
|
+
margin-left: 0;
|
14
|
+
|
15
|
+
& > li {
|
16
|
+
list-style: none;
|
17
|
+
margin-bottom: govuk-spacing(1);
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
&__link {
|
22
|
+
@extend %govuk-link;
|
23
|
+
}
|
24
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module ContentBlockTools
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace ContentBlockTools
|
4
|
+
|
5
|
+
initializer "content_block_tools.assets" do
|
6
|
+
Rails.application.config.assets.paths += %w[
|
7
|
+
app/assets/stylesheets
|
8
|
+
node_modules/govuk-frontend/dist/govuk/core
|
9
|
+
]
|
10
|
+
end
|
11
|
+
|
12
|
+
initializer "content_block_tools.initialize_logger" do
|
13
|
+
ContentBlockTools.logger = Rails.logger
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -11,8 +11,8 @@ module ContentBlockTools
|
|
11
11
|
wrapper do
|
12
12
|
output = []
|
13
13
|
|
14
|
-
output << content_tag(:p, class: "adr") do
|
15
|
-
%i[
|
14
|
+
output << content_tag(:p, class: "adr content-block__body") do
|
15
|
+
%i[recipient street_address town_or_city state_or_county postal_code country].map { |field|
|
16
16
|
next if item[field].blank?
|
17
17
|
|
18
18
|
content_tag(:span, item[field], { class: class_for_field_name(field) })
|
@@ -27,6 +27,7 @@ module ContentBlockTools
|
|
27
27
|
|
28
28
|
def class_for_field_name(field_name)
|
29
29
|
{
|
30
|
+
recipient: "organization-name",
|
30
31
|
street_address: "street-address",
|
31
32
|
town_or_city: "locality",
|
32
33
|
state_or_county: "region",
|
@@ -34,12 +35,6 @@ module ContentBlockTools
|
|
34
35
|
country: "country-name",
|
35
36
|
}[field_name]
|
36
37
|
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def show_title_in_field_names_context?
|
41
|
-
false
|
42
|
-
end
|
43
38
|
end
|
44
39
|
end
|
45
40
|
end
|
data/lib/content_block_tools/presenters/block_presenters/contact/block_level_contact_item.rb
CHANGED
@@ -12,26 +12,20 @@ module ContentBlockTools
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def wrapper(&block)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
concat yield block
|
19
|
-
end
|
20
|
-
else
|
21
|
-
yield block
|
15
|
+
content_tag(:div) do
|
16
|
+
concat title
|
17
|
+
concat yield block
|
22
18
|
end
|
23
19
|
end
|
24
20
|
|
25
21
|
def title
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
def show_title_in_field_names_context?
|
34
|
-
true
|
22
|
+
if @rendering_context == :field_names
|
23
|
+
content_tag(:p,
|
24
|
+
@content_block.title,
|
25
|
+
class: "content-block__title")
|
26
|
+
else
|
27
|
+
content_tag(:p, item[:title], class: "content-block__subtitle")
|
28
|
+
end
|
35
29
|
end
|
36
30
|
end
|
37
31
|
end
|
@@ -9,7 +9,7 @@ module ContentBlockTools
|
|
9
9
|
|
10
10
|
def render
|
11
11
|
wrapper do
|
12
|
-
content_tag(:
|
12
|
+
content_tag(:ul, class: "content-block__list") do
|
13
13
|
concat link
|
14
14
|
concat description if item[:description]
|
15
15
|
end
|
@@ -17,10 +17,10 @@ module ContentBlockTools
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def link
|
20
|
-
content_tag(:
|
20
|
+
content_tag(:li) do
|
21
21
|
content_tag(:a,
|
22
22
|
link_text,
|
23
|
-
class: "url",
|
23
|
+
class: "url content-block__link",
|
24
24
|
href: item[:url])
|
25
25
|
end
|
26
26
|
end
|
@@ -30,7 +30,9 @@ module ContentBlockTools
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def description
|
33
|
-
|
33
|
+
content_tag(:li) do
|
34
|
+
render_govspeak(item[:description])
|
35
|
+
end
|
34
36
|
end
|
35
37
|
end
|
36
38
|
end
|
@@ -9,18 +9,18 @@ module ContentBlockTools
|
|
9
9
|
|
10
10
|
def render
|
11
11
|
wrapper do
|
12
|
-
content_tag(:
|
12
|
+
content_tag(:ul, class: "content-block__list") do
|
13
13
|
concat email
|
14
|
-
concat
|
14
|
+
concat description if item[:description].present?
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
def email
|
20
|
-
content_tag(:
|
20
|
+
content_tag(:li) do
|
21
21
|
concat content_tag(:a,
|
22
22
|
link_text,
|
23
|
-
class: "email",
|
23
|
+
class: "email content-block__link",
|
24
24
|
href: "mailto:#{item[:email_address]}#{query_params}")
|
25
25
|
end
|
26
26
|
end
|
@@ -37,6 +37,12 @@ module ContentBlockTools
|
|
37
37
|
def link_text
|
38
38
|
item[:label] || item[:email_address]
|
39
39
|
end
|
40
|
+
|
41
|
+
def description
|
42
|
+
content_tag(:li) do
|
43
|
+
render_govspeak(item[:description])
|
44
|
+
end
|
45
|
+
end
|
40
46
|
end
|
41
47
|
end
|
42
48
|
end
|
@@ -9,8 +9,8 @@ module ContentBlockTools
|
|
9
9
|
|
10
10
|
def render
|
11
11
|
wrapper do
|
12
|
-
content_tag(:div
|
13
|
-
concat
|
12
|
+
content_tag(:div) do
|
13
|
+
concat description if item[:description].present?
|
14
14
|
concat number_list
|
15
15
|
concat video_relay_service
|
16
16
|
concat bsl_details
|
@@ -20,29 +20,12 @@ module ContentBlockTools
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
def title_and_description
|
24
|
-
items = [
|
25
|
-
(item_title if item[:title].present?),
|
26
|
-
(description if item[:description].present?),
|
27
|
-
].compact
|
28
|
-
|
29
|
-
if items.any?
|
30
|
-
content_tag(:div, class: "govuk-!-margin-bottom-3") do
|
31
|
-
concat items.join("").html_safe
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def item_title
|
37
|
-
content_tag(:p, item[:title], { class: "govuk-!-margin-bottom-0" })
|
38
|
-
end
|
39
|
-
|
40
23
|
def description
|
41
|
-
render_govspeak(item[:description], root_class: "
|
24
|
+
render_govspeak(item[:description], root_class: "content-block__body")
|
42
25
|
end
|
43
26
|
|
44
27
|
def number_list
|
45
|
-
content_tag(:ul) do
|
28
|
+
content_tag(:ul, class: "content-block__list") do
|
46
29
|
item[:telephone_numbers].each do |number|
|
47
30
|
concat number_list_item(number)
|
48
31
|
end
|
@@ -51,7 +34,7 @@ module ContentBlockTools
|
|
51
34
|
|
52
35
|
def number_list_item(number)
|
53
36
|
content_tag(:li) do
|
54
|
-
concat content_tag(:span, number[:label])
|
37
|
+
concat content_tag(:span, "#{number[:label]}: ")
|
55
38
|
concat content_tag(:span, number[:telephone_number], { class: "tel" })
|
56
39
|
end
|
57
40
|
end
|
@@ -61,20 +44,20 @@ module ContentBlockTools
|
|
61
44
|
|
62
45
|
if video_relay_service[:show]
|
63
46
|
content = "#{video_relay_service[:prefix]} #{video_relay_service[:telephone_number]}"
|
64
|
-
render_govspeak(content, root_class: "
|
47
|
+
render_govspeak(content, root_class: "content-block__body")
|
65
48
|
end
|
66
49
|
end
|
67
50
|
|
68
51
|
def bsl_details
|
69
52
|
bsl_guidance = item[:bsl_guidance] || {}
|
70
53
|
|
71
|
-
render_govspeak(bsl_guidance[:value], root_class: "
|
54
|
+
render_govspeak(bsl_guidance[:value], root_class: "content-block__body") if bsl_guidance[:show]
|
72
55
|
end
|
73
56
|
|
74
57
|
def opening_hours
|
75
58
|
opening_hours = item[:opening_hours] || {}
|
76
59
|
|
77
|
-
render_govspeak(opening_hours[:opening_hours], root_class: "
|
60
|
+
render_govspeak(opening_hours[:opening_hours], root_class: "content-block__body") if opening_hours[:show_opening_hours]
|
78
61
|
end
|
79
62
|
|
80
63
|
def opening_hours_list_item(item)
|
@@ -88,7 +71,7 @@ module ContentBlockTools
|
|
88
71
|
content_tag(:p) do
|
89
72
|
concat content_tag(:a,
|
90
73
|
call_charges[:label],
|
91
|
-
class: "
|
74
|
+
class: "content-block__link",
|
92
75
|
href: call_charges[:call_charges_info_url])
|
93
76
|
end
|
94
77
|
end
|
@@ -22,16 +22,12 @@ module ContentBlockTools
|
|
22
22
|
private
|
23
23
|
|
24
24
|
def default_content
|
25
|
-
content_tag(:div, class: "
|
26
|
-
content_tag(:
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
items = send(object)
|
32
|
-
concat(items.map { |item| presenter_for_object_type(object).new(item, content_block:).render }.join.html_safe)
|
33
|
-
end
|
34
|
-
end
|
25
|
+
content_tag(:div, class: "vcard") do
|
26
|
+
concat content_tag(:p, content_block.title, class: "fn org content-block__title")
|
27
|
+
concat render_govspeak(content_block.details[:description]) if content_block.details[:description]
|
28
|
+
embedded_objects.each do |object|
|
29
|
+
items = send(object)
|
30
|
+
concat(items.map { |item| presenter_for_object_type(object).new(item, content_block:).render }.join.html_safe)
|
35
31
|
end
|
36
32
|
end
|
37
33
|
end
|
data/lib/content_block_tools.rb
CHANGED
@@ -22,6 +22,8 @@ require "content_block_tools/presenters/pension_presenter"
|
|
22
22
|
require "content_block_tools/content_block"
|
23
23
|
require "content_block_tools/content_block_reference"
|
24
24
|
|
25
|
+
require "content_block_tools/engine"
|
26
|
+
|
25
27
|
require "content_block_tools/version"
|
26
28
|
|
27
29
|
module ContentBlockTools
|
@@ -35,12 +37,4 @@ module ContentBlockTools
|
|
35
37
|
@logger ||= Logger.new($stdout)
|
36
38
|
end
|
37
39
|
end
|
38
|
-
|
39
|
-
if defined?(Rails::Railtie)
|
40
|
-
class Railtie < Rails::Railtie
|
41
|
-
initializer "content_block_tools.initialize_logger" do
|
42
|
-
ContentBlockTools.logger = Rails.logger
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
40
|
end
|
data/package-lock.json
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
{
|
2
|
+
"name": "content_block_tools",
|
3
|
+
"lockfileVersion": 3,
|
4
|
+
"requires": true,
|
5
|
+
"packages": {
|
6
|
+
"": {
|
7
|
+
"name": "content_block_tools",
|
8
|
+
"license": "MIT",
|
9
|
+
"dependencies": {
|
10
|
+
"govuk-frontend": "^5.11.1"
|
11
|
+
}
|
12
|
+
},
|
13
|
+
"node_modules/govuk-frontend": {
|
14
|
+
"version": "5.11.1",
|
15
|
+
"resolved": "https://registry.npmjs.org/govuk-frontend/-/govuk-frontend-5.11.1.tgz",
|
16
|
+
"integrity": "sha512-hJJFpaer4MZLvz/2F9RZ7xZ6FqlzpxL9aw6YWOGK3F1tn419xj2WcVXwOC8Bcj/dc/LanknbWJDGkb+IdkuhTQ==",
|
17
|
+
"engines": {
|
18
|
+
"node": ">= 4.2.0"
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
data/package.json
ADDED
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.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
@@ -113,12 +113,15 @@ files:
|
|
113
113
|
- LICENSE.txt
|
114
114
|
- README.md
|
115
115
|
- Rakefile
|
116
|
+
- app/assets/stylesheets/blocks/_contact.scss
|
117
|
+
- app/assets/stylesheets/content_block_tools.scss
|
116
118
|
- bin/console
|
117
119
|
- bin/setup
|
118
120
|
- content_block_tools.gemspec
|
119
121
|
- lib/content_block_tools.rb
|
120
122
|
- lib/content_block_tools/content_block.rb
|
121
123
|
- lib/content_block_tools/content_block_reference.rb
|
124
|
+
- lib/content_block_tools/engine.rb
|
122
125
|
- lib/content_block_tools/helpers/govspeak.rb
|
123
126
|
- lib/content_block_tools/presenters/base_presenter.rb
|
124
127
|
- lib/content_block_tools/presenters/block_presenters/base_presenter.rb
|
@@ -132,6 +135,8 @@ files:
|
|
132
135
|
- lib/content_block_tools/presenters/field_presenters/contact/email_address_presenter.rb
|
133
136
|
- lib/content_block_tools/presenters/pension_presenter.rb
|
134
137
|
- lib/content_block_tools/version.rb
|
138
|
+
- package-lock.json
|
139
|
+
- package.json
|
135
140
|
homepage: https://github.com/alphagov/content_block_tools
|
136
141
|
licenses:
|
137
142
|
- MIT
|