dxw_govuk_frontend_rails 2.9.0.pre.alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.circleci/config.yml +33 -0
- data/.circleci/setup-rubygems.sh +3 -0
- data/.gitignore +9 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +91 -0
- data/Rakefile +50 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/dxw_govuk_frontend_rails.gemspec +27 -0
- data/lib/dxw_govuk_frontend_rails/version.rb +3 -0
- data/lib/dxw_govuk_frontend_rails.rb +12 -0
- data/package-lock.json +13 -0
- data/package.json +26 -0
- data/vendor/assets/fonts/bold-a2452cb66f-v1.woff2 +0 -0
- data/vendor/assets/fonts/bold-f38c792ac2-v1.woff +0 -0
- data/vendor/assets/fonts/bold-fb2676462a-v1.eot +0 -0
- data/vendor/assets/fonts/bold-tabular-357fdfbcc3-v1.eot +0 -0
- data/vendor/assets/fonts/bold-tabular-784c21afb8-v1.woff +0 -0
- data/vendor/assets/fonts/bold-tabular-b89238d840-v1.woff2 +0 -0
- data/vendor/assets/fonts/light-2c037cf7e1-v1.eot +0 -0
- data/vendor/assets/fonts/light-458f8ea81c-v1.woff +0 -0
- data/vendor/assets/fonts/light-f38ad40456-v1.woff2 +0 -0
- data/vendor/assets/fonts/light-tabular-498ea8ffe2-v1.eot +0 -0
- data/vendor/assets/fonts/light-tabular-62cc6f0a28-v1.woff +0 -0
- data/vendor/assets/fonts/light-tabular-851b10ccdd-v1.woff2 +0 -0
- data/vendor/assets/images/favicon.ico +0 -0
- data/vendor/assets/images/govuk-apple-touch-icon-152x152.png +0 -0
- data/vendor/assets/images/govuk-apple-touch-icon-167x167.png +0 -0
- data/vendor/assets/images/govuk-apple-touch-icon-180x180.png +0 -0
- data/vendor/assets/images/govuk-apple-touch-icon.png +0 -0
- data/vendor/assets/images/govuk-crest-2x.png +0 -0
- data/vendor/assets/images/govuk-crest.png +0 -0
- data/vendor/assets/images/govuk-logotype-crown.png +0 -0
- data/vendor/assets/images/govuk-mask-icon.svg +7 -0
- data/vendor/assets/images/govuk-opengraph-image.png +0 -0
- data/vendor/assets/images/icon-arrow-left.png +0 -0
- data/vendor/assets/images/icon-important.png +0 -0
- data/vendor/assets/images/icon-pointer-2x.png +0 -0
- data/vendor/assets/images/icon-pointer.png +0 -0
- data/vendor/assets/javascripts/govuk_frontend_rails.js +2358 -0
- data/vendor/assets/stylesheets/all-ie8.scss +6 -0
- data/vendor/assets/stylesheets/all.scss +11 -0
- data/vendor/assets/stylesheets/components/_all.scss +29 -0
- data/vendor/assets/stylesheets/components/accordion/_accordion.scss +188 -0
- data/vendor/assets/stylesheets/components/back-link/_back-link.scss +54 -0
- data/vendor/assets/stylesheets/components/breadcrumbs/_breadcrumbs.scss +119 -0
- data/vendor/assets/stylesheets/components/button/_button.scss +180 -0
- data/vendor/assets/stylesheets/components/character-count/_character-count.scss +31 -0
- data/vendor/assets/stylesheets/components/checkboxes/_checkboxes.scss +161 -0
- data/vendor/assets/stylesheets/components/date-input/_date-input.scss +30 -0
- data/vendor/assets/stylesheets/components/details/_details.scss +89 -0
- data/vendor/assets/stylesheets/components/error-message/_error-message.scss +15 -0
- data/vendor/assets/stylesheets/components/error-summary/_error-summary.scss +72 -0
- data/vendor/assets/stylesheets/components/fieldset/_fieldset.scss +60 -0
- data/vendor/assets/stylesheets/components/file-upload/_file-upload.scss +19 -0
- data/vendor/assets/stylesheets/components/footer/_footer.scss +233 -0
- data/vendor/assets/stylesheets/components/header/_header.scss +304 -0
- data/vendor/assets/stylesheets/components/hint/_hint.scss +50 -0
- data/vendor/assets/stylesheets/components/input/_input.scss +77 -0
- data/vendor/assets/stylesheets/components/inset-text/_inset-text.scss +28 -0
- data/vendor/assets/stylesheets/components/label/_label.scss +45 -0
- data/vendor/assets/stylesheets/components/panel/_panel.scss +44 -0
- data/vendor/assets/stylesheets/components/phase-banner/_phase-banner.scss +31 -0
- data/vendor/assets/stylesheets/components/radios/_radios.scss +187 -0
- data/vendor/assets/stylesheets/components/select/_select.scss +32 -0
- data/vendor/assets/stylesheets/components/skip-link/_skip-link.scss +26 -0
- data/vendor/assets/stylesheets/components/summary-list/_summary-list.scss +123 -0
- data/vendor/assets/stylesheets/components/table/_table.scss +53 -0
- data/vendor/assets/stylesheets/components/tabs/_tabs.scss +130 -0
- data/vendor/assets/stylesheets/components/tag/_tag.scss +33 -0
- data/vendor/assets/stylesheets/components/textarea/_textarea.scss +32 -0
- data/vendor/assets/stylesheets/components/warning-text/_warning-text.scss +59 -0
- data/vendor/assets/stylesheets/core/_all.scss +6 -0
- data/vendor/assets/stylesheets/core/_global-styles.scss +23 -0
- data/vendor/assets/stylesheets/core/_links.scss +31 -0
- data/vendor/assets/stylesheets/core/_lists.scss +58 -0
- data/vendor/assets/stylesheets/core/_section-break.scss +60 -0
- data/vendor/assets/stylesheets/core/_template.scss +35 -0
- data/vendor/assets/stylesheets/core/_typography.scss +190 -0
- data/vendor/assets/stylesheets/govuk-frontend-rails.scss +16 -0
- data/vendor/assets/stylesheets/helpers/_all.scss +12 -0
- data/vendor/assets/stylesheets/helpers/_clearfix.scss +15 -0
- data/vendor/assets/stylesheets/helpers/_colour.scss +51 -0
- data/vendor/assets/stylesheets/helpers/_device-pixels.scss +38 -0
- data/vendor/assets/stylesheets/helpers/_focusable.scss +34 -0
- data/vendor/assets/stylesheets/helpers/_font-faces.scss +67 -0
- data/vendor/assets/stylesheets/helpers/_grid.scss +107 -0
- data/vendor/assets/stylesheets/helpers/_links.scss +200 -0
- data/vendor/assets/stylesheets/helpers/_media-queries.scss +95 -0
- data/vendor/assets/stylesheets/helpers/_shape-arrow.scss +80 -0
- data/vendor/assets/stylesheets/helpers/_spacing.scss +152 -0
- data/vendor/assets/stylesheets/helpers/_typography.scss +188 -0
- data/vendor/assets/stylesheets/helpers/_visually-hidden.scss +82 -0
- data/vendor/assets/stylesheets/objects/_all.scss +4 -0
- data/vendor/assets/stylesheets/objects/_form-group.scss +25 -0
- data/vendor/assets/stylesheets/objects/_grid.scss +27 -0
- data/vendor/assets/stylesheets/objects/_main-wrapper.scss +53 -0
- data/vendor/assets/stylesheets/objects/_width-container.scss +63 -0
- data/vendor/assets/stylesheets/overrides/_all.scss +4 -0
- data/vendor/assets/stylesheets/overrides/_display.scss +18 -0
- data/vendor/assets/stylesheets/overrides/_spacing.scss +62 -0
- data/vendor/assets/stylesheets/overrides/_typography.scss +25 -0
- data/vendor/assets/stylesheets/overrides/_width.scss +49 -0
- data/vendor/assets/stylesheets/settings/_all.scss +21 -0
- data/vendor/assets/stylesheets/settings/_assets.scss +82 -0
- data/vendor/assets/stylesheets/settings/_colours-applied.scss +140 -0
- data/vendor/assets/stylesheets/settings/_colours-organisations.scss +136 -0
- data/vendor/assets/stylesheets/settings/_colours-palette.scss +37 -0
- data/vendor/assets/stylesheets/settings/_compatibility.scss +51 -0
- data/vendor/assets/stylesheets/settings/_global-styles.scss +13 -0
- data/vendor/assets/stylesheets/settings/_ie8.scss +18 -0
- data/vendor/assets/stylesheets/settings/_measurements.scss +99 -0
- data/vendor/assets/stylesheets/settings/_media-queries.scss +23 -0
- data/vendor/assets/stylesheets/settings/_spacing.scss +80 -0
- data/vendor/assets/stylesheets/settings/_typography-font-families.scss +22 -0
- data/vendor/assets/stylesheets/settings/_typography-font.scss +60 -0
- data/vendor/assets/stylesheets/settings/_typography-responsive.scss +180 -0
- data/vendor/assets/stylesheets/tools/_all.scss +8 -0
- data/vendor/assets/stylesheets/tools/_compatibility.scss +36 -0
- data/vendor/assets/stylesheets/tools/_exports.scss +33 -0
- data/vendor/assets/stylesheets/tools/_font-url.scss +28 -0
- data/vendor/assets/stylesheets/tools/_ie8.scss +51 -0
- data/vendor/assets/stylesheets/tools/_iff.scss +15 -0
- data/vendor/assets/stylesheets/tools/_image-url.scss +28 -0
- data/vendor/assets/stylesheets/tools/_px-to-em.scss +20 -0
- data/vendor/assets/stylesheets/tools/_px-to-rem.scss +20 -0
- data/vendor/assets/stylesheets/utilities/_all.scss +2 -0
- data/vendor/assets/stylesheets/utilities/_clearfix.scss +5 -0
- data/vendor/assets/stylesheets/utilities/_visually-hidden.scss +10 -0
- data/vendor/assets/stylesheets/vendor/_sass-mq.scss +351 -0
- metadata +204 -0
@@ -0,0 +1,107 @@
|
|
1
|
+
////
|
2
|
+
/// @group helpers
|
3
|
+
////
|
4
|
+
|
5
|
+
/// Grid width percentage
|
6
|
+
///
|
7
|
+
/// @param {String} $key - Name of grid width (e.g. two-thirds)
|
8
|
+
/// @return {Number} Percentage width
|
9
|
+
/// @throw if `$key` is not a valid grid width
|
10
|
+
/// @access public
|
11
|
+
|
12
|
+
@function govuk-grid-width($key) {
|
13
|
+
@if map-has-key($govuk-grid-widths, $key) {
|
14
|
+
@return map-get($govuk-grid-widths, $key);
|
15
|
+
}
|
16
|
+
|
17
|
+
@error "Unknown grid width `#{$key}`";
|
18
|
+
}
|
19
|
+
|
20
|
+
/// Grid width percentage (alias)
|
21
|
+
///
|
22
|
+
/// @alias govuk-grid-width
|
23
|
+
/// @deprecated To be removed in v3.0, replaced by govuk-grid-width
|
24
|
+
@function grid-width($key) {
|
25
|
+
@return govuk-grid-width($key);
|
26
|
+
}
|
27
|
+
|
28
|
+
/// Generate grid row styles
|
29
|
+
///
|
30
|
+
/// Creates a grid row class with a standardised margin.
|
31
|
+
///
|
32
|
+
/// @param {String} $class [govuk-grid-row] CSS class name
|
33
|
+
///
|
34
|
+
/// @example scss - Default
|
35
|
+
/// @include govuk-grid-row;
|
36
|
+
///
|
37
|
+
/// @example scss - Customising the class name
|
38
|
+
/// @include govuk-grid-row("app-grid");
|
39
|
+
///
|
40
|
+
/// @access public
|
41
|
+
/// @deprecated To be removed in v3.0, replaced by the govuk-grid-row class
|
42
|
+
|
43
|
+
@mixin govuk-grid-row($class: "govuk-grid-row") {
|
44
|
+
.#{$class} {
|
45
|
+
@include govuk-clearfix;
|
46
|
+
margin-right: - ($govuk-gutter-half);
|
47
|
+
margin-left: - ($govuk-gutter-half);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
/// Generate grid column styles
|
52
|
+
///
|
53
|
+
/// Creates a grid column with standard gutter between the columns.
|
54
|
+
///
|
55
|
+
/// If a `$class` is provided (which is the default, but deprecated behaviour),
|
56
|
+
/// the generated rules will be wrapped in a predefined selector in the format
|
57
|
+
/// `$class-$width` (e.g. `govuk-grid-column-full`). This behaviour is
|
58
|
+
/// deprecated and will be removed in v3.0
|
59
|
+
///
|
60
|
+
/// Grid widths are defined in the `$govuk-grid-widths` map.
|
61
|
+
///
|
62
|
+
/// By default the column width changes from 100% to specified width at the
|
63
|
+
/// 'tablet' breakpoint, but other breakpoints can be specified using the `$at`
|
64
|
+
/// parameter.
|
65
|
+
///
|
66
|
+
/// @param {String} $width [full] name of a grid width from $govuk-grid-widths
|
67
|
+
/// @param {String} $float [left] left | right
|
68
|
+
/// @param {String} $at [tablet] - mobile | tablet | desktop | any custom breakpoint
|
69
|
+
/// @param {String} $class [govuk-grid-column] CSS class name (deprecated)
|
70
|
+
///
|
71
|
+
/// @example scss - Default
|
72
|
+
/// .govuk-grid-column-two-thirds {
|
73
|
+
/// @include govuk-grid-column(two-thirds, $class: false)
|
74
|
+
/// }
|
75
|
+
///
|
76
|
+
/// @example scss - Customising the breakpoint where width percentage is applied
|
77
|
+
/// .govuk-grid-column-one-half-at-desktop {
|
78
|
+
/// @include govuk-grid-column(one-half, $at: desktop);
|
79
|
+
/// }
|
80
|
+
///
|
81
|
+
/// @example scss - Customising the float direction
|
82
|
+
/// .govuk-grid-column-one-half-right {
|
83
|
+
/// @include govuk-grid-column(two-thirds, $float: right, $class: false);
|
84
|
+
/// }
|
85
|
+
///
|
86
|
+
/// @example scss - Customising the class name (deprecated)
|
87
|
+
/// @include govuk-grid-column(one-half, $class: "test-column");
|
88
|
+
///
|
89
|
+
/// @access public
|
90
|
+
|
91
|
+
@mixin govuk-grid-column($width: full, $float: left, $at: tablet, $class: "govuk-grid-column") {
|
92
|
+
@if ($class) {
|
93
|
+
.#{$class}-#{$width} {
|
94
|
+
@include govuk-grid-column($width, $float, $at, $class: false);
|
95
|
+
}
|
96
|
+
} @else {
|
97
|
+
box-sizing: border-box;
|
98
|
+
@if $at != desktop {
|
99
|
+
width: 100%;
|
100
|
+
}
|
101
|
+
padding: 0 $govuk-gutter-half;
|
102
|
+
@include govuk-media-query($from: $at) {
|
103
|
+
width: govuk-grid-width($width);
|
104
|
+
float: $float;
|
105
|
+
}
|
106
|
+
}
|
107
|
+
}
|
@@ -0,0 +1,200 @@
|
|
1
|
+
////
|
2
|
+
/// @group helpers
|
3
|
+
////
|
4
|
+
|
5
|
+
/// Common link mixin
|
6
|
+
///
|
7
|
+
/// Provides the typography and focus state, regardless of link style.
|
8
|
+
///
|
9
|
+
/// @access public
|
10
|
+
|
11
|
+
@mixin govuk-link-common {
|
12
|
+
@include govuk-typography-common;
|
13
|
+
@include govuk-focusable-fill;
|
14
|
+
}
|
15
|
+
|
16
|
+
/// Default link style mixin
|
17
|
+
///
|
18
|
+
/// Provides the default unvisited, visited, hover and active states for links.
|
19
|
+
///
|
20
|
+
/// If you use this mixin in a component you must also include the
|
21
|
+
/// govuk-link-common mixin in order to get the focus state.
|
22
|
+
///
|
23
|
+
/// @example scss
|
24
|
+
/// .govuk-component__link {
|
25
|
+
/// @include govuk-link-common;
|
26
|
+
/// @include govuk-link-style-default;
|
27
|
+
/// }
|
28
|
+
///
|
29
|
+
/// @access public
|
30
|
+
|
31
|
+
@mixin govuk-link-style-default {
|
32
|
+
&:link {
|
33
|
+
color: $govuk-link-colour;
|
34
|
+
}
|
35
|
+
|
36
|
+
&:visited {
|
37
|
+
color: $govuk-link-visited-colour;
|
38
|
+
}
|
39
|
+
|
40
|
+
&:hover {
|
41
|
+
color: $govuk-link-hover-colour;
|
42
|
+
}
|
43
|
+
|
44
|
+
&:active {
|
45
|
+
color: $govuk-link-active-colour;
|
46
|
+
}
|
47
|
+
|
48
|
+
// When focussed, the text colour needs to be darker to ensure that colour
|
49
|
+
// contrast is still acceptable
|
50
|
+
&:focus {
|
51
|
+
color: $govuk-focus-text-colour;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
/// Muted style link mixin
|
56
|
+
///
|
57
|
+
/// Used for secondary links on a page - the link will appear in muted colours
|
58
|
+
/// regardless of visited state.
|
59
|
+
///
|
60
|
+
/// If you use this mixin in a component you must also include the
|
61
|
+
/// govuk-link-common mixin in order to get the focus state.
|
62
|
+
///
|
63
|
+
/// @example scss
|
64
|
+
/// .govuk-component__link {
|
65
|
+
/// @include govuk-link-common;
|
66
|
+
/// @include govuk-link-style-muted;
|
67
|
+
/// }
|
68
|
+
///
|
69
|
+
/// @access public
|
70
|
+
|
71
|
+
@mixin govuk-link-style-muted {
|
72
|
+
&:link,
|
73
|
+
&:visited,
|
74
|
+
&:hover,
|
75
|
+
&:active {
|
76
|
+
color: $govuk-secondary-text-colour;
|
77
|
+
}
|
78
|
+
|
79
|
+
// When focussed, the text colour needs to be darker to ensure that colour
|
80
|
+
// contrast is still acceptable
|
81
|
+
&:focus {
|
82
|
+
color: $govuk-focus-text-colour;
|
83
|
+
}
|
84
|
+
|
85
|
+
// alphagov/govuk_template includes a specific a:link:focus selector designed
|
86
|
+
// to make unvisited links a slightly darker blue when focussed, so we need to
|
87
|
+
// override the text colour for that combination of selectors.
|
88
|
+
@include govuk-compatibility(govuk_template) {
|
89
|
+
&:link:focus {
|
90
|
+
@include govuk-text-colour;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
/// Text style link mixin
|
96
|
+
///
|
97
|
+
/// Overrides the colour of links to match the text colour. Generally used by
|
98
|
+
/// navigation components, such as breadcrumbs or the back link.
|
99
|
+
///
|
100
|
+
/// If you use this mixin in a component you must also include the
|
101
|
+
/// govuk-link-common mixin in order to get the focus state.
|
102
|
+
///
|
103
|
+
/// @example scss
|
104
|
+
/// .govuk-component__link {
|
105
|
+
/// @include govuk-link-common;
|
106
|
+
/// @include govuk-link-style-text;
|
107
|
+
/// }
|
108
|
+
///
|
109
|
+
/// @access public
|
110
|
+
|
111
|
+
@mixin govuk-link-style-text {
|
112
|
+
// Override link colour to use text colour
|
113
|
+
&:link,
|
114
|
+
&:visited,
|
115
|
+
&:hover,
|
116
|
+
&:active,
|
117
|
+
&:focus {
|
118
|
+
@include govuk-text-colour;
|
119
|
+
}
|
120
|
+
|
121
|
+
// alphagov/govuk_template includes a specific a:link:focus selector designed
|
122
|
+
// to make unvisited links a slightly darker blue when focussed, so we need to
|
123
|
+
// override the text colour for that combination of selectors.
|
124
|
+
@include govuk-compatibility(govuk_template) {
|
125
|
+
&:link:focus {
|
126
|
+
@include govuk-text-colour;
|
127
|
+
}
|
128
|
+
}
|
129
|
+
}
|
130
|
+
|
131
|
+
|
132
|
+
/// No visited state link mixin
|
133
|
+
///
|
134
|
+
/// Used in cases where it is not helpful to distinguish between visited and
|
135
|
+
/// non-visited links.
|
136
|
+
///
|
137
|
+
/// For example, navigation links to pages with dynamic content like admin
|
138
|
+
/// dashboards. The content on the page is changing all the time, so the fact
|
139
|
+
/// that you’ve visited it before is not important.
|
140
|
+
///
|
141
|
+
/// If you use this mixin in a component you must also include the
|
142
|
+
/// govuk-link-common mixin in order to get the focus state.
|
143
|
+
///
|
144
|
+
/// @example scss
|
145
|
+
/// .govuk-component__link {
|
146
|
+
/// @include govuk-link-common;
|
147
|
+
/// @include govuk-link-style-no-visited-state;
|
148
|
+
/// }
|
149
|
+
///
|
150
|
+
/// @access public
|
151
|
+
|
152
|
+
@mixin govuk-link-style-no-visited-state {
|
153
|
+
&:link {
|
154
|
+
color: $govuk-link-colour;
|
155
|
+
}
|
156
|
+
|
157
|
+
&:visited {
|
158
|
+
color: $govuk-link-colour;
|
159
|
+
}
|
160
|
+
|
161
|
+
&:hover {
|
162
|
+
color: $govuk-link-hover-colour;
|
163
|
+
}
|
164
|
+
|
165
|
+
&:active {
|
166
|
+
color: $govuk-link-active-colour;
|
167
|
+
}
|
168
|
+
|
169
|
+
// When focussed, the text colour needs to be darker to ensure that colour
|
170
|
+
// contrast is still acceptable
|
171
|
+
&:focus {
|
172
|
+
color: $govuk-focus-text-colour;
|
173
|
+
}
|
174
|
+
}
|
175
|
+
|
176
|
+
/// Print friendly link mixin
|
177
|
+
///
|
178
|
+
/// When printing, append the the destination URL to the link text, as long
|
179
|
+
/// as the URL starts with either `/`, `http://` or `https://`.
|
180
|
+
///
|
181
|
+
/// @access public
|
182
|
+
|
183
|
+
@mixin govuk-link-print-friendly {
|
184
|
+
@include govuk-media-query($media-type: print) {
|
185
|
+
|
186
|
+
&[href^="/"],
|
187
|
+
&[href^="http://"],
|
188
|
+
&[href^="https://"] {
|
189
|
+
&::after {
|
190
|
+
content: " (" attr(href) ")";
|
191
|
+
font-size: 90%;
|
192
|
+
|
193
|
+
// Because the URLs may be very long, ensure that they may be broken
|
194
|
+
// at arbitrary points if there are no otherwise acceptable break
|
195
|
+
// points in the line
|
196
|
+
word-wrap: break-word;
|
197
|
+
}
|
198
|
+
}
|
199
|
+
}
|
200
|
+
}
|
@@ -0,0 +1,95 @@
|
|
1
|
+
////
|
2
|
+
/// @group helpers
|
3
|
+
////
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
// =========================================================
|
8
|
+
// Wrangle sass-mq config...
|
9
|
+
// =========================================================
|
10
|
+
|
11
|
+
// Pass our breakpoints and static breakpoint definitions through to sass-mq.
|
12
|
+
$mq-breakpoints: if(variable-exists(govuk-breakpoints), $govuk-breakpoints, ());
|
13
|
+
$mq-static-breakpoint: if(variable-exists(govuk-ie8-breakpoint), $govuk-ie8-breakpoint, desktop);
|
14
|
+
|
15
|
+
$mq-show-breakpoints: ();
|
16
|
+
|
17
|
+
@if (variable-exists(govuk-show-breakpoints) and $govuk-show-breakpoints) {
|
18
|
+
$mq-show-breakpoints: map-keys($govuk-breakpoints);
|
19
|
+
}
|
20
|
+
|
21
|
+
// When building a stylesheet for IE8, set $mq-responsive to false in order to
|
22
|
+
// 'rasterize' any media queries.
|
23
|
+
|
24
|
+
$mq-responsive: true;
|
25
|
+
@if (variable-exists(govuk-is-ie8) and $govuk-is-ie8) {
|
26
|
+
$mq-responsive: false;
|
27
|
+
}
|
28
|
+
|
29
|
+
// This is a horrible, horrible hack to prevent the 'dev mode' CSS to display
|
30
|
+
// the current breakpoint from being included multiple times.
|
31
|
+
//
|
32
|
+
// We can't use the `exports` mixin for this because import directives cannot be
|
33
|
+
// used within control directives 😠
|
34
|
+
$sass-mq-already-included: false !default;
|
35
|
+
|
36
|
+
@if $sass-mq-already-included {
|
37
|
+
$mq-show-breakpoints: ();
|
38
|
+
}
|
39
|
+
|
40
|
+
@import "../vendor/sass-mq";
|
41
|
+
|
42
|
+
$sass-mq-already-included: true;
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
// =========================================================
|
47
|
+
// Helpers
|
48
|
+
// =========================================================
|
49
|
+
|
50
|
+
/// Media Query
|
51
|
+
///
|
52
|
+
/// This is a currently a wrapper for sass-mq - abstracted so that we can
|
53
|
+
/// replace it in the future if we so choose.
|
54
|
+
///
|
55
|
+
/// @param {String | Boolean} $from [false] - One of $govuk-breakpoints
|
56
|
+
/// @param {String | Boolean} $until [false] - One of $govuk-breakpoints
|
57
|
+
/// @param {String | Boolean} $and [false] - Additional media query parameters
|
58
|
+
/// @param {String} $media-type [all] - Media type: screen, print…
|
59
|
+
///
|
60
|
+
/// @ignore Undocumented mq API, for advanced use only:
|
61
|
+
/// @ignore @param {Map} $breakpoints [$govuk-breakpoints]
|
62
|
+
/// @ignore @param {String} $static-breakpoint [$govuk-ie8-breakpoint]
|
63
|
+
/// @ignore @param {Boolean} $responsive [$govuk-is-ie8]
|
64
|
+
///
|
65
|
+
/// @content styling rules, wrapped into a @media query when $responsive is true
|
66
|
+
///
|
67
|
+
/// @example scss
|
68
|
+
/// .element {
|
69
|
+
/// @include govuk-media-query($from: mobile) {
|
70
|
+
/// color: red;
|
71
|
+
/// }
|
72
|
+
/// @include govuk-media-query($until: tablet) {
|
73
|
+
/// color: blue;
|
74
|
+
/// }
|
75
|
+
/// @include govuk-media-query(mobile, tablet) {
|
76
|
+
/// color: green;
|
77
|
+
/// }
|
78
|
+
/// @include govuk-media-query($from: tablet, $and: '(orientation: landscape)') {
|
79
|
+
/// color: teal;
|
80
|
+
/// }
|
81
|
+
/// @include govuk-media-query(950px) {
|
82
|
+
/// color: hotpink;
|
83
|
+
/// }
|
84
|
+
/// @include govuk-media-query(tablet, $media-type: screen) {
|
85
|
+
/// color: hotpink;
|
86
|
+
/// }
|
87
|
+
/// }
|
88
|
+
///
|
89
|
+
/// @access public
|
90
|
+
|
91
|
+
@mixin govuk-media-query($args...) {
|
92
|
+
@include mq($args...) {
|
93
|
+
@content;
|
94
|
+
};
|
95
|
+
}
|
@@ -0,0 +1,80 @@
|
|
1
|
+
////
|
2
|
+
/// @group helpers
|
3
|
+
////
|
4
|
+
|
5
|
+
/// Calculate the height of an equilateral triangle
|
6
|
+
///
|
7
|
+
/// Multiplying half the length of the base of an equilateral triangle by the
|
8
|
+
/// square root of three gives us its height. We use 1.732 as an approximation.
|
9
|
+
///
|
10
|
+
/// @param {Number} $base - Length of the base of the triangle
|
11
|
+
/// @return {Number} Calculated height of the triangle
|
12
|
+
/// @access private
|
13
|
+
|
14
|
+
@function _govuk-equilateral-height($base) {
|
15
|
+
$square-root-of-three: 1.732;
|
16
|
+
|
17
|
+
@return ($base / 2) * $square-root-of-three;
|
18
|
+
}
|
19
|
+
|
20
|
+
/// Arrow mixin
|
21
|
+
///
|
22
|
+
/// Generate Arrows (triangles) by using a mix of transparent (1) and coloured
|
23
|
+
/// borders. The coloured borders inherit the text colour of the element (2).
|
24
|
+
///
|
25
|
+
/// Ensure the arrow is rendered correctly if browser colours are overridden by
|
26
|
+
/// providing a clip path (3). Without this the transparent borders are
|
27
|
+
/// overridden to become visible which results in a square.
|
28
|
+
///
|
29
|
+
/// We need both because older browsers do not support clip-path.
|
30
|
+
///
|
31
|
+
/// @param {String} $direction - Direction for arrow: up, right, down, left.
|
32
|
+
/// @param {Number} $base - Length of the triangle 'base' side
|
33
|
+
/// @param {Number} $height [null] - Height of triangle. Omit for equilateral.
|
34
|
+
/// @param {String} $display [block] - CSS display property of the arrow
|
35
|
+
///
|
36
|
+
/// @access public
|
37
|
+
|
38
|
+
@mixin govuk-shape-arrow($direction, $base, $height: null, $display: block) {
|
39
|
+
display: $display;
|
40
|
+
|
41
|
+
width: 0;
|
42
|
+
height: 0;
|
43
|
+
|
44
|
+
border-style: solid;
|
45
|
+
border-color: transparent; // 1
|
46
|
+
|
47
|
+
$perpendicular: $base / 2;
|
48
|
+
|
49
|
+
@if ($height == null) {
|
50
|
+
$height: _govuk-equilateral-height($base);
|
51
|
+
}
|
52
|
+
|
53
|
+
@if $direction == "up" {
|
54
|
+
-webkit-clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
|
55
|
+
clip-path: polygon(50% 0%, 0% 100%, 100% 100%); // 3
|
56
|
+
|
57
|
+
border-width: 0 $perpendicular $height $perpendicular;
|
58
|
+
border-bottom-color: inherit; // 2
|
59
|
+
} @else if $direction == "right" {
|
60
|
+
-webkit-clip-path: polygon(0% 0%, 100% 50%, 0% 100%);
|
61
|
+
clip-path: polygon(0% 0%, 100% 50%, 0% 100%); // 3
|
62
|
+
|
63
|
+
border-width: $perpendicular 0 $perpendicular $height;
|
64
|
+
border-left-color: inherit; // 2
|
65
|
+
} @else if $direction == "down" {
|
66
|
+
-webkit-clip-path: polygon(0% 0%, 50% 100%, 100% 0%);
|
67
|
+
clip-path: polygon(0% 0%, 50% 100%, 100% 0%); // 3
|
68
|
+
|
69
|
+
border-width: $height $perpendicular 0 $perpendicular;
|
70
|
+
border-top-color: inherit; // 2
|
71
|
+
} @else if $direction == "left" {
|
72
|
+
-webkit-clip-path: polygon(0% 50%, 100% 100%, 100% 0%);
|
73
|
+
clip-path: polygon(0% 50%, 100% 100%, 100% 0%); // 3
|
74
|
+
|
75
|
+
border-width: $perpendicular $height $perpendicular 0;
|
76
|
+
border-right-color: inherit; // 2
|
77
|
+
} @else {
|
78
|
+
@error "Invalid arrow direction: expected `up`, `right`, `down` or `left`, got `#{$direction}`";
|
79
|
+
}
|
80
|
+
}
|
@@ -0,0 +1,152 @@
|
|
1
|
+
////
|
2
|
+
/// @group helpers
|
3
|
+
////
|
4
|
+
|
5
|
+
/// Single point spacing
|
6
|
+
///
|
7
|
+
/// Returns measurement corresponding to the spacing point requested.
|
8
|
+
///
|
9
|
+
/// @param {Number} $spacing-point - Point on the spacing scale (set in `settings/_spacing.sccs`)
|
10
|
+
///
|
11
|
+
/// @returns {String} Spacing Measurement eg. 10px
|
12
|
+
///
|
13
|
+
/// @example scss
|
14
|
+
/// .element {
|
15
|
+
/// padding: govuk-spacing(5);
|
16
|
+
/// top: govuk-spacing(2) !important; // if `!important` is required
|
17
|
+
/// }
|
18
|
+
/// @access public
|
19
|
+
|
20
|
+
@function govuk-spacing($spacing-point) {
|
21
|
+
|
22
|
+
$actual-input-type: type-of($spacing-point);
|
23
|
+
@if $actual-input-type != "number" {
|
24
|
+
@error "Expected a number (integer), but got a "
|
25
|
+
+ "#{$actual-input-type}.";
|
26
|
+
}
|
27
|
+
|
28
|
+
@if not map-has-key($govuk-spacing-points, $spacing-point) {
|
29
|
+
@error "Unknown spacing variable `#{$spacing-point}`. Make sure you are using a point from the spacing scale in `_settings/spacing.scss`.";
|
30
|
+
}
|
31
|
+
|
32
|
+
@return map-get($govuk-spacing-points, $spacing-point);
|
33
|
+
}
|
34
|
+
|
35
|
+
/// Responsive spacing
|
36
|
+
///
|
37
|
+
/// Adds responsive spacing (either padding or margin, depending on `$property`)
|
38
|
+
/// by fetching a 'spacing map' from the responsive spacing scale, which defines
|
39
|
+
/// different spacing values at different breakpoints.
|
40
|
+
///
|
41
|
+
/// To generate responsive spacing, use 'govuk-responsive-margin' or
|
42
|
+
/// 'govuk-responsive-padding' mixins
|
43
|
+
///
|
44
|
+
/// @param {Number} $responsive-spacing-point - Point on the responsive spacing
|
45
|
+
/// scale, corresponds to a map of breakpoints and spacing values
|
46
|
+
/// @param {String} $property - Property to add spacing to (e.g. 'margin')
|
47
|
+
/// @param {String} $direction [all] - Direction to add spacing to
|
48
|
+
/// (`top`, `right`, `bottom`, `left`, `all`)
|
49
|
+
/// @param {Boolean} $important [false] - Whether to mark as `!important`
|
50
|
+
/// @param {Number} $adjustment [false] - Offset to adjust spacing by
|
51
|
+
///
|
52
|
+
/// @access private
|
53
|
+
|
54
|
+
@mixin _govuk-responsive-spacing($responsive-spacing-point, $property, $direction: "all", $important: false, $adjustment: false) {
|
55
|
+
|
56
|
+
$actual-input-type: type-of($responsive-spacing-point);
|
57
|
+
@if $actual-input-type != "number" {
|
58
|
+
@error "Expected a number (integer), but got a " + "#{$actual-input-type}.";
|
59
|
+
}
|
60
|
+
|
61
|
+
@if not map-has-key($govuk-spacing-responsive-scale, $responsive-spacing-point) {
|
62
|
+
@error "Unknown spacing point `#{$responsive-spacing-point}`. Make sure you are using a point from the "
|
63
|
+
+ "responsive spacing scale in `_settings/spacing.scss`.";
|
64
|
+
}
|
65
|
+
|
66
|
+
// Make sure that the return value from `_settings/spacing.scss` is a map.
|
67
|
+
$scale-map: map-get($govuk-spacing-responsive-scale, $responsive-spacing-point);
|
68
|
+
$actual-map-type: type-of($scale-map);
|
69
|
+
@if $actual-map-type != "map" {
|
70
|
+
@error "Expected a number (integer), but got a "
|
71
|
+
+ "#{$actual-map-type}. Make sure you are using a map to set the responsive spacing in `_settings/spacing.scss`)";
|
72
|
+
}
|
73
|
+
|
74
|
+
// Loop through each breakpoint in the map
|
75
|
+
@each $breakpoint, $breakpoint-value in $scale-map {
|
76
|
+
|
77
|
+
@if ($adjustment) {
|
78
|
+
$breakpoint-value: $breakpoint-value + $adjustment;
|
79
|
+
}
|
80
|
+
|
81
|
+
// The 'null' breakpoint is for mobile.
|
82
|
+
@if $breakpoint == null {
|
83
|
+
|
84
|
+
@if $direction == all {
|
85
|
+
#{$property}: $breakpoint-value iff($important, !important);
|
86
|
+
} @else {
|
87
|
+
#{$property}-#{$direction}: $breakpoint-value iff($important, !important);
|
88
|
+
}
|
89
|
+
} @else {
|
90
|
+
@include govuk-media-query($from: $breakpoint) {
|
91
|
+
@if $direction == all {
|
92
|
+
#{$property}: $breakpoint-value iff($important, !important);
|
93
|
+
} @else {
|
94
|
+
#{$property}-#{$direction}: $breakpoint-value iff($important, !important);
|
95
|
+
}
|
96
|
+
}
|
97
|
+
}
|
98
|
+
}
|
99
|
+
}
|
100
|
+
|
101
|
+
/// Responsive margin
|
102
|
+
///
|
103
|
+
/// Adds responsive margin by fetching a 'spacing map' from the responsive
|
104
|
+
/// spacing scale, which defines different spacing values at different
|
105
|
+
/// breakpoints. Wrapper for the `_govuk-responsive-spacing` mixin.
|
106
|
+
///
|
107
|
+
/// @see {mixin} _govuk-responsive-spacing
|
108
|
+
///
|
109
|
+
/// @param {Number} $responsive-spacing-point - Point on the responsive spacing
|
110
|
+
/// scale, corresponds to a map of breakpoints and spacing values
|
111
|
+
/// @param {String} $direction [all] - Direction to add spacing to
|
112
|
+
/// (`top`, `right`, `bottom`, `left`, `all`)
|
113
|
+
/// @param {Boolean} $important [false] - Whether to mark as `!important`
|
114
|
+
/// @param {Number} $adjustment [false] - Offset to adjust spacing by
|
115
|
+
///
|
116
|
+
/// @example scss
|
117
|
+
/// .element {
|
118
|
+
/// @include govuk-responsive-margin(6, "left", $adjustment: 1px);
|
119
|
+
/// }
|
120
|
+
///
|
121
|
+
/// @access public
|
122
|
+
|
123
|
+
@mixin govuk-responsive-margin($responsive-spacing-point, $direction: "all", $important: false, $adjustment: false) {
|
124
|
+
@include _govuk-responsive-spacing($responsive-spacing-point, "margin", $direction, $important, $adjustment);
|
125
|
+
}
|
126
|
+
|
127
|
+
/// Responsive padding
|
128
|
+
///
|
129
|
+
/// Adds responsive padding by fetching a 'spacing map' from the responsive
|
130
|
+
/// spacing scale, which defines different spacing values at different
|
131
|
+
/// breakpoints. Wrapper for the `_govuk-responsive-spacing` mixin.
|
132
|
+
///
|
133
|
+
/// @see {mixin} _govuk-responsive-spacing
|
134
|
+
///
|
135
|
+
/// @param {Number} $responsive-spacing-point - Point on the responsive spacing
|
136
|
+
/// scale, corresponds to a map of breakpoints and spacing values
|
137
|
+
/// @param {String} $direction [all] - Direction to add spacing to
|
138
|
+
/// (`top`, `right`, `bottom`, `left`, `all`)
|
139
|
+
/// @param {Boolean} $important [false] - Whether to mark as `!important`
|
140
|
+
/// @param {Number} $adjustment [false] - Offset to adjust spacing
|
141
|
+
///
|
142
|
+
/// @example scss
|
143
|
+
/// .element {
|
144
|
+
/// @include govuk-responsive-padding(6, "left", $adjustment: 1px);
|
145
|
+
/// }
|
146
|
+
///
|
147
|
+
/// @access public
|
148
|
+
|
149
|
+
|
150
|
+
@mixin govuk-responsive-padding($responsive-spacing-point, $direction: "all", $important: false, $adjustment: false) {
|
151
|
+
@include _govuk-responsive-spacing($responsive-spacing-point, "padding", $direction, $important, $adjustment);
|
152
|
+
}
|