govuk_tech_docs 5.2.2 → 6.0.0.beta

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 (145) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -0
  3. data/CHANGELOG.md +15 -0
  4. data/README.md +11 -3
  5. data/example/config/tech-docs.yml +1 -1
  6. data/govuk_tech_docs.gemspec +1 -1
  7. data/lib/assets/stylesheets/_core.scss +1 -0
  8. data/lib/assets/stylesheets/_govuk_tech_docs.scss +13 -15
  9. data/lib/assets/stylesheets/modules/_app-pane.scss +3 -3
  10. data/lib/assets/stylesheets/modules/_page-review.scss +4 -4
  11. data/lib/assets/stylesheets/modules/_search.scss +3 -3
  12. data/lib/assets/stylesheets/modules/_service-navigation.scss +5 -0
  13. data/lib/assets/stylesheets/modules/_technical-documentation.scss +7 -7
  14. data/lib/assets/stylesheets/modules/_toc.scss +13 -13
  15. data/lib/assets/stylesheets/palette/_syntax-highlighting.scss +9 -7
  16. data/lib/govuk_tech_docs/meta_tags.rb +1 -1
  17. data/lib/govuk_tech_docs/version.rb +1 -1
  18. data/lib/source/layouts/_header.erb +2 -16
  19. data/lib/source/layouts/_service_navigation.erb +27 -0
  20. data/lib/source/layouts/core.erb +7 -7
  21. data/node_modules/govuk-frontend/dist/govuk/_base.scss +1 -0
  22. data/node_modules/govuk-frontend/dist/govuk/all.bundle.js +87 -229
  23. data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs +88 -229
  24. data/node_modules/govuk-frontend/dist/govuk/all.mjs +0 -1
  25. data/node_modules/govuk-frontend/dist/govuk/assets/images/favicon.ico +0 -0
  26. data/node_modules/govuk-frontend/dist/govuk/assets/images/favicon.svg +1 -1
  27. data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-icon-180.png +0 -0
  28. data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-icon-192.png +0 -0
  29. data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-icon-512.png +0 -0
  30. data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-opengraph-image.png +0 -0
  31. data/node_modules/govuk-frontend/dist/govuk/common/govuk-frontend-version.mjs +1 -1
  32. data/node_modules/govuk-frontend/dist/govuk/components/accordion/_index.scss +18 -15
  33. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js +1 -126
  34. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs +1 -126
  35. data/node_modules/govuk-frontend/dist/govuk/components/back-link/_index.scss +2 -2
  36. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/_index.scss +2 -2
  37. data/node_modules/govuk-frontend/dist/govuk/components/button/_index.scss +18 -21
  38. data/node_modules/govuk-frontend/dist/govuk/components/character-count/_index.scss +2 -2
  39. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js +20 -135
  40. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs +20 -135
  41. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.mjs +19 -9
  42. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/_index.scss +7 -6
  43. data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/_index.scss +2 -5
  44. data/node_modules/govuk-frontend/dist/govuk/components/date-input/_index.scss +5 -0
  45. data/node_modules/govuk-frontend/dist/govuk/components/details/_index.scss +6 -4
  46. data/node_modules/govuk-frontend/dist/govuk/components/error-message/_index.scss +1 -1
  47. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/_index.scss +4 -2
  48. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/_index.scss +1 -1
  49. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js +1 -126
  50. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs +1 -126
  51. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/_index.scss +30 -38
  52. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.js +36 -132
  53. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.mjs +36 -132
  54. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.mjs +35 -6
  55. data/node_modules/govuk-frontend/dist/govuk/components/footer/_index.scss +30 -27
  56. data/node_modules/govuk-frontend/dist/govuk/components/header/_index.scss +89 -449
  57. data/node_modules/govuk-frontend/dist/govuk/components/hint/_index.scss +1 -1
  58. data/node_modules/govuk-frontend/dist/govuk/components/input/_index.scss +14 -20
  59. data/node_modules/govuk-frontend/dist/govuk/components/inset-text/_index.scss +2 -1
  60. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/_index.scss +10 -8
  61. data/node_modules/govuk-frontend/dist/govuk/components/pagination/_index.scss +12 -11
  62. data/node_modules/govuk-frontend/dist/govuk/components/panel/_index.scss +4 -4
  63. data/node_modules/govuk-frontend/dist/govuk/components/password-input/_index.scss +2 -2
  64. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js +1 -126
  65. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs +1 -126
  66. data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/_index.scss +12 -6
  67. data/node_modules/govuk-frontend/dist/govuk/components/radios/_index.scss +8 -7
  68. data/node_modules/govuk-frontend/dist/govuk/components/select/_index.scss +6 -11
  69. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_index.scss +55 -76
  70. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js +30 -2
  71. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.mjs +30 -2
  72. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.mjs +30 -2
  73. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/_index.scss +7 -2
  74. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/_index.scss +25 -21
  75. data/node_modules/govuk-frontend/dist/govuk/components/table/_index.scss +7 -8
  76. data/node_modules/govuk-frontend/dist/govuk/components/tabs/_index.scss +9 -6
  77. data/node_modules/govuk-frontend/dist/govuk/components/tag/_index.scss +66 -31
  78. data/node_modules/govuk-frontend/dist/govuk/components/task-list/_index.scss +7 -5
  79. data/node_modules/govuk-frontend/dist/govuk/components/textarea/_index.scss +5 -10
  80. data/node_modules/govuk-frontend/dist/govuk/components/warning-text/_index.scss +5 -4
  81. data/node_modules/govuk-frontend/dist/govuk/core/_index.scss +0 -1
  82. data/node_modules/govuk-frontend/dist/govuk/core/_lists.scss +2 -2
  83. data/node_modules/govuk-frontend/dist/govuk/core/_section-break.scss +2 -1
  84. data/node_modules/govuk-frontend/dist/govuk/core/_typography.scss +6 -20
  85. data/node_modules/govuk-frontend/dist/govuk/custom-properties/_breakpoints.scss +17 -0
  86. data/node_modules/govuk-frontend/dist/govuk/custom-properties/_frontend-version.scss +15 -0
  87. data/node_modules/govuk-frontend/dist/govuk/custom-properties/_functional-colours.scss +17 -0
  88. data/node_modules/govuk-frontend/dist/govuk/custom-properties/_index.scss +5 -0
  89. data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js +1 -1
  90. data/node_modules/govuk-frontend/dist/govuk/helpers/_colour.scss +168 -82
  91. data/node_modules/govuk-frontend/dist/govuk/helpers/_focused.scss +41 -6
  92. data/node_modules/govuk-frontend/dist/govuk/helpers/_grid.scss +1 -1
  93. data/node_modules/govuk-frontend/dist/govuk/helpers/_links.scss +24 -40
  94. data/node_modules/govuk-frontend/dist/govuk/helpers/_media-queries.scss +172 -33
  95. data/node_modules/govuk-frontend/dist/govuk/helpers/_spacing.scss +1 -1
  96. data/node_modules/govuk-frontend/dist/govuk/helpers/_typography.scss +6 -30
  97. data/node_modules/govuk-frontend/dist/govuk/i18n.mjs +1 -126
  98. data/node_modules/govuk-frontend/dist/govuk/init.mjs +1 -2
  99. data/node_modules/govuk-frontend/dist/govuk/objects/_button-group.scss +1 -1
  100. data/node_modules/govuk-frontend/dist/govuk/objects/_form-group.scss +2 -1
  101. data/node_modules/govuk-frontend/dist/govuk/objects/_main-wrapper.scss +1 -1
  102. data/node_modules/govuk-frontend/dist/govuk/objects/_template.scss +3 -7
  103. data/node_modules/govuk-frontend/dist/govuk/objects/_width-container.scss +2 -2
  104. data/node_modules/govuk-frontend/dist/govuk/overrides/_display.scss +1 -1
  105. data/node_modules/govuk-frontend/dist/govuk/overrides/_typography.scss +0 -2
  106. data/node_modules/govuk-frontend/dist/govuk/overrides/_width.scss +5 -5
  107. data/node_modules/govuk-frontend/dist/govuk/settings/_colours-applied.scss +3 -188
  108. data/node_modules/govuk-frontend/dist/govuk/settings/_colours-functional.scss +366 -0
  109. data/node_modules/govuk-frontend/dist/govuk/settings/_colours-organisations.scss +9 -255
  110. data/node_modules/govuk-frontend/dist/govuk/settings/_colours-palette.scss +117 -25
  111. data/node_modules/govuk-frontend/dist/govuk/settings/_custom-properties.scss +18 -0
  112. data/node_modules/govuk-frontend/dist/govuk/settings/_index.scss +3 -14
  113. data/node_modules/govuk-frontend/dist/govuk/settings/_media-queries.scss +0 -9
  114. data/node_modules/govuk-frontend/dist/govuk/settings/_typography-responsive.scss +12 -189
  115. data/node_modules/govuk-frontend/dist/govuk/tools/_index.scss +0 -1
  116. data/node_modules/govuk-frontend/dist/govuk/tools/_px-to-em.scss +4 -2
  117. data/node_modules/govuk-frontend/dist/govuk/tools/_px-to-rem.scss +2 -0
  118. data/package-lock.json +3228 -4
  119. data/package.json +1 -1
  120. metadata +10 -26
  121. data/node_modules/govuk-frontend/dist/govuk/all.scss +0 -9
  122. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/favicon.ico +0 -0
  123. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/favicon.svg +0 -1
  124. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-crest.svg +0 -1
  125. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-icon-180.png +0 -0
  126. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-icon-192.png +0 -0
  127. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-icon-512.png +0 -0
  128. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-icon-mask.svg +0 -1
  129. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-opengraph-image.png +0 -0
  130. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/manifest.json +0 -39
  131. data/node_modules/govuk-frontend/dist/govuk/components/_all.scss +0 -10
  132. data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.js +0 -238
  133. data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.mjs +0 -230
  134. data/node_modules/govuk-frontend/dist/govuk/components/header/header.mjs +0 -89
  135. data/node_modules/govuk-frontend/dist/govuk/core/_all.scss +0 -10
  136. data/node_modules/govuk-frontend/dist/govuk/core/_govuk-frontend-properties.scss +0 -15
  137. data/node_modules/govuk-frontend/dist/govuk/helpers/_all.scss +0 -10
  138. data/node_modules/govuk-frontend/dist/govuk/objects/_all.scss +0 -10
  139. data/node_modules/govuk-frontend/dist/govuk/overrides/_all.scss +0 -9
  140. data/node_modules/govuk-frontend/dist/govuk/settings/_all.scss +0 -10
  141. data/node_modules/govuk-frontend/dist/govuk/tools/_all.scss +0 -10
  142. data/node_modules/govuk-frontend/dist/govuk/tools/_rebrand.scss +0 -65
  143. data/node_modules/govuk-frontend/dist/govuk/utilities/_all.scss +0 -10
  144. data/node_modules/govuk-frontend/dist/govuk/vendor/_sass-mq.scss +0 -349
  145. data/node_modules/govuk-frontend/dist/govuk-prototype-kit/functions.js +0 -25
@@ -342,7 +342,7 @@ class I18n {
342
342
  return 'other';
343
343
  }
344
344
  const translation = this.translations[lookupKey];
345
- const preferredForm = this.hasIntlPluralRulesSupport() ? new Intl.PluralRules(this.locale).select(count) : this.selectPluralFormUsingFallbackRules(count);
345
+ const preferredForm = this.hasIntlPluralRulesSupport() ? new Intl.PluralRules(this.locale).select(count) : 'other';
346
346
  if (isObject(translation)) {
347
347
  if (preferredForm in translation) {
348
348
  return preferredForm;
@@ -353,132 +353,7 @@ class I18n {
353
353
  }
354
354
  throw new Error(`i18n: Plural form ".other" is required for "${this.locale}" locale`);
355
355
  }
356
- selectPluralFormUsingFallbackRules(count) {
357
- count = Math.abs(Math.floor(count));
358
- const ruleset = this.getPluralRulesForLocale();
359
- if (ruleset) {
360
- return I18n.pluralRules[ruleset](count);
361
- }
362
- return 'other';
363
- }
364
- getPluralRulesForLocale() {
365
- const localeShort = this.locale.split('-')[0];
366
- for (const pluralRule in I18n.pluralRulesMap) {
367
- const languages = I18n.pluralRulesMap[pluralRule];
368
- if (languages.includes(this.locale) || languages.includes(localeShort)) {
369
- return pluralRule;
370
- }
371
- }
372
- }
373
356
  }
374
- I18n.pluralRulesMap = {
375
- arabic: ['ar'],
376
- chinese: ['my', 'zh', 'id', 'ja', 'jv', 'ko', 'ms', 'th', 'vi'],
377
- french: ['hy', 'bn', 'fr', 'gu', 'hi', 'fa', 'pa', 'zu'],
378
- german: ['af', 'sq', 'az', 'eu', 'bg', 'ca', 'da', 'nl', 'en', 'et', 'fi', 'ka', 'de', 'el', 'hu', 'lb', 'no', 'so', 'sw', 'sv', 'ta', 'te', 'tr', 'ur'],
379
- irish: ['ga'],
380
- russian: ['ru', 'uk'],
381
- scottish: ['gd'],
382
- spanish: ['pt-PT', 'it', 'es'],
383
- welsh: ['cy']
384
- };
385
- I18n.pluralRules = {
386
- arabic(n) {
387
- if (n === 0) {
388
- return 'zero';
389
- }
390
- if (n === 1) {
391
- return 'one';
392
- }
393
- if (n === 2) {
394
- return 'two';
395
- }
396
- if (n % 100 >= 3 && n % 100 <= 10) {
397
- return 'few';
398
- }
399
- if (n % 100 >= 11 && n % 100 <= 99) {
400
- return 'many';
401
- }
402
- return 'other';
403
- },
404
- chinese() {
405
- return 'other';
406
- },
407
- french(n) {
408
- return n === 0 || n === 1 ? 'one' : 'other';
409
- },
410
- german(n) {
411
- return n === 1 ? 'one' : 'other';
412
- },
413
- irish(n) {
414
- if (n === 1) {
415
- return 'one';
416
- }
417
- if (n === 2) {
418
- return 'two';
419
- }
420
- if (n >= 3 && n <= 6) {
421
- return 'few';
422
- }
423
- if (n >= 7 && n <= 10) {
424
- return 'many';
425
- }
426
- return 'other';
427
- },
428
- russian(n) {
429
- const lastTwo = n % 100;
430
- const last = lastTwo % 10;
431
- if (last === 1 && lastTwo !== 11) {
432
- return 'one';
433
- }
434
- if (last >= 2 && last <= 4 && !(lastTwo >= 12 && lastTwo <= 14)) {
435
- return 'few';
436
- }
437
- if (last === 0 || last >= 5 && last <= 9 || lastTwo >= 11 && lastTwo <= 14) {
438
- return 'many';
439
- }
440
- return 'other';
441
- },
442
- scottish(n) {
443
- if (n === 1 || n === 11) {
444
- return 'one';
445
- }
446
- if (n === 2 || n === 12) {
447
- return 'two';
448
- }
449
- if (n >= 3 && n <= 10 || n >= 13 && n <= 19) {
450
- return 'few';
451
- }
452
- return 'other';
453
- },
454
- spanish(n) {
455
- if (n === 1) {
456
- return 'one';
457
- }
458
- if (n % 1000000 === 0 && n !== 0) {
459
- return 'many';
460
- }
461
- return 'other';
462
- },
463
- welsh(n) {
464
- if (n === 0) {
465
- return 'zero';
466
- }
467
- if (n === 1) {
468
- return 'one';
469
- }
470
- if (n === 2) {
471
- return 'two';
472
- }
473
- if (n === 3) {
474
- return 'few';
475
- }
476
- if (n === 6) {
477
- return 'many';
478
- }
479
- return 'other';
480
- }
481
- };
482
357
 
483
358
  /**
484
359
  * Exit this page component
@@ -6,8 +6,8 @@
6
6
  $file-upload-border-width: 2px;
7
7
  $component-padding: govuk-spacing(1);
8
8
  $empty-button-background-colour: govuk-colour("white");
9
- $empty-pseudo-button-background-colour: govuk-colour("light-grey");
10
- $empty-status-background-colour: govuk-tint(govuk-colour("blue"), 70%);
9
+ $empty-pseudo-button-background-colour: govuk-colour("black", $variant: "tint-95");
10
+ $empty-status-background-colour: govuk-colour("blue", $variant: "tint-80");
11
11
 
12
12
  .govuk-file-upload {
13
13
  @include govuk-font($size: 19);
@@ -27,11 +27,12 @@
27
27
  }
28
28
 
29
29
  &:focus {
30
- outline: $govuk-focus-width solid $govuk-focus-colour;
30
+ outline: $govuk-focus-width solid;
31
+ outline-color: govuk-functional-colour(focus);
31
32
  // Use `box-shadow` to add border instead of changing `border-width`
32
33
  // (which changes element size) and since `outline` is already used for
33
34
  // the yellow focus state.
34
- box-shadow: inset 0 0 0 4px $govuk-input-border-colour;
35
+ box-shadow: inset 0 0 0 4px govuk-functional-colour(input-border);
35
36
  }
36
37
 
37
38
  // Set "focus-within" to fix https://bugzil.la/1430196 so that component
@@ -40,9 +41,10 @@
40
41
  // to recognise `focus-within` and don't set any styles from the block
41
42
  // when it's a selector.
42
43
  &:focus-within {
43
- outline: $govuk-focus-width solid $govuk-focus-colour;
44
+ outline: $govuk-focus-width solid;
45
+ outline-color: govuk-functional-colour(focus);
44
46
 
45
- box-shadow: inset 0 0 0 4px $govuk-input-border-colour;
47
+ box-shadow: inset 0 0 0 4px govuk-functional-colour(input-border);
46
48
  }
47
49
 
48
50
  &:disabled {
@@ -55,7 +57,7 @@
55
57
  display: block;
56
58
  position: relative;
57
59
  z-index: 0;
58
- background-color: $govuk-body-background-colour;
60
+ background-color: govuk-functional-colour(body-background);
59
61
  }
60
62
 
61
63
  // required because disabling pointer events
@@ -82,8 +84,10 @@
82
84
  display: block;
83
85
  margin-bottom: govuk-spacing(2);
84
86
  padding: govuk-spacing(3) govuk-spacing(2);
85
- background-color: govuk-colour("white");
87
+ color: govuk-colour("white");
88
+ background-color: govuk-colour("blue");
86
89
  text-align: left;
90
+ @include govuk-text-break-word;
87
91
  }
88
92
 
89
93
  // bugs documented with button using flex
@@ -99,37 +103,38 @@
99
103
  width: 100%;
100
104
  // align the padding to be same as notification banner and error summary accounting for the thicker borders
101
105
  padding: (govuk-spacing(3) + $govuk-border-width - $file-upload-border-width);
102
- border: $file-upload-border-width govuk-colour("mid-grey") solid;
103
- background-color: govuk-colour("light-grey");
106
+ border: $file-upload-border-width govuk-colour("black", $variant: "tint-80") solid;
107
+ background-color: govuk-colour("white");
104
108
  cursor: pointer;
105
109
 
106
- @include govuk-media-query($from: tablet) {
110
+ @media #{govuk-from-breakpoint(tablet)} {
107
111
  padding: (govuk-spacing(4) + $govuk-border-width - $file-upload-border-width);
108
112
  }
109
113
 
110
114
  .govuk-file-upload-button__pseudo-button {
111
- background-color: govuk-colour("white");
115
+ background-color: govuk-colour("black", $variant: "tint-95");
112
116
  }
113
117
 
114
118
  &:hover {
115
- background-color: govuk-tint(govuk-colour("mid-grey"), 20%);
119
+ border-color: govuk-colour("black", $variant: "tint-50");
116
120
 
117
121
  .govuk-file-upload-button__pseudo-button {
118
- background-color: govuk-shade(govuk-colour("light-grey"), 10%);
122
+ background-color: govuk-colour("black", $variant: "tint-80");
119
123
  }
120
124
 
121
125
  .govuk-file-upload-button__status {
122
- background-color: govuk-tint(govuk-colour("blue"), 80%);
126
+ background-color: govuk-colour("blue");
123
127
  }
124
128
  }
125
129
 
126
130
  &:active,
127
131
  &:focus {
128
132
  border: $file-upload-border-width solid govuk-colour("black");
129
- outline: $govuk-focus-width solid $govuk-focus-colour;
133
+ outline: $govuk-focus-width solid;
134
+ outline-color: govuk-functional-colour(focus);
130
135
  // Ensure outline appears outside of the element
131
136
  outline-offset: 0;
132
- background-color: govuk-tint(govuk-colour("mid-grey"), 20%);
137
+ background-color: govuk-colour("black", $variant: "tint-95");
133
138
  // Double the border by adding its width again. Use `box-shadow` for this
134
139
  // instead of changing `border-width` - this is for consistency with
135
140
  // components such as textarea where we avoid changing `border-width` as
@@ -138,15 +143,15 @@
138
143
  box-shadow: inset 0 0 0 $govuk-border-width-form-element;
139
144
 
140
145
  .govuk-file-upload-button__pseudo-button {
141
- background-color: $govuk-focus-colour;
146
+ background-color: govuk-functional-colour(focus);
142
147
  box-shadow: 0 2px 0 govuk-colour("black");
143
148
  }
144
149
 
145
150
  &:hover .govuk-file-upload-button__pseudo-button {
146
- border-color: $govuk-focus-colour;
151
+ border-color: govuk-functional-colour(focus);
147
152
  outline: 3px solid transparent;
148
- background-color: govuk-colour("light-grey");
149
- box-shadow: inset 0 0 0 1px $govuk-focus-colour;
153
+ background-color: govuk-colour("black", $variant: "tint-80");
154
+ box-shadow: inset 0 0 0 1px govuk-functional-colour(focus);
150
155
  }
151
156
  }
152
157
  }
@@ -160,17 +165,17 @@
160
165
  }
161
166
 
162
167
  .govuk-file-upload-button__status {
163
- color: govuk-shade(govuk-colour("blue"), 60%);
168
+ color: govuk-colour("black");
164
169
  background-color: $empty-status-background-colour;
165
170
  }
166
171
 
167
172
  &:hover,
168
173
  &:focus,
169
174
  &:active {
170
- background-color: govuk-colour("light-grey");
175
+ background-color: govuk-colour("black", $variant: "tint-95");
171
176
 
172
177
  .govuk-file-upload-button__status {
173
- background-color: govuk-tint(govuk-colour("blue"), 80%);
178
+ background-color: govuk-colour("blue", $variant: "tint-80");
174
179
  }
175
180
  }
176
181
  }
@@ -181,21 +186,8 @@
181
186
 
182
187
  // extra specificity to apply when
183
188
  // empty
184
- &.govuk-file-upload-button {
185
- background-color: govuk-tint(govuk-colour("mid-grey"), 20%);
186
- }
187
-
188
189
  &.govuk-file-upload-button--empty {
189
- background-color: govuk-colour("light-grey");
190
- }
191
-
192
- &.govuk-file-upload-button--empty:not(:disabled) .govuk-file-upload-button__status,
193
- &.govuk-file-upload-button--empty .govuk-file-upload-button__pseudo-button {
194
- background-color: govuk-colour("white");
195
- }
196
-
197
- .govuk-file-upload-button__pseudo-button {
198
- background-color: govuk-shade(govuk-colour("light-grey"), 10%);
190
+ background-color: govuk-colour("black", $variant: "tint-95");
199
191
  }
200
192
  }
201
193
 
@@ -353,7 +353,7 @@
353
353
  return 'other';
354
354
  }
355
355
  const translation = this.translations[lookupKey];
356
- const preferredForm = this.hasIntlPluralRulesSupport() ? new Intl.PluralRules(this.locale).select(count) : this.selectPluralFormUsingFallbackRules(count);
356
+ const preferredForm = this.hasIntlPluralRulesSupport() ? new Intl.PluralRules(this.locale).select(count) : 'other';
357
357
  if (isObject(translation)) {
358
358
  if (preferredForm in translation) {
359
359
  return preferredForm;
@@ -364,132 +364,7 @@
364
364
  }
365
365
  throw new Error(`i18n: Plural form ".other" is required for "${this.locale}" locale`);
366
366
  }
367
- selectPluralFormUsingFallbackRules(count) {
368
- count = Math.abs(Math.floor(count));
369
- const ruleset = this.getPluralRulesForLocale();
370
- if (ruleset) {
371
- return I18n.pluralRules[ruleset](count);
372
- }
373
- return 'other';
374
- }
375
- getPluralRulesForLocale() {
376
- const localeShort = this.locale.split('-')[0];
377
- for (const pluralRule in I18n.pluralRulesMap) {
378
- const languages = I18n.pluralRulesMap[pluralRule];
379
- if (languages.includes(this.locale) || languages.includes(localeShort)) {
380
- return pluralRule;
381
- }
382
- }
383
- }
384
367
  }
385
- I18n.pluralRulesMap = {
386
- arabic: ['ar'],
387
- chinese: ['my', 'zh', 'id', 'ja', 'jv', 'ko', 'ms', 'th', 'vi'],
388
- french: ['hy', 'bn', 'fr', 'gu', 'hi', 'fa', 'pa', 'zu'],
389
- german: ['af', 'sq', 'az', 'eu', 'bg', 'ca', 'da', 'nl', 'en', 'et', 'fi', 'ka', 'de', 'el', 'hu', 'lb', 'no', 'so', 'sw', 'sv', 'ta', 'te', 'tr', 'ur'],
390
- irish: ['ga'],
391
- russian: ['ru', 'uk'],
392
- scottish: ['gd'],
393
- spanish: ['pt-PT', 'it', 'es'],
394
- welsh: ['cy']
395
- };
396
- I18n.pluralRules = {
397
- arabic(n) {
398
- if (n === 0) {
399
- return 'zero';
400
- }
401
- if (n === 1) {
402
- return 'one';
403
- }
404
- if (n === 2) {
405
- return 'two';
406
- }
407
- if (n % 100 >= 3 && n % 100 <= 10) {
408
- return 'few';
409
- }
410
- if (n % 100 >= 11 && n % 100 <= 99) {
411
- return 'many';
412
- }
413
- return 'other';
414
- },
415
- chinese() {
416
- return 'other';
417
- },
418
- french(n) {
419
- return n === 0 || n === 1 ? 'one' : 'other';
420
- },
421
- german(n) {
422
- return n === 1 ? 'one' : 'other';
423
- },
424
- irish(n) {
425
- if (n === 1) {
426
- return 'one';
427
- }
428
- if (n === 2) {
429
- return 'two';
430
- }
431
- if (n >= 3 && n <= 6) {
432
- return 'few';
433
- }
434
- if (n >= 7 && n <= 10) {
435
- return 'many';
436
- }
437
- return 'other';
438
- },
439
- russian(n) {
440
- const lastTwo = n % 100;
441
- const last = lastTwo % 10;
442
- if (last === 1 && lastTwo !== 11) {
443
- return 'one';
444
- }
445
- if (last >= 2 && last <= 4 && !(lastTwo >= 12 && lastTwo <= 14)) {
446
- return 'few';
447
- }
448
- if (last === 0 || last >= 5 && last <= 9 || lastTwo >= 11 && lastTwo <= 14) {
449
- return 'many';
450
- }
451
- return 'other';
452
- },
453
- scottish(n) {
454
- if (n === 1 || n === 11) {
455
- return 'one';
456
- }
457
- if (n === 2 || n === 12) {
458
- return 'two';
459
- }
460
- if (n >= 3 && n <= 10 || n >= 13 && n <= 19) {
461
- return 'few';
462
- }
463
- return 'other';
464
- },
465
- spanish(n) {
466
- if (n === 1) {
467
- return 'one';
468
- }
469
- if (n % 1000000 === 0 && n !== 0) {
470
- return 'many';
471
- }
472
- return 'other';
473
- },
474
- welsh(n) {
475
- if (n === 0) {
476
- return 'zero';
477
- }
478
- if (n === 1) {
479
- return 'one';
480
- }
481
- if (n === 2) {
482
- return 'two';
483
- }
484
- if (n === 3) {
485
- return 'few';
486
- }
487
- if (n === 6) {
488
- return 'many';
489
- }
490
- return 'other';
491
- }
492
- };
493
368
 
494
369
  /**
495
370
  * File upload component
@@ -604,7 +479,7 @@
604
479
  if (this.$button.disabled) return;
605
480
  if (event.target instanceof Node) {
606
481
  if (this.$root.contains(event.target)) {
607
- if (event.dataTransfer && isContainingFiles(event.dataTransfer)) {
482
+ if (event.dataTransfer && this.canDrop(event.dataTransfer)) {
608
483
  if (!this.$button.classList.contains('govuk-file-upload-button--dragging')) {
609
484
  this.showDraggingState();
610
485
  this.$announcements.innerText = this.i18n.t('enteredDropZone');
@@ -626,12 +501,30 @@
626
501
  }
627
502
  onDrop(event) {
628
503
  event.preventDefault();
629
- if (event.dataTransfer && isContainingFiles(event.dataTransfer)) {
504
+ if (event.dataTransfer && this.canFillInput(event.dataTransfer)) {
630
505
  this.$input.files = event.dataTransfer.files;
631
506
  this.$input.dispatchEvent(new CustomEvent('change'));
632
507
  this.hideDraggingState();
633
508
  }
634
509
  }
510
+ canFillInput(dataTransfer) {
511
+ return this.matchesInputCapacity(dataTransfer.files.length);
512
+ }
513
+ canDrop(dataTransfer) {
514
+ if (dataTransfer.items.length) {
515
+ return this.matchesInputCapacity(countFileItems(dataTransfer.items));
516
+ }
517
+ if (dataTransfer.types.length) {
518
+ return dataTransfer.types.includes('Files');
519
+ }
520
+ return true;
521
+ }
522
+ matchesInputCapacity(numberOfFiles) {
523
+ if (this.$input.multiple) {
524
+ return numberOfFiles > 0;
525
+ }
526
+ return numberOfFiles === 1;
527
+ }
635
528
  onChange() {
636
529
  const fileCount = this.$input.files.length;
637
530
  if (fileCount === 0) {
@@ -678,6 +571,13 @@
678
571
  this.$root.classList.toggle('govuk-drop-zone--disabled', this.$button.disabled);
679
572
  }
680
573
  }
574
+
575
+ /**
576
+ * Counts the number of `DataTransferItem` whose kind is `file`
577
+ *
578
+ * @param {DataTransferItemList} list - The list
579
+ * @returns {number} - The number of items whose kind is `file` in the list
580
+ */
681
581
  FileUpload.moduleName = 'govuk-file-upload';
682
582
  FileUpload.defaults = Object.freeze({
683
583
  i18n: {
@@ -699,10 +599,14 @@
699
599
  }
700
600
  }
701
601
  });
702
- function isContainingFiles(dataTransfer) {
703
- const hasNoTypesInfo = dataTransfer.types.length === 0;
704
- const isDraggingFiles = dataTransfer.types.some(type => type === 'Files');
705
- return hasNoTypesInfo || isDraggingFiles;
602
+ function countFileItems(list) {
603
+ let result = 0;
604
+ for (let i = 0; i < list.length; i++) {
605
+ if (list[i].kind === 'file') {
606
+ result++;
607
+ }
608
+ }
609
+ return result;
706
610
  }
707
611
 
708
612
  /**