govuk_publishing_components 45.6.1 → 45.8.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/assets/javascripts/govuk_publishing_components/components/search-with-autocomplete.js +4 -4
- data/app/views/govuk_publishing_components/components/_chart.html.erb +9 -56
- data/app/views/govuk_publishing_components/components/_label.html.erb +8 -7
- data/app/views/govuk_publishing_components/components/_lead_paragraph.html.erb +7 -6
- data/app/views/govuk_publishing_components/components/docs/chart.yml +130 -1
- data/app/views/govuk_publishing_components/components/docs/contextual_breadcrumbs.yml +2 -1
- data/app/views/govuk_publishing_components/components/docs/label.yml +1 -0
- data/app/views/govuk_publishing_components/components/docs/lead_paragraph.yml +2 -0
- data/config/locales/en.yml +1 -1
- data/lib/govuk_publishing_components/presenters/breadcrumb_selector.rb +5 -0
- data/lib/govuk_publishing_components/presenters/chart_helper.rb +106 -0
- data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_organisations.rb +36 -0
- data/lib/govuk_publishing_components/presenters/contextual_navigation.rb +16 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/lib/govuk_publishing_components.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7048798873f02e7ccdd7098ca9ce280a403df59e5b24d1ae54f93b6405971c48
|
|
4
|
+
data.tar.gz: 7145d41beda3ab925378248e55ee8dc9afb34585cc5a81df804a74fd664d1f05
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d39c1a66ce5dbe6bca7dd41e7864170d4b413c250be1806fbe6873677bbc89126cab120ebb92741735ebd90665d3deb7c1cee17145770f9b2636f236ae67a1ae
|
|
7
|
+
data.tar.gz: 0a7f8ff45a1b76035cbf7842f3344d61bf1c2174727b643868a4814aacde5dfccfe87d7fd8b0dd57406ff52b70f6a0926041fd75413433178bc571ab17b1d942
|
data/app/assets/javascripts/govuk_publishing_components/components/search-with-autocomplete.js
CHANGED
|
@@ -116,15 +116,15 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
116
116
|
// Set tracking attributes on the input field. These can be used by the containing form's
|
|
117
117
|
// analytics module to track the user's interaction with the autocomplete component.
|
|
118
118
|
setTrackingAttributes (query, results) {
|
|
119
|
-
// Only set the suggestions
|
|
120
|
-
//
|
|
121
|
-
// that doesn't generate any)
|
|
119
|
+
// Only set the suggestions and trigger input attributes when results actually come back (so
|
|
120
|
+
// these attributes track the last seen non-empty suggestions and input used to trigger them,
|
|
121
|
+
// even if the user then amends their query to one that doesn't generate any)
|
|
122
122
|
if (results.length > 0) {
|
|
123
123
|
const formattedResults = results.slice(0, 5).join('|')
|
|
124
124
|
this.$autocompleteInput.dataset.autocompleteSuggestions = formattedResults
|
|
125
|
+
this.$autocompleteInput.dataset.autocompleteTriggerInput = query
|
|
125
126
|
}
|
|
126
127
|
|
|
127
|
-
this.$autocompleteInput.dataset.autocompleteTriggerInput = query
|
|
128
128
|
this.$autocompleteInput.dataset.autocompleteSuggestionsCount = results.length
|
|
129
129
|
this.$autocompleteInput.dataset.autocompleteAccepted = false
|
|
130
130
|
}
|
|
@@ -5,28 +5,23 @@
|
|
|
5
5
|
add_gem_component_stylesheet("heading")
|
|
6
6
|
add_gem_component_stylesheet("skip-link")
|
|
7
7
|
|
|
8
|
-
chart_heading ||= nil
|
|
9
8
|
chart_heading_level ||= 2
|
|
10
9
|
table_direction ||= "horizontal"
|
|
11
|
-
h_axis_title ||= nil
|
|
12
|
-
v_axis_title ||= nil
|
|
13
10
|
rows ||= []
|
|
14
11
|
keys ||= []
|
|
15
12
|
chart_overview ||= nil
|
|
13
|
+
chart_type ||= "line"
|
|
16
14
|
minimal ||= false
|
|
17
15
|
hide_heading ||= minimal
|
|
18
|
-
hide_legend ||= minimal
|
|
19
16
|
link ||= false
|
|
20
|
-
height ||= 400
|
|
21
17
|
padding ||= false
|
|
22
|
-
point_size ||= 10
|
|
23
|
-
y_axis_auto_adjust ||= false
|
|
24
18
|
|
|
25
19
|
chart_id = "chart-id-#{SecureRandom.hex(4)}"
|
|
26
20
|
table_id = "table-id-#{SecureRandom.hex(4)}"
|
|
27
21
|
@external_script ||= OpenStruct.new(loaded: 0)
|
|
28
22
|
@external_script[:loaded] += 1
|
|
29
23
|
|
|
24
|
+
chart_helper = GovukPublishingComponents::Presenters::ChartHelper.new(local_assigns)
|
|
30
25
|
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
|
|
31
26
|
component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
|
|
32
27
|
component_helper.add_class("gem-c-chart")
|
|
@@ -36,58 +31,10 @@
|
|
|
36
31
|
|
|
37
32
|
require "chartkick"
|
|
38
33
|
Chartkick.options[:html] = '<div id="%{id}"><noscript><p class="govuk-body">Our charts are built using JavaScript but all the data is also available in the table below.</p></noscript></div>'
|
|
39
|
-
# config options are here: https://developers.google.com/chart/interactive/docs/gallery/linechart
|
|
40
|
-
font_16 = { color: '#000', fontName: 'GDS Transport', fontSize: '16', italic: false }
|
|
41
|
-
font_19 = { color: '#000', fontName: 'GDS Transport', fontSize: '19', italic: false }
|
|
42
|
-
legend = 'none'
|
|
43
|
-
legend = { position: 'top', textStyle: font_16 } unless hide_legend
|
|
44
|
-
point_size = 0 if minimal
|
|
45
|
-
enableInteractivity = true
|
|
46
|
-
enableInteractivity = false if minimal
|
|
47
|
-
textPosition = nil
|
|
48
|
-
textPosition = 'none' if minimal
|
|
49
|
-
y_axis_view_window_min = 0
|
|
50
|
-
y_axis_view_window_min = "auto" if y_axis_auto_adjust
|
|
51
34
|
|
|
52
35
|
if !minimal && !chart_heading
|
|
53
36
|
raise ArgumentError, "A chart heading must be provided for accessibility purposes."
|
|
54
37
|
end
|
|
55
|
-
|
|
56
|
-
chart_library_options = {
|
|
57
|
-
chartArea: { width: '80%', height: '60%' },
|
|
58
|
-
crosshair: { orientation: 'vertical', trigger: 'both', color: '#ccc' },
|
|
59
|
-
curveType: 'none',
|
|
60
|
-
enableInteractivity: enableInteractivity,
|
|
61
|
-
legend: legend,
|
|
62
|
-
pointSize: point_size,
|
|
63
|
-
height: height,
|
|
64
|
-
tooltip: { isHtml: true },
|
|
65
|
-
hAxis: {
|
|
66
|
-
textStyle: font_16,
|
|
67
|
-
title: h_axis_title,
|
|
68
|
-
titleTextStyle: font_19,
|
|
69
|
-
textPosition: textPosition,
|
|
70
|
-
},
|
|
71
|
-
vAxis: {
|
|
72
|
-
textStyle: font_16,
|
|
73
|
-
title: v_axis_title,
|
|
74
|
-
titleTextStyle: font_19,
|
|
75
|
-
textPosition: textPosition,
|
|
76
|
-
viewWindow: {
|
|
77
|
-
min: y_axis_view_window_min
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if rows.length > 0 && keys.length > 0
|
|
83
|
-
chart_format_data = rows.map do |row|
|
|
84
|
-
{
|
|
85
|
-
name: row[:label],
|
|
86
|
-
linewidth: 10,
|
|
87
|
-
data: keys.zip(row[:values])
|
|
88
|
-
}
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
38
|
%>
|
|
92
39
|
<% if rows.length > 0 && keys.length > 0 %>
|
|
93
40
|
<%= javascript_include_tag "https://www.gstatic.com/charts/loader.js" if @external_script[:loaded] == 1 %>
|
|
@@ -117,7 +64,13 @@
|
|
|
117
64
|
</span>
|
|
118
65
|
<% end %>
|
|
119
66
|
|
|
120
|
-
|
|
67
|
+
<% if chart_type == "column" %>
|
|
68
|
+
<%= column_chart(chart_helper.chart_format_data, library: chart_helper.chart_options) %>
|
|
69
|
+
<% elsif chart_type == "bar" %>
|
|
70
|
+
<%= bar_chart(chart_helper.chart_format_data, library: chart_helper.chart_options) %>
|
|
71
|
+
<% else %>
|
|
72
|
+
<%= line_chart(chart_helper.chart_format_data, library: chart_helper.chart_options) %>
|
|
73
|
+
<% end %>
|
|
121
74
|
<% end %>
|
|
122
75
|
|
|
123
76
|
<% unless minimal %>
|
|
@@ -4,25 +4,26 @@
|
|
|
4
4
|
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
|
|
5
5
|
|
|
6
6
|
hint_text ||= ""
|
|
7
|
-
id ||= nil
|
|
8
7
|
is_radio_label ||= false
|
|
9
8
|
bold ||= false
|
|
10
9
|
heading_size = false unless shared_helper.valid_heading_size?(heading_size)
|
|
11
10
|
is_page_heading ||= false
|
|
12
11
|
right_to_left ||= false
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
|
|
14
|
+
component_helper.add_class("gem-c-label govuk-label")
|
|
15
|
+
component_helper.add_class("govuk-label--s") if bold
|
|
16
|
+
component_helper.add_class("govuk-radios__label") if is_radio_label
|
|
17
|
+
component_helper.add_class("govuk-label--#{heading_size}") if heading_size
|
|
18
|
+
component_helper.set_dir("rtl") if right_to_left
|
|
18
19
|
%>
|
|
19
20
|
|
|
20
21
|
<% if is_page_heading %>
|
|
21
22
|
<%= tag.h1 text, class: "govuk-label-wrapper" do %>
|
|
22
|
-
<%= tag.label text,
|
|
23
|
+
<%= tag.label text, for: html_for, **component_helper.all_attributes %>
|
|
23
24
|
<% end %>
|
|
24
25
|
<% else %>
|
|
25
|
-
<%= tag.label text,
|
|
26
|
+
<%= tag.label text, for: html_for, **component_helper.all_attributes %>
|
|
26
27
|
<% end %>
|
|
27
28
|
|
|
28
29
|
<% if hint_text.present? %>
|
|
@@ -5,12 +5,13 @@
|
|
|
5
5
|
inverse ||= false
|
|
6
6
|
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
classes << custom_margin_bottom_class if local_assigns[:margin_bottom]
|
|
8
|
+
component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
|
|
9
|
+
component_helper.add_class("gem-c-lead-paragraph")
|
|
10
|
+
component_helper.add_class("gem-c-lead-paragraph--inverse") if inverse
|
|
11
|
+
component_helper.add_class(shared_helper.get_margin_bottom) if [*0..9].include?(local_assigns[:margin_bottom])
|
|
13
12
|
%>
|
|
14
13
|
<% if text.present? %>
|
|
15
|
-
<%=
|
|
14
|
+
<%= tag.p(**component_helper.all_attributes) do %>
|
|
15
|
+
<%= text %>
|
|
16
|
+
<% end %>
|
|
16
17
|
<% end %>
|
|
@@ -22,7 +22,6 @@ examples:
|
|
|
22
22
|
h_axis_title: Day
|
|
23
23
|
v_axis_title: Views
|
|
24
24
|
chart_overview: This chart shows page views for January 2015.
|
|
25
|
-
hide_legend: true
|
|
26
25
|
keys:
|
|
27
26
|
- "2015-01-01"
|
|
28
27
|
- "2015-01-02"
|
|
@@ -102,6 +101,136 @@ examples:
|
|
|
102
101
|
- 27
|
|
103
102
|
- 18
|
|
104
103
|
- 34
|
|
104
|
+
hide_legend:
|
|
105
|
+
data:
|
|
106
|
+
chart_heading: Page views chart
|
|
107
|
+
h_axis_title: Day
|
|
108
|
+
v_axis_title: Views
|
|
109
|
+
chart_overview: This chart shows page views for January 2015.
|
|
110
|
+
hide_legend: true
|
|
111
|
+
keys:
|
|
112
|
+
- "2015-01-01"
|
|
113
|
+
- "2015-01-02"
|
|
114
|
+
- "2015-01-03"
|
|
115
|
+
- "2015-01-04"
|
|
116
|
+
- "2015-01-05"
|
|
117
|
+
- "2015-01-06"
|
|
118
|
+
- "2015-01-07"
|
|
119
|
+
- "2015-01-08"
|
|
120
|
+
- "2015-01-09"
|
|
121
|
+
- "2015-01-10"
|
|
122
|
+
rows:
|
|
123
|
+
- label: January 2015
|
|
124
|
+
values:
|
|
125
|
+
- 500
|
|
126
|
+
- 1190
|
|
127
|
+
- 740
|
|
128
|
+
- 820
|
|
129
|
+
- 270
|
|
130
|
+
- 450
|
|
131
|
+
- 110
|
|
132
|
+
- 210
|
|
133
|
+
- 670
|
|
134
|
+
- 430
|
|
135
|
+
with_line_colours_and_styles:
|
|
136
|
+
description: Note that line styles and colours currently only work on line charts.
|
|
137
|
+
data:
|
|
138
|
+
chart_heading: Page views chart
|
|
139
|
+
h_axis_title: Day
|
|
140
|
+
v_axis_title: Views
|
|
141
|
+
chart_overview: This chart shows page views for January in different years.
|
|
142
|
+
line_colours:
|
|
143
|
+
- orange
|
|
144
|
+
- blue
|
|
145
|
+
- "#88AA11"
|
|
146
|
+
line_styles:
|
|
147
|
+
- solid
|
|
148
|
+
- dotted
|
|
149
|
+
- solid
|
|
150
|
+
keys:
|
|
151
|
+
- 1st
|
|
152
|
+
- 2nd
|
|
153
|
+
- 3rd
|
|
154
|
+
rows:
|
|
155
|
+
- label: January 2015
|
|
156
|
+
values:
|
|
157
|
+
- 110
|
|
158
|
+
- 119
|
|
159
|
+
- 105
|
|
160
|
+
- label: January 2016
|
|
161
|
+
values:
|
|
162
|
+
- 71
|
|
163
|
+
- 68
|
|
164
|
+
- 75
|
|
165
|
+
- label: January 2017
|
|
166
|
+
values:
|
|
167
|
+
- 21
|
|
168
|
+
- 42
|
|
169
|
+
- 18
|
|
170
|
+
bar_chart:
|
|
171
|
+
data:
|
|
172
|
+
chart_heading: Hats owned
|
|
173
|
+
h_axis_title: Day
|
|
174
|
+
v_axis_title: Views
|
|
175
|
+
chart_overview: This chart shows page views for January 2015.
|
|
176
|
+
chart_type: "bar"
|
|
177
|
+
hide_legend: true
|
|
178
|
+
keys:
|
|
179
|
+
- Jon
|
|
180
|
+
- Ash
|
|
181
|
+
- James
|
|
182
|
+
- Phil
|
|
183
|
+
rows:
|
|
184
|
+
- label: Hats owned
|
|
185
|
+
values:
|
|
186
|
+
- 3
|
|
187
|
+
- 1
|
|
188
|
+
- 1
|
|
189
|
+
- 2
|
|
190
|
+
column_chart:
|
|
191
|
+
data:
|
|
192
|
+
chart_heading: Hats owned
|
|
193
|
+
h_axis_title: Day
|
|
194
|
+
v_axis_title: Views
|
|
195
|
+
chart_overview: This chart shows page views for January 2015.
|
|
196
|
+
chart_type: "column"
|
|
197
|
+
hide_legend: true
|
|
198
|
+
keys:
|
|
199
|
+
- Jon
|
|
200
|
+
- Ash
|
|
201
|
+
- James
|
|
202
|
+
- Phil
|
|
203
|
+
rows:
|
|
204
|
+
- label: Hats owned
|
|
205
|
+
values:
|
|
206
|
+
- 3
|
|
207
|
+
- 1
|
|
208
|
+
- 1
|
|
209
|
+
- 2
|
|
210
|
+
format_axis_labels:
|
|
211
|
+
description: Sometimes if there are a lot of labels on the axes the chart can do strange truncation on the labels. If they are meant to be dates, the `h_axis_format` and `v_axis_format` will force a familiar date format to get around this problem.
|
|
212
|
+
data:
|
|
213
|
+
chart_heading: Page views chart
|
|
214
|
+
h_axis_title: Day
|
|
215
|
+
v_axis_title: Views
|
|
216
|
+
chart_overview: This chart shows page views for January.
|
|
217
|
+
h_axis_format: date
|
|
218
|
+
keys:
|
|
219
|
+
- 2024 Jan 1
|
|
220
|
+
- 2024 Jan 2
|
|
221
|
+
- 2024 Jan 3
|
|
222
|
+
- 2024 Jan 4
|
|
223
|
+
- 2024 Jan 5
|
|
224
|
+
- 2024 Jan 6
|
|
225
|
+
rows:
|
|
226
|
+
- label: January 2015
|
|
227
|
+
values:
|
|
228
|
+
- 110
|
|
229
|
+
- 119
|
|
230
|
+
- 105
|
|
231
|
+
- 109
|
|
232
|
+
- 130
|
|
233
|
+
- 131
|
|
105
234
|
vertical table:
|
|
106
235
|
description: Reorient the table to better suit the output of some data sets.
|
|
107
236
|
data:
|
|
@@ -4,11 +4,12 @@ body: |
|
|
|
4
4
|
This is a complex component that calls other components. For more accurate
|
|
5
5
|
preview with real data, see the [contextual navigation preview][preview].
|
|
6
6
|
|
|
7
|
-
There are
|
|
7
|
+
There are 4 main variants of the component:
|
|
8
8
|
|
|
9
9
|
- Step by step, which uses the [step by step header][header]
|
|
10
10
|
- Parent breadcrumb, which uses the `parent` link of the page with the [breadcrumbs component][breadcrumbs]
|
|
11
11
|
- Taxon breadcrumb, which uses the `taxons` link of the page with the [breadcrumbs component][breadcrumbs]
|
|
12
|
+
- Organisation breadcrumb, which uses the `organisations` link of the page with the [breadcrumbs component][breadcrumbs]
|
|
12
13
|
|
|
13
14
|
It must always used [together with the contextual sidebar][sidebar] and [footer].
|
|
14
15
|
|
|
@@ -2,6 +2,7 @@ name: Form label
|
|
|
2
2
|
description: Use labels for all form fields.
|
|
3
3
|
body: |
|
|
4
4
|
For use with other form inputs e.g. [Radio buttons](/component-guide/radio)
|
|
5
|
+
uses_component_wrapper_helper: true
|
|
5
6
|
accessibility_criteria: |
|
|
6
7
|
All text must have a contrast ratio higher than 4.5:1 against the background colour to meet [WCAG AA](https://www.w3.org/TR/WCAG20/#visual-audio-contrast-contrast)
|
|
7
8
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
name: Lead paragraph
|
|
2
2
|
description: The opening paragraph of content. Typically a content item’s description field.
|
|
3
|
+
uses_component_wrapper_helper: true
|
|
3
4
|
accessibility_criteria: |
|
|
4
5
|
The lead paragraph must be visually distinct from other paragraphs.
|
|
5
6
|
|
|
@@ -10,6 +11,7 @@ examples:
|
|
|
10
11
|
text: 'UK Visas and Immigration is making changes to the Immigration Rules affecting various categories.'
|
|
11
12
|
right_to_left:
|
|
12
13
|
data:
|
|
14
|
+
dir: 'rtl'
|
|
13
15
|
text: 'قرارات تحقيقات وزارة الدفاع في الانتهاكات المزعومة للمادة ٢ والمادة ٣ من المعاهدة الاوروبية لحقوق الانسان خلال العمليات العسكرية في العراق.'
|
|
14
16
|
context:
|
|
15
17
|
right_to_left: true
|
data/config/locales/en.yml
CHANGED
|
@@ -33,7 +33,7 @@ en:
|
|
|
33
33
|
characters: characters
|
|
34
34
|
words: words
|
|
35
35
|
chart:
|
|
36
|
-
table_dropdown:
|
|
36
|
+
table_dropdown: View data as a table
|
|
37
37
|
accessibility_html: This chart is a visual representation of the data available in the table.
|
|
38
38
|
accessibility_link: Skip to "%{chart_heading}" data table
|
|
39
39
|
accessibility_heading: Data table for "%{chart_heading}"
|
|
@@ -55,6 +55,11 @@ module GovukPublishingComponents
|
|
|
55
55
|
step_by_step: false,
|
|
56
56
|
breadcrumbs: navigation.breadcrumbs,
|
|
57
57
|
}
|
|
58
|
+
elsif navigation.use_organisation_breadcrumbs?
|
|
59
|
+
{
|
|
60
|
+
step_by_step: false,
|
|
61
|
+
breadcrumbs: navigation.organisation_breadcrumbs,
|
|
62
|
+
}
|
|
58
63
|
elsif navigation.use_taxon_breadcrumbs?
|
|
59
64
|
{
|
|
60
65
|
step_by_step: false,
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
module GovukPublishingComponents
|
|
2
|
+
module Presenters
|
|
3
|
+
class ChartHelper
|
|
4
|
+
def initialize(options)
|
|
5
|
+
@rows = options[:rows]
|
|
6
|
+
@keys = options[:keys]
|
|
7
|
+
@minimal = options[:minimal]
|
|
8
|
+
@enable_interactivity = false
|
|
9
|
+
@enable_interactivity = true unless @minimal
|
|
10
|
+
@hide_legend = options[:hide_legend]
|
|
11
|
+
@hide_legend = true if @minimal
|
|
12
|
+
@point_size = options[:point_size] ||= 10
|
|
13
|
+
@point_size = 0 if @minimal
|
|
14
|
+
@height = options[:height] || 400
|
|
15
|
+
@h_axis_title = options[:h_axis_title]
|
|
16
|
+
@v_axis_title = options[:v_axis_title]
|
|
17
|
+
@text_position = "none" if @minimal
|
|
18
|
+
@y_axis_view_window_min = 0
|
|
19
|
+
@y_axis_view_window_min = "auto" if options[:y_axis_auto_adjust]
|
|
20
|
+
@line_colours = options[:line_colours]
|
|
21
|
+
@line_styles = options[:line_styles]
|
|
22
|
+
@h_axis_format = "YYYY-MM-dd" if options[:h_axis_format] == "date"
|
|
23
|
+
@v_axis_format = "YYYY-MM-dd" if options[:v_axis_format] == "date"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# config options are here: https://developers.google.com/chart/interactive/docs/gallery/linechart
|
|
27
|
+
def chart_options
|
|
28
|
+
{
|
|
29
|
+
chartArea: { width: "80%", height: "60%" },
|
|
30
|
+
crosshair: { orientation: "vertical", trigger: "both", color: "#ccc" },
|
|
31
|
+
curveType: "none",
|
|
32
|
+
enableInteractivity: @enable_interactivity,
|
|
33
|
+
legend: legend_options,
|
|
34
|
+
pointSize: @point_size,
|
|
35
|
+
height: @height,
|
|
36
|
+
tooltip: { isHtml: true },
|
|
37
|
+
series: series_options,
|
|
38
|
+
hAxis: {
|
|
39
|
+
textStyle: set_font_16,
|
|
40
|
+
title: @h_axis_title,
|
|
41
|
+
titleTextStyle: set_font_19,
|
|
42
|
+
textPosition: @text_position,
|
|
43
|
+
format: @h_axis_format,
|
|
44
|
+
},
|
|
45
|
+
vAxis: {
|
|
46
|
+
textStyle: set_font_16,
|
|
47
|
+
title: @v_axis_title,
|
|
48
|
+
titleTextStyle: set_font_19,
|
|
49
|
+
textPosition: @text_position,
|
|
50
|
+
format: @v_axis_format,
|
|
51
|
+
viewWindow: {
|
|
52
|
+
min: @y_axis_view_window_min,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def chart_format_data
|
|
59
|
+
if !@rows.empty? && !@keys.empty?
|
|
60
|
+
@rows.map do |row|
|
|
61
|
+
{
|
|
62
|
+
name: row[:label],
|
|
63
|
+
data: @keys.zip(row[:values]),
|
|
64
|
+
}
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
private
|
|
70
|
+
|
|
71
|
+
def legend_options
|
|
72
|
+
return { position: "top", textStyle: set_font_16 } unless @hide_legend
|
|
73
|
+
|
|
74
|
+
"none"
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def set_font_16
|
|
78
|
+
{ color: "#000", fontName: "GDS Transport", fontSize: "16", italic: false }
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def set_font_19
|
|
82
|
+
{ color: "#000", fontName: "GDS Transport", fontSize: "19", italic: false }
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def series_options
|
|
86
|
+
series = {}
|
|
87
|
+
if @line_colours
|
|
88
|
+
@line_colours.each_with_index do |item, index|
|
|
89
|
+
series[index] = {} unless series[index]
|
|
90
|
+
series[index][:color] = item
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
if @line_styles
|
|
95
|
+
@line_styles.each_with_index do |item, index|
|
|
96
|
+
style = [2, 2] if item == "dotted"
|
|
97
|
+
series[index] = {} unless series[index]
|
|
98
|
+
series[index][:lineDashStyle] = style
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
series
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module GovukPublishingComponents
|
|
2
|
+
module Presenters
|
|
3
|
+
# @private
|
|
4
|
+
class ContentBreadcrumbsBasedOnOrganisations
|
|
5
|
+
def self.call(content_item)
|
|
6
|
+
new(content_item).breadcrumbs
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def initialize(content_item)
|
|
10
|
+
@content_item = ContentItem.new(content_item)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def breadcrumbs
|
|
14
|
+
[
|
|
15
|
+
{ title: "Home", url: "/" },
|
|
16
|
+
{ title: "Organisations", url: "/government/organisations" },
|
|
17
|
+
*organisation_breadcrumbs_items,
|
|
18
|
+
]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
attr_reader :content_item
|
|
24
|
+
|
|
25
|
+
def organisation_breadcrumbs_items
|
|
26
|
+
first_related_organisation = ContentItem.new(content_item.related_organisations.first)
|
|
27
|
+
return [] unless first_related_organisation.present?
|
|
28
|
+
|
|
29
|
+
[{
|
|
30
|
+
title: first_related_organisation.title,
|
|
31
|
+
url: first_related_organisation.base_path,
|
|
32
|
+
}]
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -33,6 +33,10 @@ module GovukPublishingComponents
|
|
|
33
33
|
@taxon_breadcrumbs ||= ContentBreadcrumbsBasedOnTaxons.call(content_item)
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
+
def organisation_breadcrumbs
|
|
37
|
+
@organisation_breadcrumbs ||= ContentBreadcrumbsBasedOnOrganisations.call(content_item)
|
|
38
|
+
end
|
|
39
|
+
|
|
36
40
|
def breadcrumbs
|
|
37
41
|
breadcrumbs_based_on_ancestors
|
|
38
42
|
end
|
|
@@ -56,6 +60,10 @@ module GovukPublishingComponents
|
|
|
56
60
|
content_is_tagged_to_a_live_taxon? && !content_is_a_specialist_document?
|
|
57
61
|
end
|
|
58
62
|
|
|
63
|
+
def use_organisation_breadcrumbs?
|
|
64
|
+
content_is_a_corporate_information_page? && content_has_related_organisations?
|
|
65
|
+
end
|
|
66
|
+
|
|
59
67
|
def content_tagged_to_a_finder?
|
|
60
68
|
content_item.dig("links", "finder").present?
|
|
61
69
|
end
|
|
@@ -72,6 +80,10 @@ module GovukPublishingComponents
|
|
|
72
80
|
content_item.dig("links", "ordered_related_items").present? && content_item.dig("links", "parent").present?
|
|
73
81
|
end
|
|
74
82
|
|
|
83
|
+
def content_has_related_organisations?
|
|
84
|
+
ContentItem.new(content_item).related_organisations.present?
|
|
85
|
+
end
|
|
86
|
+
|
|
75
87
|
def content_is_tagged_to_a_live_taxon?
|
|
76
88
|
content_item.dig("links", "taxons").to_a.any? { |taxon| taxon["phase"] == "live" }
|
|
77
89
|
end
|
|
@@ -80,6 +92,10 @@ module GovukPublishingComponents
|
|
|
80
92
|
content_item["schema_name"] == "specialist_document"
|
|
81
93
|
end
|
|
82
94
|
|
|
95
|
+
def content_is_a_corporate_information_page?
|
|
96
|
+
content_item["schema_name"] == "corporate_information_page"
|
|
97
|
+
end
|
|
98
|
+
|
|
83
99
|
def content_is_a_html_publication?
|
|
84
100
|
content_item["document_type"] == "html_publication"
|
|
85
101
|
end
|
|
@@ -15,6 +15,7 @@ require "govuk_publishing_components/presenters/big_number_helper"
|
|
|
15
15
|
require "govuk_publishing_components/presenters/breadcrumbs_helper"
|
|
16
16
|
require "govuk_publishing_components/presenters/breadcrumb_selector"
|
|
17
17
|
require "govuk_publishing_components/presenters/button_helper"
|
|
18
|
+
require "govuk_publishing_components/presenters/chart_helper"
|
|
18
19
|
require "govuk_publishing_components/presenters/contextual_navigation"
|
|
19
20
|
require "govuk_publishing_components/presenters/devolved_nations_helper"
|
|
20
21
|
require "govuk_publishing_components/presenters/emergency_banner_helper"
|
|
@@ -24,6 +25,7 @@ require "govuk_publishing_components/presenters/step_by_step_nav_helper"
|
|
|
24
25
|
require "govuk_publishing_components/presenters/page_with_step_by_step_navigation"
|
|
25
26
|
require "govuk_publishing_components/presenters/public_layout_helper"
|
|
26
27
|
require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_ancestors"
|
|
28
|
+
require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_organisations"
|
|
27
29
|
require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_taxons"
|
|
28
30
|
require "govuk_publishing_components/presenters/checkboxes_helper"
|
|
29
31
|
require "govuk_publishing_components/presenters/select_helper"
|
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: 45.
|
|
4
|
+
version: 45.8.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: 2024-11-
|
|
11
|
+
date: 2024-11-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: chartkick
|
|
@@ -939,9 +939,11 @@ files:
|
|
|
939
939
|
- lib/govuk_publishing_components/presenters/breadcrumb_selector.rb
|
|
940
940
|
- lib/govuk_publishing_components/presenters/breadcrumbs_helper.rb
|
|
941
941
|
- lib/govuk_publishing_components/presenters/button_helper.rb
|
|
942
|
+
- lib/govuk_publishing_components/presenters/chart_helper.rb
|
|
942
943
|
- lib/govuk_publishing_components/presenters/checkboxes_helper.rb
|
|
943
944
|
- lib/govuk_publishing_components/presenters/component_wrapper_helper.rb
|
|
944
945
|
- lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_ancestors.rb
|
|
946
|
+
- lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_organisations.rb
|
|
945
947
|
- lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_taxons.rb
|
|
946
948
|
- lib/govuk_publishing_components/presenters/content_item.rb
|
|
947
949
|
- lib/govuk_publishing_components/presenters/contents_list_helper.rb
|