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 +1 @@
1
- 3.1.0
1
+ 3.2.0
@@ -0,0 +1,158 @@
1
+ # Analytics
2
+
3
+ The toolkit provides an abstraction around analytics to make tracking pageviews, events and dimensions across multiple analytics providers easier. Specifically it was created to ease the migration from Google’s Classic Analytics to Universal Analytics. It includes:
4
+
5
+ * a Google Analytics classic tracker
6
+ * a Google Analytics universal tracker
7
+ * code to asynchronously load these libraries
8
+ * a generic Analytics tracker that combines these into a single API
9
+ * sensible defaults such as anonymising IPs
10
+ * data coercion into the format required by Google Analytics (eg a custom event value must be a number, a custom dimension’s value must be a string)
11
+
12
+ ## Create an analytics tracker
13
+
14
+ The minimum you need to use the analytics function is:
15
+
16
+ 1. Include the following files from /javascripts/govuk/analytics in your project:
17
+ * google-analytics-classic-tracker.js
18
+ * google-analytics-universal-tracker.js
19
+ * tracker.js
20
+ 2. Copy the following `init` script into your own project and replace the dummy IDs with your own (they begin with `UA-`).
21
+ * This initialisation can occur immediately as this API has no dependencies.
22
+ * Load and create the analytics tracker at the earliest opportunity so that:
23
+ * the time until the first pageview is tracked is kept small and pageviews aren’t missed
24
+ * javascript that depends on `GOVUK.analytics` runs after the tracker has been created
25
+
26
+ ```js
27
+ (function() {
28
+ "use strict";
29
+
30
+ // Load Google Analytics libraries
31
+ GOVUK.Tracker.load();
32
+
33
+ // Use document.domain in dev, preview and staging so that tracking works
34
+ // Otherwise explicitly set the domain as www.gov.uk (and not gov.uk).
35
+ var cookieDomain = (document.domain === 'www.gov.uk') ? '.www.gov.uk' : document.domain;
36
+
37
+ // Configure profiles and make interface public
38
+ // for custom dimensions, virtual pageviews and events
39
+ GOVUK.analytics = new GOVUK.Tracker({
40
+ universalId: 'UA-XXXXXXXX-X',
41
+ classicId: 'UA-XXXXXXXX-X',
42
+ cookieDomain: cookieDomain
43
+ });
44
+
45
+ // Set custom dimensions before tracking pageviews
46
+ // GOVUK.analytics.setDimension(…)
47
+
48
+ // Track initial pageview
49
+ GOVUK.analytics.trackPageview();
50
+ })();
51
+ ```
52
+
53
+ Once instantiated, the `GOVUK.analytics` object can be used to track virtual pageviews, custom events and custom dimensions.
54
+
55
+ ## Virtual pageviews
56
+
57
+ > Page tracking allows you to measure the number of views you had of a particular page on your web site.
58
+
59
+ * [Classic Analytics](https://developers.google.com/analytics/devguides/collection/gajs/asyncMigrationExamples#VirtualPageviews)
60
+ * [Universal Analytics](https://developers.google.com/analytics/devguides/collection/analyticsjs/pages)
61
+
62
+ Argument | Description
63
+ ---------|------------
64
+ `path` (optional) | Custom path, eg `/path`
65
+ `title` (optional) | Custom page title, Universal only
66
+
67
+
68
+ ```js
69
+ // Track current page
70
+ GOVUK.analytics.trackPageview();
71
+
72
+ // Track a custom path
73
+ GOVUK.analytics.trackPageview('/path');
74
+
75
+ // Track a custom path and custom page title
76
+ GOVUK.analytics.trackPageview('/path', 'Title');
77
+ ```
78
+
79
+ ## Custom events
80
+
81
+ > Event tracking allows you to measure how users interact with the content of your website. For example, you might want to measure how many times a button was pressed, or how many times a particular item was used.
82
+
83
+ * [Classic Analytics](https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide)
84
+ * [Universal Analytics](https://developers.google.com/analytics/devguides/collection/analyticsjs/events)
85
+
86
+ Argument | Description
87
+ ---------|------------
88
+ `category` (required) | Typically the object that was interacted with, eg "JavaScript error"
89
+ `action` (required) | The type of interaction, eg a Javascript error message
90
+ `options` (optional) | Optional parameters to further describe event
91
+
92
+ Option | Description
93
+ -------|------------
94
+ `label` | Useful for categorising events, eg Javascript error source
95
+ `value` | Values must be non-negative. Useful to pass counts, eg error happened 5 times
96
+ `nonInteraction` | Defaults to false. When set the event will not affect bounce rate
97
+
98
+ ```js
99
+ // Track a custom event with required category and action fields
100
+ GOVUK.analytics.trackEvent('category', 'action');
101
+
102
+ // Track a custom event with optional label, value and nonInteraction options
103
+ GOVUK.analytics.trackEvent('category', 'action', {
104
+ label: 'label',
105
+ value: 1,
106
+ nonInteraction: true // event will not affect bounce rate
107
+ });
108
+ ```
109
+
110
+ ## Custom dimensions and custom variables
111
+
112
+ > Custom dimensions and metrics are a powerful way to send custom data to Google Analytics. Use custom dimensions and metrics to segment and measure differences between: logged in and logged out users, authors of pages, or any other business data you have on a page.
113
+
114
+ * [Classic Analytics](https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables)
115
+ * [Universal Analytics](https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets)
116
+
117
+ Universal custom dimensions are configured within analytics. Classic custom variables rely on the javascript to additionally pass in the name and scope of the variable.
118
+
119
+ ### Set custom dimensions before tracking pageviews
120
+
121
+ Many page level custom dimensions must be set before the initial pageview is tracked. Calls to `setDimension` should typically be made before the initial `trackPageview` is sent to analytics.
122
+
123
+ ### Custom dimensions and variables must have matching indexes
124
+
125
+ When calling `setDimension`, the first argument (`index`) becomes the index of the Universal custom dimension as well as the slot of the Classic custom variable.
126
+
127
+ Argument | Description
128
+ ---------|------------
129
+ `index` (required) | The Universal dimension’s index and and Classic variable’s slot. These must be configured to the same slot and index within analytics profiles.
130
+ `value` (required) | Value of the custom dimension/variable
131
+ `name` (required) | The name of the custom variable (classic only)
132
+ `scope` (optional) | The scope of the custom variable (classic only), defaults to a [page level scope](https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables#pagelevel) (3) if omitted
133
+
134
+ ```js
135
+ // Set a custom dimension at index 1 with value and name
136
+ GOVUK.analytics.setDimension(1, 'value', 'name');
137
+
138
+ // Set a custom dimension with an alternative scope
139
+ GOVUK.analytics.setDimension(1, 'value', 'name', 2);
140
+ ```
141
+
142
+ ### Create custom dimension helpers
143
+
144
+ Because dimensions and variables rely on names and indexes being set correctly, it’s helpful to create methods that abstract away the details. For example:
145
+
146
+ ```js
147
+ function setPixelDensityDimension(pixelDensity) {
148
+ GOVUK.analytics.setDimension(1, pixelDensity, 'PixelDensity', 2);
149
+ }
150
+ ```
151
+
152
+ ## Print tracking
153
+
154
+ Pull `print-intent.js` into your project, after analytics has been initialised, to track when users are attempting to print content.
155
+
156
+ ## Error tracking
157
+
158
+ Pull `error-tracking.js` into your project, after analytics has been initialised, to track JavaScript errors.
@@ -0,0 +1,206 @@
1
+ ## JavaScript
2
+
3
+ The gem also includes some JavaScript which by itself will have no effect on a
4
+ page. It can be included with the asset_pipeline by adding the line:
5
+
6
+ //=require govuk_toolkit
7
+
8
+ ## Media player
9
+
10
+ There is a forked version of the Nomensa video player included and custom
11
+ GOV.UK styles to be used with it. To use it you will need to include the script
12
+ on your page and include the styles nested under an appropriate selector. For
13
+ example:
14
+
15
+ @import "design-patterns/media-player";
16
+
17
+ .media-player {
18
+ @include media-player;
19
+ }
20
+
21
+ You will also need to create your own initalizer to target the links you want
22
+ to turn into videos. There are examples of how this works in the [Nomensa
23
+ Accesible Media Player][nomensa] repository.
24
+
25
+ [nomensa]: https://github.com/nomensa/Accessible-Media-Player/tree/master/example
26
+
27
+ ## Multivariate test framework
28
+
29
+ `GOVUK.MultiVariateTest` runs split tests to display different content, layouts etc to users.
30
+
31
+ 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.
32
+
33
+ A simple content replacement test can be done by defining a set of cohorts with content. E.g.:
34
+
35
+ ```javascript
36
+ var test = new GOVUK.MultivariateTest({
37
+ el: '.car-tax-button',
38
+ name: 'car_tax_button_text',
39
+ customVarIndex: 555,
40
+ cohorts: {
41
+ pay_your_car_tax: {html: "Pay Your Car Tax"},
42
+ give_us_money: {html: "Give Us Money Or We Will Crush Your Car"}
43
+ }
44
+ });
45
+ ```
46
+
47
+ A more complex test can be done by defining callbacks for what to do
48
+ when a user is in each cohort:
49
+
50
+ ```javascript
51
+ var test = new GOVUK.MultivariateTest({
52
+ name: 'car_tax_button_text',
53
+ customVarIndex: 555,
54
+ cohorts: {
55
+ pay_your_car_tax: {callback: function() { ... }},
56
+ give_us_money: {callback: function() { ... }}
57
+ }
58
+ });
59
+ ```
60
+
61
+ If you want one cohort to appear 25% of the time then you can optionally weight
62
+ that cohort:
63
+
64
+ ```javascript
65
+ var test = new GOVUK.MultivariateTest({
66
+ name: 'car_tax_button_text',
67
+ customVarIndex: 555,
68
+ cohorts: {
69
+ pay_your_car_tax: {weight: 25, callback: function() { ... }}, // 25%
70
+ give_us_money: {weight: 75, callback: function() { ... }} // 75%
71
+ }
72
+ });
73
+ ```
74
+
75
+ If you have a complex test, it may be worth extending MultivariateTest with
76
+ your own. Callbacks can be strings which will call a method of that name
77
+ on the current object.
78
+
79
+ Takes these options:
80
+ - `el`: Element to run this test on (optional)
81
+ - `name`: The name of the text (alphanumeric and underscores)
82
+ - `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>
83
+ - `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.
84
+ - `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):
85
+ - `html`: HTML to fill element with when this cohort is picked.
86
+ - `callback`: Function to call when this cohort is chosen. If it is a string, that method on the test object is called.
87
+ - `weight`: Number of times this cohort should appear in an array the random cohort is picked from, defaults to the `defaultWeight` of the test.
88
+
89
+ Full documentation on how to design multivariate tests, use the data in GA and construct hypothesis tests is on its way soon.
90
+
91
+ ## Primary Links
92
+
93
+ `GOVUK.PrimaryList` hides elements in a list which don't have a supplied
94
+ selector, they will then be shown when the user clicks. `GOVUK.primaryLinks` is
95
+ a helper to add this behaviour to many elements.
96
+
97
+ Example markup:
98
+
99
+ ```html
100
+ <ul id="primary-list">
101
+ <li class="primary-item">Item 1</li>
102
+ <li>Item 2</li>
103
+ <li>Item 3</li>
104
+ </ul>
105
+ ```
106
+
107
+ To add it to all lists which have items with the class `primary-item` use
108
+ something like:
109
+
110
+ ```javascript
111
+ GOVUK.primaryLinks.init('.primary-item');
112
+ ```
113
+
114
+ Or to add it just to that list you could use:
115
+
116
+ ```javascript
117
+ new GOVUK.PrimaryList($('#primary-list'), '.primary-item');
118
+ ```
119
+
120
+ ## Stick at top when scrolling
121
+
122
+ `GOVUK.stickAtTopWhenScrolling` tries to add a class to an element when the top
123
+ of that element would be scrolled out of the viewport.
124
+
125
+ The following would cause the element to stay when you scroll:
126
+
127
+ ```html
128
+ <div class="js-stick-at-top-when-scrolling">something</div>
129
+ ```
130
+
131
+ ```css
132
+ .content-fixed {
133
+ position: fixed;
134
+ top: 0;
135
+ }
136
+ .shim {
137
+ display: block;
138
+ }
139
+ ```
140
+
141
+ ```javascript
142
+ GOVUK.stickAtTopWhenScrolling.init();
143
+ ```
144
+
145
+ If you also include the `stopScrollingAtFooter` JavaScript this will also try
146
+ and stop the elements before they get to the bottom.
147
+
148
+ ## Selection buttons
149
+
150
+ Script to support a design of radio buttons and checkboxes requiring them to be wrapped in `<label>` tags:
151
+
152
+ <label>
153
+ <input type="radio" name="size" value="medium" />
154
+ </label>
155
+
156
+ When the input is focused or its `checked` attribute is set, classes are added to their parent labels so their styling can show this.
157
+
158
+ ### Usage
159
+
160
+ #### GOVUK.SelectionButtons
161
+
162
+ To apply this behaviour to elements with the above HTML pattern, call the `GOVUK.SelectionButtons` constructor with their inputs:
163
+
164
+ ```
165
+ var $buttons = $("label input[type='radio'], label input[type='checkbox']");
166
+ var selectionButtons = new GOVUK.SelectionButtons($buttons);
167
+ ```
168
+
169
+ You can also call `GOVUK.SelectionButtons` with a selector:
170
+
171
+ ```
172
+ var selectionButtons = new GOVUK.SelectionButtons("label input[type='radio'], label input[type='checkbox']");
173
+ ```
174
+
175
+ This will bind all events to the document, meaning any changes to content (for example, by AJAX) will not effect the button's behaviour.
176
+
177
+ The classes that get added to the `<label>` tags can be passed in as options:
178
+
179
+ ```
180
+ var $buttons = $("label input[type='radio'], label input[type='checkbox']");
181
+ var selectionButtons = new GOVUK.SelectionButtons($buttons, { focusedClass : 'selectable-focused', selectedClass : 'selectable-selected' });
182
+
183
+ var selectionButtons = new GOVUK.SelectionButtons("label input[type='radio'], label input[type='checkbox']", { focusedClass : 'selectable-focused', selectedClass : 'selectable-selected' });
184
+ ```
185
+
186
+ #### destroy method
187
+
188
+ The returned instance object includes a `destroy` method to remove all events bound to either the elements or the document.
189
+
190
+ Using any of the `selectionButtons` objects created above, it can be called like so:
191
+
192
+ ```
193
+ selectionButtons.destroy();
194
+ ```
195
+
196
+ ### Deprecated functionality
197
+
198
+ 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:
199
+
200
+ ```
201
+ GOVUK.selectionButtons = function (elms, opts) {
202
+ new GOVUK.SelectionButtons(elms, opts);
203
+ };
204
+ ```
205
+
206
+ This method will mean the `destroy` method is not available to call.
@@ -0,0 +1,624 @@
1
+ ## Mixin-sets
2
+
3
+ * [`_grid_layout.scss`](#grid-layout)
4
+ * [`_conditionals.scss`](#conditionals)
5
+ * [`_colours.scss`](#colours)
6
+ * [`_css3.scss`](#css3)
7
+ * [`_typography.scss`](#typography)
8
+ * [`design-patterns/_buttons.scss`](#buttons)
9
+ * [`design-patterns/_alpha-beta.scss`](#alpha-beta)
10
+
11
+ ### <a id="grid-layout"></a>Grid layout
12
+
13
+ Grid helpers to enable easy cross browser grids. The grids use absolute widths
14
+ in older versions of IE or percentage based widths in modern browsers.
15
+
16
+ - `%site-width-container` creates a 960px wide elastic container for you site content block
17
+ - `%grid-row` container for a row of columns
18
+ - `@mixin grid-column($width, $full-width: tablet)` a mixin to create grid columns of fraction width
19
+
20
+ These three grid helpers are designed to be used together and aren't guaranteed
21
+ to work or behave in a predictable way if used in isolation.
22
+
23
+ There is also an `%outdent-to-full-width` selector which can be extended to
24
+ outdent and element and cause it to take up the edge gutters and butt up to the
25
+ edge of smaller screens.
26
+
27
+ #### Usage:
28
+
29
+ ```
30
+ #page-container {
31
+ @extend %site-width-container;
32
+ }
33
+ .grid-row {
34
+ @extend %grid-row;
35
+
36
+ .column-third {
37
+ @include grid-column( 1/3 );
38
+ }
39
+ .column-two-thirds {
40
+ @include grid-column( 2/3 );
41
+ }
42
+ }
43
+ .hero-image {
44
+ @extend %outdent-to-full-width;
45
+ }
46
+
47
+
48
+ <div id="page-container">
49
+ <div class="grid-row">
50
+ <div class="column-two-thirds">
51
+ Main content
52
+ </div>
53
+ <div class="column-third">
54
+ Sidebar
55
+ </div>
56
+ </div>
57
+
58
+ <div class="hero-image">
59
+ <img ...>
60
+ </div>
61
+ </div>
62
+ ```
63
+
64
+ ### <a id="conditionals"></a>Conditionals
65
+
66
+ Media query and IE helpers. These make producing responsive layouts and
67
+ attaching IE specific styles to elements really easy.
68
+
69
+ To use the IE conditionals you will need to add extra stylesheets for each IE which look like:
70
+
71
+ // BASE STYLESHEET FOR IE 6 COMPILER
72
+
73
+ $is-ie: true;
74
+ $ie-version: 6;
75
+
76
+ @import "application.scss";
77
+
78
+ Where `application.scss` is the name of your base stylesheet.
79
+
80
+ #### media
81
+
82
+ ##### Description
83
+
84
+ `@mixin media($size: false, $max-width: false, $min-width: false)`
85
+
86
+ ##### Parameters
87
+
88
+ ***note: the parameters are mutually exclusive and the first one found will be
89
+ used.***
90
+
91
+ `$size`
92
+
93
+ `size` can be one of `desktop`, `tablet`, `mobile`. `desktop` and `tablet`
94
+ should be used to add styles to a mobile first stylesheet. `mobile` should be
95
+ used to add styles to a desktop first stylesheet.
96
+
97
+ It is recommended that you primarily use `desktop` for new stylesheets to
98
+ enhance mobile first when serving to mobile devices.
99
+
100
+ `$min-width`
101
+ `$max-width`
102
+
103
+ These should be set to an absolute pixel value. They will get added directly to
104
+ their respective @media queries.
105
+
106
+ `$ignore-for-ie`
107
+
108
+ Styles that would normally be wrapped in @media queries by this mixin will be instead
109
+ added to the main block if the `$is-ie` variable is true.
110
+
111
+ Setting `$ignore-for-ie` to `true` means those styles will not be added.
112
+
113
+ ##### Usage
114
+
115
+ div.columns {
116
+ border: 1px solid;
117
+
118
+ @include media(desktop){
119
+ width: 30%;
120
+ float: left;
121
+ }
122
+ @include media($min-width: 500px){
123
+ width: 25%;
124
+ }
125
+ @include media($max-width: 400px){
126
+ width: 25%;
127
+ }
128
+ }
129
+
130
+ #### ie-lte
131
+
132
+ Conditially send CSS to IE browsers less than or equal to the named version.
133
+
134
+ ##### Description
135
+
136
+ `@include ie-lte($version)`
137
+
138
+ ##### Parameters
139
+
140
+ `$version`
141
+
142
+ `version` is an integer value. Possible values are `6`, `7`, `8`.
143
+
144
+ ##### Usage
145
+
146
+ div.columns {
147
+ border: 1px solid;
148
+
149
+ @include ie-lte(7){
150
+ border: 0;
151
+ }
152
+ }
153
+
154
+
155
+ #### ie
156
+
157
+ Send CSS to a named IE version.
158
+
159
+ ##### Description
160
+
161
+ `@include ie($version)`
162
+
163
+ ##### Parameters
164
+
165
+ `$version`
166
+
167
+ `version` is an integer value. Possible values are `6`, `7`, `8`.
168
+
169
+ ##### Usage
170
+
171
+ div.columns {
172
+ border: 1px solid;
173
+
174
+ @include ie(6){
175
+ border: 0;
176
+ }
177
+ }
178
+
179
+ ### <a id="colours"></a>Colours
180
+
181
+ A collection of colour variables.
182
+
183
+ #### Departmental colours
184
+
185
+ * `$treasury` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #af292e" />
186
+ * `$cabinet-office` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #005abb" />
187
+ * `$department-for-education` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #003a69" />
188
+ * `$department-for-transport` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #006c56" />
189
+ * `$home-office` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #9325b2" />
190
+ * `$department-of-health` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #00ad93" />
191
+ * `$ministry-of-justice` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #231f20" />
192
+ * `$ministry-of-defence` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #4d2942" />
193
+ * `$foreign-and-commonwealth-office` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #003e74" />
194
+ * `$department-for-communities-and-local-government` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #00857e" />
195
+ * `$department-for-energy-and-climate-change` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #009ddb" />
196
+ * `$department-for-culture-media-and-sport` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #d40072" />
197
+ * `$department-for-environment-food-and-rural-affairs` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #898700" />
198
+ * `$department-for-work-and-pensions` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #00beb7" />
199
+ * `$department-for-business-innovation-and-skills` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #003479" />
200
+ * `$department-for-international-development` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #002878" />
201
+ * `$government-equalities-office` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #9325b2" />
202
+ * `$attorney-generals-office` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #9f1888" />
203
+ * `$scotland-office` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #002663" />
204
+ * `$wales-office` <span style="display:inline-block; width: 60px; height: 10px; float: right; background-color: #a33038" />
205
+
206
+ #### Standard palette, colours
207
+
208
+ * `$purple` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #2e358b" />
209
+ * `$purple-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #9799c4" />
210
+ * `$purple-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #d5d6e7" />
211
+ * `$mauve` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #6f72af" />
212
+ * `$mauve-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #b7b9d7" />
213
+ * `$mauve-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #e2e2ef" />
214
+ * `$fuschia` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #912b88" />
215
+ * `$fuschia-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #c994c3" />
216
+ * `$fuschia-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #e9d4e6" />
217
+ * `$pink` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #d53880" />
218
+ * `$pink-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #eb9bbe" />
219
+ * `$pink-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #f6d7e5" />
220
+ * `$baby-pink` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #f499be" />
221
+ * `$baby-pink-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #faccdf" />
222
+ * `$baby-pink-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #fdebf2" />
223
+ * `$red` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #b10e1e" />
224
+ * `$red-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #d9888c" />
225
+ * `$red-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #efcfd1" />
226
+ * `$mellow-red` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #df3034" />
227
+ * `$mellow-red-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #ef9998" />
228
+ * `$mellow-red-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #f9d6d6" />
229
+ * `$orange` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #f47738" />
230
+ * `$orange-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #fabb96" />
231
+ * `$orange-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #fde4d4" />
232
+ * `$brown` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #b58840" />
233
+ * `$brown-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #dac39c" />
234
+ * `$brown-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #f0e7d7" />
235
+ * `$yellow` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #ffbf47" />
236
+ * `$yellow-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #ffdf94" />
237
+ * `$yellow-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #fff2d3" />
238
+ * `$grass-green` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #85994b" />
239
+ * `$grass-green-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #c2cca3" />
240
+ * `$grass-green-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #e7ebda" />
241
+ * `$green` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #006435" />
242
+ * `$green-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #7fb299" />
243
+ * `$green-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #cce0d6" />
244
+ * `$turquoise` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #28a197" />
245
+ * `$turquoise-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #95d0cb" />
246
+ * `$turquoise-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #d5ecea" />
247
+ * `$light-blue` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #2b8cc4" />
248
+ * `$light-blue-50` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #96c6e2" />
249
+ * `$light-blue-25` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #d5e8f3" />
250
+
251
+ #### Standard palette, greys
252
+
253
+ * `$black` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #0b0c0c" />
254
+ * `$grey-1` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #6f777b" />
255
+ * `$grey-2` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #bfc1c3" />
256
+ * `$grey-3` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #dee0e2" />
257
+ * `$grey-4` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #f8f8f8" />
258
+ * `$white` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #fff" />
259
+
260
+ #### Semantic colour names
261
+
262
+ * `$link-colour` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #2e3191" />
263
+ * `$link-active-colour` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #2e8aca" />
264
+ * `$link-hover-colour` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #2e8aca" />
265
+ * `$link-visited-colour` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #2e3191" />
266
+ * `$text-colour: $black` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #0b0c0c" />
267
+ * `$secondary-text-colour` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #6f777b" />
268
+ * `$border-colour` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #bfc1c3" />
269
+ * `$panel-colour` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #dee0e2" />
270
+ * `$canvas-colour` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #f8f8f8" />
271
+ * `$highlight-colour` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #f8f8f8" />
272
+ * `$page-colour` <span style="display: inline-block; width: 60px; height: 10px; float: right; background-color: #fff" />
273
+
274
+ #### Usage:
275
+
276
+ .column {
277
+ background: $green;
278
+ }
279
+
280
+ ### <a id="typography"></a>Typography
281
+
282
+ A collection of font-mixins. There are two different types of font mixins.
283
+
284
+ 1. Heading and Copy styles which are the font with added paddings to ensure a
285
+ consistent baseline vertical grid.
286
+ 2. Core styles which are base font styles with no extra padding.
287
+
288
+ #### Heading and Copy styles
289
+
290
+ The following heading and copy styles exist:
291
+
292
+ * `heading-80`
293
+ * `heading-48`
294
+ * `heading-36`
295
+ * `heading-27`
296
+ * `heading-24`
297
+ * `copy-19`
298
+ * `copy-16`
299
+ * `copy-14`
300
+
301
+ ##### Usage
302
+
303
+ h2 {
304
+ @include heading-27;
305
+ }
306
+
307
+ #### Core styles
308
+
309
+ The following core styles exist:
310
+
311
+ * `core-80`
312
+ * `core-48`
313
+ * `core-36`
314
+ * `core-27`
315
+ * `core-24`
316
+ * `core-19`
317
+ * `core-16`
318
+ * `core-14`
319
+
320
+ ##### Description
321
+
322
+ `@include core-[size]($line-height, $line-height-640)`
323
+
324
+ ##### Parameters
325
+
326
+ `$line-height` and `$line-height-640` are both optional. When used it is
327
+ recomended to pass a fraction in for readability.
328
+
329
+ ##### Usage
330
+
331
+ h1 {
332
+ @include core-48;
333
+ }
334
+ h2 {
335
+ @include core-24($line-height: (50/24), $line-height-640: (18/16));
336
+ }
337
+
338
+ #### Tabular numbers
339
+
340
+ 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.
341
+
342
+ `$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.
343
+
344
+ ##### Usage
345
+
346
+ h1 {
347
+ @include core-48;
348
+ }
349
+ h2 {
350
+ @include core-24($tabular-numbers: true);
351
+ }
352
+
353
+ #### external links
354
+
355
+ `external-link-default` sets up the background image for all external links.
356
+ This should be included on the default link style for a project.
357
+
358
+ After setting the default, apply includes from the following for different font sizes:
359
+
360
+ * `external-link-12`
361
+ * `external-link-12-no-hover`
362
+ * `external-link-13`
363
+ * `external-link-13-no-hover`
364
+ * `external-link-14`
365
+ * `external-link-14-bold-no-hover`
366
+ * `external-link-16`
367
+ * `external-link-16-bold-no-hover`
368
+ * `external-link-19`
369
+ * `external-link-19-no-hover`
370
+
371
+ `external-link-heading` is a unique style a background image for headings to groups of external links.
372
+
373
+ This uses the `file-url` helper which will by default output an `image-url` to
374
+ be used with Compass or Rails Asset Pipeline, if you want to use a static path
375
+ then set the `$path` variable to point to the public location of the toolkit
376
+ image assets.
377
+
378
+ #### Description
379
+
380
+ For a set style:
381
+
382
+ `@include external-link-[style]`
383
+
384
+ For a specific font size:
385
+
386
+ `@include external-link-[size]-[weight]-[no-hover]`
387
+
388
+ #### Usage
389
+
390
+ /* Default link style */
391
+ a[rel="external"] {
392
+ @include external-link-default;
393
+ @include external-link-19;
394
+ }
395
+
396
+ th.external-link {
397
+ @include external-link-heading;
398
+ }
399
+
400
+ .inner a[rel="external"] {
401
+ @include external-link-16;
402
+ }
403
+
404
+ .departments a[rel="external"] {
405
+ @include external-link-16-bold-no-hover;
406
+ }
407
+
408
+ ### <a id="css3"></a>css3
409
+
410
+ CSS3 helpers to abstract vendor prefixes.
411
+
412
+ #### border-radius
413
+
414
+ ##### Description
415
+
416
+ `@mixin border-radius($radius)`
417
+
418
+ ##### Parameters
419
+
420
+ `$radius` a pixel value.
421
+
422
+ ##### Usage
423
+
424
+ .column {
425
+ @include border-radius(5px);
426
+ }
427
+
428
+ #### box-shadow
429
+
430
+ ##### Description
431
+
432
+ `@mixin box-shadow($shadow)`
433
+
434
+ ##### Parameters
435
+
436
+ `$shadow` a value set to pass into [`box-shadow`](https://developer.mozilla.org/en-US/docs/CSS/box-shadow).
437
+
438
+ ##### Usage
439
+
440
+ .column {
441
+ @include box-shadow(0 0 5px black);
442
+ }
443
+
444
+ #### translate
445
+
446
+ ##### Description
447
+
448
+ `@mixin translate($x, $y)`
449
+
450
+ ##### Parameters
451
+
452
+ `$x` and `$y` are css values.
453
+
454
+ ##### Usage
455
+
456
+ .column {
457
+ @include translate(2px, 3px);
458
+ }
459
+
460
+ #### gradient
461
+
462
+ This can currently only handle linear top to bottom gradients.
463
+
464
+ ##### Description
465
+
466
+ `@mixin gradient($from, $to)`
467
+
468
+ ##### Parameters
469
+
470
+ `$from` and `$to` are colour values.
471
+
472
+ ##### Usage
473
+
474
+ .column {
475
+ @include gradient(#000, #fff);
476
+ }
477
+
478
+ #### transition
479
+
480
+ ##### Description
481
+
482
+ `@mixin transition($property, $duration, $function, $delay:0s)`
483
+
484
+ ##### Parameters
485
+
486
+ Match up with the respective properties from [`transition`](https://developer.mozilla.org/en-US/docs/CSS/transition).
487
+
488
+ ##### Usage
489
+
490
+ .column {
491
+ @include transition(left, 3s, ease);
492
+ }
493
+
494
+ #### box-sizing
495
+
496
+ ##### Description
497
+
498
+ `@mixin box-sizing($type)`
499
+
500
+ ##### Parameters
501
+
502
+ `$type` is one of `border-box`, `content-box` and `padding-box`.
503
+
504
+ ##### Usage
505
+
506
+ .column {
507
+ @include box-sizing(border-box);
508
+ }
509
+
510
+ #### calc
511
+
512
+ ##### Description
513
+
514
+ `@mixin calc($property, $calc)`
515
+
516
+ ##### Parameters
517
+
518
+ `$property` the property to apply the calc to.
519
+ `$calc` the calculation to.
520
+
521
+ ##### Usage
522
+
523
+ .column {
524
+ @include calc(width, "300% - 20px");
525
+ }
526
+
527
+ ### <a id="buttons"></a>Buttons
528
+
529
+ A mixin for creating buttons in the GOV.UK style.
530
+
531
+ ##### Description
532
+
533
+ `@mixin button($colour)`
534
+
535
+ ##### Parameters
536
+
537
+ `$colour` the background colour of the button (default is `$green`).
538
+
539
+ ##### Usage
540
+
541
+ .button{
542
+ @include button;
543
+ }
544
+ .button-secondary{
545
+ @include button($grey-3);
546
+ }
547
+ .button-warning{
548
+ @include button($red);
549
+ }
550
+
551
+ ##### Notes
552
+
553
+ The button text colour is set by the mixin to either light or dark, depending on the button background colour.
554
+
555
+ If you're applying these styles to non form elements, adding a class of 'disabled' to the element will emulate the disabled button style.
556
+
557
+
558
+ ### <a id="alpha-beta"></a> Phase banner
559
+
560
+ A mixin to create a GOV.UK Phase banner, with alpha/beta tag inside.
561
+
562
+ #### Description
563
+
564
+ `@mixin phase-banner($state)`
565
+
566
+ `$state` is either `alpha` or `beta`.
567
+
568
+ `$state` sets the background colour of the phase tag to the appropriate alpha or beta colour.
569
+
570
+ ##### Phase banner - Alpha
571
+
572
+ .phase-banner {
573
+ @include phase-banner(alpha);
574
+ }
575
+
576
+ <div class="phase-banner">
577
+ <p>
578
+ <strong class="phase-tag">ALPHA</strong>
579
+ <span>This is a new service – your <a href="#">feedback</a> will help us to improve it.</span>
580
+ </p>
581
+ </div>
582
+
583
+ ##### Phase banner - Beta
584
+
585
+ .phase-banner {
586
+ @include phase-banner(beta);
587
+ }
588
+
589
+ <div class="phase-banner">
590
+ <p>
591
+ <strong class="phase-tag">BETA</strong>
592
+ <span>This is a new service – your <a href="#">feedback</a> will help us to improve it.</span>
593
+ </p>
594
+ </div>
595
+
596
+ ### <a id="phase-tags"></a> Phase tags
597
+
598
+ A mixin to create an alpha/beta tag.
599
+
600
+ #### Description
601
+
602
+ `@mixin phase-tag($state)`
603
+
604
+ `$state` is either `alpha` or `beta`.
605
+
606
+ `$state` sets the background colour of the phase tag to the appropriate alpha or beta colour.
607
+
608
+ ##### Phase tag - Alpha
609
+
610
+ .alpha-tag{
611
+ @include phase-tag(alpha);
612
+ }
613
+ <h2>
614
+ Apply using the new service <span class="alpha-tag">ALPHA</span>
615
+ </h2>
616
+
617
+ ##### Phase tag - Beta
618
+
619
+ .beta-tag{
620
+ @include phase-tag(beta);
621
+ }
622
+ <h2>
623
+ Apply using the new service <span class="beta-tag">BETA</span>
624
+ </h2>