@ministryofjustice/frontend 3.3.1 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +4 -10
  2. package/govuk-prototype-kit.config.json +5 -16
  3. package/moj/all.jquery.min.js +77 -3
  4. package/moj/all.js +2021 -1436
  5. package/moj/all.scss +2 -0
  6. package/moj/all.spec.js +15 -13
  7. package/moj/components/_all.scss +1 -0
  8. package/moj/components/action-bar/_action-bar.scss +4 -6
  9. package/moj/components/add-another/_add-another.scss +9 -7
  10. package/moj/components/add-another/add-another.js +90 -69
  11. package/moj/components/add-another/add-another.spec.js +165 -0
  12. package/moj/components/alert/README.md +0 -0
  13. package/moj/components/alert/_alert.scss +142 -0
  14. package/moj/components/alert/alert.js +247 -0
  15. package/moj/components/alert/alert.spec.helper.js +67 -0
  16. package/moj/components/alert/alert.spec.js +229 -0
  17. package/moj/components/alert/macro.njk +3 -0
  18. package/moj/components/alert/template.njk +83 -0
  19. package/moj/components/badge/_badge.scss +3 -4
  20. package/moj/components/banner/_banner.scss +5 -10
  21. package/moj/components/button-menu/_button-menu.scss +10 -9
  22. package/moj/components/button-menu/button-menu.js +139 -136
  23. package/moj/components/button-menu/button-menu.spec.js +295 -296
  24. package/moj/components/cookie-banner/_cookie-banner.scss +6 -5
  25. package/moj/components/currency-input/_currency-input.scss +4 -4
  26. package/moj/components/date-picker/README.md +14 -17
  27. package/moj/components/date-picker/_date-picker.scss +122 -106
  28. package/moj/components/date-picker/date-picker.js +473 -471
  29. package/moj/components/date-picker/date-picker.spec.js +971 -923
  30. package/moj/components/filter/README.md +1 -1
  31. package/moj/components/filter/_filter.scss +53 -75
  32. package/moj/components/filter-toggle-button/filter-toggle-button.js +71 -67
  33. package/moj/components/filter-toggle-button/filter-toggle-button.spec.js +203 -205
  34. package/moj/components/form-validator/form-validator.js +117 -109
  35. package/moj/components/header/_header.scss +17 -19
  36. package/moj/components/identity-bar/_identity-bar.scss +5 -5
  37. package/moj/components/interruption-card/_interruption-card.scss +2 -2
  38. package/moj/components/messages/_messages.scss +12 -19
  39. package/moj/components/multi-file-upload/README.md +1 -1
  40. package/moj/components/multi-file-upload/_multi-file-upload.scss +34 -30
  41. package/moj/components/multi-file-upload/multi-file-upload.js +188 -152
  42. package/moj/components/multi-file-upload/multi-file-upload.spec.js +510 -0
  43. package/moj/components/multi-select/_multi-select.scss +4 -3
  44. package/moj/components/multi-select/multi-select.js +55 -50
  45. package/moj/components/multi-select/multi-select.spec.js +72 -79
  46. package/moj/components/notification-badge/_notification-badge.scss +12 -12
  47. package/moj/components/organisation-switcher/_organisation-switcher.scss +1 -1
  48. package/moj/components/page-header-actions/_page-header-actions.scss +3 -2
  49. package/moj/components/pagination/_pagination.scss +26 -31
  50. package/moj/components/password-reveal/_password-reveal.scss +1 -2
  51. package/moj/components/password-reveal/password-reveal.js +22 -21
  52. package/moj/components/password-reveal/password-reveal.spec.js +39 -37
  53. package/moj/components/primary-navigation/_primary-navigation.scss +26 -29
  54. package/moj/components/progress-bar/_progress-bar.scss +21 -26
  55. package/moj/components/rich-text-editor/_rich-text-editor.scss +17 -16
  56. package/moj/components/rich-text-editor/rich-text-editor.js +117 -103
  57. package/moj/components/search/_search.scss +6 -4
  58. package/moj/components/search-toggle/search-toggle.js +29 -30
  59. package/moj/components/search-toggle/search-toggle.scss +21 -15
  60. package/moj/components/search-toggle/search-toggle.spec.js +65 -70
  61. package/moj/components/side-navigation/_side-navigation.scss +12 -21
  62. package/moj/components/sortable-table/_sortable-table.scss +25 -23
  63. package/moj/components/sortable-table/sortable-table.js +139 -117
  64. package/moj/components/sortable-table/sortable-table.spec.js +362 -0
  65. package/moj/components/sub-navigation/_sub-navigation.scss +24 -28
  66. package/moj/components/tag/_tag.scss +8 -9
  67. package/moj/components/task-list/_task-list.scss +8 -7
  68. package/moj/components/ticket-panel/_ticket-panel.scss +14 -6
  69. package/moj/components/timeline/_timeline.scss +18 -20
  70. package/moj/filters/all.js +28 -30
  71. package/moj/filters/prototype-kit-13-filters.js +2 -1
  72. package/moj/helpers/_all.scss +1 -0
  73. package/moj/helpers/_hidden.scss +1 -1
  74. package/moj/helpers/_links.scss +20 -0
  75. package/moj/helpers.js +160 -31
  76. package/moj/helpers.spec.js +235 -0
  77. package/moj/init.js +2 -2
  78. package/moj/moj-frontend.min.css +2 -2
  79. package/moj/moj-frontend.min.js +77 -3
  80. package/moj/namespace.js +2 -1
  81. package/moj/objects/_filter-layout.scss +11 -10
  82. package/moj/objects/_scrollable-pane.scss +11 -14
  83. package/moj/settings/_colours.scss +5 -0
  84. package/moj/settings/_measurements.scss +0 -2
  85. package/moj/utilities/_hidden.scss +3 -3
  86. package/moj/utilities/_width-container.scss +1 -1
  87. package/package.json +1 -1
@@ -7,11 +7,11 @@
7
7
  }
8
8
 
9
9
  .moj-progress-bar__list {
10
- font-size: 0; // Hide white space between elements
11
- list-style: none;
10
+ position: relative;
12
11
  margin: 0;
13
12
  padding: 0;
14
- position: relative;
13
+ font-size: 0; // Hide white space between elements
14
+ list-style: none;
15
15
  text-align: justify;
16
16
  vertical-align: top;
17
17
 
@@ -22,84 +22,79 @@
22
22
  }
23
23
 
24
24
  &::before {
25
- border-top: 6px solid govuk-colour("green");
26
25
  content: "";
27
- left: 0;
28
26
  position: absolute;
29
27
  top: 13px;
28
+ left: 0;
30
29
  width: 100%;
30
+ border-top: 6px solid govuk-colour("green");
31
31
  }
32
-
33
32
  }
34
33
 
35
34
  .moj-progress-bar__item {
36
35
  @include govuk-font(19);
37
36
  display: inline-block;
38
- max-width: 20%;
39
37
  position: relative;
38
+ max-width: 20%;
40
39
  text-align: center;
41
40
  vertical-align: top;
42
41
 
43
42
  &:first-child,
44
43
  &:last-child {
45
44
  &::before {
46
- border-top: 6px solid govuk-colour("white");
47
45
  content: "";
48
46
  position: absolute;
49
- top: 13px; left: 0;
47
+ top: 13px;
48
+ left: 0;
50
49
  width: 50%;
50
+ border-top: 6px solid govuk-colour("white");
51
51
  }
52
-
53
52
  }
54
53
 
55
54
  &:first-child {
56
-
57
55
  &::before {
58
56
  left: 0;
59
57
  }
60
-
61
58
  }
62
59
 
63
60
  &:last-child {
64
-
65
61
  &::before {
66
- left: auto;
67
62
  right: 0;
63
+ left: auto;
68
64
  }
69
-
70
65
  }
71
66
 
72
- &[aria-current=step] { // https://tink.uk/using-the-aria-current-attribute
67
+ &[aria-current="step"] {
68
+ // https://tink.uk/using-the-aria-current-attribute
73
69
  @include govuk-font($size: 19, $weight: "bold");
74
70
  }
75
-
76
71
  }
77
72
 
78
73
  .moj-progress-bar__icon {
79
- position: relative;
80
- background-color: govuk-colour("white");
81
- border: 6px solid govuk-colour("green");
82
- border-radius: 50%;
83
74
  box-sizing: border-box;
84
75
  display: block;
76
+ position: relative;
77
+ width: 32px;
85
78
  height: 32px;
86
- margin-left: auto;
87
79
  margin-right: auto;
88
- width: 32px;
80
+ margin-left: auto;
81
+ border: 6px solid govuk-colour("green");
82
+ border-radius: 50%;
83
+ background-color: govuk-colour("white");
89
84
  }
90
85
 
91
86
  .moj-progress-bar__icon--complete {
92
87
  background-color: govuk-colour("green");
93
88
  background-image: url(#{$moj-images-path}icon-progress-tick.svg);
94
- background-position: 50% 50%;
95
89
  background-repeat: no-repeat;
90
+ background-position: 50% 50%;
96
91
  }
97
92
 
98
93
  .moj-progress-bar__label {
99
94
  @include govuk-font(16);
100
95
  display: block;
101
- font-weight: inherit;
102
- margin-top: govuk-spacing(3);
103
96
  position: relative;
97
+ margin-top: govuk-spacing(3);
98
+ font-weight: inherit;
104
99
  word-wrap: break-word; // Just in case
105
100
  }
@@ -8,20 +8,20 @@
8
8
  }
9
9
 
10
10
  .moj-rich-text-editor__toolbar-button {
11
+ width: 40px;
12
+ height: 40px;
13
+ margin-left: -2px;
14
+ float: left;
15
+ border: 2px solid govuk-colour("black");
16
+ outline: 0;
17
+ color: govuk-colour("black");
11
18
  background-color: govuk-colour("white");
12
- background-position: 50% 50%;
13
19
  background-repeat: no-repeat;
20
+ background-position: 50% 50%;
14
21
  background-size: 40px 40px;
15
- border: 2px solid govuk-colour("black");
16
- color: govuk-colour("black");
17
- cursor: pointer;
18
- float: left;
19
22
  text-decoration: none;
20
- height: 40px;
21
- margin-left: -2px;
22
- outline: 0;
23
23
  vertical-align: top;
24
- width: 40px;
24
+ cursor: pointer;
25
25
 
26
26
  &:first-child {
27
27
  margin-left: 0;
@@ -34,14 +34,15 @@
34
34
  }
35
35
 
36
36
  &:focus {
37
- background-color: $govuk-focus-colour;
38
- color: $govuk-focus-text-colour;
39
- box-shadow: 0 -2px $govuk-focus-colour, 0 4px $govuk-focus-text-colour;
40
- outline: none;
41
37
  position: relative;
42
38
  z-index: 2;
39
+ outline: none;
40
+ color: $govuk-focus-text-colour;
41
+ background-color: $govuk-focus-colour;
42
+ box-shadow:
43
+ 0 -2px $govuk-focus-colour,
44
+ 0 4px $govuk-focus-text-colour;
43
45
  }
44
-
45
46
  }
46
47
 
47
48
  .moj-rich-text-editor__toolbar-button--bold {
@@ -57,8 +58,8 @@
57
58
  }
58
59
 
59
60
  .moj-rich-text-editor__toolbar-button--unordered-list {
60
- background-image: url(#{$moj-images-path}icon-wysiwyg-unordered-list.svg);
61
61
  margin-left: govuk-spacing(2);
62
+ background-image: url(#{$moj-images-path}icon-wysiwyg-unordered-list.svg);
62
63
  }
63
64
 
64
65
  .moj-rich-text-editor__toolbar-button--ordered-list {
@@ -67,7 +68,7 @@
67
68
 
68
69
  .moj-rich-text-editor__content {
69
70
  min-height: 130px;
70
- outline: none;
71
71
  overflow: auto;
72
72
  resize: vertical;
73
+ outline: none;
73
74
  }
@@ -1,139 +1,153 @@
1
- if('contentEditable' in document.documentElement) {
2
- MOJFrontend.RichTextEditor = function(options) {
3
- this.options = options;
1
+ if ('contentEditable' in document.documentElement) {
2
+ MOJFrontend.RichTextEditor = function (options) {
3
+ this.options = options
4
4
  this.options.toolbar = this.options.toolbar || {
5
5
  bold: false,
6
6
  italic: false,
7
7
  underline: false,
8
8
  bullets: true,
9
9
  numbers: true
10
- };
11
- this.textarea = this.options.textarea;
12
- this.container = $(this.textarea).parent();
10
+ }
11
+ this.textarea = this.options.textarea
12
+ this.container = $(this.textarea).parent()
13
13
 
14
14
  if (this.container.data('moj-rich-text-editor-initialised')) {
15
15
  return
16
16
  }
17
17
 
18
- this.container.data('moj-rich-text-editor-initialised', true);
18
+ this.container.data('moj-rich-text-editor-initialised', true)
19
19
 
20
- this.createToolbar();
21
- this.hideDefault();
22
- this.configureToolbar();
20
+ this.createToolbar()
21
+ this.hideDefault()
22
+ this.configureToolbar()
23
23
  this.keys = {
24
24
  left: 37,
25
25
  right: 39,
26
26
  up: 38,
27
27
  down: 40
28
- };
29
- this.container.on('click', '.moj-rich-text-editor__toolbar-button', $.proxy(this, 'onButtonClick'));
30
- this.container.find('.moj-rich-text-editor__content').on('input', $.proxy(this, 'onEditorInput'));
31
- this.container.find('label').on('click', $.proxy(this, 'onLabelClick'));
32
- this.toolbar.on('keydown', $.proxy(this, 'onToolbarKeydown'));
33
- };
34
-
35
- MOJFrontend.RichTextEditor.prototype.onToolbarKeydown = function(e) {
36
- var focusableButton;
37
- switch(e.keyCode) {
28
+ }
29
+ this.container.on(
30
+ 'click',
31
+ '.moj-rich-text-editor__toolbar-button',
32
+ $.proxy(this, 'onButtonClick')
33
+ )
34
+ this.container
35
+ .find('.moj-rich-text-editor__content')
36
+ .on('input', $.proxy(this, 'onEditorInput'))
37
+ this.container.find('label').on('click', $.proxy(this, 'onLabelClick'))
38
+ this.toolbar.on('keydown', $.proxy(this, 'onToolbarKeydown'))
39
+ }
40
+
41
+ MOJFrontend.RichTextEditor.prototype.onToolbarKeydown = function (e) {
42
+ let focusableButton
43
+ switch (e.keyCode) {
38
44
  case this.keys.right:
39
- case this.keys.down:
40
- focusableButton = this.toolbar.find('button[tabindex=0]');
41
- var nextButton = focusableButton.next('button');
42
- if(nextButton[0]) {
43
- nextButton.focus();
44
- focusableButton.attr('tabindex', '-1');
45
- nextButton.attr('tabindex', '0');
45
+ case this.keys.down: {
46
+ focusableButton = this.toolbar.find('button[tabindex=0]')
47
+ const nextButton = focusableButton.next('button')
48
+ if (nextButton[0]) {
49
+ nextButton.focus()
50
+ focusableButton.attr('tabindex', '-1')
51
+ nextButton.attr('tabindex', '0')
46
52
  }
47
- break;
53
+ break
54
+ }
48
55
  case this.keys.left:
49
- case this.keys.up:
50
- focusableButton = this.toolbar.find('button[tabindex=0]');
51
- var previousButton = focusableButton.prev('button');
52
- if(previousButton[0]) {
53
- previousButton.focus();
54
- focusableButton.attr('tabindex', '-1');
55
- previousButton.attr('tabindex', '0');
56
+ case this.keys.up: {
57
+ focusableButton = this.toolbar.find('button[tabindex=0]')
58
+ const previousButton = focusableButton.prev('button')
59
+ if (previousButton[0]) {
60
+ previousButton.focus()
61
+ focusableButton.attr('tabindex', '-1')
62
+ previousButton.attr('tabindex', '0')
56
63
  }
57
- break;
64
+ break
65
+ }
58
66
  }
59
- };
67
+ }
60
68
 
61
- MOJFrontend.RichTextEditor.prototype.getToolbarHtml = function() {
62
- var html = '';
69
+ MOJFrontend.RichTextEditor.prototype.getToolbarHtml = function () {
70
+ let html = ''
63
71
 
64
- html += '<div class="moj-rich-text-editor__toolbar" role="toolbar">';
72
+ html += '<div class="moj-rich-text-editor__toolbar" role="toolbar">'
65
73
 
66
- if(this.options.toolbar.bold) {
67
- html += '<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--bold" type="button" data-command="bold"><span class="govuk-visually-hidden">Bold</span></button>';
74
+ if (this.options.toolbar.bold) {
75
+ html +=
76
+ '<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--bold" type="button" data-command="bold"><span class="govuk-visually-hidden">Bold</span></button>'
68
77
  }
69
78
 
70
- if(this.options.toolbar.italic) {
71
- html += '<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--italic" type="button" data-command="italic"><span class="govuk-visually-hidden">Italic</span></button>';
79
+ if (this.options.toolbar.italic) {
80
+ html +=
81
+ '<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--italic" type="button" data-command="italic"><span class="govuk-visually-hidden">Italic</span></button>'
72
82
  }
73
83
 
74
- if(this.options.toolbar.underline) {
75
- html += '<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--underline" type="button" data-command="underline"><span class="govuk-visually-hidden">Underline</span></button>';
84
+ if (this.options.toolbar.underline) {
85
+ html +=
86
+ '<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--underline" type="button" data-command="underline"><span class="govuk-visually-hidden">Underline</span></button>'
76
87
  }
77
88
 
78
- if(this.options.toolbar.bullets) {
79
- html += '<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--unordered-list" type="button" data-command="insertUnorderedList"><span class="govuk-visually-hidden">Unordered list</span></button>';
89
+ if (this.options.toolbar.bullets) {
90
+ html +=
91
+ '<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--unordered-list" type="button" data-command="insertUnorderedList"><span class="govuk-visually-hidden">Unordered list</span></button>'
80
92
  }
81
93
 
82
- if(this.options.toolbar.numbers) {
83
- html += '<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--ordered-list" type="button" data-command="insertOrderedList"><span class="govuk-visually-hidden">Ordered list</span></button>';
94
+ if (this.options.toolbar.numbers) {
95
+ html +=
96
+ '<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--ordered-list" type="button" data-command="insertOrderedList"><span class="govuk-visually-hidden">Ordered list</span></button>'
84
97
  }
85
98
 
86
- html += '</div>';
87
- return html;
88
- };
89
-
90
- MOJFrontend.RichTextEditor.prototype.getEnhancedHtml = function(val) {
91
- return this.getToolbarHtml() + '<div class="govuk-textarea moj-rich-text-editor__content" contenteditable="true" spellcheck="false"></div>';
92
- };
93
-
94
- MOJFrontend.RichTextEditor.prototype.hideDefault = function() {
95
- this.textarea = this.container.find('textarea');
96
- this.textarea.addClass('govuk-visually-hidden');
97
- this.textarea.attr('aria-hidden', true);
98
- this.textarea.attr('tabindex', '-1');
99
- };
100
-
101
- MOJFrontend.RichTextEditor.prototype.createToolbar = function() {
102
- this.toolbar = document.createElement('div');
103
- this.toolbar.className = 'moj-rich-text-editor';
104
- this.toolbar.innerHTML = this.getEnhancedHtml();
105
- this.container.append(this.toolbar);
106
- this.toolbar = this.container.find('.moj-rich-text-editor__toolbar');
107
- this.container.find('.moj-rich-text-editor__content').html(this.textarea.val());
108
- };
109
-
110
- MOJFrontend.RichTextEditor.prototype.configureToolbar = function() {
111
- this.buttons = this.container.find('.moj-rich-text-editor__toolbar-button');
112
- this.buttons.prop('tabindex', '-1');
113
- var firstTab = this.buttons.first();
114
- firstTab.prop('tabindex', '0');
115
- };
116
-
117
- MOJFrontend.RichTextEditor.prototype.onButtonClick = function(e) {
118
- document.execCommand($(e.currentTarget).data('command'), false, null);
119
- };
120
-
121
- MOJFrontend.RichTextEditor.prototype.getContent = function() {
122
- return this.container.find('.moj-rich-text-editor__content').html();
123
- };
124
-
125
- MOJFrontend.RichTextEditor.prototype.onEditorInput = function(e) {
126
- this.updateTextarea();
127
- };
128
-
129
- MOJFrontend.RichTextEditor.prototype.updateTextarea = function() {
130
- document.execCommand('defaultParagraphSeparator', false, 'p');
131
- this.textarea.val(this.getContent());
132
- };
133
-
134
- MOJFrontend.RichTextEditor.prototype.onLabelClick = function(e) {
135
- e.preventDefault();
136
- this.container.find('.moj-rich-text-editor__content').focus();
137
- };
138
-
99
+ html += '</div>'
100
+ return html
101
+ }
102
+
103
+ MOJFrontend.RichTextEditor.prototype.getEnhancedHtml = function (val) {
104
+ return `${this.getToolbarHtml()}<div class="govuk-textarea moj-rich-text-editor__content" contenteditable="true" spellcheck="false"></div>`
105
+ }
106
+
107
+ MOJFrontend.RichTextEditor.prototype.hideDefault = function () {
108
+ this.textarea = this.container.find('textarea')
109
+ this.textarea.addClass('govuk-visually-hidden')
110
+ this.textarea.attr('aria-hidden', true)
111
+ this.textarea.attr('tabindex', '-1')
112
+ }
113
+
114
+ MOJFrontend.RichTextEditor.prototype.createToolbar = function () {
115
+ this.toolbar = document.createElement('div')
116
+ this.toolbar.className = 'moj-rich-text-editor'
117
+ this.toolbar.innerHTML = this.getEnhancedHtml()
118
+ this.container.append(this.toolbar)
119
+ this.toolbar = this.container.find('.moj-rich-text-editor__toolbar')
120
+ this.container
121
+ .find('.moj-rich-text-editor__content')
122
+ .html(this.textarea.val())
123
+ }
124
+
125
+ MOJFrontend.RichTextEditor.prototype.configureToolbar = function () {
126
+ this.buttons = this.container.find('.moj-rich-text-editor__toolbar-button')
127
+ this.buttons.prop('tabindex', '-1')
128
+ const firstTab = this.buttons.first()
129
+ firstTab.prop('tabindex', '0')
130
+ }
131
+
132
+ MOJFrontend.RichTextEditor.prototype.onButtonClick = function (e) {
133
+ document.execCommand($(e.currentTarget).data('command'), false, null)
134
+ }
135
+
136
+ MOJFrontend.RichTextEditor.prototype.getContent = function () {
137
+ return this.container.find('.moj-rich-text-editor__content').html()
138
+ }
139
+
140
+ MOJFrontend.RichTextEditor.prototype.onEditorInput = function (e) {
141
+ this.updateTextarea()
142
+ }
143
+
144
+ MOJFrontend.RichTextEditor.prototype.updateTextarea = function () {
145
+ document.execCommand('defaultParagraphSeparator', false, 'p')
146
+ this.textarea.val(this.getContent())
147
+ }
148
+
149
+ MOJFrontend.RichTextEditor.prototype.onLabelClick = function (e) {
150
+ e.preventDefault()
151
+ this.container.find('.moj-rich-text-editor__content').focus()
152
+ }
139
153
  }
@@ -26,17 +26,19 @@
26
26
 
27
27
  .moj-search__button {
28
28
  display: inline-block;
29
- margin-bottom: 0;
30
- margin-left: govuk-spacing(2);
31
29
  position: relative;
32
30
  top: -2px; // Override default gov properties due to active pixel movement
33
- vertical-align: bottom;
34
31
  width: auto;
32
+ margin-bottom: 0;
33
+ margin-left: govuk-spacing(2);
34
+ vertical-align: bottom;
35
35
  }
36
36
 
37
37
  .moj-search--inline {
38
+ // stylelint-disable-next-line declaration-no-important
38
39
  padding: govuk-spacing(2) 0 !important;
39
40
  @include govuk-media-query($from: desktop) {
41
+ // stylelint-disable-next-line declaration-no-important
40
42
  padding: 0 !important;
41
43
  }
42
- }
44
+ }
@@ -1,53 +1,52 @@
1
1
  MOJFrontend.SearchToggle = function (options) {
2
- this.options = options;
3
- this.container = $(this.options.search.container);
4
- this.toggleButtonContainer = $(this.options.toggleButton.container);
2
+ this.options = options
3
+ this.container = $(this.options.search.container)
4
+ this.toggleButtonContainer = $(this.options.toggleButton.container)
5
5
 
6
- if (this.container.data("moj-search-toggle-initialised")) {
7
- return;
6
+ if (this.container.data('moj-search-toggle-initialised')) {
7
+ return
8
8
  }
9
9
 
10
- this.container.data("moj-search-toggle-initialised", true);
10
+ this.container.data('moj-search-toggle-initialised', true)
11
11
 
12
12
  const svg =
13
- '<svg viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="moj-search-toggle__button__icon"><path d="M7.433,12.5790048 C6.06762625,12.5808611 4.75763941,12.0392925 3.79217348,11.0738265 C2.82670755,10.1083606 2.28513891,8.79837375 2.28699522,7.433 C2.28513891,6.06762625 2.82670755,4.75763941 3.79217348,3.79217348 C4.75763941,2.82670755 6.06762625,2.28513891 7.433,2.28699522 C8.79837375,2.28513891 10.1083606,2.82670755 11.0738265,3.79217348 C12.0392925,4.75763941 12.5808611,6.06762625 12.5790048,7.433 C12.5808611,8.79837375 12.0392925,10.1083606 11.0738265,11.0738265 C10.1083606,12.0392925 8.79837375,12.5808611 7.433,12.5790048 L7.433,12.5790048 Z M14.293,12.579 L13.391,12.579 L13.071,12.269 C14.2300759,10.9245158 14.8671539,9.20813198 14.866,7.433 C14.866,3.32786745 11.5381325,-1.65045755e-15 7.433,-1.65045755e-15 C3.32786745,-1.65045755e-15 -1.65045755e-15,3.32786745 -1.65045755e-15,7.433 C-1.65045755e-15,11.5381325 3.32786745,14.866 7.433,14.866 C9.208604,14.8671159 10.9253982,14.2296624 12.27,13.07 L12.579,13.39 L12.579,14.294 L18.296,20 L20,18.296 L14.294,12.579 L14.293,12.579 Z"></path></svg>';
13
+ '<svg viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="moj-search-toggle__button__icon"><path d="M7.433,12.5790048 C6.06762625,12.5808611 4.75763941,12.0392925 3.79217348,11.0738265 C2.82670755,10.1083606 2.28513891,8.79837375 2.28699522,7.433 C2.28513891,6.06762625 2.82670755,4.75763941 3.79217348,3.79217348 C4.75763941,2.82670755 6.06762625,2.28513891 7.433,2.28699522 C8.79837375,2.28513891 10.1083606,2.82670755 11.0738265,3.79217348 C12.0392925,4.75763941 12.5808611,6.06762625 12.5790048,7.433 C12.5808611,8.79837375 12.0392925,10.1083606 11.0738265,11.0738265 C10.1083606,12.0392925 8.79837375,12.5808611 7.433,12.5790048 L7.433,12.5790048 Z M14.293,12.579 L13.391,12.579 L13.071,12.269 C14.2300759,10.9245158 14.8671539,9.20813198 14.866,7.433 C14.866,3.32786745 11.5381325,-1.65045755e-15 7.433,-1.65045755e-15 C3.32786745,-1.65045755e-15 -1.65045755e-15,3.32786745 -1.65045755e-15,7.433 C-1.65045755e-15,11.5381325 3.32786745,14.866 7.433,14.866 C9.208604,14.8671159 10.9253982,14.2296624 12.27,13.07 L12.579,13.39 L12.579,14.294 L18.296,20 L20,18.296 L14.294,12.579 L14.293,12.579 Z"></path></svg>'
14
14
 
15
15
  this.toggleButton = $(
16
- '<button class="moj-search-toggle__button" type="button" aria-haspopup="true" aria-expanded="false">' +
17
- this.options.toggleButton.text +
18
- svg +
19
- "</button>"
20
- );
21
- this.toggleButton.on("click", $.proxy(this, "onToggleButtonClick"));
22
- this.toggleButtonContainer.append(this.toggleButton);
23
- $(document).on("click", this.onDocumentClick.bind(this));
24
- $(document).on("focusin", this.onDocumentClick.bind(this));
25
- };
16
+ `<button class="moj-search-toggle__button" type="button" aria-haspopup="true" aria-expanded="false">
17
+ ${this.options.toggleButton.text} ${svg}
18
+ </button>`
19
+ )
20
+ this.toggleButton.on('click', $.proxy(this, 'onToggleButtonClick'))
21
+ this.toggleButtonContainer.append(this.toggleButton)
22
+ $(document).on('click', this.onDocumentClick.bind(this))
23
+ $(document).on('focusin', this.onDocumentClick.bind(this))
24
+ }
26
25
 
27
26
  MOJFrontend.SearchToggle.prototype.showMenu = function () {
28
- this.toggleButton.attr("aria-expanded", "true");
29
- this.container.removeClass("moj-js-hidden");
30
- this.container.find("input").first().get(0).focus();
31
- };
27
+ this.toggleButton.attr('aria-expanded', 'true')
28
+ this.container.removeClass('moj-js-hidden')
29
+ this.container.find('input').first().get(0).focus()
30
+ }
32
31
 
33
32
  MOJFrontend.SearchToggle.prototype.hideMenu = function () {
34
- this.container.addClass("moj-js-hidden");
35
- this.toggleButton.attr("aria-expanded", "false");
36
- };
33
+ this.container.addClass('moj-js-hidden')
34
+ this.toggleButton.attr('aria-expanded', 'false')
35
+ }
37
36
 
38
37
  MOJFrontend.SearchToggle.prototype.onToggleButtonClick = function () {
39
- if (this.toggleButton.attr("aria-expanded") == "false") {
40
- this.showMenu();
38
+ if (this.toggleButton.attr('aria-expanded') === 'false') {
39
+ this.showMenu()
41
40
  } else {
42
- this.hideMenu();
41
+ this.hideMenu()
43
42
  }
44
- };
43
+ }
45
44
 
46
45
  MOJFrontend.SearchToggle.prototype.onDocumentClick = function (e) {
47
46
  if (
48
47
  !$.contains(this.toggleButtonContainer[0], e.target) &&
49
48
  !$.contains(this.container[0], e.target)
50
49
  ) {
51
- this.hideMenu();
50
+ this.hideMenu()
52
51
  }
53
- };
52
+ }
@@ -1,24 +1,25 @@
1
1
  .moj-search-toggle__button {
2
2
  @include govuk-font($size: 19, $weight: bold);
3
- background-color: transparent;
4
- border: none;
5
- color: $govuk-link-colour;
6
- cursor: pointer;
7
3
  display: inline-block;
8
4
  padding-top: 12px;
5
+ padding-right: 0;
9
6
  padding-bottom: 13px;
10
7
  padding-left: 0;
11
- padding-right: 0;
8
+ border: none;
9
+ color: $govuk-link-colour;
10
+ background-color: transparent;
11
+ cursor: pointer;
12
12
  -webkit-font-smoothing: antialiased;
13
13
  -webkit-appearance: none;
14
+ appearance: none;
14
15
 
15
16
  &__icon {
16
17
  display: inline-block;
18
+ width: 20px;
17
19
  height: 20px;
18
20
  margin-left: govuk-spacing(2);
21
+ fill: currentcolor;
19
22
  vertical-align: middle;
20
- width: 20px;
21
- fill: currentColor;
22
23
 
23
24
  @media screen and (forced-colors: active) {
24
25
  fill: windowText;
@@ -26,12 +27,14 @@
26
27
  }
27
28
 
28
29
  &:focus {
29
- background-color: $govuk-focus-colour;
30
- color: $govuk-focus-text-colour;
31
- box-shadow: 0 -2px $govuk-focus-colour, 0 4px $govuk-focus-text-colour;
32
- outline: none;
33
30
  position: relative;
34
31
  z-index: 1;
32
+ outline: none;
33
+ color: $govuk-focus-text-colour;
34
+ background-color: $govuk-focus-colour;
35
+ box-shadow:
36
+ 0 -2px $govuk-focus-colour,
37
+ 0 4px $govuk-focus-text-colour;
35
38
  }
36
39
  }
37
40
 
@@ -39,14 +42,17 @@
39
42
  padding: govuk-spacing(3);
40
43
 
41
44
  @include govuk-media-query($until: desktop) {
42
- padding-left: 0 !important;
45
+ // stylelint-disable-next-line declaration-no-important
43
46
  padding-right: 0 !important;
47
+ // stylelint-disable-next-line declaration-no-important
48
+ padding-left: 0 !important;
44
49
  }
45
50
  }
46
51
 
47
52
  // JS enabled
48
53
  .js-enabled .moj-search--toggle {
49
54
  @include govuk-media-query($until: desktop) {
55
+ // stylelint-disable-next-line declaration-no-important
50
56
  padding-top: 0 !important;
51
57
  }
52
58
  }
@@ -59,11 +65,11 @@
59
65
  background-color: govuk-colour("light-grey");
60
66
 
61
67
  @include govuk-media-query($from: desktop) {
62
- max-width: 450px;
63
68
  position: absolute;
64
- right: -15px;
69
+ z-index: 10;
65
70
  top: 50px; // Height of nav bar
71
+ right: -15px;
66
72
  width: 450px;
67
- z-index: 10;
73
+ max-width: 450px;
68
74
  }
69
75
  }