govuk_tech_docs 2.2.2 → 2.4.2

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.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.nvmrc +1 -1
  4. data/.travis.yml +2 -0
  5. data/CHANGELOG.md +24 -0
  6. data/example/config/tech-docs.yml +1 -0
  7. data/example/source/single-page-nav.html.md +13 -0
  8. data/govuk_tech_docs.gemspec +2 -1
  9. data/lib/assets/javascripts/_modules/collapsible-navigation.js +7 -7
  10. data/lib/assets/javascripts/_modules/in-page-navigation.js +2 -4
  11. data/lib/assets/stylesheets/_govuk_tech_docs.scss +9 -10
  12. data/lib/assets/stylesheets/modules/_search.scss +4 -25
  13. data/lib/assets/stylesheets/modules/_technical-documentation.scss +1 -1
  14. data/lib/assets/stylesheets/modules/_toc.scss +11 -11
  15. data/lib/govuk_tech_docs/table_of_contents/heading.rb +5 -1
  16. data/lib/govuk_tech_docs/table_of_contents/heading_tree_renderer.rb +2 -2
  17. data/lib/govuk_tech_docs/table_of_contents/helpers.rb +22 -11
  18. data/lib/govuk_tech_docs/tech_docs_html_renderer.rb +1 -1
  19. data/lib/govuk_tech_docs/version.rb +1 -1
  20. data/lib/source/layouts/_header.erb +1 -2
  21. data/lib/source/layouts/layout.erb +3 -1
  22. data/node_modules/govuk-frontend/govuk/_base.scss +3 -0
  23. data/node_modules/govuk-frontend/govuk/all.js +306 -94
  24. data/node_modules/govuk-frontend/govuk/all.scss +1 -3
  25. data/node_modules/govuk-frontend/govuk/components/_all.scss +33 -29
  26. data/node_modules/govuk-frontend/govuk/components/accordion/_accordion.scss +2 -208
  27. data/node_modules/govuk-frontend/govuk/components/accordion/_index.scss +197 -0
  28. data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +1 -1
  29. data/node_modules/govuk-frontend/govuk/components/back-link/_back-link.scss +2 -65
  30. data/node_modules/govuk-frontend/govuk/components/back-link/_index.scss +99 -0
  31. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/_breadcrumbs.scss +2 -118
  32. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/_index.scss +138 -0
  33. data/node_modules/govuk-frontend/govuk/components/button/_button.scss +2 -284
  34. data/node_modules/govuk-frontend/govuk/components/button/_index.scss +288 -0
  35. data/node_modules/govuk-frontend/govuk/components/character-count/_character-count.scss +2 -31
  36. data/node_modules/govuk-frontend/govuk/components/character-count/_index.scss +25 -0
  37. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +17 -9
  38. data/node_modules/govuk-frontend/govuk/components/checkboxes/_checkboxes.scss +2 -308
  39. data/node_modules/govuk-frontend/govuk/components/checkboxes/_index.scss +320 -0
  40. data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +129 -24
  41. data/node_modules/govuk-frontend/govuk/components/cookie-banner/_cookie-banner.scss +2 -0
  42. data/node_modules/govuk-frontend/govuk/components/cookie-banner/_index.scss +51 -0
  43. data/node_modules/govuk-frontend/govuk/components/date-input/_date-input.scss +2 -30
  44. data/node_modules/govuk-frontend/govuk/components/date-input/_index.scss +26 -0
  45. data/node_modules/govuk-frontend/govuk/components/details/_details.scss +2 -88
  46. data/node_modules/govuk-frontend/govuk/components/details/_index.scss +87 -0
  47. data/node_modules/govuk-frontend/govuk/components/error-message/_error-message.scss +2 -15
  48. data/node_modules/govuk-frontend/govuk/components/error-message/_index.scss +11 -0
  49. data/node_modules/govuk-frontend/govuk/components/error-summary/_error-summary.scss +2 -59
  50. data/node_modules/govuk-frontend/govuk/components/error-summary/_index.scss +43 -0
  51. data/node_modules/govuk-frontend/govuk/components/fieldset/_fieldset.scss +2 -68
  52. data/node_modules/govuk-frontend/govuk/components/fieldset/_index.scss +64 -0
  53. data/node_modules/govuk-frontend/govuk/components/file-upload/_file-upload.scss +2 -81
  54. data/node_modules/govuk-frontend/govuk/components/file-upload/_index.scss +49 -0
  55. data/node_modules/govuk-frontend/govuk/components/footer/_footer.scss +2 -244
  56. data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +241 -0
  57. data/node_modules/govuk-frontend/govuk/components/header/_header.scss +2 -318
  58. data/node_modules/govuk-frontend/govuk/components/header/_index.scss +331 -0
  59. data/node_modules/govuk-frontend/govuk/components/header/header.js +665 -316
  60. data/node_modules/govuk-frontend/govuk/components/hint/_hint.scss +2 -50
  61. data/node_modules/govuk-frontend/govuk/components/hint/_index.scss +44 -0
  62. data/node_modules/govuk-frontend/govuk/components/input/_index.scss +191 -0
  63. data/node_modules/govuk-frontend/govuk/components/input/_input.scss +2 -103
  64. data/node_modules/govuk-frontend/govuk/components/inset-text/_index.scss +24 -0
  65. data/node_modules/govuk-frontend/govuk/components/inset-text/_inset-text.scss +2 -28
  66. data/node_modules/govuk-frontend/govuk/components/label/_index.scss +41 -0
  67. data/node_modules/govuk-frontend/govuk/components/label/_label.scss +2 -45
  68. data/node_modules/govuk-frontend/govuk/components/notification-banner/_index.scss +89 -0
  69. data/node_modules/govuk-frontend/govuk/components/notification-banner/_notification-banner.scss +2 -0
  70. data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +61 -0
  71. data/node_modules/govuk-frontend/govuk/components/panel/_index.scss +44 -0
  72. data/node_modules/govuk-frontend/govuk/components/panel/_panel.scss +2 -44
  73. data/node_modules/govuk-frontend/govuk/components/phase-banner/_index.scss +27 -0
  74. data/node_modules/govuk-frontend/govuk/components/phase-banner/_phase-banner.scss +2 -31
  75. data/node_modules/govuk-frontend/govuk/components/radios/_index.scss +342 -0
  76. data/node_modules/govuk-frontend/govuk/components/radios/_radios.scss +2 -346
  77. data/node_modules/govuk-frontend/govuk/components/radios/radios.js +76 -28
  78. data/node_modules/govuk-frontend/govuk/components/select/_index.scss +49 -0
  79. data/node_modules/govuk-frontend/govuk/components/select/_select.scss +2 -57
  80. data/node_modules/govuk-frontend/govuk/components/skip-link/_index.scss +36 -0
  81. data/node_modules/govuk-frontend/govuk/components/skip-link/_skip-link.scss +2 -37
  82. data/node_modules/govuk-frontend/govuk/components/summary-list/_index.scss +145 -0
  83. data/node_modules/govuk-frontend/govuk/components/summary-list/_summary-list.scss +2 -157
  84. data/node_modules/govuk-frontend/govuk/components/table/_index.scss +71 -0
  85. data/node_modules/govuk-frontend/govuk/components/table/_table.scss +2 -54
  86. data/node_modules/govuk-frontend/govuk/components/tabs/_index.scss +130 -0
  87. data/node_modules/govuk-frontend/govuk/components/tabs/_tabs.scss +2 -142
  88. data/node_modules/govuk-frontend/govuk/components/tag/_index.scss +86 -0
  89. data/node_modules/govuk-frontend/govuk/components/tag/_tag.scss +2 -91
  90. data/node_modules/govuk-frontend/govuk/components/textarea/_index.scss +47 -0
  91. data/node_modules/govuk-frontend/govuk/components/textarea/_textarea.scss +2 -55
  92. data/node_modules/govuk-frontend/govuk/components/warning-text/_index.scss +66 -0
  93. data/node_modules/govuk-frontend/govuk/components/warning-text/_warning-text.scss +2 -60
  94. data/node_modules/govuk-frontend/govuk/core/_global-styles.scss +5 -3
  95. data/node_modules/govuk-frontend/govuk/core/_links.scss +13 -3
  96. data/node_modules/govuk-frontend/govuk/core/_lists.scss +17 -3
  97. data/node_modules/govuk-frontend/govuk/core/_section-break.scss +5 -3
  98. data/node_modules/govuk-frontend/govuk/core/_template.scss +5 -4
  99. data/node_modules/govuk-frontend/govuk/core/_typography.scss +5 -3
  100. data/node_modules/govuk-frontend/govuk/helpers/_clearfix.scss +1 -1
  101. data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +1 -1
  102. data/node_modules/govuk-frontend/govuk/helpers/_device-pixels.scss +3 -3
  103. data/node_modules/govuk-frontend/govuk/helpers/_focused.scss +1 -1
  104. data/node_modules/govuk-frontend/govuk/helpers/_font-faces.scss +9 -11
  105. data/node_modules/govuk-frontend/govuk/helpers/_grid.scss +2 -1
  106. data/node_modules/govuk-frontend/govuk/helpers/_links.scss +246 -33
  107. data/node_modules/govuk-frontend/govuk/helpers/_media-queries.scss +2 -6
  108. data/node_modules/govuk-frontend/govuk/helpers/_shape-arrow.scss +1 -1
  109. data/node_modules/govuk-frontend/govuk/helpers/_spacing.scss +3 -2
  110. data/node_modules/govuk-frontend/govuk/helpers/_typography.scss +8 -7
  111. data/node_modules/govuk-frontend/govuk/helpers/_visually-hidden.scss +1 -1
  112. data/node_modules/govuk-frontend/govuk/objects/_all.scss +1 -0
  113. data/node_modules/govuk-frontend/govuk/objects/_button-group.scss +101 -0
  114. data/node_modules/govuk-frontend/govuk/objects/_form-group.scss +1 -4
  115. data/node_modules/govuk-frontend/govuk/objects/_grid.scss +3 -6
  116. data/node_modules/govuk-frontend/govuk/objects/_main-wrapper.scss +5 -4
  117. data/node_modules/govuk-frontend/govuk/objects/_width-container.scss +6 -4
  118. data/node_modules/govuk-frontend/govuk/overrides/_display.scss +6 -4
  119. data/node_modules/govuk-frontend/govuk/overrides/_spacing.scss +5 -3
  120. data/node_modules/govuk-frontend/govuk/overrides/_typography.scss +5 -3
  121. data/node_modules/govuk-frontend/govuk/overrides/_width.scss +6 -3
  122. data/node_modules/govuk-frontend/govuk/settings/_all.scss +2 -0
  123. data/node_modules/govuk-frontend/govuk/settings/_colours-applied.scss +11 -5
  124. data/node_modules/govuk-frontend/govuk/settings/_colours-organisations.scss +3 -0
  125. data/node_modules/govuk-frontend/govuk/settings/_colours-palette.scss +42 -35
  126. data/node_modules/govuk-frontend/govuk/settings/_compatibility.scss +0 -1
  127. data/node_modules/govuk-frontend/govuk/settings/_ie8.scss +1 -1
  128. data/node_modules/govuk-frontend/govuk/settings/_links.scss +62 -0
  129. data/node_modules/govuk-frontend/govuk/settings/_measurements.scss +4 -5
  130. data/node_modules/govuk-frontend/govuk/settings/_typography-font-families.scss +2 -2
  131. data/node_modules/govuk-frontend/govuk/settings/_typography-font.scss +14 -5
  132. data/node_modules/govuk-frontend/govuk/settings/_typography-responsive.scss +6 -2
  133. data/node_modules/govuk-frontend/govuk/tools/_compatibility.scss +1 -1
  134. data/node_modules/govuk-frontend/govuk/tools/_font-url.scss +1 -4
  135. data/node_modules/govuk-frontend/govuk/tools/_ie8.scss +1 -1
  136. data/node_modules/govuk-frontend/govuk/tools/_image-url.scss +1 -4
  137. data/node_modules/govuk-frontend/govuk/tools/_px-to-em.scss +1 -1
  138. data/node_modules/govuk-frontend/govuk/tools/_px-to-rem.scss +1 -1
  139. data/node_modules/govuk-frontend/govuk/utilities/_visually-hidden.scss +0 -1
  140. data/node_modules/govuk-frontend/govuk/vendor/_sass-mq.scss +0 -4
  141. data/package-lock.json +358 -288
  142. data/package.json +2 -2
  143. metadata +56 -4
@@ -0,0 +1,288 @@
1
+ @include govuk-exports("govuk/component/button") {
2
+ $govuk-button-colour: govuk-colour("green", $legacy: #00823b);
3
+ $govuk-button-hover-colour: govuk-shade($govuk-button-colour, 20%);
4
+ $govuk-button-shadow-colour: govuk-shade($govuk-button-colour, 60%);
5
+ $govuk-button-text-colour: govuk-colour("white");
6
+
7
+ // Secondary button variables
8
+ $govuk-secondary-button-colour: govuk-colour("light-grey", $legacy: "grey-3");
9
+ $govuk-secondary-button-hover-colour: govuk-shade($govuk-secondary-button-colour, 10%);
10
+ $govuk-secondary-button-shadow-colour: govuk-shade($govuk-secondary-button-colour, 40%);
11
+ $govuk-secondary-button-text-colour: govuk-colour("black");
12
+
13
+ // Warning button variables
14
+ $govuk-warning-button-colour: govuk-colour("red");
15
+ $govuk-warning-button-hover-colour: govuk-shade($govuk-warning-button-colour, 20%);
16
+ $govuk-warning-button-shadow-colour: govuk-shade($govuk-warning-button-colour, 60%);
17
+ $govuk-warning-button-text-colour: govuk-colour("white");
18
+
19
+ // Because the shadow (s0) is visually 'part of' the button, we need to reduce
20
+ // the height of the button to compensate by adjusting its padding (s1) and
21
+ // increase the bottom margin to include it (s2).
22
+ $button-shadow-size: $govuk-border-width-form-element;
23
+
24
+ .govuk-button {
25
+ @include govuk-font($size: 19, $line-height: 19px);
26
+
27
+ box-sizing: border-box;
28
+ display: inline-block;
29
+ position: relative;
30
+ width: 100%;
31
+ margin-top: 0;
32
+ margin-right: 0;
33
+ margin-left: 0;
34
+ @include govuk-responsive-margin(6, "bottom", $adjustment: $button-shadow-size); // s2
35
+ padding: (govuk-spacing(2) - $govuk-border-width-form-element) govuk-spacing(2) (govuk-spacing(2) - $govuk-border-width-form-element - ($button-shadow-size / 2)); // s1
36
+ border: $govuk-border-width-form-element solid transparent;
37
+ border-radius: 0;
38
+ color: $govuk-button-text-colour;
39
+ background-color: $govuk-button-colour;
40
+ box-shadow: 0 $button-shadow-size 0 $govuk-button-shadow-colour; // s0
41
+ text-align: center;
42
+ vertical-align: top;
43
+ cursor: pointer;
44
+ -webkit-appearance: none;
45
+
46
+ @include govuk-if-ie8 {
47
+ border-bottom: $button-shadow-size solid $govuk-button-shadow-colour;
48
+ }
49
+
50
+ @include govuk-media-query($from: tablet) {
51
+ width: auto;
52
+ }
53
+
54
+ // Ensure that any global link styles are overridden
55
+ &:link,
56
+ &:visited,
57
+ &:active,
58
+ &:hover {
59
+ color: $govuk-button-text-colour;
60
+ text-decoration: none;
61
+ }
62
+
63
+ // Fix unwanted button padding in Firefox
64
+ &::-moz-focus-inner {
65
+ padding: 0;
66
+ border: 0;
67
+ }
68
+
69
+ &:hover {
70
+ background-color: $govuk-button-hover-colour;
71
+ }
72
+
73
+ &:active {
74
+ // Bump the button down so it looks like its being pressed in
75
+ top: $button-shadow-size;
76
+
77
+ @include govuk-if-ie8 {
78
+ border-bottom-width: 0;
79
+ }
80
+ }
81
+
82
+ &:focus {
83
+ border-color: $govuk-focus-colour;
84
+ // When colours are overridden, for example when users have a dark mode,
85
+ // backgrounds and box-shadows disappear, so we need to ensure there's a
86
+ // transparent outline which will be set to a visible colour.
87
+ // Since Internet Explorer 8 does not support box-shadow, we want to force the user-agent outlines
88
+ @include govuk-not-ie8 {
89
+ outline: $govuk-focus-width solid transparent;
90
+ }
91
+ // Since Internet Explorer does not support `:not()` we set a clearer focus style to match user-agent outlines.
92
+ @include govuk-if-ie8 {
93
+ color: $govuk-focus-text-colour;
94
+ background-color: $govuk-focus-colour;
95
+ }
96
+ box-shadow: inset 0 0 0 1px $govuk-focus-colour;
97
+ }
98
+
99
+ // alphagov/govuk_template includes a specific a:link:focus selector
100
+ // designed to make unvisited links a slightly darker blue when focussed, so
101
+ // we need to override the text colour for that combination of selectors so
102
+ // so that unvisited links styled as buttons do not end up with dark blue
103
+ // text when focussed.
104
+ @include govuk-compatibility(govuk_template) {
105
+ &:link:focus {
106
+ color: $govuk-button-text-colour;
107
+ }
108
+ }
109
+
110
+ &:focus:not(:active):not(:hover) {
111
+ border-color: $govuk-focus-colour;
112
+ color: $govuk-focus-text-colour;
113
+ background-color: $govuk-focus-colour;
114
+ box-shadow: 0 2px 0 $govuk-focus-text-colour;
115
+ }
116
+
117
+ // The following adjustments do not work for <input type="button"> as
118
+ // non-container elements cannot include pseudo elements (i.e. ::before).
119
+
120
+ // Use a pseudo element to expand the click target area to include the
121
+ // button's shadow as well, in case users try to click it.
122
+ &:before {
123
+ content: "";
124
+ display: block;
125
+
126
+ position: absolute;
127
+
128
+ top: -$govuk-border-width-form-element;
129
+ right: -$govuk-border-width-form-element;
130
+ bottom: -($govuk-border-width-form-element + $button-shadow-size);
131
+ left: -$govuk-border-width-form-element;
132
+
133
+ background: transparent;
134
+ }
135
+
136
+ // When the button is active it is shifted down by $button-shadow-size to
137
+ // denote a 'pressed' state. If the user happened to click at the very top
138
+ // of the button, their mouse is no longer over the button (because it has
139
+ // 'moved beneath them') and so the click event is not fired.
140
+ //
141
+ // This corrects that by shifting the top of the pseudo element so that it
142
+ // continues to cover the area that the user originally clicked, which means
143
+ // the click event is still fired.
144
+ //
145
+ // 🎉
146
+ &:active:before {
147
+ top: -($govuk-border-width-form-element + $button-shadow-size);
148
+ }
149
+ }
150
+
151
+ .govuk-button--disabled,
152
+ .govuk-button[disabled="disabled"],
153
+ .govuk-button[disabled] {
154
+ opacity: (.5);
155
+
156
+ &:hover {
157
+ background-color: $govuk-button-colour;
158
+ cursor: default;
159
+ }
160
+
161
+ &:focus {
162
+ outline: none;
163
+ }
164
+
165
+ &:active {
166
+ top: 0;
167
+ box-shadow: 0 $button-shadow-size 0 $govuk-button-shadow-colour; // s0
168
+ @include govuk-if-ie8 {
169
+ border-bottom: $button-shadow-size solid $govuk-button-shadow-colour; // s0
170
+ }
171
+ }
172
+ }
173
+
174
+ .govuk-button--secondary {
175
+ background-color: $govuk-secondary-button-colour;
176
+ box-shadow: 0 $button-shadow-size 0 $govuk-secondary-button-shadow-colour;
177
+
178
+ &,
179
+ &:link,
180
+ &:visited,
181
+ &:active,
182
+ &:hover {
183
+ color: $govuk-secondary-button-text-colour;
184
+ }
185
+
186
+ // alphagov/govuk_template includes a specific a:link:focus selector
187
+ // designed to make unvisited links a slightly darker blue when focussed, so
188
+ // we need to override the text colour for that combination of selectors so
189
+ // so that unvisited links styled as buttons do not end up with dark blue
190
+ // text when focussed.
191
+ @include govuk-compatibility(govuk_template) {
192
+ &:link:focus {
193
+ color: $govuk-secondary-button-text-colour;
194
+ }
195
+ }
196
+
197
+ &:hover {
198
+ background-color: $govuk-secondary-button-hover-colour;
199
+
200
+ &[disabled] {
201
+ background-color: $govuk-secondary-button-colour;
202
+ }
203
+ }
204
+ }
205
+
206
+ .govuk-button--warning {
207
+ background-color: $govuk-warning-button-colour;
208
+ box-shadow: 0 $button-shadow-size 0 $govuk-warning-button-shadow-colour;
209
+
210
+ &,
211
+ &:link,
212
+ &:visited,
213
+ &:active,
214
+ &:hover {
215
+ color: $govuk-warning-button-text-colour;
216
+ }
217
+
218
+ // alphagov/govuk_template includes a specific a:link:focus selector
219
+ // designed to make unvisited links a slightly darker blue when focussed, so
220
+ // we need to override the text colour for that combination of selectors so
221
+ // so that unvisited links styled as buttons do not end up with dark blue
222
+ // text when focussed.
223
+ @include govuk-compatibility(govuk_template) {
224
+ &:link:focus {
225
+ color: $govuk-warning-button-text-colour;
226
+ }
227
+ }
228
+
229
+ &:hover {
230
+ background-color: $govuk-warning-button-hover-colour;
231
+
232
+ &[disabled] {
233
+ background-color: $govuk-warning-button-colour;
234
+ }
235
+ }
236
+ }
237
+
238
+ .govuk-button--start {
239
+ @include govuk-typography-weight-bold;
240
+ @include govuk-typography-responsive($size: 24, $override-line-height: 1);
241
+
242
+ display: -webkit-inline-box;
243
+
244
+ display: -webkit-inline-flex;
245
+
246
+ display: -ms-inline-flexbox;
247
+
248
+ display: inline-flex;
249
+ min-height: auto;
250
+
251
+ -webkit-box-pack: center;
252
+
253
+ -webkit-justify-content: center;
254
+
255
+ -ms-flex-pack: center;
256
+
257
+ justify-content: center;
258
+ }
259
+
260
+ .govuk-button__start-icon {
261
+ margin-left: govuk-spacing(1);
262
+
263
+ @include govuk-media-query($from: desktop) {
264
+ margin-left: govuk-spacing(2);
265
+ }
266
+ vertical-align: middle;
267
+ -webkit-flex-shrink: 0;
268
+ -ms-flex-negative: 0;
269
+ flex-shrink: 0;
270
+ -webkit-align-self: center;
271
+ -ms-flex-item-align: center;
272
+ align-self: center;
273
+ }
274
+
275
+ @if $govuk-use-legacy-font {
276
+ // Begin adjustments for font baseline offset when using v1 of nta
277
+ $offset: 2;
278
+
279
+ .govuk-button {
280
+ padding-top: (govuk-spacing(2) - $govuk-border-width-form-element - ($button-shadow-size / 2) + $offset); // s1
281
+ padding-bottom: (govuk-spacing(2) - $govuk-border-width-form-element - ($button-shadow-size / 2) - $offset + 1); // s1
282
+ }
283
+
284
+ .govuk-button__start-icon {
285
+ margin-top: -3px;
286
+ }
287
+ }
288
+ }
@@ -1,31 +1,2 @@
1
- @import "../../settings/all";
2
- @import "../../tools/all";
3
- @import "../../helpers/all";
4
-
5
- @import "../error-message/error-message";
6
- @import "../hint/hint";
7
- @import "../label/label";
8
-
9
- @include govuk-exports("govuk/component/character-count") {
10
- .govuk-character-count {
11
- @include govuk-responsive-margin(6, "bottom");
12
-
13
- .govuk-form-group,
14
- .govuk-textarea {
15
- margin-bottom: govuk-spacing(1);
16
- }
17
-
18
- .govuk-textarea--error {
19
- padding: govuk-spacing(1) - 2; // Stop a "jump" when width of border changes
20
- }
21
- }
22
-
23
- .govuk-character-count__message {
24
- margin-top: 0;
25
- margin-bottom: 0;
26
- }
27
-
28
- .govuk-character-count__message--disabled {
29
- visibility: hidden;
30
- }
31
- }
1
+ @import "../../base";
2
+ @import "./index";
@@ -0,0 +1,25 @@
1
+ @import "../error-message/index";
2
+ @import "../hint/index";
3
+ @import "../label/index";
4
+ @import "../textarea/index";
5
+
6
+ @include govuk-exports("govuk/component/character-count") {
7
+ .govuk-character-count {
8
+ @include govuk-responsive-margin(6, "bottom");
9
+
10
+ .govuk-form-group,
11
+ .govuk-textarea {
12
+ margin-bottom: govuk-spacing(1);
13
+ }
14
+ }
15
+
16
+ .govuk-character-count__message {
17
+ @include govuk-font($size: false, $tabular: true);
18
+ margin-top: 0;
19
+ margin-bottom: 0;
20
+ }
21
+
22
+ .govuk-character-count__message--disabled {
23
+ visibility: hidden;
24
+ }
25
+ }
@@ -1018,7 +1018,7 @@ function CharacterCount ($module) {
1018
1018
  this.$module = $module;
1019
1019
  this.$textarea = $module.querySelector('.govuk-js-character-count');
1020
1020
  if (this.$textarea) {
1021
- this.$countMessage = $module.querySelector('[id=' + this.$textarea.id + '-info]');
1021
+ this.$countMessage = $module.querySelector('[id="' + this.$textarea.id + '-info"]');
1022
1022
  }
1023
1023
  }
1024
1024
 
@@ -1062,13 +1062,22 @@ CharacterCount.prototype.init = function () {
1062
1062
  // Remove hard limit if set
1063
1063
  $module.removeAttribute('maxlength');
1064
1064
 
1065
- // Bind event changes to the textarea
1066
- var boundChangeEvents = this.bindChangeEvents.bind(this);
1067
- boundChangeEvents();
1065
+ // When the page is restored after navigating 'back' in some browsers the
1066
+ // state of the character count is not restored until *after* the DOMContentLoaded
1067
+ // event is fired, so we need to sync after the pageshow event in browsers
1068
+ // that support it.
1069
+ if ('onpageshow' in window) {
1070
+ window.addEventListener('pageshow', this.sync.bind(this));
1071
+ } else {
1072
+ window.addEventListener('DOMContentLoaded', this.sync.bind(this));
1073
+ }
1074
+
1075
+ this.sync();
1076
+ };
1068
1077
 
1069
- // Update count message
1070
- var boundUpdateCountMessage = this.updateCountMessage.bind(this);
1071
- boundUpdateCountMessage();
1078
+ CharacterCount.prototype.sync = function () {
1079
+ this.bindChangeEvents();
1080
+ this.updateCountMessage();
1072
1081
  };
1073
1082
 
1074
1083
  // Read data attributes
@@ -1116,8 +1125,7 @@ CharacterCount.prototype.checkIfValueChanged = function () {
1116
1125
  if (!this.$textarea.oldValue) this.$textarea.oldValue = '';
1117
1126
  if (this.$textarea.value !== this.$textarea.oldValue) {
1118
1127
  this.$textarea.oldValue = this.$textarea.value;
1119
- var boundUpdateCountMessage = this.updateCountMessage.bind(this);
1120
- boundUpdateCountMessage();
1128
+ this.updateCountMessage();
1121
1129
  }
1122
1130
  };
1123
1131
 
@@ -1,308 +1,2 @@
1
- @import "../../settings/all";
2
- @import "../../tools/all";
3
- @import "../../helpers/all";
4
-
5
- @import "../error-message/error-message";
6
- @import "../fieldset/fieldset";
7
- @import "../hint/hint";
8
- @import "../label/label";
9
-
10
- @include govuk-exports("govuk/component/checkboxes") {
11
-
12
- $govuk-touch-target-size: 44px;
13
- $govuk-checkboxes-size: 40px;
14
- $govuk-small-checkboxes-size: 24px;
15
- $govuk-checkboxes-label-padding-left-right: govuk-spacing(3);
16
-
17
- .govuk-checkboxes__item {
18
- @include govuk-font($size: 19);
19
-
20
- display: block;
21
- position: relative;
22
-
23
- min-height: $govuk-checkboxes-size;
24
-
25
- margin-bottom: govuk-spacing(2);
26
- padding-left: $govuk-checkboxes-size;
27
-
28
- clear: left;
29
- }
30
-
31
- .govuk-checkboxes__item:last-child,
32
- .govuk-checkboxes__item:last-of-type {
33
- margin-bottom: 0;
34
- }
35
-
36
- .govuk-checkboxes__input {
37
- $input-offset: ($govuk-touch-target-size - $govuk-checkboxes-size) / 2;
38
-
39
- cursor: pointer;
40
-
41
- // IE8 doesn’t support pseudo-elements, so we don’t want to hide native
42
- // elements there.
43
- @include govuk-not-ie8 {
44
- position: absolute;
45
-
46
- z-index: 1;
47
- top: $input-offset * -1;
48
- left: $input-offset * -1;
49
-
50
- width: $govuk-touch-target-size;
51
- height: $govuk-touch-target-size;
52
- margin: 0;
53
-
54
- opacity: 0;
55
- }
56
-
57
- @include govuk-if-ie8 {
58
- margin-top: 10px;
59
- margin-right: $govuk-checkboxes-size / -2;
60
- margin-left: $govuk-checkboxes-size / -2;
61
- float: left;
62
-
63
- // add focus outline to input
64
- &:focus {
65
- outline: $govuk-focus-width solid $govuk-focus-colour;
66
- }
67
- }
68
- }
69
-
70
- .govuk-checkboxes__label {
71
- display: inline-block;
72
- margin-bottom: 0;
73
- padding: 8px $govuk-checkboxes-label-padding-left-right govuk-spacing(1);
74
- cursor: pointer;
75
- // remove 300ms pause on mobile
76
- -ms-touch-action: manipulation;
77
- touch-action: manipulation;
78
- }
79
-
80
- // [ ] Check box
81
- .govuk-checkboxes__label::before {
82
- content: "";
83
- box-sizing: border-box;
84
- position: absolute;
85
- top: 0;
86
- left: 0;
87
- width: $govuk-checkboxes-size;
88
- height: $govuk-checkboxes-size;
89
- border: $govuk-border-width-form-element solid currentColor;
90
- background: transparent;
91
- }
92
-
93
- // ✔ Check mark
94
- //
95
- // The check mark is a box with a border on the left and bottom side (└──),
96
- // rotated 45 degrees
97
- .govuk-checkboxes__label::after {
98
- content: "";
99
-
100
- position: absolute;
101
- top: 11px;
102
- left: 9px;
103
- width: 18px;
104
- height: 7px;
105
-
106
- -webkit-transform: rotate(-45deg);
107
-
108
- -ms-transform: rotate(-45deg);
109
-
110
- transform: rotate(-45deg);
111
- border: solid;
112
- border-width: 0 0 $govuk-border-width $govuk-border-width;
113
- // Fix bug in IE11 caused by transform rotate (-45deg).
114
- // See: alphagov/govuk_elements/issues/518
115
- border-top-color: transparent;
116
-
117
- opacity: 0;
118
-
119
- background: transparent;
120
- }
121
-
122
- .govuk-checkboxes__hint {
123
- display: block;
124
- padding-right: $govuk-checkboxes-label-padding-left-right;
125
- padding-left: $govuk-checkboxes-label-padding-left-right;
126
- }
127
-
128
- // Focused state
129
- .govuk-checkboxes__input:focus + .govuk-checkboxes__label::before {
130
- border-width: 4px;
131
- box-shadow: 0 0 0 $govuk-focus-width $govuk-focus-colour;
132
- }
133
-
134
- // Selected state
135
- .govuk-checkboxes__input:checked + .govuk-checkboxes__label::after {
136
- opacity: 1;
137
- }
138
-
139
- // Disabled state
140
- .govuk-checkboxes__input:disabled,
141
- .govuk-checkboxes__input:disabled + .govuk-checkboxes__label {
142
- cursor: default;
143
- }
144
-
145
- .govuk-checkboxes__input:disabled + .govuk-checkboxes__label {
146
- opacity: .5;
147
- }
148
-
149
- // =========================================================
150
- // Conditional reveals
151
- // =========================================================
152
-
153
- // The narrow border is used in the conditional reveals because the border has
154
- // to be an even number in order to be centred under the 40px checkbox or radio.
155
- $conditional-border-width: $govuk-border-width-narrow;
156
- // Calculate the amount of padding needed to keep the border centered against the checkbox.
157
- $conditional-border-padding: ($govuk-checkboxes-size / 2) - ($conditional-border-width / 2);
158
- // Move the border centered with the checkbox
159
- $conditional-margin-left: $conditional-border-padding;
160
- // Move the contents of the conditional inline with the label
161
- $conditional-padding-left: $conditional-border-padding + $govuk-checkboxes-label-padding-left-right;
162
-
163
- .govuk-checkboxes__conditional {
164
- @include govuk-responsive-margin(4, "bottom");
165
- margin-left: $conditional-margin-left;
166
- padding-left: $conditional-padding-left;
167
- border-left: $conditional-border-width solid $govuk-border-colour;
168
-
169
- .js-enabled &--hidden {
170
- display: none;
171
- }
172
-
173
- & > :last-child {
174
- margin-bottom: 0;
175
- }
176
- }
177
-
178
- // =========================================================
179
- // Small checkboxes
180
- // =========================================================
181
-
182
- .govuk-checkboxes--small {
183
-
184
- $input-offset: ($govuk-touch-target-size - $govuk-small-checkboxes-size) / 2;
185
- $label-offset: $govuk-touch-target-size - $input-offset;
186
-
187
- .govuk-checkboxes__item {
188
- @include govuk-clearfix;
189
- min-height: 0;
190
- margin-bottom: 0;
191
- padding-left: $label-offset;
192
- float: left;
193
- }
194
-
195
- // Shift the touch target into the left margin so that the visible edge of
196
- // the control is aligned
197
- //
198
- // ┆What colours do you like?
199
- // ┌┆───┐
200
- // │┆[] │ Purple
201
- // └┆▲──┘
202
- // ▲┆└─ Check box pseudo element, aligned with margin
203
- // └─── Touch target (invisible input), shifted into the margin
204
- .govuk-checkboxes__input {
205
- @include govuk-not-ie8 {
206
- left: $input-offset * -1;
207
- }
208
-
209
- @include govuk-if-ie8 {
210
- margin-left: $govuk-small-checkboxes-size * -1;
211
- }
212
- }
213
-
214
- // Adjust the size and position of the label.
215
- //
216
- // Unlike larger checkboxes, we also have to float the label in order to
217
- // 'shrink' it, preventing the hover state from kicking in across the full
218
- // width of the parent element.
219
- .govuk-checkboxes__label {
220
- margin-top: -2px;
221
- padding: 13px govuk-spacing(3) 13px 1px;
222
- float: left;
223
-
224
- @include govuk-media-query($from: tablet) {
225
- padding: 11px govuk-spacing(3) 10px 1px;
226
- }
227
- }
228
-
229
- // [ ] Check box
230
- //
231
- // Reduce the size of the check box [1], vertically center it within the
232
- // touch target [2]
233
- .govuk-checkboxes__label::before {
234
- top: $input-offset - $govuk-border-width-form-element; // 2
235
- width: $govuk-small-checkboxes-size; // 1
236
- height: $govuk-small-checkboxes-size; // 1
237
- }
238
-
239
- // ✔ Check mark
240
- //
241
- // Reduce the size of the check mark and re-align within the checkbox
242
- .govuk-checkboxes__label::after {
243
- top: 15px;
244
- left: 6px;
245
- width: 9px;
246
- height: 3.5px;
247
- border-width: 0 0 3px 3px;
248
- }
249
-
250
- // Fix position of hint with small checkboxes
251
- //
252
- // Do not use hints with small checkboxes – because they're within the input
253
- // wrapper they trigger the hover state, but clicking them doesn't actually
254
- // activate the control.
255
- //
256
- // (If you do use them, they won't look completely broken... but seriously,
257
- // don't use them)
258
- .govuk-checkboxes__hint {
259
- padding: 0;
260
- clear: both;
261
- }
262
-
263
- // Align conditional reveals with small checkboxes
264
- .govuk-checkboxes__conditional {
265
- $margin-left: ($govuk-small-checkboxes-size / 2) - ($conditional-border-width / 2);
266
- margin-left: $margin-left;
267
- padding-left: $label-offset - ($margin-left + $conditional-border-width);
268
- clear: both;
269
- }
270
-
271
- // Hover state for small checkboxes.
272
- //
273
- // We use a hover state for small checkboxes because the touch target size
274
- // is so much larger than their visible size, and so we need to provide
275
- // feedback to the user as to which checkbox they will select when their
276
- // cursor is outside of the visible area.
277
- .govuk-checkboxes__item:hover .govuk-checkboxes__input:not(:disabled) + .govuk-checkboxes__label::before {
278
- box-shadow: 0 0 0 $govuk-hover-width $govuk-hover-colour;
279
- }
280
-
281
- // Because we've overridden the border-shadow provided by the focus state,
282
- // we need to redefine that too.
283
- //
284
- // We use two box shadows, one that restores the original focus state [1]
285
- // and another that then applies the hover state [2].
286
- .govuk-checkboxes__item:hover .govuk-checkboxes__input:focus + .govuk-checkboxes__label::before {
287
- // sass-lint:disable indentation
288
- box-shadow: 0 0 0 $govuk-focus-width $govuk-focus-colour, // 1
289
- 0 0 0 $govuk-hover-width $govuk-hover-colour; // 2
290
- }
291
-
292
- // For devices that explicitly don't support hover, don't provide a hover
293
- // state (e.g. on touch devices like iOS).
294
- //
295
- // We can't use `@media (hover: hover)` because we wouldn't get the hover
296
- // state in browsers that don't support `@media (hover)` (like Internet
297
- // Explorer) – so we have to 'undo' the hover state instead.
298
- @media (hover: none), (pointer: coarse) {
299
- .govuk-checkboxes__item:hover .govuk-checkboxes__input:not(:disabled) + .govuk-checkboxes__label::before {
300
- box-shadow: initial;
301
- }
302
-
303
- .govuk-checkboxes__item:hover .govuk-checkboxes__input:focus + .govuk-checkboxes__label::before {
304
- box-shadow: 0 0 0 $govuk-focus-width $govuk-focus-colour;
305
- }
306
- }
307
- }
308
- }
1
+ @import "../../base";
2
+ @import "./index";