govuk_publishing_components 24.0.0 → 24.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/analytics/scroll-tracker.js +28 -0
  3. data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +330 -4
  4. data/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +26 -6
  5. data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills/common.js +8 -0
  6. data/app/assets/stylesheets/component_guide/application.scss +0 -8
  7. data/app/assets/stylesheets/govuk_publishing_components/components/_accordion.scss +298 -14
  8. data/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss +11 -84
  9. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-header.scss +21 -5
  10. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +17 -13
  11. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav.scss +4 -0
  12. data/app/assets/stylesheets/govuk_publishing_components/components/print/_accordion.scss +17 -9
  13. data/app/assets/stylesheets/govuk_publishing_components/govuk_frontend_support.scss +1 -11
  14. data/app/models/govuk_publishing_components/audit_applications.rb +2 -2
  15. data/app/models/govuk_publishing_components/audit_comparer.rb +2 -2
  16. data/app/models/govuk_publishing_components/component_example.rb +4 -3
  17. data/app/views/govuk_publishing_components/audit/show.html.erb +211 -199
  18. data/app/views/govuk_publishing_components/components/_accordion.html.erb +15 -22
  19. data/app/views/govuk_publishing_components/components/_attachment.html.erb +3 -3
  20. data/app/views/govuk_publishing_components/components/_breadcrumbs.html.erb +1 -1
  21. data/app/views/govuk_publishing_components/components/_contents_list.html.erb +1 -1
  22. data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +50 -39
  23. data/app/views/govuk_publishing_components/components/_highlight_boxes.html.erb +1 -1
  24. data/app/views/govuk_publishing_components/components/_image_card.html.erb +1 -1
  25. data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +1 -1
  26. data/app/views/govuk_publishing_components/components/_metadata.html.erb +1 -1
  27. data/app/views/govuk_publishing_components/components/_organisation_logo.html.erb +1 -1
  28. data/app/views/govuk_publishing_components/components/_previous_and_next_navigation.html.erb +1 -1
  29. data/app/views/govuk_publishing_components/components/_share_links.html.erb +1 -1
  30. data/app/views/govuk_publishing_components/components/_step_by_step_nav_header.html.erb +1 -1
  31. data/app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb +1 -1
  32. data/app/views/govuk_publishing_components/components/_subscription_links.html.erb +1 -1
  33. data/app/views/govuk_publishing_components/components/_taxonomy_list.html.erb +1 -1
  34. data/app/views/govuk_publishing_components/components/_translation_nav.html.erb +1 -1
  35. data/app/views/govuk_publishing_components/components/attachment/{_thumbnail_document.svg → _thumbnail_document.html.erb} +0 -0
  36. data/app/views/govuk_publishing_components/components/attachment/{_thumbnail_generic.svg → _thumbnail_generic.html.erb} +0 -0
  37. data/app/views/govuk_publishing_components/components/attachment/{_thumbnail_spreadsheet.svg → _thumbnail_spreadsheet.html.erb} +0 -0
  38. data/app/views/govuk_publishing_components/components/contextual_sidebar/_brexit_cta.html.erb +1 -1
  39. data/app/views/govuk_publishing_components/components/docs/accordion.yml +37 -3
  40. data/app/views/govuk_publishing_components/components/docs/cookie_banner.yml +9 -0
  41. data/app/views/govuk_publishing_components/components/docs/inverse_header.yml +1 -1
  42. data/app/views/govuk_publishing_components/components/layout_header/_header_logo.html.erb +1 -1
  43. data/app/views/govuk_publishing_components/components/layout_header/_navigation_items.html.erb +2 -0
  44. data/app/views/govuk_publishing_components/components/related_navigation/_section.html.erb +2 -2
  45. data/lib/govuk_publishing_components/app_helpers/table_helper.rb +2 -1
  46. data/lib/govuk_publishing_components/presenters/machine_readable/faq_page_schema.rb +1 -1
  47. data/lib/govuk_publishing_components/presenters/machine_readable/html_publication_schema.rb +1 -7
  48. data/lib/govuk_publishing_components/presenters/meta_tags.rb +1 -2
  49. data/lib/govuk_publishing_components/presenters/related_navigation_helper.rb +2 -2
  50. data/lib/govuk_publishing_components/version.rb +1 -1
  51. data/lib/tasks/govuk_publishing_components_tasks.rake +1 -1
  52. metadata +11 -10
@@ -0,0 +1,8 @@
1
+ function nodeListForEach (nodes, callback) {
2
+ if (window.NodeList.prototype.forEach) {
3
+ return nodes.forEach(callback)
4
+ }
5
+ for (var i = 0; i < nodes.length; i++) {
6
+ callback.call(window, nodes[i], i, nodes);
7
+ }
8
+ }
@@ -262,14 +262,6 @@ html {
262
262
  }
263
263
  }
264
264
 
265
- // Hide survey banner
266
- // stylelint-disable selector-max-id
267
- #user-satisfaction-survey-container,
268
- #global-cookie-message {
269
- display: none;
270
- }
271
- // stylelint-enable selector-max-id
272
-
273
265
  // Rouge syntax highlighting
274
266
  // Based on https://github.com/alphagov/tech-docs-template/blob/master/template/source/stylesheets/palette/_syntax-highlighting.scss
275
267
 
@@ -1,25 +1,309 @@
1
- @import "govuk/components/accordion/accordion";
1
+ $gem-c-accordion-border-width: 3px;
2
+ $gem-c-accordion-bottom-border-width: 1px;
2
3
 
3
- .gem-c-accordion {
4
- .govuk-accordion__section-heading {
5
- // this is a temporary addition to fix the line height when it
6
- // is being overridden by styles from govuk-template in collections
7
- @include govuk-media-query($until: desktop) {
8
- @include govuk-font(24, $weight: bold, $line-height: 1.6);
4
+ // Buttons within the sections don’t need default styling
5
+ .gem-c-accordion__section-button {
6
+ display: inline-block;
7
+ margin-bottom: 0;
8
+ padding-top: govuk-spacing(3);
9
+ font-weight: bold;
10
+ @include govuk-font($size: 24, $weight: bold);
11
+ }
12
+
13
+ .gem-c-accordion__section-header {
14
+ padding-top: govuk-spacing(2) 0;
15
+ }
16
+
17
+ .gem-c-accordion__section-heading {
18
+ margin: govuk-spacing(1) 0;
19
+ }
20
+
21
+ .js-enabled {
22
+ .gem-c-accordion {
23
+ border-bottom: $gem-c-accordion-bottom-border-width solid $govuk-border-colour;
24
+ }
25
+
26
+ .gem-c-accordion__controls {
27
+ text-align: left;
28
+ }
29
+
30
+ .gem-c-accordion__open-all {
31
+ position: relative;
32
+ z-index: 1;
33
+ border-width: 0;
34
+ color: $govuk-link-colour;
35
+ background: none;
36
+ -webkit-appearance: none;
37
+ cursor: pointer;
38
+ margin-bottom: govuk-spacing(4);
39
+ padding: 0 govuk-spacing(1) govuk-spacing(1) 0;
40
+ @include govuk-font($size: 16);
41
+ @include govuk-link-common;
42
+ @include govuk-link-style-default;
43
+ // Remove default button focus outline in Firefox
44
+ &::-moz-focus-inner {
45
+ padding: 0;
46
+ border: 0;
9
47
  }
10
48
  }
11
- }
12
49
 
13
- .govuk-accordion--condensed {
14
- .govuk-accordion__section-button {
15
- @include govuk-media-query($from: tablet) {
16
- @include govuk-font($size: 19, $weight: bold);
50
+ .gem-c-accordion__open-all:hover,
51
+ .gem-c-accordion__open-all-text:hover {
52
+ text-decoration: underline;
53
+ color: $govuk-link-colour;
54
+ }
55
+
56
+ // Focus state, also to change chervon icon to black
57
+ .gem-c-accordion__open-all:focus {
58
+ .gem-c-accordion__open-all-text,
59
+ .gem-c-accordion-nav__chevron {
60
+ color: $govuk-focus-text-colour;
61
+ text-decoration: none;
17
62
  }
18
63
  }
19
64
 
20
- .govuk-accordion__section-summary {
65
+ // Create Chervon icon align with text
66
+ .gem-c-accordion-nav__chevron {
67
+ vertical-align: text-top;
68
+ display: inline-block;
69
+ box-sizing: border-box;
70
+ position: relative;
71
+ width: em(20, 14);
72
+ height: em(20, 14);
73
+ margin-left: em(5, 14);
74
+ border: em(1, 14) solid;
75
+ border-radius: em(100, 14);
76
+ // Main icon size across views, yet keep responsive for zoom
21
77
  @include govuk-media-query($from: tablet) {
22
- @include govuk-font($size: 16);
78
+ width: em(20, 16);
79
+ height: em(20, 16);
80
+ margin-left: em(5, 16);
81
+ border: em(1, 16) solid;
82
+ }
83
+
84
+ &:after {
85
+ content: "";
86
+ display: block;
87
+ box-sizing: border-box;
88
+ position: absolute;
89
+ overflow: visible;
90
+ width: em(6, 14);
91
+ height: em(6, 14);
92
+ border-top: em(2, 14) solid;
93
+ border-right: em(2, 14) solid;
94
+ transform: rotate(-45deg);
95
+ left: em(6, 14);
96
+ bottom: em(5, 14);
97
+ @include govuk-media-query($from: tablet) {
98
+ width: em(6, 16);
99
+ height: em(6, 16);
100
+ border-top: em(2, 16) solid;
101
+ border-right: em(2, 16) solid;
102
+ left: em(6, 16);
103
+ bottom: em(5, 16);
104
+ }
105
+ }
106
+ }
107
+
108
+ // Rotate icon to create "Down" version
109
+ .gem-c-accordion-nav__chevron--down {
110
+ transform: rotate(180deg);
111
+ }
112
+
113
+ .gem-c-accordion__section-heading {
114
+ // Override browser defaults to ensure consistent element height
115
+ margin-top: 0; // Override browser default
116
+ margin-bottom: 0; // Override browser default
117
+ @include govuk-font(24);
118
+ }
119
+
120
+ // Section headers have a pointer cursor as an additional affordance
121
+ .gem-c-accordion__section-header {
122
+ position: relative;
123
+ }
124
+
125
+ // For devices that can't hover such as touch devices,
126
+ // remove hover state as it can be stuck in that state (iOS).
127
+ @media (hover: none) {
128
+ .gem-c-accordion__section-header:hover {
129
+ border-top-color: $govuk-link-colour;
130
+ box-shadow: inset 0 $gem-c-accordion-border-width 0 0 $govuk-link-colour;
131
+
132
+ .gem-c-accordion__section-button {
133
+ border-top-color: $govuk-link-colour;
134
+ }
135
+ }
136
+ }
137
+
138
+ // Buttons within the headers don’t need default styling
139
+ .gem-c-accordion__section-button {
140
+ padding: govuk-spacing(2) 0 govuk-spacing(5);
141
+ position: relative;
142
+ margin: 0;
143
+ border-width: $gem-c-accordion-bottom-border-width 0 0 0;
144
+ border-top: $gem-c-accordion-bottom-border-width solid $govuk-border-colour;
145
+ color: $govuk-text-colour;
146
+ background: none;
147
+ text-align: left;
148
+ cursor: pointer;
149
+ -webkit-appearance: none;
150
+ @include govuk-typography-common;
151
+ width: 100%;
152
+
153
+ &:active {
154
+ z-index: 1;
155
+ color: $govuk-link-active-colour;
156
+ background: none;
157
+ }
158
+
159
+ // Remove default button focus outline in Firefox
160
+ &::-moz-focus-inner {
161
+ padding: 0;
162
+ border: 0;
163
+ }
164
+ }
165
+
166
+ .gem-c-accordion__section-button:hover {
167
+ color: $govuk-link-colour;
168
+ // On hover, add underline to toggle link
169
+ .gem-c-accordion__toggle-text {
170
+ text-decoration: underline;
171
+ color: $govuk-link-colour;
172
+ }
173
+ }
174
+
175
+ .gem-c-accordion__section-button:focus {
176
+ @include govuk-focused-text;
177
+ // Overwrite focus border to top
178
+ box-shadow: 0 0, 0 -4px;
179
+ border-top: 1px solid transparent;
180
+
181
+ // Focus state to change the toggle link within individual sections
182
+ .gem-c-accordion__toggle-text {
183
+ color: $govuk-focus-text-colour;
184
+ text-decoration: none;
185
+ }
186
+ // Focus state to change chervon icon colour within individual sections
187
+ .gem-c-accordion-nav__chevron {
188
+ color: $govuk-text-colour;
189
+ }
190
+ }
191
+
192
+ // Extend the touch area of the button to span the section header
193
+ .gem-c-accordion__section-button:after {
194
+ content: "";
195
+ position: absolute;
196
+ top: 0;
197
+ right: 0;
198
+ bottom: 0;
199
+ left: 0;
200
+ }
201
+
202
+ .gem-c-accordion__section-button:hover:not(:focus) {
203
+ text-decoration: none;
204
+ }
205
+
206
+ // For devices that can't hover such as touch devices,
207
+ // remove hover state as it can be stuck in that state (iOS).
208
+ @media (hover: none) {
209
+ .gem-c-accordion__section-button:hover {
210
+ text-decoration: none;
211
+ }
212
+ }
213
+
214
+ // Add toggle link with Chevron icon on right.
215
+ .gem-c-accordion__toggle-link {
216
+ display: block;
217
+ color: $govuk-link-colour;
218
+ text-transform: capitalize;
219
+ margin-top: govuk-spacing(1);
220
+ margin-bottom: govuk-spacing(1);
221
+ @include govuk-font($size: 16, $line-height: 1);
222
+
223
+ &:active {
224
+ background: $govuk-link-active-colour;
225
+ }
226
+ }
227
+
228
+ // Setting width of the text, so the icon doesn't shift (left / right) when toggled
229
+ .gem-c-accordion__toggle-text {
230
+ min-width: em(40, 16);
231
+ display: inline-block;
232
+ }
233
+
234
+ .gem-c-accordion__open-all-text {
235
+ min-width: em(120, 16);
236
+ display: inline-block;
237
+ text-align: left;
238
+ }
239
+
240
+ // Change the summary subheading size.
241
+ .gem-c-accordion__section-summary {
242
+ @include govuk-responsive-margin(1, "top");
243
+ @include govuk-responsive-margin(2, "bottom");
244
+ @include govuk-typography-common;
245
+ @include govuk-typography-responsive($size: 19);
246
+ }
247
+
248
+ // Hide body of expanded sections
249
+ .gem-c-accordion__section-content {
250
+ display: none;
251
+ @include govuk-responsive-padding(0, "top");
252
+ @include govuk-responsive-padding(8, "bottom");
253
+ }
254
+
255
+ // Show the body of expanded sections
256
+ .gem-c-accordion__section--expanded .gem-c-accordion__section-content {
257
+ display: block;
258
+ }
259
+
260
+ // Remove the bottom margin from the last item inside the content
261
+ .gem-c-accordion__section-content > :last-child {
262
+ margin-bottom: 0;
263
+ }
264
+
265
+ // Condensed layout
266
+ .gem-c-accordion--condensed {
267
+ .gem-c-accordion__open-all {
268
+ margin-bottom: govuk-spacing(5);
269
+ @include govuk-font($size: 14, $line-height: 1);
270
+ }
271
+
272
+ .gem-c-accordion__section-button {
273
+ @include govuk-typography-responsive($size: 19, $important: true);
274
+ padding-top: govuk-spacing(1);
275
+ padding-bottom: govuk-spacing(5);
276
+ }
277
+
278
+ // Reduce Chevron size
279
+ .gem-c-accordion-nav__chevron {
280
+ width: em(20, 14);
281
+ height: em(20, 14);
282
+ margin-left: em(5, 14);
283
+ border: em(1, 14) solid;
284
+ border-radius: em(100, 14);
285
+ transform: scale(.875);
286
+
287
+ &:after {
288
+ width: em(6, 14);
289
+ height: em(6, 14);
290
+ border-top: em(2, 14) solid;
291
+ border-right: em(2, 14) solid;
292
+ left: em(6, 14);
293
+ bottom: em(5, 14);
294
+ }
295
+ }
296
+
297
+ .gem-c-accordion-nav__chevron--down {
298
+ transform: scale(.875) rotate(180deg);
299
+ }
300
+
301
+ .gem-c-accordion__section-summary {
302
+ @include govuk-typography-responsive($size: 16, $important: true);
303
+ }
304
+
305
+ .gem-c-accordion__toggle-link {
306
+ @include govuk-font($size: 14, $line-height: 1);
23
307
  }
24
308
  }
25
309
  }
@@ -1,3 +1,4 @@
1
+ @import "govuk/components/cookie-banner/cookie-banner";
1
2
  $govuk-cookie-banner-background: govuk-colour("light-grey", "grey-4");
2
3
 
3
4
  .js-enabled {
@@ -7,50 +8,14 @@ $govuk-cookie-banner-background: govuk-colour("light-grey", "grey-4");
7
8
  }
8
9
 
9
10
  .gem-c-cookie-banner {
10
- @include govuk-font($size: 16);
11
- padding: govuk-spacing(2) 0;
12
11
  background-color: $govuk-cookie-banner-background;
13
12
  }
14
13
 
15
- .gem-c-cookie-banner--services {
14
+ // can't be used without js so implement there
15
+ .gem-c-cookie-banner .gem-c-button {
16
16
  display: none;
17
17
  }
18
18
 
19
- .gem-c-cookie-banner__message {
20
- display: inline-block;
21
- padding-bottom: govuk-spacing(2);
22
-
23
- @include govuk-font($size: 16);
24
- @include govuk-media-query($from: desktop) {
25
- padding-right: govuk-spacing(4);
26
- }
27
- }
28
-
29
- .gem-c-cookie-banner__button {
30
- &.govuk-grid-column-one-half-from-desktop {
31
- padding: 0;
32
- }
33
-
34
- .govuk-button {
35
- @include govuk-media-query($from: desktop) {
36
- width: 90%;
37
- }
38
-
39
- @include govuk-media-query($until: desktop) {
40
- margin-bottom: govuk-spacing(4);
41
- }
42
- }
43
- }
44
-
45
- // Only show accept button if users have js and can accept
46
- .gem-c-cookie-banner__button-accept {
47
- display: none;
48
- }
49
-
50
- .js-enabled .gem-c-cookie-banner__button-accept {
51
- display: inline-block;
52
- }
53
-
54
19
  .gem-c-cookie-banner__confirmation {
55
20
  display: none;
56
21
  position: relative;
@@ -81,51 +46,18 @@ $govuk-cookie-banner-background: govuk-colour("light-grey", "grey-4");
81
46
  }
82
47
  }
83
48
 
84
- .gem-c-cookie-banner__hide-button {
85
- @include govuk-font($size: 19);
86
- outline: 0;
87
- border: 0;
88
- background: none;
89
- text-decoration: underline;
90
- color: $govuk-link-colour;
91
- padding: govuk-spacing(0);
92
- margin-top: govuk-spacing(2);
49
+ // Override style from design system so we can have consistent
50
+ // padding on the the banner and the confirmation
93
51
 
94
- &:hover {
95
- color: $govuk-link-hover-colour;
96
- cursor: pointer;
97
- }
98
-
99
- &:focus {
100
- @include govuk-focused-text;
101
- }
102
-
103
- @include govuk-media-query($from: desktop) {
104
- margin-top: govuk-spacing(0);
105
- position: absolute;
106
- right: govuk-spacing(1);
107
- }
108
- }
109
-
110
- .gem-c-cookie-banner__buttons--flex {
111
- display: flex;
112
- flex-wrap: wrap;
113
- align-items: baseline;
114
-
115
- .govuk-button,
116
- .gem-c-cookie-banner__link {
117
- flex-grow: 1;
118
- flex-basis: 10rem;
119
- margin-right: govuk-spacing(3);
120
- margin-bottom: govuk-spacing(3);
121
- }
52
+ .govuk-cookie-banner {
53
+ padding-top: 0;
122
54
  }
123
55
 
124
56
  // Override the styles from govuk_template
125
57
  // stylelint-disable selector-max-id
126
58
  .gem-c-cookie-banner#global-cookie-message {
127
59
  background-color: $govuk-cookie-banner-background;
128
- padding: govuk-spacing(4) 0;
60
+ padding: govuk-spacing(3) 0 0 0;
129
61
  box-sizing: border-box;
130
62
 
131
63
  .gem-c-cookie-banner__message,
@@ -135,18 +67,13 @@ $govuk-cookie-banner-background: govuk-colour("light-grey", "grey-4");
135
67
  @include govuk-font($size: 19);
136
68
  }
137
69
 
138
- .gem-c-cookie-banner__message {
139
- margin-bottom: 0;
140
- }
141
-
142
70
  p {
143
71
  @include govuk-font($size: 19);
144
72
  margin: 0 0 govuk-spacing(2) 0;
145
73
  }
146
74
 
147
- .gem-c-cookie-banner__confirmation-message {
148
- @include govuk-media-query($from: desktop) {
149
- margin-bottom: 0;
150
- }
75
+ .gem-c-cookie-banner__message,
76
+ .gem-c-cookie-banner__confirmation {
77
+ margin-bottom: - govuk-spacing(2);
151
78
  }
152
79
  }