govuk_publishing_components 6.4.0 → 6.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93f509e545e321d18c1ffbc1107cdb70dd011ee1dba8c5619759a7aa472a2db7
4
- data.tar.gz: ed7ef2fec6f995d6a04b599c9c813f323d1768ceff04823a3e4451d4ee764c81
3
+ metadata.gz: 07a0593663e9c5f0382e38e40b4cdd4e83e5c87b1010f040add2f9272763bc47
4
+ data.tar.gz: 81dab152fcdf00ab3f9ac78aaa97119c08eaf167c2324710043fda7e5c511524
5
5
  SHA512:
6
- metadata.gz: 87d4fa9ae3d5e51598a46d656317e6c8211df10716f1d03a7916a32ee763e2c961ce54ee82e8c142db7fedb453c067a357905aa27e8daadaf804b7731cd6ae16
7
- data.tar.gz: b655caa3d93a9599c20a26e3519434e02db51fc2e1110b760c2d3d770917efa0a443b7d23660c9e9b867dd4b9ac2f034b03bda3d562b6a91b77aa67ee07bfecc
6
+ metadata.gz: 475babd9cbe5265f77983b1ee83b56f782751ed02799c85cf9928210ed32db56e8f9244323fedb3bfc55fe1d781397c3cd11e468f6f9e7e09263edcb5597fb2c
7
+ data.tar.gz: 159320d6deaabaa6e72df96b941fae40ba97e5e4fa6c31336e16c0ca39ee9ddaf830e0bdf0c27365e76315050f48cb5939ed989f3240a440c7834e72c2460f42
@@ -1,29 +1,10 @@
1
- // Most of this is originally from the service manual but has changed considerably since then
2
-
3
1
  (function (Modules) {
4
2
  "use strict";
5
3
  window.GOVUK = window.GOVUK || {};
6
4
 
7
5
  Modules.Gemstepnav = function () {
8
6
 
9
- var actions = {
10
- showLinkText: "Show",
11
- hideLinkText: "Hide"
12
- };
13
-
14
- var bulkActions = {
15
- showAll: {
16
- buttonText: "Show all",
17
- eventLabel: "Show All",
18
- linkText: "Show"
19
- },
20
- hideAll: {
21
- buttonText: "Hide all",
22
- eventLabel: "Hide All",
23
- linkText: "Hide"
24
- }
25
- };
26
-
7
+ var actions = {}; // stores text for JS appended elements 'show' and 'hide' on steps, and 'show/hide all' button
27
8
  var rememberShownStep = false;
28
9
  var stepNavSize;
29
10
  var sessionStoreLink = 'govuk-step-nav-active-link';
@@ -52,6 +33,7 @@
52
33
  var uniqueId = $element.data('id') || false;
53
34
  var stepNavTracker = new StepNavTracker(totalSteps, totalLinks, uniqueId);
54
35
 
36
+ getTextForInsertedElements();
55
37
  addButtonstoSteps();
56
38
  addShowHideAllButton();
57
39
  addShowHideToggle();
@@ -65,6 +47,13 @@
65
47
  bindToggleShowHideAllButton(stepNavTracker);
66
48
  bindComponentLinkClicks(stepNavTracker);
67
49
 
50
+ function getTextForInsertedElements() {
51
+ actions.showText = $element.attr('data-show-text');
52
+ actions.hideText = $element.attr('data-hide-text');
53
+ actions.showAllText = $element.attr('data-show-all-text');
54
+ actions.hideAllText = $element.attr('data-hide-all-text');
55
+ }
56
+
68
57
  // When navigating back in browser history to the step nav, the browser will try to be "clever" and return
69
58
  // the user to their previous scroll position. However, since we collapse all but the currently-anchored
70
59
  // step, the content length changes and the user is returned to the wrong position (often the footer).
@@ -84,15 +73,15 @@
84
73
  }
85
74
 
86
75
  function addShowHideAllButton() {
87
- $element.prepend('<div class="gem-c-step-nav__controls"><button aria-expanded="false" class="gem-c-step-nav__button gem-c-step-nav__button--controls js-step-controls-button">' + bulkActions.showAll.buttonText + '</button></div>');
76
+ $element.prepend('<div class="gem-c-step-nav__controls"><button aria-expanded="false" class="gem-c-step-nav__button gem-c-step-nav__button--controls js-step-controls-button">' + actions.showAllText + '</button></div>');
88
77
  }
89
78
 
90
79
  function addShowHideToggle() {
91
80
  $stepHeaders.each(function() {
92
- var linkText = actions.showLinkText;
81
+ var linkText = actions.showText;
93
82
 
94
83
  if (headerIsOpen($(this))) {
95
- linkText = actions.hideLinkText;
84
+ linkText = actions.hideText;
96
85
  }
97
86
  if (!$(this).find('.js-toggle-link').length) {
98
87
  $(this).find('.js-step-title-button').append('<span class="gem-c-step-nav__toggle-link js-toggle-link" aria-hidden="true">' + linkText + '</span>');
@@ -254,21 +243,21 @@
254
243
  $showOrHideAllButton.on('click', function () {
255
244
  var shouldshowAll;
256
245
 
257
- if ($showOrHideAllButton.text() == bulkActions.showAll.buttonText) {
258
- $showOrHideAllButton.text(bulkActions.hideAll.buttonText);
259
- $element.find('.js-toggle-link').text(actions.hideLinkText)
246
+ if ($showOrHideAllButton.text() == actions.showAllText) {
247
+ $showOrHideAllButton.text(actions.hideAllText);
248
+ $element.find('.js-toggle-link').text(actions.hideText)
260
249
  shouldshowAll = true;
261
250
 
262
251
  stepNavTracker.track('pageElementInteraction', 'stepNavAllShown', {
263
- label: bulkActions.showAll.eventLabel + ": " + stepNavSize
252
+ label: actions.showAllText + ": " + stepNavSize
264
253
  });
265
254
  } else {
266
- $showOrHideAllButton.text(bulkActions.showAll.buttonText);
267
- $element.find('.js-toggle-link').text(actions.showLinkText);
255
+ $showOrHideAllButton.text(actions.showAllText);
256
+ $element.find('.js-toggle-link').text(actions.showText);
268
257
  shouldshowAll = false;
269
258
 
270
259
  stepNavTracker.track('pageElementInteraction', 'stepNavAllHidden', {
271
- label: bulkActions.hideAll.eventLabel + ": " + stepNavSize
260
+ label: actions.hideAllText + ": " + stepNavSize
272
261
  });
273
262
  }
274
263
 
@@ -285,9 +274,9 @@
285
274
  var shownSteps = $element.find('.step-is-shown').length;
286
275
  // Find out if the number of is-opens == total number of steps
287
276
  if (shownSteps === totalSteps) {
288
- $showOrHideAllButton.text(bulkActions.hideAll.buttonText);
277
+ $showOrHideAllButton.text(actions.hideAllText);
289
278
  } else {
290
- $showOrHideAllButton.text(bulkActions.showAll.buttonText);
279
+ $showOrHideAllButton.text(actions.showAllText);
291
280
  }
292
281
  }
293
282
 
@@ -332,7 +321,7 @@
332
321
  $stepElement.toggleClass('step-is-shown', isShown);
333
322
  $stepContent.toggleClass('js-hidden', !isShown);
334
323
  $titleLink.attr("aria-expanded", isShown);
335
- $stepElement.find('.js-toggle-link').text(isShown ? actions.hideLinkText : actions.showLinkText);
324
+ $stepElement.find('.js-toggle-link').text(isShown ? actions.hideText : actions.showText);
336
325
 
337
326
  if (shouldUpdateHash) {
338
327
  updateHash($stepElement);
@@ -8,6 +8,7 @@
8
8
  @import "colours";
9
9
 
10
10
  @import "components/back-link";
11
+ @import "components/button";
11
12
  @import "components/document-list";
12
13
  @import "components/error-summary";
13
14
  @import "components/fieldset";
@@ -0,0 +1,58 @@
1
+ @import "design-patterns/buttons";
2
+ @import "mixins/media-down";
3
+ @import "mixins/margins";
4
+
5
+ %gem-c-button,
6
+ .gem-c-button {
7
+ @include button;
8
+
9
+ @media(max-width: 425px) {
10
+ box-sizing: border-box;
11
+ width: 100%;
12
+ text-align: center;
13
+ }
14
+
15
+ &:focus {
16
+ outline: 3px solid $focus-colour;
17
+ }
18
+ }
19
+
20
+ // this will be moved and extended into a model for general component spacing
21
+ // once this has been decided upon and other work completed, see:
22
+ // https://trello.com/c/KEkNsxG3/142-3-implement-customisable-spacing-for-components
23
+ .gem-c-button--bottom-margin {
24
+ @include responsive-bottom-margin;
25
+ }
26
+
27
+ %gem-c-button--start,
28
+ .gem-c-button--start {
29
+ @include bold-24($line-height: (24 / 20));
30
+ display: inline-block;
31
+ padding: 0.6em 1.7em 0.45em 0.67em;
32
+
33
+ @include media(tablet) {
34
+ padding-top: 0.3em;
35
+ padding-bottom: 0.15em;
36
+ }
37
+
38
+ background-image: image-url("icon-pointer.png");
39
+ background-position: 100% 50%;
40
+ background-repeat: no-repeat;
41
+
42
+ @include media-down(mobile) {
43
+ background-position: center right -.35em;
44
+ }
45
+
46
+ @include device-pixel-ratio() {
47
+ background-image: image-url("icon-pointer-2x.png");
48
+ background-size: 30px 19px;
49
+ }
50
+ }
51
+
52
+ // scss-lint:disable SelectorFormat
53
+ .gem-c-button__info-text {
54
+ display: block;
55
+ margin-top: .5em;
56
+ max-width: 14em;
57
+ }
58
+ // scss-lint:enable SelectorFormat
@@ -1,5 +1,5 @@
1
1
  @import "helpers/variables";
2
- @import "helpers/clearfix";
2
+ @import "mixins/clearfix";
3
3
 
4
4
  .gem-c-fieldset {
5
5
  margin: 0 0 $gem-spacing-scale-4;
@@ -0,0 +1,20 @@
1
+ @mixin responsive-bottom-margin {
2
+ margin-bottom: $gutter-half;
3
+
4
+ @include media(tablet) {
5
+ margin-bottom: $gutter * 1.5;
6
+ }
7
+ }
8
+
9
+ @mixin responsive-top-margin {
10
+ margin-top: $gutter-half;
11
+
12
+ @include media(tablet) {
13
+ margin-top: $gutter * 1.5;
14
+ }
15
+ }
16
+
17
+ @mixin responsive-vertical-margins {
18
+ @include responsive-bottom-margin;
19
+ @include responsive-top-margin;
20
+ }
@@ -0,0 +1,22 @@
1
+ // Media query helpers. These make producing IE layouts
2
+ // super easy.
3
+
4
+ // These are desktop and down media queries
5
+
6
+ // There is also a local version of this in Smartanswers.
7
+
8
+ $is-ie: false !default;
9
+
10
+ @mixin media-down($size: false, $max-width: false, $min-width: false) {
11
+ @if $is-ie == false {
12
+ @if $size == mobile {
13
+ @media (max-width: 640px){
14
+ @content;
15
+ }
16
+ } @else if $size == tablet {
17
+ @media (max-width: 800px){
18
+ @content;
19
+ }
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,29 @@
1
+ <%
2
+ start ||= false
3
+ href ||= false
4
+ info_text ||= false
5
+ rel ||= false
6
+ text ||= ""
7
+ margin_bottom ||= false
8
+ data_attributes ||= false
9
+ title ||= false
10
+ css_classes = %w(gem-c-button)
11
+ css_classes << "gem-c-button--start" if start
12
+ css_classes << "gem-c-button--bottom-margin" if margin_bottom
13
+ css_classes = css_classes.join(" ")
14
+ html_options = { class: css_classes }
15
+ html_options[:role] = "button" if href
16
+ html_options[:rel] = rel if rel
17
+ html_options[:data] = data_attributes if data_attributes
18
+ html_options[:title] = title if title
19
+ %>
20
+ <% if href %>
21
+ <%= link_to(text, href.try(:html_safe), html_options) %>
22
+ <% else %>
23
+ <%= button_tag(text, html_options) %>
24
+ <% end %>
25
+ <% if info_text %>
26
+ <span class="gem-c-button__info-text">
27
+ <%= info_text.try(:html_safe) %>
28
+ </span>
29
+ <% end %>
@@ -22,6 +22,10 @@
22
22
  class="gem-c-step-nav js-hidden <% unless small %>gem-c-step-nav--large<% end %>"
23
23
  <%= "data-remember" if remember_last_step %>
24
24
  <%= "data-id=#{tracking_id}" if tracking_id %>
25
+ data-show-text="<%= t("govuk_component.step_by_step_nav.show", default: "Show") %>"
26
+ data-hide-text="<%= t("govuk_component.step_by_step_nav.hide", default: "Hide") %>"
27
+ data-show-all-text="<%= t("govuk_component.step_by_step_nav.show_all", default: "Show all") %>"
28
+ data-hide-all-text="<%= t("govuk_component.step_by_step_nav.hide_all", default: "Hide all") %>"
25
29
  >
26
30
  <ol class="gem-c-step-nav__steps">
27
31
  <% steps.each_with_index do |step, step_index| %>
@@ -0,0 +1,73 @@
1
+ name: Button
2
+ description: Use buttons to move though a transaction, aim to use only one button per page.
3
+ body: |
4
+ Button text should be short and describe the action the button performs.
5
+
6
+ [GOV.UK Elements has more information](https://govuk-elements.herokuapp.com/buttons/) on how buttons should be used.
7
+
8
+ Note: We do not consume GOV.UK Elements directly due to the naming conventions being leaky,
9
+ in time this component will be a wrapper for the [GOV.UK Frontend](https://github.com/alphagov/govuk-frontend) project's button component.
10
+
11
+ This component is also [extended for use in govspeak](https://govuk-static.herokuapp.com/component-guide/govspeak/button).
12
+
13
+ These instances of buttons are added by Content Designers, ideally this duplication would not exist but we currently don't have shared markup
14
+ via our components within the generated [govspeak](https://github.com/alphagov/govspeak).
15
+ (This is a challenge to the reader)
16
+ accessibility_criteria: |
17
+ The button must:
18
+
19
+ - accept focus
20
+ - be focusable with a keyboard
21
+ - indicate when it has focus
22
+ - activate when focused and space is pressed
23
+ - activate when focused and enter is pressed
24
+ - have a role of button
25
+ - have an accessible label
26
+ examples:
27
+ default:
28
+ data:
29
+ text: "Submit"
30
+ link_button:
31
+ data:
32
+ text: "I'm really a link sssh"
33
+ href: "#"
34
+ start_now_button:
35
+ data:
36
+ text: "Start now"
37
+ href: "#"
38
+ start: true
39
+ rel: "external"
40
+ start_now_button_with_info_text:
41
+ data:
42
+ text: "Start now"
43
+ href: "#"
44
+ start: true
45
+ info_text: "Sometimes you want to explain where a user is going to."
46
+ with_margin_bottom:
47
+ description: "Sometimes it's useful to break up a page, for example if a button is at the bottom of a page."
48
+ data:
49
+ text: "Submit"
50
+ margin_bottom: true
51
+ extreme_text:
52
+ data:
53
+ text: "I'm a button with lots of text to test how the component scales at extremes."
54
+ href: "#"
55
+ extreme_text_start_now_button:
56
+ data:
57
+ text: "I'm a start now button with lots of text to test how the component scales at extremes."
58
+ start: true
59
+ href: "#"
60
+ with_data_attributes:
61
+ data:
62
+ text: "Track this!"
63
+ margin_bottom: true
64
+ data_attributes: {
65
+ "module": "cross-domain-tracking",
66
+ "tracking-code": "GA-123ABC",
67
+ "tracking-name": "transactionTracker"
68
+ }
69
+ with_title_attribute:
70
+ data:
71
+ text: "Click me"
72
+ margin_bottom: true
73
+ title: "A button to click"
@@ -36,6 +36,11 @@ en:
36
36
  topics: "Explore the topic"
37
37
  topical_events: "Topical event"
38
38
  world_locations: "World locations"
39
+ step_by_step_nav:
40
+ show: "Show"
41
+ hide: "Hide"
42
+ show_all: "Show all"
43
+ hide_all: "Hide all"
39
44
  step_by_step_nav_related:
40
45
  part_of: "Part of"
41
46
  taxonomy_navigation:
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '6.4.0'.freeze
2
+ VERSION = '6.5.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: 6.4.0
4
+ version: 6.5.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-04-06 00:00:00.000000000 Z
11
+ date: 2018-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config
@@ -319,6 +319,7 @@ files:
319
319
  - app/assets/stylesheets/govuk_publishing_components/_all_components.scss
320
320
  - app/assets/stylesheets/govuk_publishing_components/_all_components_print.scss
321
321
  - app/assets/stylesheets/govuk_publishing_components/components/_back-link.scss
322
+ - app/assets/stylesheets/govuk_publishing_components/components/_button.scss
322
323
  - app/assets/stylesheets/govuk_publishing_components/components/_document-list.scss
323
324
  - app/assets/stylesheets/govuk_publishing_components/components/_error-summary.scss
324
325
  - app/assets/stylesheets/govuk_publishing_components/components/_feedback.scss
@@ -334,9 +335,11 @@ files:
334
335
  - app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav.scss
335
336
  - app/assets/stylesheets/govuk_publishing_components/components/_success-alert.scss
336
337
  - app/assets/stylesheets/govuk_publishing_components/components/_taxonomy-navigation.scss
337
- - app/assets/stylesheets/govuk_publishing_components/components/helpers/_clearfix.scss
338
338
  - app/assets/stylesheets/govuk_publishing_components/components/helpers/_px-to-em.scss
339
339
  - app/assets/stylesheets/govuk_publishing_components/components/helpers/_variables.scss
340
+ - app/assets/stylesheets/govuk_publishing_components/components/mixins/_clearfix.scss
341
+ - app/assets/stylesheets/govuk_publishing_components/components/mixins/_margins.scss
342
+ - app/assets/stylesheets/govuk_publishing_components/components/mixins/_media-down.scss
340
343
  - app/assets/stylesheets/govuk_publishing_components/components/print/_feedback.scss
341
344
  - app/assets/stylesheets/govuk_publishing_components/components/print/_step-by-step-nav-header.scss
342
345
  - app/assets/stylesheets/govuk_publishing_components/components/print/_step-by-step-nav.scss
@@ -355,6 +358,7 @@ files:
355
358
  - app/views/govuk_publishing_components/component_guide/preview.html.erb
356
359
  - app/views/govuk_publishing_components/component_guide/show.html.erb
357
360
  - app/views/govuk_publishing_components/components/_back_link.html.erb
361
+ - app/views/govuk_publishing_components/components/_button.html.erb
358
362
  - app/views/govuk_publishing_components/components/_contextual_breadcrumbs.html.erb
359
363
  - app/views/govuk_publishing_components/components/_contextual_sidebar.html.erb
360
364
  - app/views/govuk_publishing_components/components/_document_list.html.erb
@@ -373,6 +377,7 @@ files:
373
377
  - app/views/govuk_publishing_components/components/_success_alert.html.erb
374
378
  - app/views/govuk_publishing_components/components/_taxonomy_navigation.html.erb
375
379
  - app/views/govuk_publishing_components/components/docs/back_link.yml
380
+ - app/views/govuk_publishing_components/components/docs/button.yml
376
381
  - app/views/govuk_publishing_components/components/docs/contextual_breadcrumbs.yml
377
382
  - app/views/govuk_publishing_components/components/docs/contextual_sidebar.yml
378
383
  - app/views/govuk_publishing_components/components/docs/document_list.yml