govuk_publishing_components 61.2.0 → 61.3.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 +4 -4
- data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +0 -1
- data/app/controllers/govuk_publishing_components/component_guide_controller.rb +44 -0
- data/app/views/govuk_publishing_components/component_guide/preview.html.erb +17 -1
- data/app/views/layouts/govuk_publishing_components/application.html.erb +1 -9
- data/lib/govuk_publishing_components/config.rb +1 -3
- data/lib/govuk_publishing_components/presenters/component_wrapper_helper.rb +1 -1
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +1 -2
- data/app/assets/stylesheets/govuk_publishing_components/components/_copy-to-clipboard.scss +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a87851becee1d2a17743023f74057913c96f5a6b1f7b59e05f7209149e28a9b
|
4
|
+
data.tar.gz: 0263a75ae09eb9fa63677a03b146e6668ec4da01b9c989256864cd4db6663aef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18a4f902404fc7757833b25044bbeddb6b5730845d2f1ed4232be223b49ca4939874a8f26036fc26c37dfe193f13cc1821307b3b2ba518c39d487f7e32dc708b
|
7
|
+
data.tar.gz: d15b3f54fd67cdd8bc0677a6040e594ade6c7455756709a8c6d933e7231d97a543e7c4884764c271b3a501e0467c271c564d814e3226ae1defc327c96ee6aefc
|
@@ -26,7 +26,6 @@
|
|
26
26
|
@import "components/contextual-guidance";
|
27
27
|
@import "components/contextual-sidebar";
|
28
28
|
@import "components/cookie-banner";
|
29
|
-
@import "components/copy-to-clipboard";
|
30
29
|
@import "components/cross-service-header";
|
31
30
|
@import "components/date-input";
|
32
31
|
@import "components/details";
|
@@ -35,6 +35,21 @@ module GovukPublishingComponents
|
|
35
35
|
def preview
|
36
36
|
@component_examples = []
|
37
37
|
@component_doc = component_docs.get(params[:component])
|
38
|
+
|
39
|
+
@all_components = true if params[:all_components] == "true"
|
40
|
+
@all_gem_component_docs = []
|
41
|
+
@all_app_component_docs = []
|
42
|
+
if @all_components
|
43
|
+
@component_gem_path = Gem.loaded_specs["govuk_publishing_components"].full_gem_path
|
44
|
+
|
45
|
+
# Remove components without CSS, and the current component. The current component is excluded as the view will handle rendering its CSS.
|
46
|
+
@all_gem_component_docs = gem_component_docs.all.reject { |component| !component_has_sass_file(component.id.gsub("_", "-")) || component.id == @component_doc.id }
|
47
|
+
@all_app_component_docs = component_docs.all.reject { |component| !app_component_has_sass_file(component.id.gsub("_", "-")) || component.id == @component_doc.id }
|
48
|
+
|
49
|
+
@current_component_id = @component_doc.id.gsub("_", "-")
|
50
|
+
@render_component_first = params[:render_component_first] == "true" unless !component_has_sass_file(@current_component_id) && !app_component_has_sass_file(@current_component_id)
|
51
|
+
end
|
52
|
+
|
38
53
|
@preview = true
|
39
54
|
|
40
55
|
if params[:example].present?
|
@@ -42,6 +57,9 @@ module GovukPublishingComponents
|
|
42
57
|
else
|
43
58
|
@component_examples = @component_doc.examples
|
44
59
|
end
|
60
|
+
|
61
|
+
@percy = true if params[:percy] == "true"
|
62
|
+
@preview_title = preview_title(@component_doc, @component_examples, @all_components, @render_component_first, @percy)
|
45
63
|
end
|
46
64
|
|
47
65
|
def components_in_use_sass
|
@@ -136,6 +154,10 @@ module GovukPublishingComponents
|
|
136
154
|
extra_components.flatten.uniq.sort
|
137
155
|
end
|
138
156
|
|
157
|
+
def app_component_has_sass_file(component)
|
158
|
+
Pathname.new(Rails.root + "app/assets/stylesheets/components/_#{component}.scss").exist?
|
159
|
+
end
|
160
|
+
|
139
161
|
def component_has_sass_file(component)
|
140
162
|
Pathname.new(@component_gem_path + "/app/assets/stylesheets/govuk_publishing_components/components/_#{component}.scss").exist?
|
141
163
|
end
|
@@ -168,5 +190,27 @@ module GovukPublishingComponents
|
|
168
190
|
h[:url] = component_doc_path(component_doc.id) if component_example
|
169
191
|
end
|
170
192
|
end
|
193
|
+
|
194
|
+
def preview_title(component, component_examples, all_components, render_component_first, percy)
|
195
|
+
title = [component.name]
|
196
|
+
|
197
|
+
if component_examples.length == 1 && !percy
|
198
|
+
title[0] << ": #{component_examples.first.name} preview"
|
199
|
+
end
|
200
|
+
|
201
|
+
if all_components
|
202
|
+
title << "+ every component's CSS file"
|
203
|
+
|
204
|
+
title << if render_component_first
|
205
|
+
"- component rendering first"
|
206
|
+
else
|
207
|
+
"- component rendering last"
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
title << "- #{GovukPublishingComponents::Config.component_guide_title}" unless percy
|
212
|
+
|
213
|
+
title.join(" ")
|
214
|
+
end
|
171
215
|
end
|
172
216
|
end
|
@@ -1,4 +1,20 @@
|
|
1
|
-
<% content_for :application_stylesheet do
|
1
|
+
<% content_for :application_stylesheet do
|
2
|
+
if @all_components
|
3
|
+
# If rendering the component CSS first, do it explicitly here. If not, the component partial render will handle the CSS import.
|
4
|
+
if @render_component_first
|
5
|
+
if @component_doc.source == "application"
|
6
|
+
add_app_component_stylesheet(@current_component_id)
|
7
|
+
else
|
8
|
+
add_gem_component_stylesheet(@current_component_id)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
@all_gem_component_docs.each do |component|
|
12
|
+
add_gem_component_stylesheet(component.id.gsub("_", "-"))
|
13
|
+
end
|
14
|
+
@all_app_component_docs.each do |component|
|
15
|
+
add_app_component_stylesheet(component.id.gsub("_", "-"))
|
16
|
+
end
|
17
|
+
end %>
|
2
18
|
<% if @component_doc.source == "application" && application_stylesheet_in_use? %>
|
3
19
|
<%= render "application_stylesheet" %>
|
4
20
|
<% end %>
|
@@ -26,15 +26,7 @@
|
|
26
26
|
<html lang="en" class="<%= "govuk-template" unless @preview %> govuk-template--rebranded">
|
27
27
|
<head>
|
28
28
|
<meta charset="utf-8">
|
29
|
-
<title>
|
30
|
-
<% if @preview %>
|
31
|
-
<%= @component_doc.name %><% if @component_examples.length == 1 %>:
|
32
|
-
<%= @component_examples.first.name %>
|
33
|
-
<% end %>
|
34
|
-
preview -
|
35
|
-
<% end %>
|
36
|
-
<%= yield :title %><% if content_for(:title) %> - <% end %><%= GovukPublishingComponents::Config.component_guide_title %>
|
37
|
-
</title>
|
29
|
+
<title><% if @preview %><%= @preview_title %><% else %><%= yield :title %><% if content_for(:title) %> - <% end %><%= GovukPublishingComponents::Config.component_guide_title %><% end %></title>
|
38
30
|
<meta name="robots" content="noindex,nofollow,noimageindex">
|
39
31
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
40
32
|
<%= csrf_meta_tags %>
|
@@ -37,12 +37,10 @@ module GovukPublishingComponents
|
|
37
37
|
|
38
38
|
def self.all_stylesheets
|
39
39
|
stylesheets = Dir.glob("#{gem_directory}/app/assets/stylesheets/govuk_publishing_components/components/*.scss")
|
40
|
-
# _copy-to-clipboard.css is removed due to being an empty stylesheet
|
41
|
-
included_files = stylesheets.reject { |path| path.include?("copy-to-clipboard") }
|
42
40
|
|
43
41
|
application_stylesheet_hash = { "#{gem_directory}/app/assets/stylesheets/component_guide/application.scss" => "component_guide/application.css" }
|
44
42
|
|
45
|
-
|
43
|
+
stylesheets.each_with_object(application_stylesheet_hash) do |path, hsh|
|
46
44
|
hsh[path] = "govuk_publishing_components/components/#{File.basename(path, '.*')}.css"
|
47
45
|
end
|
48
46
|
end
|
@@ -183,7 +183,7 @@ module GovukPublishingComponents
|
|
183
183
|
def check_lang_is_valid(lang)
|
184
184
|
return if lang.blank?
|
185
185
|
|
186
|
-
langs = %w[ab aa af ak sq am ar an hy as av ae ay az bm ba eu be bn bh bi bs br bg my ca ch ce ny zh zh-Hans zh-Hant cv kw co cr hr cs da dv nl dz en eo et ee fo fj fi fr ff gl gd gv ka de el kl gn gu ht ha he hz hi ho hu is io ig id in ia ie iu ik ga it ja jv kl kn kr ks kk km ki rw rn ky kv kg ko ku kj lo la lv li ln lt lu lg lb gv mk mg ms ml mt mi mr mh mo mn na nv ng nd ne no nb nn ii oc oj cu or om os pi ps fa pl pt pa qu rm ro ru se sm sg sa sr sh st tn sn ii sd si ss sk sl so nr es su sw ss sv tl ty tg ta tt te th bo ti to ts tr tk tw ug uk ur uz ve vi vo wa cy wo fy xh yi ji yo za zu]
|
186
|
+
langs = %w[ab aa af ak sq am ar an hy as av ae ay az bm ba eu be bn bh bi bs br bg my ca ch ce ny zh zh-Hans zh-Hant zh-tw cv kw co cr hr cs da dv nl dz en eo et ee fo fj fi fr ff gl gd gv ka de el kl gn gu ht ha he hz hi ho hu is io ig id in ia ie iu ik ga it ja jv kl kn kr ks kk km ki rw rn ky kv kg ko ku kj lo la lv li ln lt lu lg lb gv mk mg ms ml mt mi mr mh mo mn na nv ng nd ne no nb nn ii oc oj cu or om os pi ps fa pl pt pa pa-pk qu rm ro ru se sm sg sa sr sh st tn sn ii sd si ss sk sl so nr es su sw ss sv tl ty tg ta tt te th bo ti to ts tr tk tw ug uk ur uz ve vi vo wa cy wo fy xh yi ji yo za zu]
|
187
187
|
unless langs.include? lang
|
188
188
|
raise(ArgumentError, "lang attribute (#{lang}) is not recognised")
|
189
189
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_publishing_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 61.
|
4
|
+
version: 61.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
@@ -561,7 +561,6 @@ files:
|
|
561
561
|
- app/assets/stylesheets/govuk_publishing_components/components/_contextual-guidance.scss
|
562
562
|
- app/assets/stylesheets/govuk_publishing_components/components/_contextual-sidebar.scss
|
563
563
|
- app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss
|
564
|
-
- app/assets/stylesheets/govuk_publishing_components/components/_copy-to-clipboard.scss
|
565
564
|
- app/assets/stylesheets/govuk_publishing_components/components/_cross-service-header.scss
|
566
565
|
- app/assets/stylesheets/govuk_publishing_components/components/_date-input.scss
|
567
566
|
- app/assets/stylesheets/govuk_publishing_components/components/_details.scss
|
@@ -1 +0,0 @@
|
|
1
|
-
// No styles, this component just uses subcomponents
|