govuk_frontend_toolkit 3.1.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ # 3.2.0
2
+
3
+ - Add: Analytics API https://github.com/alphagov/govuk_frontend_toolkit/pull/162 https://github.com/alphagov/govuk_frontend_toolkit/blob/master/docs/analytics.md
4
+
1
5
  # 3.1.0
2
6
 
3
7
  - Fix: outdent to add right margin rather than only left
@@ -30,10 +30,13 @@ module.exports = function(grunt) {
30
30
  javascripts: {
31
31
  src: [
32
32
  'node_modules/jquery-browser/lib/jquery.js',
33
+ 'javascripts/govuk/analytics/google-analytics-classic-tracker.js',
34
+ 'javascripts/govuk/analytics/google-analytics-universal-tracker.js',
35
+ 'javascripts/govuk/analytics/tracker.js',
33
36
  'javascripts/**/*.js'
34
37
  ],
35
38
  options: {
36
- specs: 'spec/unit/*Spec.js',
39
+ specs: 'spec/unit/**/*Spec.js',
37
40
  helpers: 'spec/unit/*Helper.js'
38
41
  }
39
42
  }
data/app/assets/LICENCE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 HM Government
1
+ Copyright (c) 2012 Crown Copyright (Government Digital Service)
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/app/assets/README.md CHANGED
@@ -28,6 +28,11 @@ follow the [installation instructions][toolkit_gem_github_readme].
28
28
  [toolkit_npm_github]: https://github.com/alphagov/govuk_frontend_toolkit_npm
29
29
  [toolkit_npm]: https://npmjs.org/package/govuk_frontend_toolkit
30
30
 
31
+ If you are using a build tool that depends on Libsass then you
32
+ may need to upgrade to a more recent version to use the grid helpers. Minimal
33
+ compatible versions include `node-sass` 1.0.0, `grunt-sass` 0.16.0,
34
+ `gulp-sass` 1.2.0 and `libsass` 3.0.0.
35
+
31
36
  ### Composer
32
37
 
33
38
  [govuk_frontend_toolkit_composer][toolkit_composer_github] is an composer package that can be
@@ -98,840 +103,30 @@ In production:
98
103
 
99
104
  sass --style compressed --load-path [path to]/govuk_frontend_toolkit/stylesheets input.scss output.css
100
105
 
101
-
102
-
103
- ## Mixin-sets
104
-
105
- * [`_grid_layout.scss`](#grid-layout)
106
- * [`_conditionals.scss`](#conditionals)
107
- * [`_colours.scss`](#colours)
108
- * [`_css3.scss`](#css3)
109
- * [`_typography.scss`](#typography)
110
- * [`design-patterns/_buttons.scss`](#buttons)
111
- * [`design-patterns/_alpha-beta.scss`](#alpha-beta)
112
-
113
- ### <a id="grid-layout"></a>Grid layout
114
-
115
- Grid helpers to enable easy cross browser grids. The grids use absolute widths
116
- in older versions of IE or percentage based widths in modern browsers.
117
-
118
- - `%site-width-container` creates a 960px wide elastic container for you site content block
119
- - `%grid-row` container for a row of columns
120
- - `@mixin grid-column($width, $full-width: tablet)` a mixin to create grid columns of fraction width
121
-
122
- These three grid helpers are designed to be used together and aren't guaranteed
123
- to work or behave in a predictable way if used in isolation.
124
-
125
- There is also an `%outdent-to-full-width` selector which can be extended to
126
- outdent and element and cause it to take up the edge gutters and butt up to the
127
- edge of smaller screens.
128
-
129
- #### Usage:
130
-
131
- ```
132
- #page-container {
133
- @extend %site-width-container;
134
- }
135
- .grid-row {
136
- @extend %grid-row;
137
-
138
- .column-third {
139
- @include grid-column( 1/3 );
140
- }
141
- .column-two-thirds {
142
- @include grid-column( 2/3 );
143
- }
144
- }
145
- .hero-image {
146
- @extend %outdent-to-full-width;
147
- }
148
-
149
-
150
- <div id="page-container">
151
- <div class="grid-row">
152
- <div class="column-two-thirds">
153
- Main content
154
- </div>
155
- <div class="column-third">
156
- Sidebar
157
- </div>
158
- </div>
159
-
160
- <div class="hero-image">
161
- <img ...>
162
- </div>
163
- </div>
164
- ```
165
-
166
- ### <a id="conditionals"></a>Conditionals
167
-
168
- Media query and IE helpers. These make producing responsive layouts and
169
- attaching IE specific styles to elements really easy.
170
-
171
- To use the IE conditionals you will need to add extra stylesheets for each IE which look like:
172
-
173
- // BASE STYLESHEET FOR IE 6 COMPILER
174
-
175
- $is-ie: true;
176
- $ie-version: 6;
177
-
178
- @import "application.scss";
179
-
180
- Where `application.scss` is the name of your base stylesheet.
181
-
182
- #### media
183
-
184
- ##### Description
185
-
186
- `@mixin media($size: false, $max-width: false, $min-width: false)`
187
-
188
- ##### Parameters
189
-
190
- ***note: the parameters are mutually exclusive and the first one found will be
191
- used.***
192
-
193
- `$size`
194
-
195
- `size` can be one of `desktop`, `tablet`, `mobile`. `desktop` and `tablet`
196
- should be used to add styles to a mobile first stylesheet. `mobile` should be
197
- used to add styles to a desktop first stylesheet.
198
-
199
- It is recommended that you primarily use `desktop` for new stylesheets to
200
- enhance mobile first when serving to mobile devices.
201
-
202
- `$min-width`
203
- `$max-width`
204
-
205
- These should be set to an absolute pixel value. They will get added directly to
206
- their respective @media queries.
207
-
208
- `$ignore-for-ie`
209
-
210
- Styles that would normally be wrapped in @media queries by this mixin will be instead
211
- added to the main block if the `$is-ie` variable is true.
212
-
213
- Setting `$ignore-for-ie` to `true` means those styles will not be added.
214
-
215
- ##### Usage
216
-
217
- div.columns {
218
- border: 1px solid;
219
-
220
- @include media(desktop){
221
- width: 30%;
222
- float: left;
223
- }
224
- @include media($min-width: 500px){
225
- width: 25%;
226
- }
227
- @include media($max-width: 400px){
228
- width: 25%;
229
- }
230
- }
231
-
232
- #### ie-lte
233
-
234
- Conditially send CSS to IE browsers less than or equal to the named version.
235
-
236
- ##### Description
237
-
238
- `@include ie-lte($version)`
239
-
240
- ##### Parameters
241
-
242
- `$version`
243
-
244
- `version` is an integer value. Possible values are `6`, `7`, `8`.
245
-
246
- ##### Usage
247
-
248
- div.columns {
249
- border: 1px solid;
250
-
251
- @include ie-lte(7){
252
- border: 0;
253
- }
254
- }
255
-
256
-
257
- #### ie
258
-
259
- Send CSS to a named IE version.
260
-
261
- ##### Description
262
-
263
- `@include ie($version)`
264
-
265
- ##### Parameters
266
-
267
- `$version`
268
-
269
- `version` is an integer value. Possible values are `6`, `7`, `8`.
270
-
271
- ##### Usage
272
-
273
- div.columns {
274
- border: 1px solid;
275
-
276
- @include ie(6){
277
- border: 0;
278
- }
279
- }
280
-
281
- ### <a id="colours"></a>Colours
282
-
283
- A collection of colour variables.
284
-
285
- #### Departmental colours
286
-
287
- * `$treasury` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #af292e" />
288
- * `$cabinet-office` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #005abb" />
289
- * `$department-for-education` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #003a69" />
290
- * `$department-for-transport` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #006c56" />
291
- * `$home-office` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #9325b2" />
292
- * `$department-of-health` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #00ad93" />
293
- * `$ministry-of-justice` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #231f20" />
294
- * `$ministry-of-defence` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #4d2942" />
295
- * `$foreign-and-commonwealth-office` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #003e74" />
296
- * `$department-for-communities-and-local-government` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #00857e" />
297
- * `$department-for-energy-and-climate-change` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #009ddb" />
298
- * `$department-for-culture-media-and-sport` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #d40072" />
299
- * `$department-for-environment-food-and-rural-affairs` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #898700" />
300
- * `$department-for-work-and-pensions` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #00beb7" />
301
- * `$department-for-business-innovation-and-skills` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #003479" />
302
- * `$department-for-international-development` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #002878" />
303
- * `$government-equalities-office` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #9325b2" />
304
- * `$attorney-generals-office` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #9f1888" />
305
- * `$scotland-office` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #002663" />
306
- * `$wales-office` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #a33038" />
307
-
308
- #### Standard palette, colours
309
-
310
- * `$purple` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #2e358b" />
311
- * `$purple-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #9799c4" />
312
- * `$purple-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #d5d6e7" />
313
- * `$mauve` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #6f72af" />
314
- * `$mauve-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #b7b9d7" />
315
- * `$mauve-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #e2e2ef" />
316
- * `$fuschia` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #912b88" />
317
- * `$fuschia-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #c994c3" />
318
- * `$fuschia-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #e9d4e6" />
319
- * `$pink` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #d53880" />
320
- * `$pink-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #eb9bbe" />
321
- * `$pink-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #f6d7e5" />
322
- * `$baby-pink` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #f499be" />
323
- * `$baby-pink-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #faccdf" />
324
- * `$baby-pink-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #fdebf2" />
325
- * `$red` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #b10e1e" />
326
- * `$red-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #d9888c" />
327
- * `$red-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #efcfd1" />
328
- * `$mellow-red` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #df3034" />
329
- * `$mellow-red-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #ef9998" />
330
- * `$mellow-red-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #f9d6d6" />
331
- * `$orange` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #f47738" />
332
- * `$orange-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #fabb96" />
333
- * `$orange-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #fde4d4" />
334
- * `$brown` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #b58840" />
335
- * `$brown-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #dac39c" />
336
- * `$brown-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #f0e7d7" />
337
- * `$yellow` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #ffbf47" />
338
- * `$yellow-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #ffdf94" />
339
- * `$yellow-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #fff2d3" />
340
- * `$grass-green` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #85994b" />
341
- * `$grass-green-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #c2cca3" />
342
- * `$grass-green-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #e7ebda" />
343
- * `$green` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #006435" />
344
- * `$green-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #7fb299" />
345
- * `$green-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #cce0d6" />
346
- * `$turquoise` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #28a197" />
347
- * `$turquoise-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #95d0cb" />
348
- * `$turquoise-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #d5ecea" />
349
- * `$light-blue` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #2b8cc4" />
350
- * `$light-blue-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #96c6e2" />
351
- * `$light-blue-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #d5e8f3" />
352
-
353
- #### Standard palette, greys
354
-
355
- * `$black` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #0b0c0c" />
356
- * `$grey-1` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #6f777b" />
357
- * `$grey-2` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #bfc1c3" />
358
- * `$grey-3` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #dee0e2" />
359
- * `$grey-4` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #f8f8f8" />
360
- * `$white` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #fff" />
361
-
362
- #### Semantic colour names
363
-
364
- * `$link-colour` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #2e3191" />
365
- * `$link-active-colour` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #2e8aca" />
366
- * `$link-hover-colour` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #2e8aca" />
367
- * `$link-visited-colour` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #2e3191" />
368
- * `$text-colour: $black` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #0b0c0c" />
369
- * `$secondary-text-colour` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #6f777b" />
370
- * `$border-colour` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #bfc1c3" />
371
- * `$panel-colour` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #dee0e2" />
372
- * `$canvas-colour` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #f8f8f8" />
373
- * `$highlight-colour` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #f8f8f8" />
374
- * `$page-colour` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #fff" />
375
-
376
- #### Usage:
377
-
378
- .column {
379
- background: $green;
380
- }
381
-
382
- ### <a id="typography"></a>Typography
383
-
384
- A collection of font-mixins. There are two different types of font mixins.
385
-
386
- 1. Heading and Copy styles which are the font with added paddings to ensure a
387
- consistent baseline vertical grid.
388
- 2. Core styles which are base font styles with no extra padding.
389
-
390
- #### Heading and Copy styles
391
-
392
- The following heading and copy styles exist:
393
-
394
- * `heading-80`
395
- * `heading-48`
396
- * `heading-36`
397
- * `heading-27`
398
- * `heading-24`
399
- * `copy-19`
400
- * `copy-16`
401
- * `copy-14`
402
-
403
- ##### Usage
404
-
405
- h2 {
406
- @include heading-27;
407
- }
408
-
409
- #### Core styles
410
-
411
- The following core styles exist:
412
-
413
- * `core-80`
414
- * `core-48`
415
- * `core-36`
416
- * `core-27`
417
- * `core-24`
418
- * `core-19`
419
- * `core-16`
420
- * `core-14`
421
-
422
- ##### Description
423
-
424
- `@include core-[size]($line-height, $line-height-640)`
425
-
426
- ##### Parameters
427
-
428
- `$line-height` and `$line-height-640` are both optional. When used it is
429
- recomended to pass a fraction in for readability.
430
-
431
- ##### Usage
432
-
433
- h1 {
434
- @include core-48;
435
- }
436
- h2 {
437
- @include core-24($line-height: (50/24), $line-height-640: (18/16));
438
- }
439
-
440
- #### Tabular numbers
441
-
442
- Tabular numbers have numerals of a standard fixed width. As all numbers have the same width, sets of numbers may be more easily compared. We recommend using them where different numbers are likely to be compared, or where different numbers should line up with each other, eg in tables.
443
-
444
- `$tabular-numbers` is an optional variable that may be passed to the heading, copy and core styles to use (or explicitly not use) tabular numbers. When no variable is passed, the default is non-tabular.
445
-
446
- ##### Usage
447
-
448
- h1 {
449
- @include core-48;
450
- }
451
- h2 {
452
- @include core-24($tabular-numbers: true);
453
- }
454
-
455
- #### external links
456
-
457
- `external-link-default` sets up the background image for all external links.
458
- This should be included on the default link style for a project.
459
-
460
- After setting the default, apply includes from the following for different font sizes:
461
-
462
- * `external-link-12`
463
- * `external-link-12-no-hover`
464
- * `external-link-13`
465
- * `external-link-13-no-hover`
466
- * `external-link-14`
467
- * `external-link-14-bold-no-hover`
468
- * `external-link-16`
469
- * `external-link-16-bold-no-hover`
470
- * `external-link-19`
471
- * `external-link-19-no-hover`
472
-
473
- `external-link-heading` is a unique style a background image for headings to groups of external links.
474
-
475
- This uses the `file-url` helper which will by default output an `image-url` to
476
- be used with Compass or Rails Asset Pipeline, if you want to use a static path
477
- then set the `$path` variable to point to the public location of the toolkit
478
- image assets.
479
-
480
- #### Description
481
-
482
- For a set style:
483
-
484
- `@include external-link-[style]`
485
-
486
- For a specific font size:
487
-
488
- `@include external-link-[size]-[weight]-[no-hover]`
489
-
490
- #### Usage
491
-
492
- /* Default link style */
493
- a[rel="external"] {
494
- @include external-link-default;
495
- @include external-link-19;
496
- }
497
-
498
- th.external-link {
499
- @include external-link-heading;
500
- }
501
-
502
- .inner a[rel="external"] {
503
- @include external-link-16;
504
- }
505
-
506
- .departments a[rel="external"] {
507
- @include external-link-16-bold-no-hover;
508
- }
509
-
510
- ### <a id="css3"></a>css3
511
-
512
- CSS3 helpers to abstract vendor prefixes.
513
-
514
- #### border-radius
515
-
516
- ##### Description
517
-
518
- `@mixin border-radius($radius)`
519
-
520
- ##### Parameters
521
-
522
- `$radius` a pixel value.
523
-
524
- ##### Usage
525
-
526
- .column {
527
- @include border-radius(5px);
528
- }
529
-
530
- #### box-shadow
531
-
532
- ##### Description
533
-
534
- `@mixin box-shadow($shadow)`
535
-
536
- ##### Parameters
537
-
538
- `$shadow` a value set to pass into [`box-shadow`](https://developer.mozilla.org/en-US/docs/CSS/box-shadow).
539
-
540
- ##### Usage
541
-
542
- .column {
543
- @include box-shadow(0 0 5px black);
544
- }
545
-
546
- #### translate
547
-
548
- ##### Description
549
-
550
- `@mixin translate($x, $y)`
551
-
552
- ##### Parameters
553
-
554
- `$x` and `$y` are css values.
555
-
556
- ##### Usage
557
-
558
- .column {
559
- @include translate(2px, 3px);
560
- }
561
-
562
- #### gradient
563
-
564
- This can currently only handle linear top to bottom gradients.
565
-
566
- ##### Description
567
-
568
- `@mixin gradient($from, $to)`
569
-
570
- ##### Parameters
571
-
572
- `$from` and `$to` are colour values.
573
-
574
- ##### Usage
575
-
576
- .column {
577
- @include gradient(#000, #fff);
578
- }
579
-
580
- #### transition
581
-
582
- ##### Description
583
-
584
- `@mixin transition($property, $duration, $function, $delay:0s)`
585
-
586
- ##### Parameters
587
-
588
- Match up with the respective properties from [`transition`](https://developer.mozilla.org/en-US/docs/CSS/transition).
589
-
590
- ##### Usage
591
-
592
- .column {
593
- @include transition(left, 3s, ease);
594
- }
595
-
596
- #### box-sizing
597
-
598
- ##### Description
599
-
600
- `@mixin box-sizing($type)`
601
-
602
- ##### Parameters
603
-
604
- `$type` is one of `border-box`, `content-box` and `padding-box`.
605
-
606
- ##### Usage
607
-
608
- .column {
609
- @include box-sizing(border-box);
610
- }
611
-
612
- #### calc
613
-
614
- ##### Description
615
-
616
- `@mixin calc($property, $calc)`
617
-
618
- ##### Parameters
619
-
620
- `$property` the property to apply the calc to.
621
- `$calc` the calculation to.
622
-
623
- ##### Usage
624
-
625
- .column {
626
- @include calc(width, "300% - 20px");
627
- }
628
-
629
- ### <a id="buttons"></a>Buttons
630
-
631
- A mixin for creating buttons in the GOV.UK style.
632
-
633
- ##### Description
634
-
635
- `@mixin button($colour)`
636
-
637
- ##### Parameters
638
-
639
- `$colour` the background colour of the button (default is `$green`).
640
-
641
- ##### Usage
642
-
643
- .button{
644
- @include button;
645
- }
646
- .button-secondary{
647
- @include button($grey-3);
648
- }
649
- .button-warning{
650
- @include button($red);
651
- }
652
-
653
- ##### Notes
654
-
655
- The button text colour is set by the mixin to either light or dark, depending on the button background colour.
656
-
657
- If you're applying these styles to non form elements, adding a class of 'disabled' to the element will emulate the disabled button style.
658
-
659
-
660
- ### <a id="alpha-beta"></a> Phase banner
661
-
662
- A mixin to create a GOV.UK Phase banner, with alpha/beta tag inside.
663
-
664
- #### Description
665
-
666
- `@mixin phase-banner($state)`
667
-
668
- `$state` is either `alpha` or `beta`.
669
-
670
- `$state` sets the background colour of the phase tag to the appropriate alpha or beta colour.
671
-
672
- ##### Phase banner - Alpha
673
-
674
- .phase-banner {
675
- @include phase-banner(alpha);
676
- }
677
-
678
- <div class="phase-banner">
679
- <p>
680
- <strong class="phase-tag">ALPHA</strong>
681
- <span>This is a new service – your <a href="#">feedback</a> will help us to improve it.</span>
682
- </p>
683
- </div>
684
-
685
- ##### Phase banner - Beta
686
-
687
- .phase-banner {
688
- @include phase-banner(beta);
689
- }
690
-
691
- <div class="phase-banner">
692
- <p>
693
- <strong class="phase-tag">BETA</strong>
694
- <span>This is a new service – your <a href="#">feedback</a> will help us to improve it.</span>
695
- </p>
696
- </div>
697
-
698
- ### <a id="phase-tags"></a> Phase tags
699
-
700
- A mixin to create an alpha/beta tag.
701
-
702
- #### Description
703
-
704
- `@mixin phase-tag($state)`
705
-
706
- `$state` is either `alpha` or `beta`.
707
-
708
- `$state` sets the background colour of the phase tag to the appropriate alpha or beta colour.
709
-
710
- ##### Phase tag - Alpha
711
-
712
- .alpha-tag{
713
- @include phase-tag(alpha);
714
- }
715
- <h2>
716
- Apply using the new service <span class="alpha-tag">ALPHA</span>
717
- </h2>
718
-
719
- ##### Phase tag - Beta
720
-
721
- .beta-tag{
722
- @include phase-tag(beta);
723
- }
724
- <h2>
725
- Apply using the new service <span class="beta-tag">BETA</span>
726
- </h2>
727
-
728
-
729
- ## JavaScript
730
-
731
- The gem also includes some JavaScript which by itself will have no effect on a
732
- page. It can be included with the asset_pipeline by adding the line:
733
-
734
- //=require govuk_toolkit
735
-
736
- ## Media player
737
-
738
- There is a forked version of the Nomensa video player included and custom
739
- GOV.UK styles to be used with it. To use it you will need to include the script
740
- on your page and include the styles nested under an appropriate selector. For
741
- example:
742
-
743
- @import "design-patterns/media-player";
744
-
745
- .media-player {
746
- @include media-player;
747
- }
748
-
749
- You will also need to create your own initalizer to target the links you want
750
- to turn into videos. There are examples of how this works in the [Nomensa
751
- Accesible Media Player][nomensa] repository.
752
-
753
- [nomensa]: https://github.com/nomensa/Accessible-Media-Player/tree/master/example
754
-
755
- ## Multivariate test framework
756
-
757
- `GOVUK.MultiVariateTest` runs split tests to display different content, layouts etc to users.
758
-
759
- It randomly assigns a user a cohort on first execution by setting a cookie, and on every execution sets a session level custom variable on Google Analytics to mark which cohort a user is in. This can be used to segment users in GA.
760
-
761
- A simple content replacement test can be done by defining a set of cohorts with content. E.g.:
762
-
763
- ```javascript
764
- var test = new GOVUK.MultivariateTest({
765
- el: '.car-tax-button',
766
- name: 'car_tax_button_text',
767
- customVarIndex: 555,
768
- cohorts: {
769
- pay_your_car_tax: {html: "Pay Your Car Tax"},
770
- give_us_money: {html: "Give Us Money Or We Will Crush Your Car"}
771
- }
772
- });
773
- ```
774
-
775
- A more complex test can be done by defining callbacks for what to do
776
- when a user is in each cohort:
777
-
778
- ```javascript
779
- var test = new GOVUK.MultivariateTest({
780
- name: 'car_tax_button_text',
781
- customVarIndex: 555,
782
- cohorts: {
783
- pay_your_car_tax: {callback: function() { ... }},
784
- give_us_money: {callback: function() { ... }}
785
- }
786
- });
787
- ```
788
-
789
- If you want one cohort to appear 25% of the time then you can optionally weight
790
- that cohort:
791
-
792
- ```javascript
793
- var test = new GOVUK.MultivariateTest({
794
- name: 'car_tax_button_text',
795
- customVarIndex: 555,
796
- cohorts: {
797
- pay_your_car_tax: {weight: 25, callback: function() { ... }}, // 25%
798
- give_us_money: {weight: 75, callback: function() { ... }} // 75%
799
- }
800
- });
801
- ```
802
-
803
- If you have a complex test, it may be worth extending MultivariateTest with
804
- your own. Callbacks can be strings which will call a method of that name
805
- on the current object.
806
-
807
- Takes these options:
808
- - `el`: Element to run this test on (optional)
809
- - `name`: The name of the text (alphanumeric and underscores)
810
- - `customVarIndex`: The index of the custom variable in Google Analytics. GA only gives 50 integer slots to each account, and it is important that a unique integer is assigned to each test. Current contact for assigning a custom var slot for GOV.UK is: Ashraf Chohan <ashraf.chohan@digital.cabinet-office.gov.uk>
811
- - `defaultWeight`: Number of times each cohorts should appear in an array the random cohort is picked from, to be used in conjunction with weights on individual cohorts.
812
- - `cohorts`: An object that maps cohort name to an object that defines the cohort. Name must be same format as test name. Object contains keys (all optional):
813
- - `html`: HTML to fill element with when this cohort is picked.
814
- - `callback`: Function to call when this cohort is chosen. If it is a string, that method on the test object is called.
815
- - `weight`: Number of times this cohort should appear in an array the random cohort is picked from, defaults to the `defaultWeight` of the test.
816
-
817
- Full documentation on how to design multivariate tests, use the data in GA and construct hypothesis tests is on its way soon.
818
-
819
- ## Primary Links
820
-
821
- `GOVUK.PrimaryList` hides elements in a list which don't have a supplied
822
- selector, they will then be shown when the user clicks. `GOVUK.primaryLinks` is
823
- a helper to add this behaviour to many elements.
824
-
825
- Example markup:
826
-
827
- ```html
828
- <ul id="primary-list">
829
- <li class="primary-item">Item 1</li>
830
- <li>Item 2</li>
831
- <li>Item 3</li>
832
- </ul>
833
- ```
834
-
835
- To add it to all lists which have items with the class `primary-item` use
836
- something like:
837
-
838
- ```javascript
839
- GOVUK.primaryLinks.init('.primary-item');
840
- ```
841
-
842
- Or to add it just to that list you could use:
843
-
844
- ```javascript
845
- new GOVUK.PrimaryList($('#primary-list'), '.primary-item');
846
- ```
847
-
848
- ## Stick at top when scrolling
849
-
850
- `GOVUK.stickAtTopWhenScrolling` tries to add a class to an element when the top
851
- of that element would be scrolled out of the viewport.
852
-
853
- The following would cause the element to stay when you scroll:
854
-
855
- ```html
856
- <div class="js-stick-at-top-when-scrolling">something</div>
857
- ```
858
-
859
- ```css
860
- .content-fixed {
861
- position: fixed;
862
- top: 0;
863
- }
864
- .shim {
865
- display: block;
866
- }
867
- ```
868
-
869
- ```javascript
870
- GOVUK.stickAtTopWhenScrolling.init();
871
- ```
872
-
873
- If you also include the `stopScrollingAtFooter` JavaScript this will also try
874
- and stop the elements before they get to the bottom.
875
-
876
- ## Selection buttons
877
-
878
- Script to support a design of radio buttons and checkboxes requiring them to be wrapped in `<label>` tags:
879
-
880
- <label>
881
- <input type="radio" name="size" value="medium" />
882
- </label>
883
-
884
- When the input is focused or its `checked` attribute is set, classes are added to their parent labels so their styling can show this.
885
-
886
- ### Usage
887
-
888
- #### GOVUK.SelectionButtons
889
-
890
- To apply this behaviour to elements with the above HTML pattern, call the `GOVUK.SelectionButtons` constructor with their inputs:
891
-
892
- ```
893
- var $buttons = $("label input[type='radio'], label input[type='checkbox']");
894
- var selectionButtons = new GOVUK.SelectionButtons($buttons);
895
- ```
896
-
897
- You can also call `GOVUK.SelectionButtons` with a selector:
898
-
899
- ```
900
- var selectionButtons = new GOVUK.SelectionButtons("label input[type='radio'], label input[type='checkbox']");
901
- ```
902
-
903
- This will bind all events to the document, meaning any changes to content (for example, by AJAX) will not effect the button's behaviour.
904
-
905
- The classes that get added to the `<label>` tags can be passed in as options:
906
-
907
- ```
908
- var $buttons = $("label input[type='radio'], label input[type='checkbox']");
909
- var selectionButtons = new GOVUK.SelectionButtons($buttons, { focusedClass : 'selectable-focused', selectedClass : 'selectable-selected' });
910
-
911
- var selectionButtons = new GOVUK.SelectionButtons("label input[type='radio'], label input[type='checkbox']", { focusedClass : 'selectable-focused', selectedClass : 'selectable-selected' });
912
- ```
913
-
914
- #### destroy method
915
-
916
- The returned instance object includes a `destroy` method to remove all events bound to either the elements or the document.
917
-
918
- Using any of the `selectionButtons` objects created above, it can be called like so:
919
-
920
- ```
921
- selectionButtons.destroy();
922
- ```
923
-
924
- ### Deprecated functionality
925
-
926
- The previous method of calling selection buttons is now deprecated. If you need to call them using this method, you will need to define this function:
927
-
928
- ```
929
- GOVUK.selectionButtons = function (elms, opts) {
930
- new GOVUK.SelectionButtons(elms, opts);
931
- };
932
- ```
933
-
934
- This method will mean the `destroy` method is not available to call.
106
+ ## Documentation
107
+
108
+ * [Mixin-sets](/docs/mixins.md)
109
+ * [Grid layout](/docs/mixins.md#grid-layout)
110
+ * [Conditionals](/docs/mixins.md#conditionals)
111
+ * [Colours](/docs/mixins.md#colours)
112
+ * [Typography](/docs/mixins.md#typography)
113
+ * [CSS3](/docs/mixins.md#css3)
114
+ * [Buttons](/docs/mixins.md#buttons)
115
+ * [Phase banner](/docs/mixins.md#-phase-banner)
116
+ * [Phase tags](/docs/mixins.md#-phase-tags)
117
+ * [JavaScript](/docs/javascript.md)
118
+ * [Media player](/docs/javascript.md#media-player)
119
+ * [Multivariate test framework](/docs/javascript.md#multivariate-test-framework)
120
+ * [Primary links](/docs/javascript.md#primary-links)
121
+ * [Stick at top when scrolling](/docs/javascript.md#stick-at-top-when-scrolling)
122
+ * [Selection buttons](/docs/javascript.md#selection-buttons)
123
+ * [Analytics](/docs/analytics.md)
124
+ * [Create an analytics tracker](/docs/analytics.md#create-an-analytics-tracker)
125
+ * [Virtual pageviews](/docs/analytics.md#virtual-pageviews)
126
+ * [Custom events](/docs/analytics.md#custom-events)
127
+ * [Custom dimensions and custom variables](/docs/analytics.md#custom-dimensions-and-custom-variables)
128
+ * [Print tracking](/docs/analytics.md#print-tracking)
129
+ * [Error tracking](/docs/analytics.md#error-tracking)
935
130
 
936
131
  ## Licence
937
132