govuk_frontend_toolkit 0.43.2 → 0.44.0
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.
- data/README.md +9 -1
- data/app/assets/README.md +30 -1
- data/app/assets/javascripts/govuk/primary-links.js +49 -0
- data/app/assets/spec/PrimaryLinksSpec.js +49 -0
- data/app/assets/stylesheets/_css3.scss +3 -3
- data/app/assets/stylesheets/_shims.scss +14 -17
- data/app/assets/stylesheets/design-patterns/_buttons.scss +12 -15
- data/app/assets/stylesheets/design-patterns/_media-player.scss +1 -1
- data/lib/govuk_frontend_toolkit/version.rb +1 -1
- metadata +6 -4
data/README.md
CHANGED
@@ -8,6 +8,12 @@ Just include `govuk_frontend_toolkit` in your `Gemfile`. It
|
|
8
8
|
automatically attaches itself to your asset path so the static/SCSS
|
9
9
|
files will be available to the asset pipeline.
|
10
10
|
|
11
|
+
### Development
|
12
|
+
|
13
|
+
If you are installing from git, ensure you enable submodules like so:
|
14
|
+
|
15
|
+
gem 'govuk_frontend_toolkit', :git => "https://github.com/alphagov/govuk_frontend_toolkit_gem.git", :submodules => true
|
16
|
+
|
11
17
|
You will need to check that the gem is included while in development. Often
|
12
18
|
asset related gems are in a bundler group called `assets`. Old Rails projects
|
13
19
|
do not inluded this in development by default so you need to ensure bundler is
|
@@ -20,7 +26,9 @@ included using the following lines at the top of the `/config/application.rb`:
|
|
20
26
|
# Bundler.require(:default, :assets, Rails.env)
|
21
27
|
end
|
22
28
|
|
23
|
-
|
29
|
+
### Production
|
30
|
+
|
31
|
+
You will need to ensure that the correct assets are precompiled for
|
24
32
|
production. These are set using the variable `config.assets.precompile` in
|
25
33
|
`/config/application.rb`. An example of what this may look like is:
|
26
34
|
|
data/app/assets/README.md
CHANGED
@@ -655,7 +655,7 @@ var test = new GOVUK.MultivariateTest({
|
|
655
655
|
});
|
656
656
|
```
|
657
657
|
|
658
|
-
If you have a complex test, it may be worth extending MultivariateTest with
|
658
|
+
If you have a complex test, it may be worth extending MultivariateTest with
|
659
659
|
your own. Callbacks can be strings which will call a method of that name
|
660
660
|
on the current object.
|
661
661
|
|
@@ -669,6 +669,35 @@ Takes these options:
|
|
669
669
|
|
670
670
|
Full documentation on how to design multivariate tests, use the data in GA and construct hypothesis tests is on its way soon.
|
671
671
|
|
672
|
+
## Primary Links
|
673
|
+
|
674
|
+
`GOVUK.PrimaryList` hides elements in a list which don't have a supplied
|
675
|
+
selector, they will then be shown when the user clicks. `GOVUK.primaryLinks` is
|
676
|
+
a helper to add this behaviour to many elements.
|
677
|
+
|
678
|
+
Example markup:
|
679
|
+
|
680
|
+
```html
|
681
|
+
<ul id="primary-list">
|
682
|
+
<li class="primary-item">Item 1</li>
|
683
|
+
<li>Item 2</li>
|
684
|
+
<li>Item 3</li>
|
685
|
+
</ul>
|
686
|
+
```
|
687
|
+
|
688
|
+
To add it to all lists which have items with the class `primary-item` use
|
689
|
+
something like:
|
690
|
+
|
691
|
+
```javascript
|
692
|
+
GOVUK.primaryLinks.init('.primary-item');
|
693
|
+
```
|
694
|
+
|
695
|
+
Or to add it just to that list you could use:
|
696
|
+
|
697
|
+
```javascript
|
698
|
+
new GOVUK.PrimaryList($('#primary-list'), '.primary-item');
|
699
|
+
```
|
700
|
+
|
672
701
|
|
673
702
|
## Licence
|
674
703
|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
(function() {
|
2
|
+
"use strict";
|
3
|
+
window.GOVUK = window.GOVUK || {};
|
4
|
+
|
5
|
+
// Only show the first {n} items in a list, documentation is in the README.md
|
6
|
+
var PrimaryList = function(el, selector){
|
7
|
+
this.$el = $(el);
|
8
|
+
this.$extraLinks = this.$el.find('li:not('+selector+')');
|
9
|
+
// only hide more than one extra link
|
10
|
+
if(this.$extraLinks.length > 1){
|
11
|
+
this.addToggleLink();
|
12
|
+
this.hideExtraLinks();
|
13
|
+
}
|
14
|
+
}
|
15
|
+
PrimaryList.prototype = {
|
16
|
+
toggleText: function(){
|
17
|
+
if(this.$extraLinks.length > 1){
|
18
|
+
return '+'+ this.$extraLinks.length +' others';
|
19
|
+
} else {
|
20
|
+
return '+'+ this.$extraLinks.length +' other';
|
21
|
+
}
|
22
|
+
},
|
23
|
+
addToggleLink: function(){
|
24
|
+
this.$toggleLink = $('<a href="#">'+ this.toggleText() + '</a>')
|
25
|
+
this.$toggleLink.click($.proxy(this.toggleLinks, this));
|
26
|
+
this.$toggleLink.insertAfter(this.$el);
|
27
|
+
},
|
28
|
+
toggleLinks: function(e){
|
29
|
+
e.preventDefault();
|
30
|
+
this.$toggleLink.remove();
|
31
|
+
this.showExtraLinks();
|
32
|
+
},
|
33
|
+
hideExtraLinks: function(){
|
34
|
+
this.$extraLinks.addClass('visuallyhidden');
|
35
|
+
},
|
36
|
+
showExtraLinks: function(){
|
37
|
+
this.$extraLinks.removeClass('visuallyhidden');
|
38
|
+
}
|
39
|
+
};
|
40
|
+
GOVUK.PrimaryList = PrimaryList;
|
41
|
+
|
42
|
+
GOVUK.primaryLinks = {
|
43
|
+
init: function(selector){
|
44
|
+
$(selector).parent().each(function(i, el){
|
45
|
+
new GOVUK.PrimaryList(el, selector);
|
46
|
+
});
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}());
|
@@ -0,0 +1,49 @@
|
|
1
|
+
describe('primary-links', function(){
|
2
|
+
var shortList, mediumList, longList;
|
3
|
+
|
4
|
+
beforeEach(function () {
|
5
|
+
shortList = $('<ul><li class="primary">one</li><li>two</li></ul>');
|
6
|
+
mediumList = $('<ul><li class="primary">one</li><li>two</li><li>three</li></ul>');
|
7
|
+
longList = $('<ul><li class="primary">one</li><li class="primary">two</li><li>three</li><li>four</li></ul>');
|
8
|
+
});
|
9
|
+
|
10
|
+
it('visually hides extra links', function(){
|
11
|
+
var list = new GOVUK.PrimaryList(mediumList, '.primary');
|
12
|
+
|
13
|
+
expect(mediumList.find('.visuallyhidden').length).toBe(2);
|
14
|
+
});
|
15
|
+
|
16
|
+
it('creates appropriate toggle text', function(){
|
17
|
+
var short = new GOVUK.PrimaryList(shortList, '.primary');
|
18
|
+
var medium = new GOVUK.PrimaryList(mediumList, '.primary');
|
19
|
+
|
20
|
+
expect(short.toggleText()).toEqual('+1 other');
|
21
|
+
expect(medium.toggleText()).toEqual('+2 others');
|
22
|
+
});
|
23
|
+
|
24
|
+
it('add a toggle link', function(){
|
25
|
+
var container = $('<div>').append(mediumList);
|
26
|
+
var list = new GOVUK.PrimaryList(mediumList, '.primary');
|
27
|
+
|
28
|
+
expect(container.find('a').length).toBe(1);
|
29
|
+
});
|
30
|
+
|
31
|
+
it('show extra links when toggled', function(){
|
32
|
+
var list = new GOVUK.PrimaryList(mediumList, '.primary');
|
33
|
+
var event = { preventDefault: function(){} };
|
34
|
+
spyOn(event, 'preventDefault');
|
35
|
+
spyOn(list, 'showExtraLinks');
|
36
|
+
|
37
|
+
list.toggleLinks(event);
|
38
|
+
expect(event.preventDefault).toHaveBeenCalled();
|
39
|
+
expect(list.showExtraLinks).toHaveBeenCalled();
|
40
|
+
});
|
41
|
+
|
42
|
+
it('only adds toggle if more than one extra link', function(){
|
43
|
+
var short = new GOVUK.PrimaryList(shortList, '.primary');
|
44
|
+
var medium = new GOVUK.PrimaryList(mediumList, '.primary');
|
45
|
+
|
46
|
+
expect(shortList.find('.visuallyhidden').length).toBe(0);
|
47
|
+
expect(mediumList.find('.visuallyhidden').length).toBe(2);
|
48
|
+
});
|
49
|
+
});
|
@@ -1,7 +1,7 @@
|
|
1
|
-
|
1
|
+
// CSS 3 Mixins
|
2
|
+
|
3
|
+
// Add them as you need them. This should let us manage vendor prefixes in one place.
|
2
4
|
|
3
|
-
Add them as you need them. This should let us manage vendor prefixes in one place.
|
4
|
-
*/
|
5
5
|
|
6
6
|
@mixin border-radius($radius) {
|
7
7
|
-webkit-border-radius: $radius;
|
@@ -1,20 +1,18 @@
|
|
1
|
-
|
1
|
+
// Cross-browser shims
|
2
|
+
// Ways of normalising properties across browsers.
|
2
3
|
|
3
|
-
Ways of normalising properties across browsers.
|
4
|
-
*/
|
5
4
|
@import "_conditionals";
|
6
5
|
|
7
6
|
// From: https://blog.mozilla.org/webdev/2009/02/20/cross-browser-inline-block/
|
8
7
|
|
9
|
-
|
10
|
-
|
8
|
+
// Usage:
|
9
|
+
//
|
10
|
+
// @include inline-block
|
11
|
+
// or
|
12
|
+
// @include inline-block("250px")
|
13
|
+
//
|
14
|
+
// which gives a min-height to the inline-block elements.
|
11
15
|
|
12
|
-
or
|
13
|
-
|
14
|
-
@include inline-block("250px")
|
15
|
-
|
16
|
-
which gives a min-height to the inline-block elements.
|
17
|
-
*/
|
18
16
|
|
19
17
|
@mixin inline-block($min-height: "") {
|
20
18
|
display: -moz-inline-stack;
|
@@ -37,13 +35,12 @@
|
|
37
35
|
}
|
38
36
|
|
39
37
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
38
|
+
// Contain floats usage:
|
39
|
+
//
|
40
|
+
// .this-has-floated-children {
|
41
|
+
// @extend %contain-floats;
|
42
|
+
// }
|
45
43
|
|
46
|
-
*/
|
47
44
|
|
48
45
|
%contain-floats {
|
49
46
|
&:after {
|
@@ -2,25 +2,22 @@
|
|
2
2
|
@import '../_css3.scss';
|
3
3
|
@import '../_conditionals.scss';
|
4
4
|
|
5
|
-
|
5
|
+
// Mixin and defaults for making buttons on GOV.UK services.
|
6
6
|
|
7
|
-
|
7
|
+
// For guidance, see: https://www.gov.uk/service-manual/design-and-content/resources/buttons.html
|
8
8
|
|
9
|
-
|
9
|
+
// Example usage:
|
10
10
|
|
11
|
-
|
11
|
+
// .button{
|
12
|
+
// @include button;
|
13
|
+
// }
|
14
|
+
// .button-secondary{
|
15
|
+
// @include button($grey-3);
|
16
|
+
// }
|
17
|
+
// .button-warning{
|
18
|
+
// @include button($red);
|
19
|
+
// }
|
12
20
|
|
13
|
-
.button{
|
14
|
-
@include button;
|
15
|
-
}
|
16
|
-
.button-secondary{
|
17
|
-
@include button($grey-3);
|
18
|
-
}
|
19
|
-
.button-warning{
|
20
|
-
@include button($red);
|
21
|
-
}
|
22
|
-
|
23
|
-
*/
|
24
21
|
|
25
22
|
@mixin button($colour: $button-colour){
|
26
23
|
// Colour
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_frontend_toolkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.44.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-03-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -203,6 +203,7 @@ files:
|
|
203
203
|
- app/assets/images/player-icon-rewind.png
|
204
204
|
- app/assets/images/player-icon-volume.png
|
205
205
|
- app/assets/javascripts/govuk/multivariate-test.js
|
206
|
+
- app/assets/javascripts/govuk/primary-links.js
|
206
207
|
- app/assets/javascripts/govuk/stop-scrolling-at-footer.js
|
207
208
|
- app/assets/javascripts/govuk_toolkit.js
|
208
209
|
- app/assets/javascripts/stageprompt.js
|
@@ -210,6 +211,7 @@ files:
|
|
210
211
|
- app/assets/jenkins.sh
|
211
212
|
- app/assets/package.json
|
212
213
|
- app/assets/spec/MultivariateTestSpec.js
|
214
|
+
- app/assets/spec/PrimaryLinksSpec.js
|
213
215
|
- app/assets/stylesheets/.gitkeep
|
214
216
|
- app/assets/stylesheets/_colours.scss
|
215
217
|
- app/assets/stylesheets/_conditionals.scss
|
@@ -238,7 +240,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
238
240
|
version: '0'
|
239
241
|
segments:
|
240
242
|
- 0
|
241
|
-
hash:
|
243
|
+
hash: 4141806898857661575
|
242
244
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
243
245
|
none: false
|
244
246
|
requirements:
|
@@ -247,7 +249,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
247
249
|
version: '0'
|
248
250
|
segments:
|
249
251
|
- 0
|
250
|
-
hash:
|
252
|
+
hash: 4141806898857661575
|
251
253
|
requirements: []
|
252
254
|
rubyforge_project:
|
253
255
|
rubygems_version: 1.8.23
|