content_block_tools 1.6.2 → 1.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 +4 -4
- data/app/components/content_block_tools/base_component.rb +2 -0
- data/app/components/content_block_tools/contact_component.html.erb +14 -18
- data/app/components/content_block_tools/contacts/contact_link_component.html.erb +1 -1
- data/app/components/content_block_tools/contacts/email_address_component.html.erb +1 -1
- data/app/components/content_block_tools/contacts/telephone_component.html.erb +1 -1
- data/lib/content_block_tools/helpers/override_classes.rb +99 -0
- data/lib/content_block_tools/version.rb +1 -1
- data/lib/content_block_tools.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8bf99fd8affbea779c0cdf676527123d493ef6e52736b2ef53e037751edda3db
|
|
4
|
+
data.tar.gz: 00c4d22fd4f3c02a2d287cb9897ded18cdcb45d8e65c9788c11b0a1e9f783cc1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4e69ba2bb65f19db0f5f8d5f74d958cf5e4a999c40498579d1caec2425b43dfee14e2d42597682f9f7956ecc4e25c95245ccf4e63ab96a8eb9960bbd8f8f9f0b
|
|
7
|
+
data.tar.gz: 40e4924121bfe450ca64b92bf8f6b4e89da077c189cb236fd09b61853e5e2a4fac63135de438413cbb791e72e84dd7ee692ba28bba1fc3dd4d19538eb5792cce
|
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
<
|
|
2
|
-
<dt class="content-block__contact-key fn org"><%= content_block.title %></dt>
|
|
3
|
-
|
|
1
|
+
<div class="vcard">
|
|
4
2
|
<% if block_type.nil? %>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
</
|
|
3
|
+
<%= render_govspeak(content_block.details[:description]) if content_block.details[:description] %>
|
|
4
|
+
<dl class="<%= margin_classes(0) %> <%= padding_classes(0) %>">
|
|
5
|
+
<% items.each do |block_type, _, item| %>
|
|
6
|
+
<dt class="<%= margin_classes(0, 0, 4, 0) %> <%= padding_classes(0) %> <%= font_classes(19, "bold") %>">
|
|
7
|
+
<%= item[:title] %>
|
|
8
|
+
</dt>
|
|
9
|
+
<dd class="<%= margin_classes(0) %>">
|
|
10
|
+
<%= component_for_block_type(block_type).new(item:).render.html_safe %>
|
|
11
|
+
</dd>
|
|
12
|
+
<% end %>
|
|
13
|
+
</dl>
|
|
16
14
|
<% else %>
|
|
17
|
-
|
|
18
|
-
<%= component_for_block_type(block_type).new(item: item_to_render).render.html_safe %>
|
|
19
|
-
</dd>
|
|
15
|
+
<%= component_for_block_type(block_type).new(item: item_to_render).render.html_safe %>
|
|
20
16
|
<% end %>
|
|
21
|
-
</
|
|
17
|
+
</div>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<%= render_govspeak(item[:description]) %>
|
|
3
3
|
<% end %>
|
|
4
4
|
|
|
5
|
-
<ul class="
|
|
5
|
+
<ul class="govuk-list list-no-bullets <%= margin_classes(0) %>">
|
|
6
6
|
<% item[:telephone_numbers].each do |number| %>
|
|
7
7
|
<li class="govuk-!-margin-bottom-1">
|
|
8
8
|
<span><%= number[:label] %>: </span>
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Module for generating GOV.UK Design System CSS utility classes
|
|
2
|
+
module ContentBlockTools
|
|
3
|
+
# Helper methods for generating override CSS classes
|
|
4
|
+
# These methods generate CSS class names for spacing and typography utilities
|
|
5
|
+
# from the GOV.UK Design System.
|
|
6
|
+
module OverrideClasses
|
|
7
|
+
# Generates margin CSS classes
|
|
8
|
+
#
|
|
9
|
+
# @param top [Integer, String] the margin value for all sides (if used alone) or top margin
|
|
10
|
+
# @param right [Integer, String, nil] the right margin value (optional)
|
|
11
|
+
# @param bottom [Integer, String, nil] the bottom margin value (optional)
|
|
12
|
+
# @param left [Integer, String, nil] the left margin value (optional)
|
|
13
|
+
# @return [String] the generated margin class(es)
|
|
14
|
+
#
|
|
15
|
+
# @example Generate uniform margin
|
|
16
|
+
# margin_classes(4)
|
|
17
|
+
# # => "govuk-!-margin-4"
|
|
18
|
+
#
|
|
19
|
+
# @example Generate individual side margins
|
|
20
|
+
# margin_classes(4, 3, 2, 1)
|
|
21
|
+
# # => "govuk-!-margin-top-4 govuk-!-margin-right-3 govuk-!-margin-bottom-2 govuk-!-margin-left-1"
|
|
22
|
+
def margin_classes(top, right = nil, bottom = nil, left = nil)
|
|
23
|
+
spacing_classes("margin", top, right, bottom, left)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Generates padding CSS classes
|
|
27
|
+
#
|
|
28
|
+
# @param top [Integer, String] the padding value for all sides (if used alone) or top padding
|
|
29
|
+
# @param right [Integer, String, nil] the right padding value (optional)
|
|
30
|
+
# @param bottom [Integer, String, nil] the bottom padding value (optional)
|
|
31
|
+
# @param left [Integer, String, nil] the left padding value (optional)
|
|
32
|
+
# @return [String] the generated padding class(es)
|
|
33
|
+
#
|
|
34
|
+
# @example Generate uniform padding
|
|
35
|
+
# padding_classes(4)
|
|
36
|
+
# # => "govuk-!-padding-4"
|
|
37
|
+
#
|
|
38
|
+
# @example Generate individual side paddings
|
|
39
|
+
# padding_classes(4, 3, 2, 1)
|
|
40
|
+
# # => "govuk-!-padding-top-4 govuk-!-padding-right-3 govuk-!-padding-bottom-2 govuk-!-padding-left-1"
|
|
41
|
+
def padding_classes(top, right = nil, bottom = nil, left = nil)
|
|
42
|
+
spacing_classes("padding", top, right, bottom, left)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Generates combined font size and weight CSS classes
|
|
46
|
+
#
|
|
47
|
+
# @param size [Integer, String] the font size value (e.g., 16, 19, 24)
|
|
48
|
+
# @param weight [String, Symbol] the font weight value (e.g., "bold", "regular")
|
|
49
|
+
# @return [String] the generated font size and weight classes separated by a space
|
|
50
|
+
#
|
|
51
|
+
# @example Generate font classes with size and weight
|
|
52
|
+
# font_classes(19, "bold")
|
|
53
|
+
# # => "govuk-!-font-size-19 govuk-!-font-weight-bold"
|
|
54
|
+
#
|
|
55
|
+
# @example Generate font classes with different values
|
|
56
|
+
# font_classes(24, "regular")
|
|
57
|
+
# # => "govuk-!-font-size-24 govuk-!-font-weight-regular"
|
|
58
|
+
def font_classes(size, weight)
|
|
59
|
+
[
|
|
60
|
+
font_size_class(size),
|
|
61
|
+
font_weight_class(weight),
|
|
62
|
+
].join(" ")
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Generates a font size CSS class
|
|
66
|
+
#
|
|
67
|
+
# @param size [Integer, String] the font size value (e.g., 16, 19, 24)
|
|
68
|
+
# @return [String] the generated font size class
|
|
69
|
+
#
|
|
70
|
+
# @example
|
|
71
|
+
# font_size_class(19)
|
|
72
|
+
# # => "govuk-!-font-size-19"
|
|
73
|
+
def font_size_class(size)
|
|
74
|
+
"govuk-!-font-size-#{size}"
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Generates a font weight CSS class
|
|
78
|
+
#
|
|
79
|
+
# @param weight [String, Symbol] the font weight value (e.g., "bold", "regular")
|
|
80
|
+
# @return [String] the generated font weight class
|
|
81
|
+
#
|
|
82
|
+
# @example
|
|
83
|
+
# font_weight_class("bold")
|
|
84
|
+
# # => "govuk-!-font-weight-bold"
|
|
85
|
+
def font_weight_class(weight)
|
|
86
|
+
"govuk-!-font-weight-#{weight}"
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
private
|
|
90
|
+
|
|
91
|
+
def spacing_classes(type, top, right = nil, bottom = nil, left = nil)
|
|
92
|
+
if right.nil? && bottom.nil? && left.nil?
|
|
93
|
+
"govuk-!-#{type}-#{top}"
|
|
94
|
+
else
|
|
95
|
+
%W[govuk-!-#{type}-top-#{top} govuk-!-#{type}-right-#{right} govuk-!-#{type}-bottom-#{bottom} govuk-!-#{type}-left-#{left}].join(" ")
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
data/lib/content_block_tools.rb
CHANGED
|
@@ -6,6 +6,7 @@ require "gds-api-adapters"
|
|
|
6
6
|
require "govspeak"
|
|
7
7
|
|
|
8
8
|
require "content_block_tools/helpers/govspeak"
|
|
9
|
+
require "content_block_tools/helpers/override_classes"
|
|
9
10
|
|
|
10
11
|
require "content_block_tools/presenters/field_presenters/base_presenter"
|
|
11
12
|
require "content_block_tools/presenters/field_presenters/contact/email_presenter"
|
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: 1.
|
|
4
|
+
version: 1.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- GOV.UK Dev
|
|
@@ -185,6 +185,7 @@ files:
|
|
|
185
185
|
- lib/content_block_tools/content_block_reference.rb
|
|
186
186
|
- lib/content_block_tools/engine.rb
|
|
187
187
|
- lib/content_block_tools/helpers/govspeak.rb
|
|
188
|
+
- lib/content_block_tools/helpers/override_classes.rb
|
|
188
189
|
- lib/content_block_tools/presenters/field_presenters/base_presenter.rb
|
|
189
190
|
- lib/content_block_tools/presenters/field_presenters/contact/email_presenter.rb
|
|
190
191
|
- lib/content_block_tools/version.rb
|