govuk_publishing_components 9.5.3 → 9.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 51687893e007b2b8670406ccda7045a8afe684cc91997683752b01b1ed830a96
4
- data.tar.gz: ebce78f938ed96d8553bef568dab8f8b7bf00c366e85458ffb1178b330ba188d
3
+ metadata.gz: ee1bc2d4e6fb993c27eba2510c283cda497987294f93fc21f3a30e94f2deecf8
4
+ data.tar.gz: 9f9cc5eb7519cd81ba336464e8a9f6f3b7dc3fb0c254d5d12d59e667201ed6d8
5
5
  SHA512:
6
- metadata.gz: ed685a583720028754d1428b2a4c68f5e5baf6be94fb705c0f188b9e537e59bd8997694c1bc5302da868567076ffc0d30892d6f9e0fb07989fad1169efbd4ac7
7
- data.tar.gz: e32489b5857c458ba38d7d595a43c049aa5885e2529c1021e992e732afb9cfec658a5296596af14f0c872ac7e84b134155c72143b786d38110db9f08b0302255
6
+ metadata.gz: f7fd7e8f9617b31d253a820723d312b67cbd7d2c770c90f8e05c205463505e1155cf3a990c8e292e20d0fd58cdb1533506f49f31b0a50f4a0c68c51f612ba764
7
+ data.tar.gz: 14141157d36c0985c423074c3e2d095bb1ca6c7d0c066b45417d201cc8e61a0f6ba5853ca44d6d60e486463b8a94e3420c85b8530a709c4e9e58525abd0afe8b
@@ -9,6 +9,7 @@
9
9
  var stepNavSize;
10
10
  var sessionStoreLink = 'govuk-step-nav-active-link';
11
11
  var activeLinkClass = 'gem-c-step-nav__list-item--active';
12
+ var activeStepClass = 'gem-c-step-nav__step--active';
12
13
  var activeLinkHref = '#content';
13
14
  var uniqueId;
14
15
 
@@ -29,6 +30,11 @@
29
30
  var $showOrHideAllButton;
30
31
 
31
32
  uniqueId = $element.data('id') || false;
33
+
34
+ if (uniqueId) {
35
+ sessionStoreLink = sessionStoreLink + "_" + uniqueId;
36
+ }
37
+
32
38
  var stepNavTracker = new StepNavTracker(totalSteps, totalLinks, uniqueId);
33
39
 
34
40
  getTextForInsertedElements();
@@ -37,8 +43,8 @@
37
43
  addShowHideToggle();
38
44
  addAriaControlsAttrForShowHideAllButton();
39
45
 
40
- showPreviouslyOpenedSteps();
41
46
  ensureOnlyOneActiveLink();
47
+ showPreviouslyOpenedSteps();
42
48
 
43
49
  bindToggleForSteps(stepNavTracker);
44
50
  bindToggleShowHideAllButton(stepNavTracker);
@@ -190,11 +196,12 @@
190
196
  var thisLinkHref = $(this).attr('href');
191
197
 
192
198
  if ($(this).attr('rel') !== 'external') {
193
- saveToSessionStorage(sessionStoreLink, $(this).data('position'));
199
+ saveToSessionStorage(sessionStoreLink, $(this).attr('data-position'));
194
200
  }
195
201
 
196
202
  if (thisLinkHref == activeLinkHref) {
197
203
  setOnlyThisLinkActive($(this));
204
+ setActiveStepClass();
198
205
  }
199
206
  });
200
207
  }
@@ -216,6 +223,11 @@
216
223
  clicked.parent().addClass(activeLinkClass);
217
224
  }
218
225
 
226
+ // if a link occurs more than once in a step nav, the backend doesn't know which one to highlight
227
+ // so it gives all those links the 'active' attribute and highlights the last step containing that link
228
+ // if the user clicked on one of those links previously, it will be in the session store
229
+ // this code ensures only that link and its corresponding step have the highlighting
230
+ // otherwise it accepts what the backend has already passed to the component
219
231
  function ensureOnlyOneActiveLink() {
220
232
  var $activeLinks = $element.find('.js-list-item.' + activeLinkClass);
221
233
 
@@ -226,10 +238,15 @@
226
238
  var lastClicked = loadFromSessionStorage(sessionStoreLink);
227
239
 
228
240
  if (lastClicked) {
241
+ // it's possible for the saved link position value to not match any of the currently duplicate highlighted links
242
+ // so check this otherwise it'll take the highlighting off all of them
243
+ if (!$element.find('.js-link[data-position="' + lastClicked + '"]').parent().hasClass(activeLinkClass)) {
244
+ lastClicked = $element.find('.' + activeLinkClass).first().find('.js-link').attr('data-position');
245
+ }
229
246
  removeActiveStateFromAllButCurrent($activeLinks, lastClicked);
230
- removeFromSessionStorage(sessionStoreLink);
247
+ setActiveStepClass();
231
248
  } else {
232
- var activeLinkInActiveStep = $element.find('.gem-c-step-nav__step--active').find('.' + activeLinkClass).first();
249
+ var activeLinkInActiveStep = $element.find('.' + activeStepClass).find('.' + activeLinkClass).first();
233
250
 
234
251
  if (activeLinkInActiveStep.length) {
235
252
  $activeLinks.removeClass(activeLinkClass);
@@ -240,14 +257,19 @@
240
257
  }
241
258
  }
242
259
 
243
- function removeActiveStateFromAllButCurrent($links, current) {
244
- $links.each(function() {
245
- if ($(this).find('.js-link').data('position').toString() !== current.toString()) {
260
+ function removeActiveStateFromAllButCurrent($activeLinks, current) {
261
+ $activeLinks.each(function() {
262
+ if ($(this).find('.js-link').attr('data-position').toString() !== current.toString()) {
246
263
  $(this).removeClass(activeLinkClass);
247
264
  }
248
265
  });
249
266
  }
250
267
 
268
+ function setActiveStepClass() {
269
+ $element.find('.' + activeStepClass).removeClass(activeStepClass).removeAttr('data-show');
270
+ $element.find('.' + activeLinkClass).closest('.gem-c-step-nav__step').addClass(activeStepClass).attr('data-show', "");
271
+ }
272
+
251
273
  function bindToggleShowHideAllButton(stepNavTracker) {
252
274
  $showOrHideAllButton = $element.find('.js-step-controls-button');
253
275
  $showOrHideAllButton.on('click', function () {
@@ -19,7 +19,7 @@
19
19
  }
20
20
 
21
21
  @include media-down(mobile) {
22
- &.gem-c-breadcrumbs--collapse-on-mobile .gem-c-breadcrumbs--item {
22
+ &.gem-c-breadcrumbs--collapse-on-mobile .gem-c-breadcrumbs__item {
23
23
  display: none;
24
24
 
25
25
  &.gem-c-breadcrumbs--parent {
@@ -0,0 +1 @@
1
+ // This component relies on styles from GOV.UK Frontend
@@ -21,7 +21,7 @@
21
21
  css_class = invert_class.concat(crumb[:is_current_page] ? ' gem-c-breadcrumbs--current ' : '')
22
22
  %>
23
23
 
24
- <li class='gem-c-breadcrumbs--item <%= "gem-c-breadcrumbs--parent" if crumb[:is_page_parent] %>'>
24
+ <li class='gem-c-breadcrumbs__item <%= "gem-c-breadcrumbs--parent" if crumb[:is_page_parent] %>'>
25
25
  <% if is_link %>
26
26
  <%= link_to(
27
27
  crumb[:title],
@@ -0,0 +1,17 @@
1
+ <%
2
+ options ||= []
3
+ id ||= false
4
+ label ||= false
5
+ %>
6
+ <% if options.any? && id && label %>
7
+ <div class="govuk-form-group gem-c-select">
8
+ <label class="govuk-label" for="<%= id %>">
9
+ <%= label %>
10
+ </label>
11
+ <select class="govuk-select" id="<%= id %>" name="<%= id %>">
12
+ <% options.each do |option| %>
13
+ <option value="<%= option[:value] %>" <% if option[:selected] %>selected<% end %>><%= option[:text] %></option>
14
+ <% end %>
15
+ </select>
16
+ </div>
17
+ <% end %>
@@ -0,0 +1,35 @@
1
+ name: Select (experimental)
2
+ description: A dropdown select
3
+ part_of_admin_layout: true
4
+ govuk_frontend_components:
5
+ - select
6
+ accessibility_criteria: |
7
+ The component must:
8
+ - accept focus
9
+ - be focusable with a keyboard
10
+ - be usable with a keyboard
11
+ - indicate when it has focus
12
+ examples:
13
+ default:
14
+ data:
15
+ id: 'dropdown1'
16
+ label: 'My Dropdown'
17
+ options:
18
+ - text: 'Option one'
19
+ value: 'option1'
20
+ - text: 'Option two'
21
+ value: 'option2'
22
+ - text: 'Option three'
23
+ value: 'option3'
24
+ with_preselect:
25
+ data:
26
+ id: 'dropdown2'
27
+ label: 'My Dropdown'
28
+ options:
29
+ - text: 'Option one'
30
+ value: 'option1'
31
+ - text: 'Option two'
32
+ value: 'option2'
33
+ selected: true
34
+ - text: 'Option three'
35
+ value: 'option3'
@@ -340,18 +340,19 @@ examples:
340
340
  ]
341
341
  solve_the_double_dot_problem:
342
342
  description: |
343
- If a page is in a step by step navigation more than once and a user is viewing that URL, both links to it will be highlighted as the site has no way to know which link the user is currently viewing (highlighted links should only occur when the step by step navigation is in the sidebar).
343
+ If a page is in a step by step navigation more than once and a user is viewing that URL, both links to it will be highlighted as the backend has no way to know which link the user is currently viewing (links should only be highlighted when the step by step navigation is in the sidebar).
344
344
 
345
- JavaScript is included in the component to solve this. It uses sessionStorage to capture the data-position attribute of non-external links when clicked, and then uses this value to decide which link to highlight when the new page loads. This session storage data is immediately deleted after it is read on page load, mainly to prevent problems with highlighting if the user were to move between different step by step navigations.
345
+ JavaScript is included in the component to solve this. It uses sessionStorage to capture the data-position attribute of non-external links when clicked, and then uses this value to decide which link (and parent step) to highlight and expand when the new page loads. Note that it uses the tracking_id attribute to uniquely identify the current step nav. If tracking_id is not set this may result in other step navs having the wrong link highlighted.
346
346
 
347
347
  If a user has not clicked a link (i.e. has visited the page without first clicking on a step by step navigation) the first active link in the first active step will be highlighted. If there is no active step, the first active link will be highlighted (but there should always be an active step).
348
348
 
349
349
  The current page in the step by step navigation is an anchor link to the top of the page. If there are more than one of these and the user clicks one that is not currently highlighted, that one will be highlighted.
350
350
 
351
- The example below will show all links highlighted if JS is disabled, in the real world no more than two or three links are likely to be highlighted at once.
351
+ The example below will show all non-external links highlighted if JS is disabled. In the real world no more than two or three links are likely to be highlighted at once.
352
352
  data:
353
353
  highlight_step: 2
354
354
  show_step: 2
355
+ tracking_id: "example-id"
355
356
  steps: [
356
357
  {
357
358
  title: "Not the active step",
@@ -83,7 +83,6 @@ module GovukPublishingComponents
83
83
  link[:active] = true
84
84
  step_nav_content[:show_step] = step_index + 1
85
85
  step_nav_content[:highlight_step] = step_index + 1
86
- return step_nav_content
87
86
  end
88
87
  end
89
88
  end
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '9.5.3'.freeze
2
+ VERSION = '9.6.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.5.3
4
+ version: 9.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-17 00:00:00.000000000 Z
11
+ date: 2018-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config
@@ -364,6 +364,7 @@ files:
364
364
  - app/assets/stylesheets/govuk_publishing_components/components/_radio.scss
365
365
  - app/assets/stylesheets/govuk_publishing_components/components/_related-navigation.scss
366
366
  - app/assets/stylesheets/govuk_publishing_components/components/_search.scss
367
+ - app/assets/stylesheets/govuk_publishing_components/components/_select.scss
367
368
  - app/assets/stylesheets/govuk_publishing_components/components/_share-links.scss
368
369
  - app/assets/stylesheets/govuk_publishing_components/components/_skip-link.scss
369
370
  - app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-header.scss
@@ -461,6 +462,7 @@ files:
461
462
  - app/views/govuk_publishing_components/components/_radio.html.erb
462
463
  - app/views/govuk_publishing_components/components/_related_navigation.html.erb
463
464
  - app/views/govuk_publishing_components/components/_search.html.erb
465
+ - app/views/govuk_publishing_components/components/_select.html.erb
464
466
  - app/views/govuk_publishing_components/components/_share_links.html.erb
465
467
  - app/views/govuk_publishing_components/components/_skip_link.html.erb
466
468
  - app/views/govuk_publishing_components/components/_step_by_step_nav.html.erb
@@ -504,6 +506,7 @@ files:
504
506
  - app/views/govuk_publishing_components/components/docs/radio.yml
505
507
  - app/views/govuk_publishing_components/components/docs/related_navigation.yml
506
508
  - app/views/govuk_publishing_components/components/docs/search.yml
509
+ - app/views/govuk_publishing_components/components/docs/select.yml
507
510
  - app/views/govuk_publishing_components/components/docs/share_links.yml
508
511
  - app/views/govuk_publishing_components/components/docs/skip_link.yml
509
512
  - app/views/govuk_publishing_components/components/docs/step_by_step_nav.yml