govuk_publishing_components 21.60.1 → 21.63.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/components/checkboxes.js +102 -73
  3. data/app/assets/javascripts/govuk_publishing_components/ie.js +2 -0
  4. data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/youtube-link-enhancement.js +1 -1
  5. data/app/assets/javascripts/govuk_publishing_components/vendor/html5shiv-printshiv.js +4 -0
  6. data/app/assets/javascripts/govuk_publishing_components/vendor/json2.js +487 -0
  7. data/app/assets/stylesheets/component_guide/application.scss +4 -0
  8. data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +1 -0
  9. data/app/assets/stylesheets/govuk_publishing_components/components/_breadcrumbs.scss +3 -16
  10. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-footer.scss +8 -0
  11. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-for-public.scss +4 -0
  12. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-header.scss +87 -1
  13. data/app/assets/stylesheets/govuk_publishing_components/components/_radio.scss +1 -1
  14. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +46 -0
  15. data/app/assets/stylesheets/govuk_publishing_components/govuk_frontend_support.scss +8 -0
  16. data/app/models/govuk_publishing_components/audit_applications.rb +35 -23
  17. data/app/models/govuk_publishing_components/audit_comparer.rb +13 -0
  18. data/app/models/govuk_publishing_components/component_example.rb +4 -0
  19. data/app/views/govuk_publishing_components/audit/show.html.erb +32 -3
  20. data/app/views/govuk_publishing_components/component_guide/component_doc/_component.html.erb +1 -0
  21. data/app/views/govuk_publishing_components/components/_breadcrumbs.html.erb +1 -1
  22. data/app/views/govuk_publishing_components/components/_document_list.html.erb +18 -9
  23. data/app/views/govuk_publishing_components/components/_image_card.html.erb +1 -1
  24. data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +32 -21
  25. data/app/views/govuk_publishing_components/components/_layout_for_public.html.erb +76 -0
  26. data/app/views/govuk_publishing_components/components/_layout_header.html.erb +39 -51
  27. data/app/views/govuk_publishing_components/components/_search.html.erb +10 -5
  28. data/app/views/govuk_publishing_components/components/_share_links.html.erb +9 -9
  29. data/app/views/govuk_publishing_components/components/docs/document_list.yml +18 -0
  30. data/app/views/govuk_publishing_components/components/docs/image_card.yml +13 -1
  31. data/app/views/govuk_publishing_components/components/docs/layout_footer.yml +17 -0
  32. data/app/views/govuk_publishing_components/components/docs/layout_for_admin.yml +5 -1
  33. data/app/views/govuk_publishing_components/components/docs/layout_for_public.yml +29 -0
  34. data/app/views/govuk_publishing_components/components/docs/layout_header.yml +34 -0
  35. data/app/views/govuk_publishing_components/components/docs/search.yml +6 -0
  36. data/app/views/govuk_publishing_components/components/feedback/_problem_form.html.erb +6 -6
  37. data/app/views/govuk_publishing_components/components/feedback/_survey_signup_form.html.erb +6 -6
  38. data/app/views/govuk_publishing_components/components/feedback/_yes_no_banner.html.erb +8 -10
  39. data/app/views/govuk_publishing_components/components/layout_header/_header_logo.html.erb +23 -0
  40. data/app/views/govuk_publishing_components/components/layout_header/_navigation_items.html.erb +17 -0
  41. data/app/views/govuk_publishing_components/components/layout_header/_search.html.erb +9 -0
  42. data/config/initializers/assets.rb +8 -0
  43. data/config/locales/en.yml +18 -0
  44. data/lib/govuk_publishing_components.rb +1 -0
  45. data/lib/govuk_publishing_components/presenters/breadcrumb_selector.rb +5 -0
  46. data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_priority.rb +1 -0
  47. data/lib/govuk_publishing_components/presenters/image_card_helper.rb +3 -2
  48. data/lib/govuk_publishing_components/presenters/public_layout_helper.rb +380 -0
  49. data/lib/govuk_publishing_components/version.rb +1 -1
  50. data/node_modules/govuk-frontend/govuk/components/character-count/_index.scss +0 -4
  51. data/node_modules/govuk-frontend/govuk/settings/_colours-palette.scss +33 -33
  52. data/node_modules/govuk-frontend/package.json +1 -1
  53. metadata +12 -2
@@ -125,6 +125,10 @@ $gem-guide-border-width: 1px;
125
125
  background-color: govuk-colour("blue");
126
126
  }
127
127
 
128
+ &.black-background {
129
+ background-color: govuk-colour("black");
130
+ }
131
+
128
132
  &.component-output {
129
133
  padding: 0;
130
134
  }
@@ -44,6 +44,7 @@
44
44
  @import "components/label";
45
45
  @import "components/layout-footer";
46
46
  @import "components/layout-for-admin";
47
+ @import "components/layout-for-public";
47
48
  @import "components/layout-header";
48
49
  @import "components/lead-paragraph";
49
50
  @import "components/metadata";
@@ -21,37 +21,24 @@
21
21
  border-color: govuk-colour("white");
22
22
  }
23
23
 
24
- .gem-c-breadcrumbs--collapse-on-mobile {
24
+ .govuk-breadcrumbs--collapse-on-mobile {
25
25
  @include govuk-media-query($until: tablet) {
26
- .govuk-breadcrumbs__list {
27
- display: flex;
28
- }
29
-
30
- .govuk-breadcrumbs__list-item:not(:last-child):not(:first-child) {
31
- display: none;
32
- }
33
-
34
26
  .govuk-breadcrumbs__list-item {
35
27
  padding-top: 14px;
36
28
  padding-bottom: 14px;
37
29
  }
38
30
 
39
31
  .govuk-breadcrumbs__list-item:before {
40
- margin: 0;
41
32
  top: 18px;
42
33
  }
43
34
 
44
- .govuk-breadcrumbs__link {
45
- position: relative;
46
- }
47
-
48
35
  .govuk-breadcrumbs__link:after {
49
36
  content: "";
50
37
  position: absolute;
51
- top: -14px;
38
+ top: 0;
52
39
  right: 0;
53
40
  left: 0;
54
- bottom: -14px;
41
+ bottom: 0;
55
42
  }
56
43
  }
57
44
  }
@@ -1 +1,9 @@
1
1
  @import "govuk/components/footer/footer";
2
+
3
+ .gem-c-layout-footer--border {
4
+ border-top: govuk-spacing(2) solid govuk-colour("blue");
5
+ }
6
+
7
+ .gem-c-layout-footer .govuk-footer__list {
8
+ padding-bottom: govuk-spacing(7);
9
+ }
@@ -0,0 +1,4 @@
1
+ .gem-c-layout-for-public {
2
+ margin: 0;
3
+ font-family: $govuk-font-family;
4
+ }
@@ -1,3 +1,5 @@
1
+ @import "govuk_publishing_components/components/search";
2
+ @import "govuk_publishing_components/components/skip-link";
1
3
  @import "govuk/components/header/header";
2
4
  @import "govuk/components/tag/tag";
3
5
 
@@ -18,8 +20,80 @@
18
20
  border-bottom-color: govuk-colour("dark-grey", $legacy: "grey-1");
19
21
  }
20
22
 
23
+ .gem-c-layout-header--no-bottom-border,
24
+ .gem-c-layout-header--no-bottom-border .govuk-header__container {
25
+ margin-bottom: 0;
26
+ border-bottom: 0;
27
+
28
+ @include govuk-media-query($until: tablet) {
29
+ padding-bottom: govuk-spacing(1);
30
+ }
31
+ }
32
+
33
+ .gem-c-layout-header--search-left {
34
+ .gem-c-header__menu-button {
35
+ margin-top: - govuk-spacing(7);
36
+ left: 0;
37
+ }
38
+
39
+ .gem-c-header__nav-wrapper {
40
+ position: relative;
41
+ padding-left: 0;
42
+ }
43
+
44
+ .govuk-header__navigation--end {
45
+ padding-top: 0;
46
+ text-align: left;
47
+ }
48
+
49
+ .gem-c-layout-header__search {
50
+ margin-bottom: govuk-spacing(2);
51
+ padding-bottom: govuk-spacing(5);
52
+ }
53
+
54
+ .gem-c-header__content {
55
+ position: relative;
56
+ width: 100%;
57
+ padding-bottom: govuk-spacing(2);
58
+ }
59
+
60
+ @include govuk-media-query($from: desktop) {
61
+ .gem-c-layout-header__search {
62
+ padding-bottom: govuk-spacing(1);
63
+ }
64
+
65
+ .govuk-header__navigation-item {
66
+ padding: 0 0 govuk-spacing(1) 0;
67
+ }
68
+
69
+ .gem-c-header__logo {
70
+ margin-top: 0;
71
+ }
72
+
73
+ .gem-c-header__content {
74
+ @include govuk-grid-column(two-thirds);
75
+ padding-left: govuk-spacing(6);
76
+ padding-right: govuk-spacing(1);
77
+ }
78
+ }
79
+ }
80
+
81
+ .gem-c-layout-header__logo,
82
+ .gem-c-layout-header__search {
83
+ padding: 0;
84
+
85
+ @include govuk-media-query($until: "tablet") {
86
+ margin-bottom: govuk-spacing(3);
87
+ }
88
+ }
89
+
21
90
  .gem-c-header__logo {
22
- width: auto;
91
+ margin-top: govuk-spacing(1);
92
+ margin-bottom: govuk-spacing(3);
93
+
94
+ @include govuk-media-query($from: desktop) {
95
+ white-space: nowrap;
96
+ }
23
97
  }
24
98
 
25
99
  .gem-c-header__content {
@@ -68,3 +142,15 @@
68
142
  display: none;
69
143
  }
70
144
  }
145
+
146
+ .gem-c-layout-header__search-form {
147
+ display: none;
148
+
149
+ &.js-visible {
150
+ display: block;
151
+ }
152
+
153
+ @include govuk-media-query($from: tablet) {
154
+ display: block;
155
+ }
156
+ }
@@ -1,5 +1,5 @@
1
1
  @import "govuk/components/radios/radios";
2
2
 
3
3
  .gem-c-radio__heading-text {
4
- margin: 0;
4
+ margin: 0 0 govuk-spacing(4) 0;
5
5
  }
@@ -179,6 +179,12 @@ $large-input-size: 50px;
179
179
  }
180
180
  }
181
181
 
182
+ .gem-c-search--no-border {
183
+ .gem-c-search__input[type="search"] {
184
+ border: 0;
185
+ }
186
+ }
187
+
182
188
  .gem-c-search--large {
183
189
  .gem-c-search__label {
184
190
  @include govuk-font($size: 19, $line-height: $large-input-size);
@@ -208,3 +214,43 @@ $large-input-size: 50px;
208
214
  padding-left: 0;
209
215
  }
210
216
  }
217
+
218
+ .search-toggle {
219
+ background-color: govuk-colour("blue");
220
+ background-image: image-url("govuk_publishing_components/search-button.png");
221
+ background-position: 0 50%;
222
+ background-repeat: no-repeat;
223
+ display: block;
224
+ float: right;
225
+ height: 30px;
226
+ margin: -46px 0;
227
+ overflow: hidden;
228
+ padding: 0;
229
+ text-indent: -5000px;
230
+ width: 36px;
231
+
232
+ &:focus {
233
+ border-width: 0;
234
+ box-shadow: inset 0 0 0 4px $govuk-input-border-colour;
235
+ outline: $govuk-focus-width solid $govuk-focus-colour;
236
+ outline-offset: 0;
237
+ }
238
+
239
+ &:focus,
240
+ &:hover {
241
+ background-color: lighten(govuk-colour("blue"), 5%);
242
+ }
243
+
244
+ &.js-hidden {
245
+ display: none;
246
+ }
247
+
248
+ @include govuk-device-pixel-ratio {
249
+ background-size: 52.5px 35px;
250
+ background-position: 100% 50%;
251
+ }
252
+
253
+ @include govuk-media-query($from: tablet) {
254
+ display: none;
255
+ }
256
+ }
@@ -4,3 +4,11 @@
4
4
  @import "govuk/settings/all";
5
5
  @import "govuk/tools/all";
6
6
  @import "govuk/helpers/all";
7
+ $govuk-colours-organisations: map-merge(
8
+ $govuk-colours-organisations,
9
+ (
10
+ "foreign-commonwealth-development-office": (
11
+ colour: #012169
12
+ )
13
+ )
14
+ );
@@ -3,37 +3,39 @@ module GovukPublishingComponents
3
3
  attr_reader :data
4
4
 
5
5
  def initialize(path, name)
6
- templates = Dir["#{path}/app/views/**/*.erb"]
7
- stylesheets = Dir["#{path}/app/assets/stylesheets/**/*.scss"]
8
- javascripts = Dir["#{path}/app/assets/javascripts/**/*.js"]
6
+ @path = path
7
+ application_found = application_exists(path)
8
+ components_found = []
9
+ @gem_style_references = []
9
10
 
10
- find_components = /(?<=govuk_publishing_components\/components\/)[\/a-zA-Z_-]+(?=['"])/
11
+ if application_found
12
+ templates = Dir["#{path}/app/views/**/*.erb"]
13
+ stylesheets = Dir["#{path}/app/assets/stylesheets/**/*.scss"]
14
+ javascripts = Dir["#{path}/app/assets/javascripts/**/*.js"]
11
15
 
12
- @find_all_stylesheets = /@import ["']{1}govuk_publishing_components\/all_components/
13
- find_stylesheets = /(?<=@import ["']{1}govuk_publishing_components\/components\/)(?!print\/)+[a-zA-Z_-]+(?=['"])/
16
+ find_components = /(?<=govuk_publishing_components\/components\/)[\/a-zA-Z_-]+(?=['"])/
14
17
 
15
- @find_all_print_stylesheets = /@import ["']{1}govuk_publishing_components\/all_components_print/
16
- find_print_stylesheets = /(?<=@import ["']{1}govuk_publishing_components\/components\/print\/)[a-zA-Z_-]+(?=['"])/
18
+ @find_all_stylesheets = /@import ["']{1}govuk_publishing_components\/all_components/
19
+ find_stylesheets = /(?<=@import ["']{1}govuk_publishing_components\/components\/)(?!print\/)+[a-zA-Z_-]+(?=['"])/
17
20
 
18
- @find_all_javascripts = /\/\/[ ]*= require govuk_publishing_components\/all_components/
19
- find_javascripts = /(?<=require govuk_publishing_components\/components\/)[a-zA-Z_-]+/
21
+ @find_all_print_stylesheets = /@import ["']{1}govuk_publishing_components\/all_components_print/
22
+ find_print_stylesheets = /(?<=@import ["']{1}govuk_publishing_components\/components\/print\/)[a-zA-Z_-]+(?=['"])/
20
23
 
21
- components_in_templates = find_components(templates, find_components, "templates") || []
22
- components_in_stylesheets = find_components(stylesheets, find_stylesheets, "stylesheets") || []
23
- components_in_print_stylesheets = find_components(stylesheets, find_print_stylesheets, "print_stylesheets") || []
24
- components_in_javascripts = find_components(javascripts, find_javascripts, "javascripts") || []
24
+ @find_all_javascripts = /\/\/[ ]*= require govuk_publishing_components\/all_components/
25
+ find_javascripts = /(?<=require govuk_publishing_components\/components\/)[a-zA-Z_-]+/
25
26
 
26
- ruby_paths = %w[/app/helpers/ /app/presenters/ /lib/]
27
- components_in_ruby = []
28
- ruby_paths.each do |ruby_path|
29
- components_in_ruby << find_components(Dir["#{path}#{ruby_path}**/*.{rb,erb}"], find_components, "ruby") || []
30
- end
31
- components_in_ruby = components_in_ruby.flatten.uniq
27
+ components_in_templates = find_components(templates, find_components, "templates") || []
28
+ components_in_stylesheets = find_components(stylesheets, find_stylesheets, "stylesheets") || []
29
+ components_in_print_stylesheets = find_components(stylesheets, find_print_stylesheets, "print_stylesheets") || []
30
+ components_in_javascripts = find_components(javascripts, find_javascripts, "javascripts") || []
32
31
 
33
- application_found = application_exists(path)
34
- components_found = []
32
+ ruby_paths = %w[/app/helpers/ /app/presenters/ /lib/]
33
+ components_in_ruby = []
34
+ ruby_paths.each do |ruby_path|
35
+ components_in_ruby << find_components(Dir["#{path}#{ruby_path}**/*.{rb,erb}"], find_components, "ruby") || []
36
+ end
37
+ components_in_ruby = components_in_ruby.flatten.uniq
35
38
 
36
- if application_found
37
39
  components_found = [
38
40
  {
39
41
  location: "templates",
@@ -62,6 +64,7 @@ module GovukPublishingComponents
62
64
  name: name,
63
65
  application_found: application_found,
64
66
  components_found: components_found,
67
+ gem_style_references: @gem_style_references.flatten.uniq.sort,
65
68
  }
66
69
  end
67
70
 
@@ -73,6 +76,8 @@ module GovukPublishingComponents
73
76
  files.each do |file|
74
77
  src = File.read(file)
75
78
  components_found << find_match(find, src, type)
79
+ gem_references = find_gem_references(file, src)
80
+ @gem_style_references << gem_references if gem_references
76
81
  rescue StandardError
77
82
  puts "File #{file} not found"
78
83
  end
@@ -94,6 +99,13 @@ module GovukPublishingComponents
94
99
  all_matches
95
100
  end
96
101
 
102
+ def find_gem_references(file, src)
103
+ find_gem_classes = /gem-c-[-_a-zA-Z]+/
104
+ clean_file_path = /(?<=#{Regexp.escape(@path)}\/)[\/a-zA-Z_-]+.[a-zA-Z.]+/
105
+
106
+ return file[clean_file_path] if find_gem_classes.match?(src)
107
+ end
108
+
97
109
  def clean_file_name(name)
98
110
  name.tr("_-", " ").strip
99
111
  end
@@ -36,6 +36,7 @@ module GovukPublishingComponents
36
36
  warnings = []
37
37
  warnings << warn_about_missing_components(result[:components_found])
38
38
  warnings << warn_about_missing_assets(result[:components_found])
39
+ warnings << warn_about_style_overrides(result[:gem_style_references])
39
40
  warnings = warnings.flatten
40
41
 
41
42
  data << {
@@ -65,6 +66,7 @@ module GovukPublishingComponents
65
66
  ],
66
67
  warnings: warnings,
67
68
  warning_count: warnings.length,
69
+ gem_style_references: result[:gem_style_references],
68
70
  }
69
71
  else
70
72
  data << {
@@ -150,6 +152,17 @@ module GovukPublishingComponents
150
152
  !@gem_data[:component_code].include?(component) unless component == "all"
151
153
  end
152
154
 
155
+ def warn_about_style_overrides(results)
156
+ warnings = []
157
+
158
+ results.each do |result|
159
+ warnings << create_warning("Possible component style override", result) if result.include? ".scss"
160
+ warnings << create_warning("Possible hard coded component markup", result) if [".html", ".rb"].any? { |needle| result.include? needle }
161
+ end
162
+
163
+ warnings
164
+ end
165
+
153
166
  def find_missing(needle, haystack)
154
167
  (haystack - needle).flatten.sort
155
168
  end
@@ -78,6 +78,10 @@ module GovukPublishingComponents
78
78
  context["dark_background"].present?
79
79
  end
80
80
 
81
+ def black_background?
82
+ !!context["black_background"]
83
+ end
84
+
81
85
  def html_description
82
86
  markdown_to_html(description) if description.present?
83
87
  end
@@ -20,7 +20,11 @@
20
20
  </li>
21
21
  </ul>
22
22
  <div class="govuk-tabs__panel" id="applications">
23
- <h2 class="govuk-heading-l">Applications</h2>
23
+ <%= render "govuk_publishing_components/components/heading", {
24
+ text: "Applications",
25
+ font_size: "l",
26
+ margin_bottom: 6
27
+ } %>
24
28
 
25
29
  <% if @applications.any? %>
26
30
  <details class="govuk-details" data-module="govuk-details">
@@ -66,7 +70,12 @@
66
70
  </p>
67
71
  <% end %>
68
72
 
69
- <h3 class="govuk-heading-m">Components used</h3>
73
+ <%= render "govuk_publishing_components/components/heading", {
74
+ text: "Components used",
75
+ font_size: "m",
76
+ margin_bottom: 4,
77
+ heading_level: 3,
78
+ } %>
70
79
 
71
80
  <dl class="govuk-summary-list">
72
81
  <% application[:summary].each do |item| %>
@@ -84,6 +93,22 @@
84
93
  </div>
85
94
  <% end %>
86
95
  </dl>
96
+
97
+ <% if application[:gem_style_references].any? %>
98
+ <%= render "govuk_publishing_components/components/heading", {
99
+ text: "Component references",
100
+ font_size: "m",
101
+ margin_bottom: 4,
102
+ heading_level: 3,
103
+ } %>
104
+
105
+ <p class="govuk-body">This shows instances of `gem-c-` classes found in the application. If a reference is found in a stylesheet or in code a warning is created, as this could be a style override or hard coded component markup.</p>
106
+ <ul class="govuk-list govuk-list--bullet">
107
+ <% application[:gem_style_references].each do |ref| %>
108
+ <li><%= ref %></li>
109
+ <% end %>
110
+ </ul>
111
+ <% end %>
87
112
  <% else %>
88
113
  <p class="govuk-body">This application was not found. This could be because you do not have this repository checked out locally.</p>
89
114
  <% end %>
@@ -97,7 +122,11 @@
97
122
  </div>
98
123
 
99
124
  <div class="govuk-tabs__panel govuk-tabs__panel--hidden" id="components-gem">
100
- <h2 class="govuk-heading-l">Components</h2>
125
+ <%= render "govuk_publishing_components/components/heading", {
126
+ text: "Components",
127
+ font_size: "l",
128
+ margin_bottom: 6,
129
+ } %>
101
130
 
102
131
  <% if @components.any? %>
103
132
  <div class="govuk-accordion" data-module="govuk-accordion" id="accordion-default">