govuk_publishing_components 13.6.0 → 13.6.1

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 (28) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/dependencies.js +3 -3
  3. data/app/assets/javascripts/govuk_publishing_components/lib/toggle.js +52 -28
  4. data/app/views/govuk_publishing_components/components/docs/related_navigation.yml +216 -201
  5. data/lib/govuk_publishing_components/presenters/meta_tags.rb +0 -7
  6. data/lib/govuk_publishing_components/presenters/related_navigation_helper.rb +3 -3
  7. data/lib/govuk_publishing_components/version.rb +1 -1
  8. data/node_modules/govuk-frontend/all.js +1197 -943
  9. data/node_modules/govuk-frontend/components/_all.scss +2 -0
  10. data/node_modules/govuk-frontend/components/accordion/README.md +17 -0
  11. data/node_modules/govuk-frontend/components/accordion/_accordion.scss +173 -0
  12. data/node_modules/govuk-frontend/components/accordion/accordion.js +1011 -0
  13. data/node_modules/govuk-frontend/components/accordion/macro-options.json +70 -0
  14. data/node_modules/govuk-frontend/components/accordion/macro.njk +3 -0
  15. data/node_modules/govuk-frontend/components/accordion/template.njk +27 -0
  16. data/node_modules/govuk-frontend/components/input/macro-options.json +7 -0
  17. data/node_modules/govuk-frontend/components/summary-list/README.md +15 -0
  18. data/node_modules/govuk-frontend/components/summary-list/_summary-list.scss +112 -0
  19. data/node_modules/govuk-frontend/components/summary-list/macro-options.json +95 -0
  20. data/node_modules/govuk-frontend/components/summary-list/macro.njk +3 -0
  21. data/node_modules/govuk-frontend/components/summary-list/template.njk +35 -0
  22. data/node_modules/govuk-frontend/helpers/_grid.scss +43 -35
  23. data/node_modules/govuk-frontend/helpers/_visually-hidden.scss +4 -2
  24. data/node_modules/govuk-frontend/objects/_grid.scss +21 -8
  25. data/node_modules/govuk-frontend/package.json +11 -11
  26. data/node_modules/govuk-frontend/settings/_measurements.scss +14 -0
  27. data/node_modules/govuk-frontend/template.njk +2 -0
  28. metadata +13 -2
@@ -0,0 +1,70 @@
1
+ [
2
+ {
3
+ "name": "id",
4
+ "type": "string",
5
+ "required": true,
6
+ "description": "Must be **unique** across the domain of your service (as the expanded state of individual instances of the component persists across page loads using [`localStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage)). Used as an `id` in the HTML for the accordion as a whole, and also as a prefix for the `id`s of the section contents and the buttons that open them, so that those `id`s can be the target of `aria-labelledby` and `aria-control` attributes."
7
+ },
8
+ {
9
+ "name": "headingLevel",
10
+ "type": "integer",
11
+ "required": false,
12
+ "description": "Heading level, from 1 to 6. Default is `2`."
13
+ },
14
+ {
15
+ "name": "classes",
16
+ "type": "string",
17
+ "required": false,
18
+ "description": "Classes to add to the accordion."
19
+ },
20
+ {
21
+ "name": "attributes",
22
+ "type": "object",
23
+ "required": false,
24
+ "description": "HTML attributes (for example data attributes) to add to the accordion."
25
+ },
26
+ {
27
+ "name": "items",
28
+ "type": "array",
29
+ "required": true,
30
+ "description": "An array of sections within the accordion.",
31
+ "params": [
32
+ {
33
+ "name": "heading.text",
34
+ "type": "string",
35
+ "required": false,
36
+ "description": "The title of each section. If `heading.html` is supplied, this is ignored. This is used both as the title for each section, and as the button to open or close each section."
37
+ },
38
+ {
39
+ "name": "heading.html",
40
+ "type": "string",
41
+ "required": false,
42
+ "description": "The HTML content of the header for each section which is used both as the title for each section, and as the button to open or close each section."
43
+ },
44
+ {
45
+ "name": "summary.text",
46
+ "type": "string",
47
+ "required": false,
48
+ "description": "Text content for summary line. If `summary.html` is supplied, this is ignored."
49
+ },
50
+ {
51
+ "name": "summary.html",
52
+ "type": "string",
53
+ "required": false,
54
+ "description": "HTML content for summary line."
55
+ },
56
+ {
57
+ "name": "content.html",
58
+ "type": "string",
59
+ "required": true,
60
+ "description": "The HTML content of each section, which is hidden when the section is closed."
61
+ },
62
+ {
63
+ "name": "expanded",
64
+ "type": "boolean",
65
+ "required": false,
66
+ "description": "Whether the section should be expanded upon initial load or not. Defaults to `false`."
67
+ }
68
+ ]
69
+ }
70
+ ]
@@ -0,0 +1,3 @@
1
+ {% macro govukAccordion(params) %}
2
+ {%- include "./template.njk" -%}
3
+ {% endmacro %}
@@ -0,0 +1,27 @@
1
+ {% set id = params.id %}
2
+ {% set headingLevel = params.headingLevel if params.headingLevel else 2 %}
3
+
4
+ <div class="govuk-accordion {%- if params.classes %} {{ params.classes }}{% endif -%}" data-module="accordion" id="{{ id }}"
5
+ {%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %}>
6
+
7
+ {% for item in params.items %}
8
+ <div class="govuk-accordion__section {% if item.expanded %}govuk-accordion__section--expanded{% endif %}">
9
+ <div class="govuk-accordion__section-header">
10
+ <h{{ headingLevel }} class="govuk-accordion__section-heading">
11
+ <span class="govuk-accordion__section-button" id="{{ id }}-heading-{{ loop.index }}">
12
+ {{ item.heading.html | safe if item.heading.html else item.heading.text }}
13
+ </span>
14
+ </h{{ headingLevel }}>
15
+ {% if item.summary.html or item.summary.text %}
16
+ <div class="govuk-accordion__section-summary govuk-body" id="{{ id }}-summary-{{ loop.index }}">
17
+ {{ item.summary.html | safe if item.summary.html else item.summary.text }}
18
+ </div>
19
+ {% endif %}
20
+ </div>
21
+ <div id="{{ id }}-content-{{ loop.index }}" class="govuk-accordion__section-content" aria-labelledby="{{ id }}-heading-{{ loop.index }}">
22
+ {{ item.content.html | safe if item.content.html else item.content.text }}
23
+ </div>
24
+ </div>
25
+ {% endfor %}
26
+
27
+ </div>
@@ -23,6 +23,13 @@
23
23
  "required": false,
24
24
  "description": "Optional initial value of the input."
25
25
  },
26
+ {
27
+ "name": "label",
28
+ "type": "object",
29
+ "required": true,
30
+ "description": "Options for the label component.",
31
+ "isComponent": true
32
+ },
26
33
  {
27
34
  "name": "hint",
28
35
  "type": "object",
@@ -0,0 +1,15 @@
1
+ # Summary list
2
+
3
+ ## Installation
4
+
5
+ See the [main README quick start guide](https://github.com/alphagov/govuk-frontend#quick-start) for how to install this component.
6
+
7
+ ## Guidance and Examples
8
+
9
+ Find out when to use the details component in your service in the [GOV.UK Design System](https://design-system.service.gov.uk/components/summary-list).
10
+
11
+ ## Component options
12
+
13
+ Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.
14
+
15
+ See [options table](https://design-system.service.gov.uk/components/summary-list/#options-example-default) for details.
@@ -0,0 +1,112 @@
1
+ @import "../../settings/all";
2
+ @import "../../tools/all";
3
+ @import "../../helpers/all";
4
+
5
+ @include govuk-exports("govuk/component/summary-list") {
6
+
7
+ .govuk-summary-list {
8
+ @include govuk-font($size: 19);
9
+ @include govuk-text-colour;
10
+ @include govuk-media-query($from: tablet) {
11
+ display: table;
12
+ width: 100%;
13
+ }
14
+ margin: 0; // Reset default user agent styles
15
+ @include govuk-responsive-margin(6, "bottom");
16
+ }
17
+
18
+ .govuk-summary-list__row {
19
+ @include govuk-media-query($until: tablet) {
20
+ margin-bottom: govuk-spacing(3);
21
+ border-bottom: 1px solid $govuk-border-colour;
22
+ }
23
+ @include govuk-media-query($from: tablet) {
24
+ display: table-row;
25
+ }
26
+ }
27
+
28
+ .govuk-summary-list__key,
29
+ .govuk-summary-list__value,
30
+ .govuk-summary-list__actions {
31
+ margin: 0; // Reset default user agent styles
32
+
33
+ @include govuk-media-query($from: tablet) {
34
+ display: table-cell;
35
+ padding-right: govuk-spacing(4);
36
+ }
37
+ }
38
+
39
+ .govuk-summary-list__key,
40
+ .govuk-summary-list__value,
41
+ .govuk-summary-list__actions {
42
+ @include govuk-media-query($from: tablet) {
43
+ padding-top: govuk-spacing(2);
44
+ padding-bottom: govuk-spacing(2);
45
+ border-bottom: 1px solid $govuk-border-colour;
46
+ }
47
+ }
48
+
49
+ .govuk-summary-list__actions {
50
+ margin-bottom: govuk-spacing(3);
51
+ @include govuk-media-query($from: tablet) {
52
+ padding-right: 0;
53
+ text-align: right;
54
+ }
55
+ }
56
+
57
+ .govuk-summary-list__key {
58
+ margin-bottom: govuk-spacing(1);
59
+ @include govuk-typography-weight-bold;
60
+ word-break: break-word;
61
+ @include govuk-media-query($from: tablet) {
62
+ width: 30%;
63
+ }
64
+ }
65
+
66
+ .govuk-summary-list__value {
67
+ @include govuk-media-query($until: tablet) {
68
+ margin-bottom: govuk-spacing(3);
69
+ }
70
+ }
71
+
72
+ .govuk-summary-list__value > p {
73
+ margin-bottom: govuk-spacing(2);
74
+ }
75
+
76
+ .govuk-summary-list__value > :last-child {
77
+ margin-bottom: 0;
78
+ }
79
+
80
+ .govuk-summary-list__actions-list {
81
+ width: 100%;
82
+ margin: 0; // Reset default user agent styles
83
+ padding: 0; // Reset default user agent styles
84
+ }
85
+
86
+ .govuk-summary-list__actions-list-item {
87
+ display: inline;
88
+ margin-right: govuk-spacing(2);
89
+ padding-right: govuk-spacing(2);
90
+ }
91
+
92
+ // In older browsers such as IE8, :last-child is not available,
93
+ // so only show the border divider where it is available.
94
+ .govuk-summary-list__actions-list-item:not(:last-child) {
95
+ border-right: 1px solid $govuk-border-colour;
96
+ }
97
+
98
+ .govuk-summary-list__actions-list-item:last-child {
99
+ margin-right: 0;
100
+ padding-right: 0;
101
+ border: 0;
102
+ }
103
+
104
+ .govuk-summary-list--no-border {
105
+ .govuk-summary-list__key,
106
+ .govuk-summary-list__value,
107
+ .govuk-summary-list__actions,
108
+ .govuk-summary-list__row {
109
+ border: 0;
110
+ }
111
+ }
112
+ }
@@ -0,0 +1,95 @@
1
+ [
2
+ {
3
+ "name": "rows",
4
+ "type": "array",
5
+ "required": true,
6
+ "description": "Array of row item objects",
7
+ "params": [
8
+ {
9
+ "name": "key.text",
10
+ "type": "string",
11
+ "required": true,
12
+ "description": "If `html` is set, this is not required. Text to use within the each key. If `html` is provided, the `text` argument will be ignored."
13
+ },
14
+ {
15
+ "name": "key.html",
16
+ "type": "string",
17
+ "required": true
18
+ },
19
+ {
20
+ "name": "key.classes",
21
+ "type": "string",
22
+ "required": false,
23
+ "description": "Classes to add to the key wrapper"
24
+ },
25
+ {
26
+ "name": "value.text",
27
+ "type": "string",
28
+ "required": true,
29
+ "description": "If `html` is set, this is not required. Text to use within the each value. If `html` is provided, the `text` argument will be ignored."
30
+ },
31
+ {
32
+ "name": "value.html",
33
+ "type": "string",
34
+ "required": true,
35
+ "description": "If `text` is set, this is not required. HTML to use within the each value. If `html` is provided, the `text` argument will be ignored."
36
+ },
37
+ {
38
+ "name": "value.classes",
39
+ "type": "string",
40
+ "required": false,
41
+ "description": "Classes to add to the value wrapper"
42
+ },
43
+ {
44
+ "name": "actions.items",
45
+ "type": "array",
46
+ "required": false,
47
+ "description": "Array of action item objects",
48
+ "params": [
49
+ {
50
+ "name": "classes",
51
+ "type": "string",
52
+ "required": false,
53
+ "description": "Classes to add to the actions wrapper"
54
+ },
55
+ {
56
+ "name": "href",
57
+ "type": "string",
58
+ "required": true,
59
+ "description": "The value of the link href attribute for an action item"
60
+ },
61
+ {
62
+ "name": "text",
63
+ "type": "string",
64
+ "required": true,
65
+ "description": "If `html` is set, this is not required. Text to use within each action item. If `html` is provided, the `text` argument will be ignored."
66
+ },
67
+ {
68
+ "name": "html",
69
+ "type": "string",
70
+ "required": true,
71
+ "description": "If `text` is set, this is not required. HTML to use within the each action item. If `html` is provided, the `text` argument will be ignored."
72
+ },
73
+ {
74
+ "name": "visuallyHiddenText",
75
+ "type": "string",
76
+ "required": false,
77
+ "description": "Actions rely on context from the surrounding content so may require additional accessible text, text supplied to this option is appended to the end, use `html` for more complicated scenarios."
78
+ }
79
+ ]
80
+ }
81
+ ]
82
+ },
83
+ {
84
+ "name": "classes",
85
+ "type": "string",
86
+ "required": false,
87
+ "description": "Classes to add to the container."
88
+ },
89
+ {
90
+ "name": "attributes",
91
+ "type": "object",
92
+ "required": false,
93
+ "description": "HTML attributes (for example data attributes) to add to the container."
94
+ }
95
+ ]
@@ -0,0 +1,3 @@
1
+ {% macro govukSummaryList(params) %}
2
+ {%- include "./template.njk" -%}
3
+ {% endmacro %}
@@ -0,0 +1,35 @@
1
+ {%- macro _actionLink(action) %}
2
+ <a class="govuk-link" href="{{ action.href }}">
3
+ {{ action.html | safe if action.html else action.text }}
4
+ {%- if action.visuallyHiddenText -%}
5
+ <span class="govuk-visually-hidden"> {{ action.visuallyHiddenText }}</span>
6
+ {% endif -%}
7
+ </a>
8
+ {% endmacro -%}
9
+ <dl class="govuk-summary-list {%- if params.classes %} {{ params.classes }}{% endif %}"{% for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %}>
10
+ {% for row in params.rows %}
11
+ <div class="govuk-summary-list__row">
12
+ <dt class="govuk-summary-list__key {%- if row.key.classes %} {{ row.key.classes }}{% endif %}">
13
+ {{ row.key.html | safe if row.key.html else row.key.text }}
14
+ </dt>
15
+ <dd class="govuk-summary-list__value {%- if row.value.classes %} {{ row.value.classes }}{% endif %}">
16
+ {{ row.value.html | indent(8) | trim | safe if row.value.html else row.value.text }}
17
+ </dd>
18
+ {% if row.actions.items %}
19
+ <dd class="govuk-summary-list__actions {%- if row.actions.classes %} {{ row.actions.classes }}{% endif %}">
20
+ {% if row.actions.items.length == 1 %}
21
+ {{ _actionLink(row.actions.items[0]) | indent(12) | trim }}
22
+ {% else %}
23
+ <ul class="govuk-summary-list__actions-list">
24
+ {% for action in row.actions.items %}
25
+ <li class="govuk-summary-list__actions-list-item">
26
+ {{ _actionLink(action) | indent(18) | trim }}
27
+ </li>
28
+ {% endfor %}
29
+ </ul>
30
+ {% endif %}
31
+ </dd>
32
+ {% endif %}
33
+ </div>
34
+ {% endfor %}
35
+ </dl>
@@ -2,20 +2,6 @@
2
2
  /// @group helpers
3
3
  ////
4
4
 
5
- /// Map of grid column widths
6
- ///
7
- /// @type Map
8
- /// @access private
9
-
10
- $_govuk-grid-widths: (
11
- one-quarter: 25%,
12
- one-third: 33.3333%,
13
- one-half: 50%,
14
- two-thirds: 66.6666%,
15
- three-quarters: 75%,
16
- full: 100%
17
- ) !default;
18
-
19
5
  /// Grid width percentage
20
6
  ///
21
7
  /// @param {String} $key - Name of grid width (e.g. two-thirds)
@@ -23,14 +9,22 @@ $_govuk-grid-widths: (
23
9
  /// @throw if `$key` is not a valid grid width
24
10
  /// @access public
25
11
 
26
- @function grid-width($key) {
27
- @if map-has-key($_govuk-grid-widths, $key) {
28
- @return map-get($_govuk-grid-widths, $key);
12
+ @function govuk-grid-width($key) {
13
+ @if map-has-key($govuk-grid-widths, $key) {
14
+ @return map-get($govuk-grid-widths, $key);
29
15
  }
30
16
 
31
17
  @error "Unknown grid width `#{$key}`";
32
18
  }
33
19
 
20
+ /// Grid width percentage (alias)
21
+ ///
22
+ /// @alias govuk-grid-width
23
+ /// @deprecated To be removed in v3.0, replaced by govuk-grid-width
24
+ @function grid-width($key) {
25
+ @return govuk-grid-width($key);
26
+ }
27
+
34
28
  /// Generate grid row styles
35
29
  ///
36
30
  /// Creates a grid row class with a standardised margin.
@@ -44,6 +38,7 @@ $_govuk-grid-widths: (
44
38
  /// @include govuk-grid-row("app-grid");
45
39
  ///
46
40
  /// @access public
41
+ /// @deprecated To be removed in v3.0, replaced by the govuk-grid-row class
47
42
 
48
43
  @mixin govuk-grid-row($class: "govuk-grid-row") {
49
44
  .#{$class} {
@@ -55,44 +50,57 @@ $_govuk-grid-widths: (
55
50
 
56
51
  /// Generate grid column styles
57
52
  ///
58
- /// Creates a cross browser grid column with a class of '.govuk-grid-column' by
59
- /// default, and a standardised gutter between the columns.
53
+ /// Creates a grid column with standard gutter between the columns.
60
54
  ///
61
- /// Common widths are predefined above as keywords in the `$grid-widths` map.
55
+ /// If a `$class` is provided (which is the default, but deprecated behaviour),
56
+ /// the generated rules will be wrapped in a predefined selector in the format
57
+ /// `$class-$width` (e.g. `govuk-grid-column-full`). This behaviour is
58
+ /// deprecated and will be removed in v3.0
62
59
  ///
63
- /// By default their width changes from 100% to specified width at the 'tablet'
64
- /// breakpoint, but that can be configured to be any other breakpoint by using
65
- /// the `$at` parameter.
60
+ /// Grid widths are defined in the `$govuk-grid-widths` map.
66
61
  ///
67
- /// @param {String} $class [govuk-grid-column] CSS class name
68
- /// @param {String} $width [full] one-quarter | one-third | one-half | two-third | three-quarters | full
62
+ /// By default the column width changes from 100% to specified width at the
63
+ /// 'tablet' breakpoint, but other breakpoints can be specified using the `$at`
64
+ /// parameter.
65
+ ///
66
+ /// @param {String} $width [full] name of a grid width from $govuk-grid-widths
69
67
  /// @param {String} $float [left] left | right
70
- /// @param {String} $at [tablet] - mobile | tablet | desktop | any custom breakpoint in px or em
68
+ /// @param {String} $at [tablet] - mobile | tablet | desktop | any custom breakpoint
69
+ /// @param {String} $class [govuk-grid-column] CSS class name (deprecated)
71
70
  ///
72
71
  /// @example scss - Default
73
- /// @include govuk-grid-column(two-thirds)
74
- ///
75
- /// @example scss - Customising the class name
76
- /// @include govuk-grid-column(one-half, $class: "test-column");
72
+ /// .govuk-grid-column-two-thirds {
73
+ /// @include govuk-grid-column(two-thirds, $class: false)
74
+ /// }
77
75
  ///
78
76
  /// @example scss - Customising the breakpoint where width percentage is applied
79
- /// @include govuk-grid-column(one-half, $at: desktop);
77
+ /// .govuk-grid-column-one-half-at-desktop {
78
+ /// @include govuk-grid-column(one-half, $at: desktop);
79
+ /// }
80
80
  ///
81
81
  /// @example scss - Customising the float direction
82
- /// @include govuk-grid-column(one-half, $float: right);
82
+ /// .govuk-grid-column-one-half-right {
83
+ /// @include govuk-grid-column(two-thirds, $float: right, $class: false);
84
+ /// }
85
+ ///
86
+ /// @example scss - Customising the class name (deprecated)
87
+ /// @include govuk-grid-column(one-half, $class: "test-column");
83
88
  ///
84
89
  /// @access public
85
90
 
86
91
  @mixin govuk-grid-column($width: full, $float: left, $at: tablet, $class: "govuk-grid-column") {
87
-
88
- .#{$class}-#{$width} {
92
+ @if ($class) {
93
+ .#{$class}-#{$width} {
94
+ @include govuk-grid-column($width, $float, $at, $class: false);
95
+ }
96
+ } @else {
89
97
  box-sizing: border-box;
90
98
  @if $at != desktop {
91
99
  width: 100%;
92
100
  }
93
101
  padding: 0 $govuk-gutter-half;
94
102
  @include govuk-media-query($from: $at) {
95
- width: grid-width($width);
103
+ width: govuk-grid-width($width);
96
104
  float: $float;
97
105
  }
98
106
  }