govuk_publishing_components 12.20.0 → 12.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/govuk_publishing_components/components/_image-card.scss +2 -2
- data/app/assets/stylesheets/govuk_publishing_components/components/_related-navigation.scss +8 -0
- data/app/views/govuk_publishing_components/components/_contextual_breadcrumbs.html.erb +8 -8
- data/app/views/govuk_publishing_components/components/_contextual_footer.html.erb +10 -0
- data/app/views/govuk_publishing_components/components/_contextual_sidebar.html.erb +5 -14
- data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +5 -3
- data/app/views/govuk_publishing_components/components/_related_navigation.html.erb +10 -6
- data/app/views/govuk_publishing_components/components/docs/contextual_breadcrumbs.yml +3 -2
- data/app/views/govuk_publishing_components/components/docs/contextual_footer.yml +71 -0
- data/app/views/govuk_publishing_components/components/docs/contextual_sidebar.yml +18 -9
- data/app/views/govuk_publishing_components/components/docs/layout_footer.yml +17 -0
- data/app/views/govuk_publishing_components/components/docs/related_navigation.yml +53 -0
- data/app/views/govuk_publishing_components/components/related_navigation/_section.html.erb +10 -5
- data/config/locales/en.yml +5 -6
- data/lib/govuk_publishing_components.rb +0 -2
- data/lib/govuk_publishing_components/presenters/contextual_navigation.rb +0 -4
- data/lib/govuk_publishing_components/presenters/related_navigation_helper.rb +108 -90
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/govuk-frontend/components/back-link/README.md +4 -73
- data/node_modules/govuk-frontend/components/breadcrumbs/README.md +4 -238
- data/node_modules/govuk-frontend/components/button/README.md +4 -174
- data/node_modules/govuk-frontend/components/character-count/README.md +4 -340
- data/node_modules/govuk-frontend/components/character-count/template.njk +0 -3
- data/node_modules/govuk-frontend/components/checkboxes/README.md +4 -705
- data/node_modules/govuk-frontend/components/checkboxes/template.njk +1 -0
- data/node_modules/govuk-frontend/components/date-input/README.md +4 -563
- data/node_modules/govuk-frontend/components/date-input/template.njk +1 -0
- data/node_modules/govuk-frontend/components/details/README.md +4 -128
- data/node_modules/govuk-frontend/components/error-message/README.md +4 -58
- data/node_modules/govuk-frontend/components/error-summary/README.md +4 -94
- data/node_modules/govuk-frontend/components/fieldset/README.md +4 -92
- data/node_modules/govuk-frontend/components/file-upload/README.md +4 -199
- data/node_modules/govuk-frontend/components/file-upload/template.njk +1 -0
- data/node_modules/govuk-frontend/components/footer/README.md +4 -91
- data/node_modules/govuk-frontend/components/footer/_footer.scss +22 -13
- data/node_modules/govuk-frontend/components/header/README.md +4 -351
- data/node_modules/govuk-frontend/components/hint/README.md +5 -77
- data/node_modules/govuk-frontend/components/input/README.md +4 -407
- data/node_modules/govuk-frontend/components/input/template.njk +1 -0
- data/node_modules/govuk-frontend/components/inset-text/README.md +4 -76
- data/node_modules/govuk-frontend/components/label/README.md +5 -97
- data/node_modules/govuk-frontend/components/panel/README.md +4 -93
- data/node_modules/govuk-frontend/components/phase-banner/README.md +4 -67
- data/node_modules/govuk-frontend/components/radios/README.md +4 -665
- data/node_modules/govuk-frontend/components/radios/template.njk +1 -0
- data/node_modules/govuk-frontend/components/select/README.md +4 -257
- data/node_modules/govuk-frontend/components/select/template.njk +1 -0
- data/node_modules/govuk-frontend/components/skip-link/README.md +4 -57
- data/node_modules/govuk-frontend/components/table/README.md +4 -368
- data/node_modules/govuk-frontend/components/tabs/README.md +4 -242
- data/node_modules/govuk-frontend/components/tag/README.md +4 -77
- data/node_modules/govuk-frontend/components/textarea/README.md +4 -193
- data/node_modules/govuk-frontend/components/textarea/template.njk +1 -0
- data/node_modules/govuk-frontend/components/warning-text/README.md +4 -63
- data/node_modules/govuk-frontend/components/warning-text/_warning-text.scss +1 -2
- data/node_modules/govuk-frontend/core/_lists.scss +17 -8
- data/node_modules/govuk-frontend/package.json +10 -10
- metadata +4 -5
- data/app/views/govuk_publishing_components/components/_taxonomy_navigation.html.erb +0 -116
- data/app/views/govuk_publishing_components/components/docs/taxonomy_navigation.yml +0 -119
- data/lib/govuk_publishing_components/presenters/taxonomy_navigation.rb +0 -47
@@ -1,185 +1,15 @@
|
|
1
1
|
# Button
|
2
2
|
|
3
|
-
##
|
3
|
+
## Installation
|
4
4
|
|
5
|
-
|
5
|
+
See the [main README quick start guide](https://github.com/alphagov/govuk-frontend#quick-start) for how to install this component.
|
6
6
|
|
7
|
-
## Guidance
|
7
|
+
## Guidance and Examples
|
8
8
|
|
9
9
|
Find out when to use the button component in your service in the [GOV.UK Design System](https://design-system.service.gov.uk/components/button).
|
10
10
|
|
11
|
-
## Quick start examples
|
12
|
-
|
13
|
-
Buttons are configured to perform an action and they can have a different look. For example, they can be disabled until a valid action has been performed by the user.
|
14
|
-
|
15
|
-
### Button
|
16
|
-
|
17
|
-
[Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/button/preview)
|
18
|
-
|
19
|
-
#### Markup
|
20
|
-
|
21
|
-
<button type="submit" class="govuk-button">
|
22
|
-
Save and continue
|
23
|
-
</button>
|
24
|
-
|
25
|
-
#### Macro
|
26
|
-
|
27
|
-
{% from "button/macro.njk" import govukButton %}
|
28
|
-
|
29
|
-
{{ govukButton({
|
30
|
-
"text": "Save and continue"
|
31
|
-
}) }}
|
32
|
-
|
33
|
-
### Button disabled
|
34
|
-
|
35
|
-
[Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/button/disabled/preview)
|
36
|
-
|
37
|
-
#### Markup
|
38
|
-
|
39
|
-
<button type="submit" disabled="disabled" aria-disabled="true" class="govuk-button govuk-button--disabled">
|
40
|
-
Disabled button
|
41
|
-
</button>
|
42
|
-
|
43
|
-
#### Macro
|
44
|
-
|
45
|
-
{% from "button/macro.njk" import govukButton %}
|
46
|
-
|
47
|
-
{{ govukButton({
|
48
|
-
"text": "Disabled button",
|
49
|
-
"disabled": true
|
50
|
-
}) }}
|
51
|
-
|
52
|
-
### Button link
|
53
|
-
|
54
|
-
[Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/button/link/preview)
|
55
|
-
|
56
|
-
#### Markup
|
57
|
-
|
58
|
-
<a href="/" role="button" draggable="false" class="govuk-button">
|
59
|
-
Link button
|
60
|
-
</a>
|
61
|
-
|
62
|
-
#### Macro
|
63
|
-
|
64
|
-
{% from "button/macro.njk" import govukButton %}
|
65
|
-
|
66
|
-
{{ govukButton({
|
67
|
-
"text": "Link button",
|
68
|
-
"href": "/"
|
69
|
-
}) }}
|
70
|
-
|
71
|
-
### Button link disabled
|
72
|
-
|
73
|
-
[Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/button/link-disabled/preview)
|
74
|
-
|
75
|
-
#### Markup
|
76
|
-
|
77
|
-
<a href="/" role="button" draggable="false" class="govuk-button govuk-button--disabled">
|
78
|
-
Disabled link button
|
79
|
-
</a>
|
80
|
-
|
81
|
-
#### Macro
|
82
|
-
|
83
|
-
{% from "button/macro.njk" import govukButton %}
|
84
|
-
|
85
|
-
{{ govukButton({
|
86
|
-
"text": "Disabled link button",
|
87
|
-
"href": "/",
|
88
|
-
"disabled": true
|
89
|
-
}) }}
|
90
|
-
|
91
|
-
### Button start link
|
92
|
-
|
93
|
-
[Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/button/start-link/preview)
|
94
|
-
|
95
|
-
#### Markup
|
96
|
-
|
97
|
-
<a href="/" role="button" draggable="false" class="govuk-button govuk-button--start">
|
98
|
-
Start now link button
|
99
|
-
</a>
|
100
|
-
|
101
|
-
#### Macro
|
102
|
-
|
103
|
-
{% from "button/macro.njk" import govukButton %}
|
104
|
-
|
105
|
-
{{ govukButton({
|
106
|
-
"text": "Start now link button",
|
107
|
-
"href": "/",
|
108
|
-
"classes": "govuk-button--start"
|
109
|
-
}) }}
|
110
|
-
|
111
|
-
### Button input
|
112
|
-
|
113
|
-
[Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/button/input/preview)
|
114
|
-
|
115
|
-
#### Markup
|
116
|
-
|
117
|
-
<input value="Start now" name="start-now" type="submit" class="govuk-button">
|
118
|
-
|
119
|
-
#### Macro
|
120
|
-
|
121
|
-
{% from "button/macro.njk" import govukButton %}
|
122
|
-
|
123
|
-
{{ govukButton({
|
124
|
-
"element": "input",
|
125
|
-
"name": "start-now",
|
126
|
-
"text": "Start now"
|
127
|
-
}) }}
|
128
|
-
|
129
|
-
### Button input disabled
|
130
|
-
|
131
|
-
[Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/button/input-disabled/preview)
|
132
|
-
|
133
|
-
#### Markup
|
134
|
-
|
135
|
-
<input value="Explicit input button disabled" type="submit" disabled="disabled" aria-disabled="true" class="govuk-button govuk-button--disabled">
|
136
|
-
|
137
|
-
#### Macro
|
138
|
-
|
139
|
-
{% from "button/macro.njk" import govukButton %}
|
140
|
-
|
141
|
-
{{ govukButton({
|
142
|
-
"element": "input",
|
143
|
-
"text": "Explicit input button disabled",
|
144
|
-
"disabled": true
|
145
|
-
}) }}
|
146
|
-
|
147
|
-
## Requirements
|
148
|
-
|
149
|
-
### Build tool configuration
|
150
|
-
|
151
|
-
When compiling the Sass files you'll need to define includePaths to reference the node_modules directory. Below is a sample configuration using gulp
|
152
|
-
|
153
|
-
.pipe(sass({
|
154
|
-
includePaths: 'node_modules/'
|
155
|
-
}))
|
156
|
-
|
157
|
-
### Static asset path configuration
|
158
|
-
|
159
|
-
In order to include the images used in the components, you need to configure your app to show these assets. Below is a sample configuration using Express js:
|
160
|
-
|
161
|
-
app.use('/assets', express.static(path.join(__dirname, '/node_modules/govuk-frontend/assets')))
|
162
|
-
|
163
11
|
## Component options
|
164
12
|
|
165
13
|
Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.
|
166
14
|
|
167
|
-
See [options table](https://design-system.service.gov.uk/components/button/#options-example-default) for details.
|
168
|
-
|
169
|
-
### Setting up Nunjucks views and paths
|
170
|
-
|
171
|
-
Below is an example setup using express configure views:
|
172
|
-
|
173
|
-
nunjucks.configure('node_modules/govuk-frontend/components', {
|
174
|
-
autoescape: true,
|
175
|
-
cache: false,
|
176
|
-
express: app
|
177
|
-
})
|
178
|
-
|
179
|
-
## Contribution
|
180
|
-
|
181
|
-
Guidelines can be found at [on our Github repository.](https://github.com/alphagov/govuk-frontend/blob/master/CONTRIBUTING.md "link to contributing guidelines on our github repository")
|
182
|
-
|
183
|
-
## License
|
184
|
-
|
185
|
-
MIT
|
15
|
+
See [options table](https://design-system.service.gov.uk/components/button/#options-example-default) for details.
|
@@ -1,351 +1,15 @@
|
|
1
1
|
# Character count
|
2
2
|
|
3
|
-
##
|
3
|
+
## Installation
|
4
4
|
|
5
|
-
|
5
|
+
See the [main README quick start guide](https://github.com/alphagov/govuk-frontend#quick-start) for how to install this component.
|
6
6
|
|
7
|
-
## Guidance
|
7
|
+
## Guidance and Examples
|
8
8
|
|
9
9
|
Find out when to use the character count component in your service in the [GOV.UK Design System](https://design-system.service.gov.uk/components/character-count).
|
10
10
|
|
11
|
-
## Quick start examples
|
12
|
-
|
13
|
-
### Character count
|
14
|
-
|
15
|
-
[Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/character-count/preview)
|
16
|
-
|
17
|
-
#### Markup
|
18
|
-
|
19
|
-
<div class="govuk-character-count" data-module="character-count" data-maxlength="10">
|
20
|
-
|
21
|
-
<div class="govuk-form-group">
|
22
|
-
<label class="govuk-label" for="more-detail">
|
23
|
-
Can you provide more detail?
|
24
|
-
</label>
|
25
|
-
|
26
|
-
<textarea class="govuk-textarea js-character-count " id="more-detail" name="more-detail" rows="5"></textarea>
|
27
|
-
</div>
|
28
|
-
|
29
|
-
<span id="more-detail-info" class="govuk-hint govuk-character-count__message" aria-live="polite">
|
30
|
-
You can enter up to 10 characters
|
31
|
-
</span>
|
32
|
-
</div>
|
33
|
-
|
34
|
-
#### Macro
|
35
|
-
|
36
|
-
{% from "character-count/macro.njk" import govukCharacterCount %}
|
37
|
-
|
38
|
-
{{ govukCharacterCount({
|
39
|
-
"name": "more-detail",
|
40
|
-
"id": "more-detail",
|
41
|
-
"maxlength": 10,
|
42
|
-
"label": {
|
43
|
-
"text": "Can you provide more detail?"
|
44
|
-
}
|
45
|
-
}) }}
|
46
|
-
|
47
|
-
### Character count with hint
|
48
|
-
|
49
|
-
[Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/character-count/with-hint/preview)
|
50
|
-
|
51
|
-
#### Markup
|
52
|
-
|
53
|
-
<div class="govuk-character-count" data-module="character-count" data-maxlength="10">
|
54
|
-
|
55
|
-
<div class="govuk-form-group">
|
56
|
-
<label class="govuk-label" for="with-hint">
|
57
|
-
Can you provide more detail?
|
58
|
-
</label>
|
59
|
-
|
60
|
-
<span id="with-hint-hint" class="govuk-hint">
|
61
|
-
Don't include personal or financial information, eg your National Insurance number or credit card details.
|
62
|
-
</span>
|
63
|
-
|
64
|
-
<textarea class="govuk-textarea js-character-count " id="with-hint" name="with-hint" rows="5" aria-describedby="with-hint-hint"></textarea>
|
65
|
-
</div>
|
66
|
-
|
67
|
-
<span id="with-hint-info" class="govuk-hint govuk-character-count__message" aria-live="polite">
|
68
|
-
You can enter up to 10 characters
|
69
|
-
</span>
|
70
|
-
</div>
|
71
|
-
|
72
|
-
#### Macro
|
73
|
-
|
74
|
-
{% from "character-count/macro.njk" import govukCharacterCount %}
|
75
|
-
|
76
|
-
{{ govukCharacterCount({
|
77
|
-
"name": "with-hint",
|
78
|
-
"id": "with-hint",
|
79
|
-
"maxlength": 10,
|
80
|
-
"label": {
|
81
|
-
"text": "Can you provide more detail?"
|
82
|
-
},
|
83
|
-
"hint": {
|
84
|
-
"text": "Don't include personal or financial information, eg your National Insurance number or credit card details."
|
85
|
-
}
|
86
|
-
}) }}
|
87
|
-
|
88
|
-
### Character count with default value
|
89
|
-
|
90
|
-
[Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/character-count/with-default-value/preview)
|
91
|
-
|
92
|
-
#### Markup
|
93
|
-
|
94
|
-
<div class="govuk-character-count" data-module="character-count" data-maxlength="100">
|
95
|
-
|
96
|
-
<div class="govuk-form-group">
|
97
|
-
<label class="govuk-label" for="with-default-value">
|
98
|
-
Full address
|
99
|
-
</label>
|
100
|
-
|
101
|
-
<textarea class="govuk-textarea js-character-count " id="with-default-value" name="default-value" rows="5">221B Baker Street
|
102
|
-
London
|
103
|
-
NW1 6XE
|
104
|
-
</textarea>
|
105
|
-
</div>
|
106
|
-
|
107
|
-
<span id="with-default-value-info" class="govuk-hint govuk-character-count__message" aria-live="polite">
|
108
|
-
You can enter up to 100 characters
|
109
|
-
</span>
|
110
|
-
</div>
|
111
|
-
|
112
|
-
#### Macro
|
113
|
-
|
114
|
-
{% from "character-count/macro.njk" import govukCharacterCount %}
|
115
|
-
|
116
|
-
{{ govukCharacterCount({
|
117
|
-
"id": "with-default-value",
|
118
|
-
"name": "default-value",
|
119
|
-
"maxlength": 100,
|
120
|
-
"label": {
|
121
|
-
"text": "Full address"
|
122
|
-
},
|
123
|
-
"value": "221B Baker Street\nLondon\nNW1 6XE\n"
|
124
|
-
}) }}
|
125
|
-
|
126
|
-
### Character count with default value exceeding limit
|
127
|
-
|
128
|
-
[Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/character-count/with-default-value-exceeding-limit/preview)
|
129
|
-
|
130
|
-
#### Markup
|
131
|
-
|
132
|
-
<div class="govuk-character-count" data-module="character-count" data-maxlength="10">
|
133
|
-
|
134
|
-
<div class="govuk-form-group govuk-form-group--error">
|
135
|
-
<label class="govuk-label" for="exceeding-characters">
|
136
|
-
Full address
|
137
|
-
</label>
|
138
|
-
|
139
|
-
<span id="exceeding-characters-error" class="govuk-error-message">
|
140
|
-
Please do not exceed the maximum allowed limit
|
141
|
-
</span>
|
142
|
-
|
143
|
-
<textarea class="govuk-textarea govuk-textarea--error js-character-count govuk-textarea--error" id="exceeding-characters" name="exceeding" rows="5" aria-describedby="exceeding-characters-error">221B Baker Street
|
144
|
-
London
|
145
|
-
NW1 6XE
|
146
|
-
</textarea>
|
147
|
-
</div>
|
148
|
-
|
149
|
-
<span id="exceeding-characters-info" class="govuk-hint govuk-character-count__message" aria-live="polite">
|
150
|
-
You can enter up to 10 characters
|
151
|
-
</span>
|
152
|
-
</div>
|
153
|
-
|
154
|
-
#### Macro
|
155
|
-
|
156
|
-
{% from "character-count/macro.njk" import govukCharacterCount %}
|
157
|
-
|
158
|
-
{{ govukCharacterCount({
|
159
|
-
"id": "exceeding-characters",
|
160
|
-
"name": "exceeding",
|
161
|
-
"maxlength": 10,
|
162
|
-
"value": "221B Baker Street\nLondon\nNW1 6XE\n",
|
163
|
-
"label": {
|
164
|
-
"text": "Full address"
|
165
|
-
},
|
166
|
-
"errorMessage": {
|
167
|
-
"text": "Please do not exceed the maximum allowed limit"
|
168
|
-
}
|
169
|
-
}) }}
|
170
|
-
|
171
|
-
### Character count with custom rows
|
172
|
-
|
173
|
-
[Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/character-count/with-custom-rows/preview)
|
174
|
-
|
175
|
-
#### Markup
|
176
|
-
|
177
|
-
<div class="govuk-character-count" data-module="character-count" data-maxlength="10">
|
178
|
-
|
179
|
-
<div class="govuk-form-group">
|
180
|
-
<label class="govuk-label" for="custom-rows">
|
181
|
-
Full address
|
182
|
-
</label>
|
183
|
-
|
184
|
-
<textarea class="govuk-textarea js-character-count " id="custom-rows" name="custom" rows="8"></textarea>
|
185
|
-
</div>
|
186
|
-
|
187
|
-
<span id="custom-rows-info" class="govuk-hint govuk-character-count__message" aria-live="polite">
|
188
|
-
You can enter up to 10 characters
|
189
|
-
</span>
|
190
|
-
</div>
|
191
|
-
|
192
|
-
#### Macro
|
193
|
-
|
194
|
-
{% from "character-count/macro.njk" import govukCharacterCount %}
|
195
|
-
|
196
|
-
{{ govukCharacterCount({
|
197
|
-
"id": "custom-rows",
|
198
|
-
"name": "custom",
|
199
|
-
"maxlength": 10,
|
200
|
-
"label": {
|
201
|
-
"text": "Full address"
|
202
|
-
},
|
203
|
-
"rows": 8
|
204
|
-
}) }}
|
205
|
-
|
206
|
-
### Character count with label as page heading
|
207
|
-
|
208
|
-
[Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/character-count/with-label-as-page-heading/preview)
|
209
|
-
|
210
|
-
#### Markup
|
211
|
-
|
212
|
-
<div class="govuk-character-count" data-module="character-count" data-maxlength="10">
|
213
|
-
|
214
|
-
<div class="govuk-form-group">
|
215
|
-
<h1 class="govuk-label-wrapper">
|
216
|
-
<label class="govuk-label" for="textarea-with-page-heading">
|
217
|
-
Full address
|
218
|
-
</label>
|
219
|
-
|
220
|
-
</h1>
|
221
|
-
|
222
|
-
<textarea class="govuk-textarea js-character-count " id="textarea-with-page-heading" name="address" rows="5"></textarea>
|
223
|
-
</div>
|
224
|
-
|
225
|
-
<span id="textarea-with-page-heading-info" class="govuk-hint govuk-character-count__message" aria-live="polite">
|
226
|
-
You can enter up to 10 characters
|
227
|
-
</span>
|
228
|
-
</div>
|
229
|
-
|
230
|
-
#### Macro
|
231
|
-
|
232
|
-
{% from "character-count/macro.njk" import govukCharacterCount %}
|
233
|
-
|
234
|
-
{{ govukCharacterCount({
|
235
|
-
"id": "textarea-with-page-heading",
|
236
|
-
"name": "address",
|
237
|
-
"maxlength": 10,
|
238
|
-
"label": {
|
239
|
-
"text": "Full address",
|
240
|
-
"isPageHeading": true
|
241
|
-
}
|
242
|
-
}) }}
|
243
|
-
|
244
|
-
### Character count with word count
|
245
|
-
|
246
|
-
[Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/character-count/with-word-count/preview)
|
247
|
-
|
248
|
-
#### Markup
|
249
|
-
|
250
|
-
<div class="govuk-character-count" data-module="character-count" data-maxwords="10">
|
251
|
-
|
252
|
-
<div class="govuk-form-group">
|
253
|
-
<label class="govuk-label" for="word-count">
|
254
|
-
Full address
|
255
|
-
</label>
|
256
|
-
|
257
|
-
<textarea class="govuk-textarea js-character-count " id="word-count" name="word-count" rows="5"></textarea>
|
258
|
-
</div>
|
259
|
-
|
260
|
-
<span id="word-count-info" class="govuk-hint govuk-character-count__message" aria-live="polite">
|
261
|
-
You can enter up to 10 words
|
262
|
-
</span>
|
263
|
-
</div>
|
264
|
-
|
265
|
-
#### Macro
|
266
|
-
|
267
|
-
{% from "character-count/macro.njk" import govukCharacterCount %}
|
268
|
-
|
269
|
-
{{ govukCharacterCount({
|
270
|
-
"id": "word-count",
|
271
|
-
"name": "word-count",
|
272
|
-
"maxwords": 10,
|
273
|
-
"label": {
|
274
|
-
"text": "Full address"
|
275
|
-
}
|
276
|
-
}) }}
|
277
|
-
|
278
|
-
### Character count with threshold
|
279
|
-
|
280
|
-
[Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/character-count/with-threshold/preview)
|
281
|
-
|
282
|
-
#### Markup
|
283
|
-
|
284
|
-
<div class="govuk-character-count" data-module="character-count" data-maxlength="10" data-threshold="75">
|
285
|
-
|
286
|
-
<div class="govuk-form-group">
|
287
|
-
<label class="govuk-label" for="with-threshold">
|
288
|
-
Full address
|
289
|
-
</label>
|
290
|
-
|
291
|
-
<textarea class="govuk-textarea js-character-count " id="with-threshold" name="with-threshold" rows="5"></textarea>
|
292
|
-
</div>
|
293
|
-
|
294
|
-
<span id="with-threshold-info" class="govuk-hint govuk-character-count__message" aria-live="polite">
|
295
|
-
You can enter up to 10 characters
|
296
|
-
</span>
|
297
|
-
</div>
|
298
|
-
|
299
|
-
#### Macro
|
300
|
-
|
301
|
-
{% from "character-count/macro.njk" import govukCharacterCount %}
|
302
|
-
|
303
|
-
{{ govukCharacterCount({
|
304
|
-
"id": "with-threshold",
|
305
|
-
"name": "with-threshold",
|
306
|
-
"maxlength": 10,
|
307
|
-
"threshold": 75,
|
308
|
-
"label": {
|
309
|
-
"text": "Full address"
|
310
|
-
}
|
311
|
-
}) }}
|
312
|
-
|
313
|
-
## Requirements
|
314
|
-
|
315
|
-
### Build tool configuration
|
316
|
-
|
317
|
-
When compiling the Sass files you'll need to define includePaths to reference the node_modules directory. Below is a sample configuration using gulp
|
318
|
-
|
319
|
-
.pipe(sass({
|
320
|
-
includePaths: 'node_modules/'
|
321
|
-
}))
|
322
|
-
|
323
|
-
### Static asset path configuration
|
324
|
-
|
325
|
-
In order to include the images used in the components, you need to configure your app to show these assets. Below is a sample configuration using Express js:
|
326
|
-
|
327
|
-
app.use('/assets', express.static(path.join(__dirname, '/node_modules/govuk-frontend/assets')))
|
328
|
-
|
329
11
|
## Component options
|
330
12
|
|
331
13
|
Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.
|
332
14
|
|
333
|
-
See [options table](https://design-system.service.gov.uk/components/character-count/#options-example-default) for details.
|
334
|
-
|
335
|
-
### Setting up Nunjucks views and paths
|
336
|
-
|
337
|
-
Below is an example setup using express configure views:
|
338
|
-
|
339
|
-
nunjucks.configure('node_modules/govuk-frontend/components', {
|
340
|
-
autoescape: true,
|
341
|
-
cache: false,
|
342
|
-
express: app
|
343
|
-
})
|
344
|
-
|
345
|
-
## Contribution
|
346
|
-
|
347
|
-
Guidelines can be found at [on our Github repository.](https://github.com/alphagov/govuk-frontend/blob/master/CONTRIBUTING.md "link to contributing guidelines on our github repository")
|
348
|
-
|
349
|
-
## License
|
350
|
-
|
351
|
-
MIT
|
15
|
+
See [options table](https://design-system.service.gov.uk/components/character-count/#options-example-default) for details.
|