govuk_publishing_components 29.15.0 → 29.15.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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +17 -22
- data/app/models/govuk_publishing_components/audit_applications.rb +31 -9
- data/app/models/govuk_publishing_components/audit_comparer.rb +15 -9
- data/app/views/govuk_publishing_components/audit/_components.html.erb +20 -2
- data/app/views/govuk_publishing_components/components/_table.html.erb +3 -2
- data/app/views/govuk_publishing_components/components/docs/back_link.yml +1 -1
- data/app/views/govuk_publishing_components/components/docs/big_number.yml +2 -2
- data/app/views/govuk_publishing_components/components/docs/breadcrumbs.yml +2 -2
- data/app/views/govuk_publishing_components/components/docs/button.yml +41 -40
- data/app/views/govuk_publishing_components/components/docs/cards.yml +2 -0
- data/app/views/govuk_publishing_components/components/docs/checkboxes.yml +216 -216
- data/app/views/govuk_publishing_components/components/docs/cookie_banner.yml +2 -1
- data/app/views/govuk_publishing_components/components/docs/copy_to_clipboard.yml +2 -2
- data/app/views/govuk_publishing_components/components/docs/details.yml +5 -1
- data/app/views/govuk_publishing_components/components/docs/document_list.yml +1 -2
- data/app/views/govuk_publishing_components/components/docs/error_alert.yml +4 -0
- data/app/views/govuk_publishing_components/components/docs/error_summary.yml +4 -6
- data/app/views/govuk_publishing_components/components/docs/image_card.yml +2 -1
- data/app/views/govuk_publishing_components/components/docs/intervention.yml +25 -25
- data/app/views/govuk_publishing_components/components/docs/organisation_logo.yml +1 -2
- data/app/views/govuk_publishing_components/components/docs/print_link.yml +5 -1
- data/app/views/govuk_publishing_components/components/docs/select.yml +101 -98
- data/app/views/govuk_publishing_components/components/docs/table.yml +6 -1
- data/app/views/govuk_publishing_components/components/docs/tabs.yml +4 -0
- data/lib/govuk_publishing_components/app_helpers/table_helper.rb +4 -2
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d9201a328c875b8cb5c93315a6365ea7dbc632027d0b973f9b0e700c86e01f6a
|
|
4
|
+
data.tar.gz: 78cd444356c208537d7108cda4c471774a09b140c9db3e7aec1b0899adebf968
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cf29058c5c655fed33c3f10e34728752117387c0006893c70dccf563862a5cc98dae584218e974b40b63b71f64aef1ea8ffb9b9f0c98dde7bbc49fcea331da99
|
|
7
|
+
data.tar.gz: 94bac53144fd6f7685976fbc884485d054ac991f07e1bee42c31707509cf6702063f3c1b9f67314e54dc48ea5f5d08ab00562a68e2af65b9b7dd0f98a7d5e1e5
|
|
@@ -10,27 +10,22 @@ window.GOVUK.Modules.GovukAccordion = window.GOVUKFrontend.Accordion;
|
|
|
10
10
|
function GemAccordion ($module) {
|
|
11
11
|
this.$module = $module
|
|
12
12
|
this.sectionClass = 'govuk-accordion__section'
|
|
13
|
-
this.
|
|
14
|
-
this.
|
|
15
|
-
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
this.sectionExpandedClass = 'govuk-accordion__section--expanded'
|
|
14
|
+
this.sectionInnerContentClass = 'govuk-accordion__section-content'
|
|
15
|
+
|
|
16
|
+
this.sectionHeader = '.govuk-accordion__section-header'
|
|
17
|
+
this.showAllControls = '.govuk-accordion__show-all'
|
|
18
|
+
this.sectionButton = '.govuk-accordion__section-button'
|
|
19
|
+
this.headingText = '.govuk-accordion__section-heading-text'
|
|
20
|
+
|
|
21
|
+
// language attribute pulled from data attributes
|
|
21
22
|
this.$module.actions = {}
|
|
22
23
|
this.$module.actions.locale = this.$module.getAttribute('data-locale')
|
|
23
|
-
this.$module.actions.showText = this.$module.getAttribute('data-show-text')
|
|
24
|
-
this.$module.actions.hideText = this.$module.getAttribute('data-hide-text')
|
|
25
|
-
this.$module.actions.showAllText = this.$module.getAttribute('data-show-all-text')
|
|
26
|
-
this.$module.actions.hideAllText = this.$module.getAttribute('data-hide-all-text')
|
|
27
|
-
this.$module.actions.thisSectionVisuallyHidden = this.$module.getAttribute('data-this-section-visually-hidden')
|
|
28
24
|
}
|
|
29
25
|
|
|
30
26
|
GemAccordion.prototype.init = function () {
|
|
31
27
|
// Indicate that JavaScript has worked
|
|
32
|
-
this.$module.classList.add('gem-c-
|
|
33
|
-
this.$module.querySelector('.' + this.showAllControls).classList.add('gem-c-accordion__show-all')
|
|
28
|
+
this.$module.querySelector(this.showAllControls).classList.add('gem-c-accordion__show-all')
|
|
34
29
|
|
|
35
30
|
// Feature flag for anchor tag navigation used on manuals
|
|
36
31
|
if (this.$module.getAttribute('data-anchor-navigation') === 'true') {
|
|
@@ -50,7 +45,7 @@ window.GOVUK.Modules.GovukAccordion = window.GOVUKFrontend.Accordion;
|
|
|
50
45
|
var showAllAttributes = this.$module.getAttribute('data-show-all-attributes')
|
|
51
46
|
if (showAllAttributes) {
|
|
52
47
|
try {
|
|
53
|
-
var showAll = this.$module.querySelector(
|
|
48
|
+
var showAll = this.$module.querySelector(this.showAllControls)
|
|
54
49
|
var values = JSON.parse(showAllAttributes)
|
|
55
50
|
var keys = Object.keys(values)
|
|
56
51
|
for (var i = 0; i < keys.length; i++) {
|
|
@@ -74,7 +69,7 @@ window.GOVUK.Modules.GovukAccordion = window.GOVUKFrontend.Accordion;
|
|
|
74
69
|
// Add event listeners for links to open accordion sections when navigated to using said anchor links on the page
|
|
75
70
|
// Adding an event listener to all anchor link a tags in an accordion is risky but we circumvent this risk partially by only being a layer of accordion behaviour instead of any sort of change to link behaviour
|
|
76
71
|
GemAccordion.prototype.addEventListenersForAnchors = function () {
|
|
77
|
-
var links = this.$module.querySelectorAll(
|
|
72
|
+
var links = this.$module.querySelectorAll(this.sectionInnerContentClass + ' a[href*="#"]')
|
|
78
73
|
|
|
79
74
|
nodeListForEach(links, function (link) {
|
|
80
75
|
if (link.pathname === window.location.pathname) {
|
|
@@ -87,7 +82,7 @@ window.GOVUK.Modules.GovukAccordion = window.GOVUKFrontend.Accordion;
|
|
|
87
82
|
GemAccordion.prototype.openForAnchor = function (hash) {
|
|
88
83
|
var target = document.getElementById(hash)
|
|
89
84
|
var $section = this.getContainingSection(target)
|
|
90
|
-
var $header = $section.querySelector(
|
|
85
|
+
var $header = $section.querySelector(this.sectionHeader)
|
|
91
86
|
var $expanded = this.getContainingSection($section)
|
|
92
87
|
var $parent = $header.parentElement
|
|
93
88
|
|
|
@@ -95,7 +90,7 @@ window.GOVUK.Modules.GovukAccordion = window.GOVUKFrontend.Accordion;
|
|
|
95
90
|
// Should the target anchor link be within the same page, open section - navigate normally
|
|
96
91
|
// Should the target anchor link be within a different, closed section, open this section
|
|
97
92
|
// Should the target anchor link be within a different page and different, closed section open this section
|
|
98
|
-
if ($expanded && (!$parent.classList.contains(this.
|
|
93
|
+
if ($expanded && (!$parent.classList.contains(this.sectionExpandedClass))) {
|
|
99
94
|
$header.click()
|
|
100
95
|
}
|
|
101
96
|
}
|
|
@@ -119,7 +114,7 @@ window.GOVUK.Modules.GovukAccordion = window.GOVUKFrontend.Accordion;
|
|
|
119
114
|
|
|
120
115
|
// To track the Accordion's "Show all sections" / "Hide all sections" button click events and pass them to the GA event tracking
|
|
121
116
|
GemAccordion.prototype.addAccordionOpenAllTracking = function () {
|
|
122
|
-
this.$module.querySelector(
|
|
117
|
+
this.$module.querySelector(this.showAllControls).addEventListener('click', function (event) {
|
|
123
118
|
var expanded = event.target.getAttribute('aria-expanded') === 'true'
|
|
124
119
|
var label = expanded ? 'Show all sections' : 'Hide all sections'
|
|
125
120
|
var action = expanded ? 'accordionOpened' : 'accordionClosed'
|
|
@@ -141,7 +136,7 @@ window.GOVUK.Modules.GovukAccordion = window.GOVUKFrontend.Accordion;
|
|
|
141
136
|
}
|
|
142
137
|
|
|
143
138
|
GemAccordion.prototype.addEventListenerSections = function () {
|
|
144
|
-
var sections = this.$module.querySelectorAll(
|
|
139
|
+
var sections = this.$module.querySelectorAll(this.sectionButton)
|
|
145
140
|
nodeListForEach(sections, function (section) {
|
|
146
141
|
section.addEventListener('click', this.addAccordionSectionTracking.bind(this, section))
|
|
147
142
|
}.bind(this))
|
|
@@ -150,7 +145,7 @@ window.GOVUK.Modules.GovukAccordion = window.GOVUKFrontend.Accordion;
|
|
|
150
145
|
// If the Accordion's sections are opened on click, then pass them to the GA event tracking
|
|
151
146
|
GemAccordion.prototype.addAccordionSectionTracking = function (section) {
|
|
152
147
|
var expanded = section.getAttribute('aria-expanded') === 'false'
|
|
153
|
-
var label = section.querySelector(
|
|
148
|
+
var label = section.querySelector(this.headingText).textContent
|
|
154
149
|
var action = expanded ? 'accordionOpened' : 'accordionClosed'
|
|
155
150
|
var options = { transport: 'beacon', label: label }
|
|
156
151
|
|
|
@@ -6,6 +6,7 @@ module GovukPublishingComponents
|
|
|
6
6
|
@path = path
|
|
7
7
|
application_found = application_exists(path)
|
|
8
8
|
components_found = []
|
|
9
|
+
@component_locations = {}
|
|
9
10
|
@gem_style_references = []
|
|
10
11
|
@jquery_references = []
|
|
11
12
|
|
|
@@ -25,15 +26,15 @@ module GovukPublishingComponents
|
|
|
25
26
|
@find_all_javascripts = /\/\/ *= require govuk_publishing_components\/all_components/
|
|
26
27
|
find_javascripts = /(?<=require govuk_publishing_components\/components\/)[a-zA-Z_-]+/
|
|
27
28
|
|
|
28
|
-
components_in_templates = find_components(templates, find_components, "templates") || []
|
|
29
|
-
components_in_stylesheets = find_components(stylesheets, find_stylesheets, "stylesheets") || []
|
|
30
|
-
components_in_print_stylesheets = find_components(stylesheets, find_print_stylesheets, "print_stylesheets") || []
|
|
31
|
-
components_in_javascripts = find_components(javascripts, find_javascripts, "javascripts") || []
|
|
29
|
+
components_in_templates = find_components(templates, find_components, "templates", true) || []
|
|
30
|
+
components_in_stylesheets = find_components(stylesheets, find_stylesheets, "stylesheets", false) || []
|
|
31
|
+
components_in_print_stylesheets = find_components(stylesheets, find_print_stylesheets, "print_stylesheets", false) || []
|
|
32
|
+
components_in_javascripts = find_components(javascripts, find_javascripts, "javascripts", false) || []
|
|
32
33
|
|
|
33
34
|
ruby_paths = %w[/app/helpers/ /app/presenters/ /lib/]
|
|
34
35
|
components_in_ruby = []
|
|
35
36
|
ruby_paths.each do |ruby_path|
|
|
36
|
-
components_in_ruby << find_components(Dir["#{path}#{ruby_path}**/*.{rb,erb}"], find_components, "ruby") || []
|
|
37
|
+
components_in_ruby << find_components(Dir["#{path}#{ruby_path}**/*.{rb,erb}"], find_components, "ruby", true) || []
|
|
37
38
|
end
|
|
38
39
|
components_in_ruby = components_in_ruby.flatten.uniq
|
|
39
40
|
|
|
@@ -67,17 +68,32 @@ module GovukPublishingComponents
|
|
|
67
68
|
components_found: components_found,
|
|
68
69
|
gem_style_references: @gem_style_references.flatten.uniq.sort,
|
|
69
70
|
jquery_references: @jquery_references.flatten.uniq.sort,
|
|
71
|
+
component_locations: @component_locations,
|
|
70
72
|
}
|
|
71
73
|
end
|
|
72
74
|
|
|
73
75
|
private
|
|
74
76
|
|
|
75
|
-
def find_components(files, find, type)
|
|
77
|
+
def find_components(files, find, type, keep_locations)
|
|
76
78
|
components_found = []
|
|
77
79
|
|
|
78
80
|
files.each do |file|
|
|
79
81
|
src = File.read(file)
|
|
80
|
-
|
|
82
|
+
|
|
83
|
+
if keep_locations
|
|
84
|
+
components = find_match(find, src, type)
|
|
85
|
+
if components.any?
|
|
86
|
+
components_found << components
|
|
87
|
+
components.each do |component|
|
|
88
|
+
component_sym = component.to_sym
|
|
89
|
+
@component_locations[component_sym] = [] unless @component_locations[component_sym]
|
|
90
|
+
@component_locations[component_sym] << clean_file_path(file)
|
|
91
|
+
@component_locations[component_sym].sort!
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
else
|
|
95
|
+
components_found << find_match(find, src, type)
|
|
96
|
+
end
|
|
81
97
|
|
|
82
98
|
if type == "javascripts"
|
|
83
99
|
jquery_references = find_code_references(file, src, /\$\(/)
|
|
@@ -93,12 +109,16 @@ module GovukPublishingComponents
|
|
|
93
109
|
components_found.flatten.uniq.sort
|
|
94
110
|
end
|
|
95
111
|
|
|
112
|
+
# looks for components in the given src of a file
|
|
113
|
+
# returns an array of component names or an empty array
|
|
96
114
|
def find_match(find, src, type)
|
|
97
115
|
return %w[all] if src.match(@find_all_stylesheets) && type == "stylesheets"
|
|
98
116
|
return %w[all] if src.match(@find_all_print_stylesheets) && type == "print_stylesheets"
|
|
99
117
|
return %w[all] if src.match(@find_all_javascripts) && type == "javascripts"
|
|
100
118
|
|
|
101
119
|
matches = src.scan(find)
|
|
120
|
+
return [] unless matches.any?
|
|
121
|
+
|
|
102
122
|
all_matches = []
|
|
103
123
|
matches.each do |match|
|
|
104
124
|
all_matches << clean_file_name(match.tr('[])\'"', ""))
|
|
@@ -108,9 +128,11 @@ module GovukPublishingComponents
|
|
|
108
128
|
end
|
|
109
129
|
|
|
110
130
|
def find_code_references(file, src, regex)
|
|
111
|
-
clean_file_path
|
|
131
|
+
return clean_file_path(file) if regex.match?(src)
|
|
132
|
+
end
|
|
112
133
|
|
|
113
|
-
|
|
134
|
+
def clean_file_path(file)
|
|
135
|
+
file[/(?<=#{Regexp.escape(@path.to_s)}\/)[\/a-zA-Z_-]+.[a-zA-Z.]+/]
|
|
114
136
|
end
|
|
115
137
|
|
|
116
138
|
def clean_file_name(name)
|
|
@@ -106,6 +106,7 @@ module GovukPublishingComponents
|
|
|
106
106
|
warning_count: warnings.length,
|
|
107
107
|
gem_style_references: result[:gem_style_references],
|
|
108
108
|
jquery_references: result[:jquery_references],
|
|
109
|
+
component_locations: result[:component_locations],
|
|
109
110
|
}
|
|
110
111
|
else
|
|
111
112
|
data << {
|
|
@@ -244,28 +245,33 @@ module GovukPublishingComponents
|
|
|
244
245
|
(haystack - needle).flatten.sort
|
|
245
246
|
end
|
|
246
247
|
|
|
248
|
+
# returns details of component inclusion by applications
|
|
247
249
|
def get_components_by_application
|
|
248
250
|
results = []
|
|
249
251
|
found_something = false
|
|
250
252
|
|
|
251
253
|
@gem_data[:component_listing].each do |component|
|
|
252
|
-
|
|
254
|
+
component_name = component[:name]
|
|
255
|
+
locations = []
|
|
253
256
|
|
|
254
257
|
@applications_data.each do |application|
|
|
255
|
-
next unless application[:application_found]
|
|
258
|
+
next unless application[:application_found] && application[:component_locations][component_name.to_sym]
|
|
256
259
|
|
|
257
|
-
|
|
260
|
+
application_name = application[:name]
|
|
258
261
|
found_something = true
|
|
259
262
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
+
locations << {
|
|
264
|
+
name: application_name,
|
|
265
|
+
locations: application[:component_locations][component_name.to_sym],
|
|
266
|
+
}
|
|
263
267
|
end
|
|
264
268
|
|
|
269
|
+
locations = locations.flatten
|
|
270
|
+
|
|
265
271
|
results << {
|
|
266
|
-
component:
|
|
267
|
-
count:
|
|
268
|
-
|
|
272
|
+
component: component_name,
|
|
273
|
+
count: locations.length,
|
|
274
|
+
locations: locations,
|
|
269
275
|
}
|
|
270
276
|
end
|
|
271
277
|
|
|
@@ -63,10 +63,28 @@
|
|
|
63
63
|
<% @components[:components_by_application].each do |component| %>
|
|
64
64
|
<div class="govuk-summary-list__row">
|
|
65
65
|
<dt class="govuk-summary-list__key">
|
|
66
|
-
<%= component[:component] %> (<%= component[:count] %>)
|
|
66
|
+
<%= component[:component] %> (<%= pluralize(component[:count], 'use') %>)
|
|
67
67
|
</dt>
|
|
68
68
|
<dd class="govuk-summary-list__value">
|
|
69
|
-
|
|
69
|
+
<% component[:locations].each do |application| %>
|
|
70
|
+
<% github_link = 'https://github.com/alphagov/' + application[:name] + '/blob/main/' %>
|
|
71
|
+
<details class="govuk-details govuk-!-margin-bottom-2" data-module="govuk-details">
|
|
72
|
+
<summary class="govuk-details__summary">
|
|
73
|
+
<span class="govuk-details__summary-text">
|
|
74
|
+
<%= application[:name] %> (<%= application[:locations].length %>)
|
|
75
|
+
</span>
|
|
76
|
+
</summary>
|
|
77
|
+
<div class="govuk-details__text">
|
|
78
|
+
<ul class="govuk-list govuk-list--bullet">
|
|
79
|
+
<% application[:locations].each do |location| %>
|
|
80
|
+
<li>
|
|
81
|
+
<a href="<%= github_link %><%= location %>" class="govuk-link"><%= location %></a>
|
|
82
|
+
</li>
|
|
83
|
+
<% end %>
|
|
84
|
+
</ul>
|
|
85
|
+
</div>
|
|
86
|
+
</details>
|
|
87
|
+
<% end %>
|
|
70
88
|
</dd>
|
|
71
89
|
</div>
|
|
72
90
|
<% end %>
|
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
%>
|
|
14
14
|
|
|
15
15
|
<% @table = capture do %>
|
|
16
|
-
<%= GovukPublishingComponents::AppHelpers::TableHelper.helper(self, caption,
|
|
16
|
+
<%= GovukPublishingComponents::AppHelpers::TableHelper.helper(self, caption, {
|
|
17
17
|
sortable: sortable,
|
|
18
18
|
filterable: filterable,
|
|
19
|
-
caption_classes: caption_classes
|
|
19
|
+
caption_classes: caption_classes,
|
|
20
|
+
table_id: table_id
|
|
20
21
|
}) do |t| %>
|
|
21
22
|
|
|
22
23
|
<% if head.any? %>
|
|
@@ -36,8 +36,8 @@ examples:
|
|
|
36
36
|
with_data_attributes:
|
|
37
37
|
description: |
|
|
38
38
|
If a `href` attribute is present, `data_attributes` will apply to the `span` containing the number value (see below).
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
|
|
40
|
+
Note that the component does not include built in tracking. If this is required consider using the [track click script](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics/track-click.md).
|
|
41
41
|
data:
|
|
42
42
|
number: 23
|
|
43
43
|
label: Ministerial departments
|
|
@@ -2,9 +2,9 @@ name: "Breadcrumbs"
|
|
|
2
2
|
description: "Navigational breadcrumbs, showing page hierarchy"
|
|
3
3
|
body: |
|
|
4
4
|
Accepts an array of breadcrumb objects. Each crumb must have a title and a URL.
|
|
5
|
-
Links have tracking data but links to the homepage (any link with a url of `/`) will be tracked separately as `homeLinkClicked
|
|
5
|
+
Links have tracking data but links to the homepage (any link with a url of `/`) will be tracked separately as `homeLinkClicked`.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
We recommend that if using the breadcrumbs for navigation purposes, you set `collapse_on_mobile` to `true` to make things more readable for mobile users. However, you can specify `collapse_on_mobile:``false` or remove the flag completely to stop this behaviour.
|
|
8
8
|
shared_accessibility_criteria:
|
|
9
9
|
- link
|
|
10
10
|
accessibility_criteria:
|
|
@@ -23,92 +23,93 @@ govuk_frontend_components:
|
|
|
23
23
|
examples:
|
|
24
24
|
default:
|
|
25
25
|
data:
|
|
26
|
-
text:
|
|
26
|
+
text: Submit
|
|
27
27
|
link_button:
|
|
28
28
|
data:
|
|
29
|
-
text:
|
|
30
|
-
href:
|
|
29
|
+
text: I'm really a link sssh
|
|
30
|
+
href: '#'
|
|
31
31
|
link_button_target_blank:
|
|
32
32
|
data:
|
|
33
|
-
text:
|
|
34
|
-
href:
|
|
35
|
-
target:
|
|
33
|
+
text: I'm really a link sssh
|
|
34
|
+
href: http://www.gov.uk
|
|
35
|
+
target: _blank
|
|
36
36
|
with_type:
|
|
37
37
|
description: Buttons default to having a type of submit, but in some cases it may be desirable to have a different type.
|
|
38
38
|
data:
|
|
39
|
-
text:
|
|
40
|
-
type:
|
|
39
|
+
text: Button type button
|
|
40
|
+
type: button
|
|
41
41
|
start_now_button:
|
|
42
42
|
data:
|
|
43
|
-
text:
|
|
44
|
-
href:
|
|
43
|
+
text: Start now
|
|
44
|
+
href: '#'
|
|
45
45
|
start: true
|
|
46
|
-
rel:
|
|
46
|
+
rel: external
|
|
47
47
|
secondary_button:
|
|
48
48
|
data:
|
|
49
|
-
text:
|
|
49
|
+
text: Secondary button
|
|
50
50
|
secondary: true
|
|
51
51
|
secondary_quiet_button:
|
|
52
52
|
data:
|
|
53
|
-
text:
|
|
53
|
+
text: Secondary quiet button
|
|
54
54
|
secondary_quiet: true
|
|
55
55
|
secondary_solid_button:
|
|
56
56
|
data:
|
|
57
|
-
text:
|
|
57
|
+
text: Secondary solid button
|
|
58
58
|
secondary_solid: true
|
|
59
59
|
destructive_button:
|
|
60
60
|
data:
|
|
61
|
-
text:
|
|
61
|
+
text: Destructive button
|
|
62
62
|
destructive: true
|
|
63
63
|
start_now_button_with_info_text:
|
|
64
64
|
data:
|
|
65
|
-
text:
|
|
66
|
-
href:
|
|
65
|
+
text: Start now
|
|
66
|
+
href: '#'
|
|
67
67
|
start: true
|
|
68
|
-
info_text:
|
|
68
|
+
info_text: Sometimes you want to explain where a user is going to.
|
|
69
69
|
with_margin_bottom:
|
|
70
70
|
description: The component accepts a number for margin bottom from `0` to `9` (`0px` to `60px`) using the [GOV.UK Frontend spacing scale](https://design-system.service.gov.uk/styles/spacing/#the-responsive-spacing-scale). It defaults to having no margin bottom.
|
|
71
71
|
data:
|
|
72
|
-
text:
|
|
72
|
+
text: Submit
|
|
73
73
|
margin_bottom: 6
|
|
74
74
|
start_now_button_with_info_text_and_margin_bottom:
|
|
75
75
|
description: When the component requires margin bottom and has info text, the margin is applied to the info text.
|
|
76
76
|
data:
|
|
77
|
-
text:
|
|
78
|
-
href:
|
|
77
|
+
text: Start now
|
|
78
|
+
href: '#'
|
|
79
79
|
start: true
|
|
80
|
-
info_text:
|
|
80
|
+
info_text: Sometimes you want to explain where a user is going to and have a margin bottom
|
|
81
81
|
margin_bottom: 6
|
|
82
82
|
extreme_text:
|
|
83
83
|
data:
|
|
84
|
-
text:
|
|
85
|
-
href:
|
|
84
|
+
text: I'm a button with lots of text to test how the component scales at extremes.
|
|
85
|
+
href: '#'
|
|
86
86
|
extreme_text_start_now_button:
|
|
87
87
|
data:
|
|
88
|
-
text:
|
|
88
|
+
text: I'm a start now button with lots of text to test how the component scales at extremes.
|
|
89
89
|
start: true
|
|
90
|
-
href:
|
|
90
|
+
href: '#'
|
|
91
91
|
with_data_attributes:
|
|
92
|
+
description: Data attributes can be applied as required. Note that the component does not include built in tracking. If this is required consider using the [track click script](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics/track-click.md).
|
|
92
93
|
data:
|
|
93
|
-
text:
|
|
94
|
+
text: Track this!
|
|
94
95
|
margin_bottom: true
|
|
95
96
|
data_attributes: {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
module: cross-domain-tracking,
|
|
98
|
+
tracking-code: GA-123ABC,
|
|
99
|
+
tracking-name: transactionTracker
|
|
99
100
|
}
|
|
100
101
|
with_title_attribute:
|
|
101
102
|
data:
|
|
102
|
-
text:
|
|
103
|
+
text: Click me
|
|
103
104
|
margin_bottom: true
|
|
104
|
-
title:
|
|
105
|
+
title: A button to click
|
|
105
106
|
inline_layout:
|
|
106
107
|
description: Buttons will display adjacent to each other until mobile view, when they will appear on top of each other.
|
|
107
108
|
embed: |
|
|
108
109
|
<button class="gem-c-button govuk-button gem-c-button--inline">First button</button>
|
|
109
110
|
<%= component %>
|
|
110
111
|
data:
|
|
111
|
-
text:
|
|
112
|
+
text: Second button
|
|
112
113
|
inline_layout: true
|
|
113
114
|
with_name_and_value_set:
|
|
114
115
|
description: |
|
|
@@ -116,15 +117,15 @@ examples:
|
|
|
116
117
|
|
|
117
118
|
Please note that Internet Explorer 6 and 7 have **breaking bugs** when submitting a form with multiple buttons - this can [change what value is submitted by the button](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Notes). Make sure to check your user needs and browser usage.
|
|
118
119
|
data:
|
|
119
|
-
text:
|
|
120
|
-
value:
|
|
121
|
-
name:
|
|
120
|
+
text: This is the button text
|
|
121
|
+
value: this_is_the_value
|
|
122
|
+
name: this_is_the_name
|
|
122
123
|
with_js_classes:
|
|
123
124
|
description: Use `js-` prefixed classes only as interaction hooks – to query and operate on elements via JavaScript
|
|
124
125
|
data:
|
|
125
|
-
text:
|
|
126
|
-
classes:
|
|
126
|
+
text: Button
|
|
127
|
+
classes: js-selector-1 js-selector-2
|
|
127
128
|
with_aria_label:
|
|
128
129
|
data:
|
|
129
|
-
text:
|
|
130
|
-
aria_label:
|
|
130
|
+
text: Button
|
|
131
|
+
aria_label: Button with custom label
|
|
@@ -119,6 +119,8 @@ examples:
|
|
|
119
119
|
with_data_attributes:
|
|
120
120
|
description: |
|
|
121
121
|
Data attributes can be passed to individual links within the component as shown.
|
|
122
|
+
|
|
123
|
+
Note that the component does not include built in tracking. If this is required consider using the [track click script](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics/track-click.md).
|
|
122
124
|
data:
|
|
123
125
|
items:
|
|
124
126
|
- link:
|