govuk_publishing_components 9.25.0 → 9.26.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd0431873bfd24e6d770033d912c371dde3c33b33ced0c36205db2c970d122e8
4
- data.tar.gz: 5692cd938bc333869b439de5b1a07bb560ea324ccf88922c5f3156f343a2f600
3
+ metadata.gz: 2bc4ea81c6afca132f69c421bad8aba0f4ccf9702ae9e067123a924fc46c2f59
4
+ data.tar.gz: dc45f0ac53c4b2d333a344485e689242728dbd837708c5fa26a6abecd3f9319b
5
5
  SHA512:
6
- metadata.gz: 6a23c1b4980f24754815743f808093b47485939fce5d97a2b6d41ed298596af1650e805b86f3fd6b413d2fecf91b3580125b08433375d9fba9975e54b799049a
7
- data.tar.gz: 35ec2d9303ab22bb9394ca34e102dfdede8eaecae66f0c24f4ecacd3eefc04df28a19fe31786c2242f0e9376563ac10a720fdd966b919a0a7f783e12205b7bc5
6
+ metadata.gz: 6c82bf497d2fecd01310d5116781130462be995d696041fae6623226368f230b10de534ec0945e15ed2d3a3856cb3414d74ef2d2da99c6ac0422702b766c112b
7
+ data.tar.gz: eab2eb21fadcfe73cd29cff6e3601b7c156188daa16b1fea3294245ff7710fe7c7ec5df9427ac91d7b8c8bb091a8d24ecb057ce89deb6bba88e4f76a4eae036f
@@ -43,6 +43,7 @@
43
43
  @import "components/subscription-links";
44
44
  @import "components/success-alert";
45
45
  @import "components/error-alert";
46
+ @import "components/table";
46
47
  @import "components/tabs";
47
48
  @import "components/taxonomy-navigation";
48
49
  @import "components/taxonomy-list";
@@ -8,9 +8,14 @@ $gem-secondary-button-colour: #00823b;
8
8
  $gem-secondary-button-hover-colour: darken($gem-secondary-button-colour, 5%);
9
9
  $gem-secondary-button-background-colour: govuk-colour("white");
10
10
  $gem-secondary-button-hover-background-colour: govuk-colour("grey-4");
11
+
11
12
  $gem-quiet-button-colour: govuk-colour("grey-1");
12
13
  $gem-quiet-button-hover-colour: darken($gem-quiet-button-colour, 5%);
13
14
 
15
+ $gem-destructive-button-background-colour: govuk-colour("red");
16
+ $gem-destructive-button-hover-background-colour: darken($gem-destructive-button-background-colour, 5%);
17
+ $gem-destructive-button-border-colour: govuk-colour("black");
18
+
14
19
  @import "../../../../node_modules/govuk-frontend/components/button/button";
15
20
 
16
21
  @import "mixins/margins";
@@ -97,6 +102,21 @@ $gem-quiet-button-hover-colour: darken($gem-quiet-button-colour, 5%);
97
102
  }
98
103
  }
99
104
 
105
+ .gem-c-button--destructive {
106
+ background-color: $gem-destructive-button-background-colour;
107
+ box-shadow: 0 2px 0 $gem-destructive-button-border-colour;
108
+
109
+ &:link,
110
+ &:visited,
111
+ &:active {
112
+ background-color: $gem-destructive-button-background-colour;
113
+ }
114
+
115
+ &:hover {
116
+ background-color: $gem-destructive-button-hover-background-colour;
117
+ }
118
+ }
119
+
100
120
  // Begin adjustments for font baseline offset
101
121
  // These should be removed when the font is updated with the correct baseline
102
122
  // For the 1px addition please see https://github.com/alphagov/govuk-frontend/pull/365#discussion_r154349428
@@ -0,0 +1,126 @@
1
+ // This component relies on styles from GOV.UK Frontend
2
+
3
+ // Specify the functions used to resolve assets paths in SCSS
4
+ $govuk-font-url-function: "font-url";
5
+
6
+ @import "../../../../node_modules/govuk-frontend/components/table/table";
7
+ @import "../../../../node_modules/govuk-frontend/core/links";
8
+
9
+ $table-border-width: 1px;
10
+ $table-border-colour: govuk-colour("grey-2");
11
+ $table-header-border-width: 2px;
12
+ $table-header-background-colour: govuk-colour("grey-3");
13
+ $sort-link-active-colour: govuk-colour("white");
14
+ $sort-link-arrow-size: 14px;
15
+ $sort-link-arrow-size-small: 8px;
16
+ $sort-link-arrow-spacing: $sort-link-arrow-size / 2;
17
+ $table-row-hover-background-colour: rgba(43, 140, 196, .2);
18
+ $table-row-even-background-colour: govuk-colour("grey-4");
19
+
20
+ .govuk-table__cell:empty,
21
+ .govuk-table__cell--empty {
22
+ color: $govuk-secondary-text-colour;
23
+ }
24
+
25
+ .govuk-table--sortable {
26
+ outline: $table-border-width solid $table-border-colour;
27
+ outline-offset: 0;
28
+
29
+ .govuk-table__header {
30
+ padding: govuk-spacing(2);
31
+ border-right: $table-header-border-width solid govuk-colour("white");
32
+ border-bottom: $table-header-border-width solid govuk-colour("white");
33
+ background: $table-header-background-colour;
34
+ font-weight: normal;
35
+
36
+ &:last-child {
37
+ border-right: 0;
38
+ }
39
+
40
+ .app-table__sort-link {
41
+ @include govuk-link-common;
42
+ position: relative;
43
+ padding-right: $sort-link-arrow-size;
44
+ color: $govuk-link-colour;
45
+ text-decoration: none;
46
+
47
+ &::after {
48
+ content: "";
49
+ position: absolute;
50
+ top: 5px;
51
+ right: 0;
52
+
53
+ @include govuk-shape-arrow($direction: up, $base: $sort-link-arrow-size-small, $display: block);
54
+ }
55
+
56
+ &::before {
57
+ content: "";
58
+ position: absolute;
59
+ top: 13px;
60
+ right: 0;
61
+
62
+ @include govuk-shape-arrow($direction: down, $base: $sort-link-arrow-size-small, $display: block);
63
+ }
64
+ }
65
+ }
66
+
67
+ .govuk-table__header--active {
68
+ color: $sort-link-active-colour;
69
+ background: $govuk-link-colour;
70
+
71
+ .app-table__sort-link {
72
+ padding-right: govuk-spacing(4);
73
+ color: $sort-link-active-colour;
74
+
75
+ &:focus {
76
+ color: $govuk-link-colour;
77
+ }
78
+ }
79
+
80
+ .app-table__sort-link--ascending::before,
81
+ .app-table__sort-link--descending::before {
82
+ content: none;
83
+ }
84
+
85
+ .app-table__sort-link--ascending::after {
86
+ content: "";
87
+ position: absolute;
88
+ top: $sort-link-arrow-spacing;
89
+ right: 0;
90
+ margin-left: govuk-spacing(1);
91
+
92
+ @include govuk-shape-arrow($direction: up, $base: $sort-link-arrow-size, $display: inline-block);
93
+ }
94
+
95
+ .app-table__sort-link--descending::after {
96
+ content: "";
97
+ position: absolute;
98
+ top: $sort-link-arrow-spacing;
99
+ right: 0;
100
+ margin-left: govuk-spacing(1);
101
+
102
+ @include govuk-shape-arrow($direction: down, $base: $sort-link-arrow-size, $display: inline-block);
103
+ }
104
+
105
+ }
106
+
107
+ .govuk-table__row {
108
+ &:hover {
109
+ background-color: $table-row-hover-background-colour;
110
+ }
111
+
112
+ &:nth-child(even) {
113
+ background-color: $table-row-even-background-colour;
114
+
115
+ &:hover {
116
+ background-color: $table-row-hover-background-colour;
117
+ }
118
+ }
119
+ }
120
+
121
+ .govuk-table__cell {
122
+ padding: govuk-spacing(2);
123
+ border: 0;
124
+ }
125
+ }
126
+
@@ -0,0 +1,46 @@
1
+ <%
2
+ caption ||= nil
3
+ head ||= []
4
+ rows ||= []
5
+ first_cell_is_header ||=false
6
+ caption_classes ||= nil
7
+ sortable ||=false
8
+ %>
9
+
10
+ <%= GovukPublishingComponents::AppHelpers::TableHelper.helper(self, caption, {
11
+ sortable: sortable,
12
+ caption_classes: caption_classes
13
+ }) do |t| %>
14
+
15
+ <% if head.any? %>
16
+ <%= t.head do %>
17
+ <% head.each_with_index do |item, cellindex| %>
18
+ <%= t.header item[:text], {
19
+ format: item[:format],
20
+ href: item[:href],
21
+ sort_direction: item[:sort_direction]
22
+ } %>
23
+ <% end %>
24
+ <% end %>
25
+ <% end %>
26
+
27
+ <%= t.body do %>
28
+ <% rows.each_with_index do |row, rowindex| %>
29
+ <%= t.row do %>
30
+ <% row.each_with_index do |cell, cellindex| %>
31
+ <% if cellindex == 0 && first_cell_is_header %>
32
+ <%= t.header cell[:text], {
33
+ scope: "row",
34
+ format: cell[:format]
35
+ } %>
36
+ <% else %>
37
+ <%= t.cell cell[:text], {
38
+ format: cell[:format]
39
+ } %>
40
+ <% end %>
41
+ <% end %>
42
+ <% end %>
43
+ <% end %>
44
+ <% end %>
45
+
46
+ <% end %>
@@ -51,6 +51,12 @@ examples:
51
51
  href: "#"
52
52
  secondary_quiet: true
53
53
  rel: "external"
54
+ destructive_button:
55
+ data:
56
+ text: "Destructive button"
57
+ href: "#"
58
+ destructive: true
59
+ rel: "external"
54
60
  start_now_button_with_info_text:
55
61
  data:
56
62
  text: "Start now"
@@ -0,0 +1,131 @@
1
+ name: Table
2
+ description: A table component to make information easier to compare and scan for users.
3
+ accessibility_criteria: |
4
+ Accessible tables need HTML markup that indicates header cells and data cells and defines their relationship. Assistive technologies use this information to provide context to users.
5
+ Header cells must be marked up with <th>, and data cells with <td> to make tables accessible.
6
+ For more complex tables, explicit associations is needed using scope attributes.
7
+ shared_accessibility_criteria:
8
+ - link
9
+ type: helper
10
+ examples:
11
+ default:
12
+ data:
13
+ rows:
14
+ -
15
+ - text: January
16
+ - text: £85
17
+ format: numeric
18
+ - text: £95
19
+ format: numeric
20
+ -
21
+ - text: February
22
+ - text: £75
23
+ format: numeric
24
+ - text: £55
25
+ format: numeric
26
+ -
27
+ - text: March
28
+ - text: £165
29
+ format: numeric
30
+ - text: £125
31
+ format: numeric
32
+ with_head:
33
+ data:
34
+ head:
35
+ - text: Month you apply
36
+ - text: Rate for bicycles
37
+ format: numeric
38
+ - text: Rate for vehicles
39
+ format: numeric
40
+ rows:
41
+ -
42
+ - text: January
43
+ - text: £85
44
+ format: numeric
45
+ - text: £95
46
+ format: numeric
47
+ -
48
+ - text: February
49
+ - text: £75
50
+ format: numeric
51
+ - text: £55
52
+ format: numeric
53
+ -
54
+ - text: March
55
+ - text: £165
56
+ format: numeric
57
+ - text: £125
58
+ format: numeric
59
+ with_head_and_caption:
60
+ data:
61
+ caption: 'Caption 1: Months and rates'
62
+ caption_classes: govuk-heading-m
63
+ first_cell_is_header: true
64
+ head:
65
+ - text: Month you apply
66
+ - text: Rate for bicycles
67
+ format: numeric
68
+ - text: Rate for vehicles
69
+ format: numeric
70
+ rows:
71
+ -
72
+ - text: January
73
+ - text: £85
74
+ format: numeric
75
+ - text: £95
76
+ format: numeric
77
+ -
78
+ - text: February
79
+ - text: £75
80
+ format: numeric
81
+ - text: £55
82
+ format: numeric
83
+ -
84
+ - text: March
85
+ - text: £165
86
+ format: numeric
87
+ - text: £125
88
+ format: numeric
89
+ with_sortable_head:
90
+ data:
91
+ sortable: true
92
+ head:
93
+ - text: Month you apply
94
+ - text: Rate for bicycles
95
+ format: numeric
96
+ sort_direction: descending
97
+ href: /?sort_direction=desc
98
+ - text: Rate for vehicles
99
+ format: numeric
100
+ href: /?sort_direction=desc
101
+ rows:
102
+ -
103
+ - text: January
104
+ - text:
105
+ format: numeric
106
+ - text: £95
107
+ format: numeric
108
+ -
109
+ - text: February
110
+ - text: £75
111
+ format: numeric
112
+ - text: £55
113
+ format: numeric
114
+ -
115
+ - text: March
116
+ - text: £125
117
+ format: numeric
118
+ - text: £60
119
+ format: numeric
120
+ -
121
+ - text: April
122
+ - text: £135
123
+ format: numeric
124
+ - text: £62
125
+ format: numeric
126
+ -
127
+ - text: May
128
+ - text: £150
129
+ format: numeric
130
+ - text: £80
131
+ format: numeric
@@ -25,6 +25,7 @@ require "govuk_publishing_components/presenters/highlight_boxes_helper"
25
25
  require "govuk_publishing_components/presenters/taxonomy_list_helper"
26
26
 
27
27
  require "govuk_publishing_components/app_helpers/taxon_breadcrumbs"
28
+ require "govuk_publishing_components/app_helpers/table_helper"
28
29
  require "govuk_publishing_components/app_helpers/brand_helper"
29
30
 
30
31
  module GovukPublishingComponents
@@ -0,0 +1,68 @@
1
+ module GovukPublishingComponents
2
+ module AppHelpers
3
+ class TableHelper
4
+ def self.helper(context, caption = nil, opt = {})
5
+ builder = TableBuilder.new(context.tag)
6
+
7
+ classes = %w(gem-c-table govuk-table)
8
+ classes << "govuk-table--sortable" if opt[:sortable]
9
+
10
+ caption_classes = %w(govuk-table__caption)
11
+ caption_classes << opt[:caption_classes] if opt[:caption_classes]
12
+
13
+ context.tag.table class: classes do
14
+ context.concat context.tag.caption caption, class: caption_classes
15
+ yield(builder)
16
+ end
17
+ end
18
+ class TableBuilder
19
+ include ActionView::Helpers::UrlHelper
20
+ include ActionView::Helpers::TagHelper
21
+
22
+ attr_reader :tag
23
+
24
+ def initialize(tag)
25
+ @tag = tag
26
+ end
27
+
28
+ def head
29
+ tag.thead class: "govuk-table__head" do
30
+ tag.tr class: "govuk-table__row" do
31
+ yield(self)
32
+ end
33
+ end
34
+ end
35
+
36
+ def body
37
+ tag.tbody class: "govuk-table__body" do
38
+ yield(self)
39
+ end
40
+ end
41
+
42
+ def row
43
+ tag.tr class: "govuk-table__row" do
44
+ yield(self)
45
+ end
46
+ end
47
+
48
+ def header(str, opt = {})
49
+ classes = %w(govuk-table__header)
50
+ classes << "govuk-table__header--#{opt[:format]}" if opt[:format]
51
+ classes << "govuk-table__header--active" if opt[:sort_direction]
52
+ link_clases = %w(app-table__sort-link)
53
+ link_clases << "app-table__sort-link--#{opt[:sort_direction]}" if opt[:sort_direction]
54
+ str = link_to str, opt[:href], class: link_clases if opt[:href]
55
+ tag.th str, class: classes, scope: opt[:scope] ? opt[:scope] : "col"
56
+ end
57
+
58
+ def cell(str, opt = {})
59
+ classes = %w(govuk-table__cell)
60
+ classes << "govuk-table__cell--" + opt[:format] if opt[:format]
61
+ classes << "govuk-table__cell--empty" unless str
62
+ str ||= "Not set"
63
+ tag.td str, class: classes
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -4,7 +4,7 @@ module GovukPublishingComponents
4
4
  module Presenters
5
5
  class ButtonHelper
6
6
  attr_reader :href, :text, :title, :info_text, :rel, :data_attributes,
7
- :start, :secondary, :secondary_quiet, :margin_bottom, :target
7
+ :margin_bottom, :target, :start, :secondary, :secondary_quiet, :destructive
8
8
 
9
9
  def initialize(local_assigns)
10
10
  @href = local_assigns[:href]
@@ -13,11 +13,12 @@ module GovukPublishingComponents
13
13
  @info_text = local_assigns[:info_text]
14
14
  @rel = local_assigns[:rel]
15
15
  @data_attributes = local_assigns[:data_attributes]
16
+ @margin_bottom = local_assigns[:margin_bottom]
17
+ @target = local_assigns[:target]
16
18
  @start = local_assigns[:start]
17
19
  @secondary = local_assigns[:secondary]
18
20
  @secondary_quiet = local_assigns[:secondary_quiet]
19
- @margin_bottom = local_assigns[:margin_bottom]
20
- @target = local_assigns[:target]
21
+ @destructive = local_assigns[:destructive]
21
22
  end
22
23
 
23
24
  def link?
@@ -42,6 +43,7 @@ module GovukPublishingComponents
42
43
  classes << "govuk-button--start" if start
43
44
  classes << "gem-c-button--secondary" if secondary
44
45
  classes << "gem-c-button--secondary-quiet" if secondary_quiet
46
+ classes << "gem-c-button--destructive" if destructive
45
47
  classes << "gem-c-button--bottom-margin" if margin_bottom
46
48
  classes.join(" ")
47
49
  end
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '9.25.0'.freeze
2
+ VERSION = '9.26.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.25.0
4
+ version: 9.26.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-20 00:00:00.000000000 Z
11
+ date: 2018-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config
@@ -382,6 +382,7 @@ files:
382
382
  - app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav.scss
383
383
  - app/assets/stylesheets/govuk_publishing_components/components/_subscription-links.scss
384
384
  - app/assets/stylesheets/govuk_publishing_components/components/_success-alert.scss
385
+ - app/assets/stylesheets/govuk_publishing_components/components/_table.scss
385
386
  - app/assets/stylesheets/govuk_publishing_components/components/_tabs.scss
386
387
  - app/assets/stylesheets/govuk_publishing_components/components/_taxonomy-list.scss
387
388
  - app/assets/stylesheets/govuk_publishing_components/components/_taxonomy-navigation.scss
@@ -492,6 +493,7 @@ files:
492
493
  - app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb
493
494
  - app/views/govuk_publishing_components/components/_subscription-links.html.erb
494
495
  - app/views/govuk_publishing_components/components/_success_alert.html.erb
496
+ - app/views/govuk_publishing_components/components/_table.html.erb
495
497
  - app/views/govuk_publishing_components/components/_tabs.html.erb
496
498
  - app/views/govuk_publishing_components/components/_taxonomy_list.html.erb
497
499
  - app/views/govuk_publishing_components/components/_taxonomy_navigation.html.erb
@@ -548,6 +550,7 @@ files:
548
550
  - app/views/govuk_publishing_components/components/docs/step_by_step_nav_related.yml
549
551
  - app/views/govuk_publishing_components/components/docs/subscription-links.yml
550
552
  - app/views/govuk_publishing_components/components/docs/success_alert.yml
553
+ - app/views/govuk_publishing_components/components/docs/table.yml
551
554
  - app/views/govuk_publishing_components/components/docs/tabs.yml
552
555
  - app/views/govuk_publishing_components/components/docs/taxonomy_list.yml
553
556
  - app/views/govuk_publishing_components/components/docs/taxonomy_navigation.yml
@@ -568,6 +571,7 @@ files:
568
571
  - lib/generators/govuk_publishing_components/templates/component.yml.erb
569
572
  - lib/govuk_publishing_components.rb
570
573
  - lib/govuk_publishing_components/app_helpers/brand_helper.rb
574
+ - lib/govuk_publishing_components/app_helpers/table_helper.rb
571
575
  - lib/govuk_publishing_components/app_helpers/taxon_breadcrumbs.rb
572
576
  - lib/govuk_publishing_components/config.rb
573
577
  - lib/govuk_publishing_components/engine.rb