govuk_tech_docs 3.2.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of govuk_tech_docs might be problematic. Click here for more details.

Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/publish.yaml +1 -1
  3. data/CHANGELOG.md +26 -7
  4. data/README.md +2 -2
  5. data/example/source/code.html.md +3 -26
  6. data/lib/govuk_tech_docs/contribution_banner.rb +1 -1
  7. data/lib/govuk_tech_docs/tech_docs_html_renderer.rb +3 -3
  8. data/lib/govuk_tech_docs/version.rb +1 -1
  9. data/lib/source/layouts/core.erb +1 -1
  10. data/node_modules/govuk-frontend/govuk/all.js +1548 -311
  11. data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js +70 -0
  12. data/node_modules/govuk-frontend/govuk/common/index.js +172 -0
  13. data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js +373 -0
  14. data/node_modules/govuk-frontend/govuk/common.js +138 -3
  15. data/node_modules/govuk-frontend/govuk/components/_all.scss +1 -0
  16. data/node_modules/govuk-frontend/govuk/components/accordion/_index.scss +5 -6
  17. data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +754 -36
  18. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/_index.scss +0 -2
  19. data/node_modules/govuk-frontend/govuk/components/button/_index.scss +29 -21
  20. data/node_modules/govuk-frontend/govuk/components/button/button.js +365 -107
  21. data/node_modules/govuk-frontend/govuk/components/character-count/_index.scss +9 -0
  22. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +1092 -109
  23. data/node_modules/govuk-frontend/govuk/components/checkboxes/_index.scss +3 -2
  24. data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +30 -2
  25. data/node_modules/govuk-frontend/govuk/components/details/details.js +51 -33
  26. data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +289 -6
  27. data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +13 -23
  28. data/node_modules/govuk-frontend/govuk/components/header/_index.scss +30 -24
  29. data/node_modules/govuk-frontend/govuk/components/header/header.js +59 -11
  30. data/node_modules/govuk-frontend/govuk/components/input/_index.scss +13 -23
  31. data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +252 -2
  32. data/node_modules/govuk-frontend/govuk/components/pagination/_index.scss +247 -0
  33. data/node_modules/govuk-frontend/govuk/components/pagination/_pagination.scss +2 -0
  34. data/node_modules/govuk-frontend/govuk/components/panel/_index.scss +1 -1
  35. data/node_modules/govuk-frontend/govuk/components/radios/_index.scss +5 -12
  36. data/node_modules/govuk-frontend/govuk/components/radios/radios.js +30 -2
  37. data/node_modules/govuk-frontend/govuk/components/select/_index.scss +11 -0
  38. data/node_modules/govuk-frontend/govuk/components/skip-link/_index.scss +1 -3
  39. data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js +10 -4
  40. data/node_modules/govuk-frontend/govuk/components/summary-list/_index.scss +45 -13
  41. data/node_modules/govuk-frontend/govuk/components/table/_index.scss +1 -1
  42. data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +28 -0
  43. data/node_modules/govuk-frontend/govuk/core/_section-break.scss +1 -1
  44. data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +5 -5
  45. data/node_modules/govuk-frontend/govuk/helpers/_focused.scss +5 -0
  46. data/node_modules/govuk-frontend/govuk/helpers/_links.scss +13 -11
  47. data/node_modules/govuk-frontend/govuk/helpers/_media-queries.scss +2 -2
  48. data/node_modules/govuk-frontend/govuk/helpers/_shape-arrow.scss +1 -1
  49. data/node_modules/govuk-frontend/govuk/helpers/_spacing.scss +3 -3
  50. data/node_modules/govuk-frontend/govuk/helpers/_typography.scss +16 -9
  51. data/node_modules/govuk-frontend/govuk/i18n.js +390 -0
  52. data/node_modules/govuk-frontend/govuk/objects/_button-group.scss +10 -26
  53. data/node_modules/govuk-frontend/govuk/objects/_template.scss +1 -1
  54. data/node_modules/govuk-frontend/govuk/objects/_width-container.scss +0 -4
  55. data/node_modules/govuk-frontend/govuk/overrides/_spacing.scss +56 -12
  56. data/node_modules/govuk-frontend/govuk/settings/_all.scss +1 -0
  57. data/node_modules/govuk-frontend/govuk/settings/_colours-palette.scss +12 -0
  58. data/node_modules/govuk-frontend/govuk/settings/_compatibility.scss +26 -0
  59. data/node_modules/govuk-frontend/govuk/settings/_spacing.scss +4 -8
  60. data/node_modules/govuk-frontend/govuk/settings/_typography-font.scss +23 -0
  61. data/node_modules/govuk-frontend/govuk/settings/_typography-responsive.scss +12 -0
  62. data/node_modules/govuk-frontend/govuk/settings/_warnings.scss +53 -0
  63. data/node_modules/govuk-frontend/govuk/tools/_compatibility.scss +20 -6
  64. data/node_modules/govuk-frontend/govuk/tools/_exports.scss +1 -1
  65. data/node_modules/govuk-frontend/govuk/tools/_font-url.scss +1 -1
  66. data/node_modules/govuk-frontend/govuk/tools/_image-url.scss +1 -1
  67. data/node_modules/govuk-frontend/govuk/tools/_px-to-em.scss +2 -2
  68. data/node_modules/govuk-frontend/govuk/tools/_px-to-rem.scss +1 -1
  69. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js +21 -0
  70. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js +300 -0
  71. data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js +21 -0
  72. data/node_modules/govuk-frontend/govuk-prototype-kit/init.js +7 -0
  73. data/node_modules/govuk-frontend/govuk-prototype-kit/init.scss +12 -0
  74. data/package-lock.json +12 -12
  75. data/package.json +1 -1
  76. metadata +17 -5
@@ -4,10 +4,24 @@
4
4
  (factory((global.GOVUKFrontend = {})));
5
5
  }(this, (function (exports) { 'use strict';
6
6
 
7
+ /**
8
+ * Common helpers which do not require polyfill.
9
+ *
10
+ * IMPORTANT: If a helper require a polyfill, please isolate it in its own module
11
+ * so that the polyfill can be properly tree-shaken and does not burden
12
+ * the components that do not need that helper
13
+ *
14
+ * @module common/index
15
+ */
16
+
7
17
  /**
8
18
  * TODO: Ideally this would be a NodeList.prototype.forEach polyfill
9
19
  * This seems to fail in IE8, requires more investigation.
10
20
  * See: https://github.com/imagitama/nodelist-foreach-polyfill
21
+ *
22
+ * @param {NodeListOf<Element>} nodes - NodeList from querySelectorAll()
23
+ * @param {nodeListIterator} callback - Callback function to run for each node
24
+ * @returns {undefined}
11
25
  */
12
26
  function nodeListForEach (nodes, callback) {
13
27
  if (window.NodeList.prototype.forEach) {
@@ -18,9 +32,13 @@ function nodeListForEach (nodes, callback) {
18
32
  }
19
33
  }
20
34
 
21
- // Used to generate a unique string, allows multiple instances of the component without
22
- // Them conflicting with each other.
23
- // https://stackoverflow.com/a/8809472
35
+ /**
36
+ * Used to generate a unique string, allows multiple instances of the component
37
+ * without them conflicting with each other.
38
+ * https://stackoverflow.com/a/8809472
39
+ *
40
+ * @returns {string} Unique ID
41
+ */
24
42
  function generateUniqueID () {
25
43
  var d = new Date().getTime();
26
44
  if (typeof window.performance !== 'undefined' && typeof window.performance.now === 'function') {
@@ -33,7 +51,124 @@ function generateUniqueID () {
33
51
  })
34
52
  }
35
53
 
54
+ /**
55
+ * Config flattening function
56
+ *
57
+ * Takes any number of objects, flattens them into namespaced key-value pairs,
58
+ * (e.g. {'i18n.showSection': 'Show section'}) and combines them together, with
59
+ * greatest priority on the LAST item passed in.
60
+ *
61
+ * @returns {object} A flattened object of key-value pairs.
62
+ */
63
+ function mergeConfigs (/* configObject1, configObject2, ...configObjects */) {
64
+ /**
65
+ * Function to take nested objects and flatten them to a dot-separated keyed
66
+ * object. Doing this means we don't need to do any deep/recursive merging of
67
+ * each of our objects, nor transform our dataset from a flat list into a
68
+ * nested object.
69
+ *
70
+ * @param {object} configObject - Deeply nested object
71
+ * @returns {object} Flattened object with dot-separated keys
72
+ */
73
+ var flattenObject = function (configObject) {
74
+ // Prepare an empty return object
75
+ var flattenedObject = {};
76
+
77
+ // Our flattening function, this is called recursively for each level of
78
+ // depth in the object. At each level we prepend the previous level names to
79
+ // the key using `prefix`.
80
+ var flattenLoop = function (obj, prefix) {
81
+ // Loop through keys...
82
+ for (var key in obj) {
83
+ // Check to see if this is a prototypical key/value,
84
+ // if it is, skip it.
85
+ if (!Object.prototype.hasOwnProperty.call(obj, key)) {
86
+ continue
87
+ }
88
+ var value = obj[key];
89
+ var prefixedKey = prefix ? prefix + '.' + key : key;
90
+ if (typeof value === 'object') {
91
+ // If the value is a nested object, recurse over that too
92
+ flattenLoop(value, prefixedKey);
93
+ } else {
94
+ // Otherwise, add this value to our return object
95
+ flattenedObject[prefixedKey] = value;
96
+ }
97
+ }
98
+ };
99
+
100
+ // Kick off the recursive loop
101
+ flattenLoop(configObject);
102
+ return flattenedObject
103
+ };
104
+
105
+ // Start with an empty object as our base
106
+ var formattedConfigObject = {};
107
+
108
+ // Loop through each of the remaining passed objects and push their keys
109
+ // one-by-one into configObject. Any duplicate keys will override the existing
110
+ // key with the new value.
111
+ for (var i = 0; i < arguments.length; i++) {
112
+ var obj = flattenObject(arguments[i]);
113
+ for (var key in obj) {
114
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
115
+ formattedConfigObject[key] = obj[key];
116
+ }
117
+ }
118
+ }
119
+
120
+ return formattedConfigObject
121
+ }
122
+
123
+ /**
124
+ * Extracts keys starting with a particular namespace from a flattened config
125
+ * object, removing the namespace in the process.
126
+ *
127
+ * @param {object} configObject - The object to extract key-value pairs from.
128
+ * @param {string} namespace - The namespace to filter keys with.
129
+ * @returns {object} Flattened object with dot-separated key namespace removed
130
+ */
131
+ function extractConfigByNamespace (configObject, namespace) {
132
+ // Check we have what we need
133
+ if (!configObject || typeof configObject !== 'object') {
134
+ throw new Error('Provide a `configObject` of type "object".')
135
+ }
136
+ if (!namespace || typeof namespace !== 'string') {
137
+ throw new Error('Provide a `namespace` of type "string" to filter the `configObject` by.')
138
+ }
139
+ var newObject = {};
140
+ for (var key in configObject) {
141
+ // Split the key into parts, using . as our namespace separator
142
+ var keyParts = key.split('.');
143
+ // Check if the first namespace matches the configured namespace
144
+ if (Object.prototype.hasOwnProperty.call(configObject, key) && keyParts[0] === namespace) {
145
+ // Remove the first item (the namespace) from the parts array,
146
+ // but only if there is more than one part (we don't want blank keys!)
147
+ if (keyParts.length > 1) {
148
+ keyParts.shift();
149
+ }
150
+ // Join the remaining parts back together
151
+ var newKey = keyParts.join('.');
152
+ // Add them to our new object
153
+ newObject[newKey] = configObject[key];
154
+ }
155
+ }
156
+ return newObject
157
+ }
158
+
159
+ /**
160
+ * @callback nodeListIterator
161
+ * @param {Element} value - The current node being iterated on
162
+ * @param {number} index - The current index in the iteration
163
+ * @param {NodeListOf<Element>} nodes - NodeList from querySelectorAll()
164
+ * @returns {undefined}
165
+ */
166
+
167
+ // Implementation of common function is gathered in the `common` folder
168
+
36
169
  exports.nodeListForEach = nodeListForEach;
37
170
  exports.generateUniqueID = generateUniqueID;
171
+ exports.mergeConfigs = mergeConfigs;
172
+ exports.extractConfigByNamespace = extractConfigByNamespace;
38
173
 
39
174
  })));
@@ -21,6 +21,7 @@
21
21
  @import "inset-text/index";
22
22
  @import "label/index";
23
23
  @import "notification-banner/index";
24
+ @import "pagination/index";
24
25
  @import "panel/index";
25
26
  @import "phase-banner/index";
26
27
  @import "tabs/index";
@@ -1,7 +1,7 @@
1
1
  @include govuk-exports("govuk/component/accordion") {
2
2
  $govuk-accordion-base-colour: govuk-colour("black");
3
3
  $govuk-accordion-hover-colour: govuk-colour("light-grey", $legacy: "grey-3");
4
- $govuk-accordion-icon-focus-colour: govuk-colour("yellow");
4
+ $govuk-accordion-icon-focus-colour: $govuk-focus-colour;
5
5
  $govuk-accordion-bottom-border-width: 1px;
6
6
 
7
7
  .govuk-accordion {
@@ -22,6 +22,7 @@
22
22
  }
23
23
 
24
24
  .govuk-accordion__section-button {
25
+ @include govuk-font($size: 24, $weight: bold);
25
26
  @include govuk-text-colour;
26
27
 
27
28
  display: block;
@@ -29,10 +30,6 @@
29
30
  padding-top: govuk-spacing(3);
30
31
  }
31
32
 
32
- .govuk-accordion__section-heading-text {
33
- @include govuk-font($size: 24, $weight: bold);
34
- }
35
-
36
33
  // Remove the bottom margin from the last item inside the content
37
34
  .govuk-accordion__section-content > :last-child {
38
35
  margin-bottom: 0;
@@ -53,6 +50,7 @@
53
50
  .govuk-accordion__section-content {
54
51
  display: none;
55
52
  @include govuk-responsive-padding(8, "bottom");
53
+ @include govuk-responsive-padding(3, "top");
56
54
  }
57
55
 
58
56
  // Show the body of expanded sections
@@ -305,7 +303,8 @@
305
303
 
306
304
  // Add toggle link with Chevron icon on left.
307
305
  .govuk-accordion__section-toggle {
308
- @include govuk-font($size: 19);
306
+ @include govuk-typography-responsive($size: 19);
307
+ @include govuk-typography-weight-regular;
309
308
  color: $govuk-link-colour;
310
309
  }
311
310