govuk_publishing_components 21.25.0 → 21.26.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 04e2dde0c324eadb613ca21bf75464158fc7736d65fcd76ed49fc39d39b9859b
4
- data.tar.gz: 014ed07b9ec95bdf59a243129a2121231aa47f5b39469134e175a4d6ff462a0e
3
+ metadata.gz: 85bfabc41347e3eabf194ea1267d038be37fb4a7d1f2275a114768760400fdbb
4
+ data.tar.gz: 94857248756288979fa76c7d836de06a412572d3162b56999b554bf5c48f6d6f
5
5
  SHA512:
6
- metadata.gz: 52031cc0a250839e6738e617d653fca57d86ce733cf8b945e8d4eb09fb6398d3565aba3bd76d278a27fa19d0c8559b3164720a3a16cf1d15227ddf57f6ecaae5
7
- data.tar.gz: b42b626497d9c42c2404ba057a1975116b78adaf9ca3f216e6609f63e468cd57e8c24c8a8f6fe63a0c1506ebf1af464d1a606fe2652d3ca1941ff43b68390c3b
6
+ metadata.gz: '05045873de72f2d7ee83c5e3ff3409f4617914f012a8dddd7156d5babccc0ad6e7eccc765e89303f301e8721eadee9730e0ebfe66189d3965566f03547ae5405'
7
+ data.tar.gz: 51a1441882dce26a073c3f18e431346f4ad628487213c19c9d6110398125338f5abc387675e05a93411713e1a6aed8f665bd5dc2a450efd290b31fa5fa3aa5c4
@@ -7,6 +7,8 @@
7
7
  @import "govuk/helpers/all";
8
8
  @import "govuk/core/all";
9
9
 
10
+ @import "govuk_publishing_components/all_components";
11
+
10
12
  $gem-guide-border-width: 1px;
11
13
 
12
14
  .component-list {
@@ -0,0 +1,16 @@
1
+ // This file should be included in an application prior to specific components
2
+ // It provides supporting gem component helpers and mixins
3
+ // and everything else from govuk-frontend not included in govuk_frontend_support
4
+ @import "govuk/core/all";
5
+ @import "govuk/objects/all";
6
+ @import "govuk/components/all";
7
+ @import "govuk/utilities/all";
8
+ @import "govuk/overrides/all";
9
+
10
+ @import "govuk_publishing_components/components/helpers/variables";
11
+ @import "govuk_publishing_components/components/helpers/brand-colours";
12
+ @import "govuk_publishing_components/components/mixins/govuk-template-link-focus-override";
13
+ @import "govuk_publishing_components/components/mixins/media-down";
14
+ @import "govuk_publishing_components/components/mixins/margins";
15
+ @import "govuk_publishing_components/components/mixins/clearfix";
16
+ @import "govuk_publishing_components/components/mixins/css3";
@@ -0,0 +1,6 @@
1
+ // This file should be included in an application prior to specific components
2
+ // It provides govuk-frontend but adds no weight to the compiled CSS
3
+ @import "components/helpers/govuk-frontend-settings";
4
+ @import "govuk/settings/all";
5
+ @import "govuk/tools/all";
6
+ @import "govuk/helpers/all";
@@ -5,6 +5,9 @@ module GovukPublishingComponents
5
5
  def index
6
6
  @component_docs = component_docs.all
7
7
  @gem_component_docs = gem_component_docs.all
8
+ @components_in_use_docs = components_in_use_docs.used_in_this_app
9
+ @components_in_use_sass = components_in_use_sass(false)
10
+ @components_in_use_print_sass = components_in_use_sass(true)
8
11
  end
9
12
 
10
13
  def show
@@ -36,6 +39,16 @@ module GovukPublishingComponents
36
39
  end
37
40
  end
38
41
 
42
+ def components_in_use_sass(print_styles)
43
+ print_path = "print/" if print_styles
44
+ additional_files = "@import 'govuk_publishing_components/govuk_frontend_support';\n"
45
+ additional_files << "@import 'govuk_publishing_components/component_support';\n" unless print_styles
46
+
47
+ components_in_use.map { |component|
48
+ "@import 'govuk_publishing_components/components/#{print_path}_#{component.gsub('_', '-')}';" if component_has_sass_file(component.gsub('_', '-'), print_styles)
49
+ }.join("\n").squeeze("\n").prepend(additional_files)
50
+ end
51
+
39
52
  private
40
53
 
41
54
  def component_docs
@@ -46,6 +59,27 @@ module GovukPublishingComponents
46
59
  @gem_component_docs ||= ComponentDocs.new(gem_components: true)
47
60
  end
48
61
 
62
+ def components_in_use_docs
63
+ @components_in_use_docs ||= ComponentDocs.new(gem_components: true, limit_to: components_in_use)
64
+ end
65
+
66
+ def components_in_use
67
+ matches = []
68
+
69
+ files = Dir["#{Rails.root}/app/views/**/*.html.erb"]
70
+ files.each do |file|
71
+ data = File.read(file)
72
+ matches << data.scan(/(govuk_publishing_components\/components\/[a-z_-]+)/)
73
+ end
74
+
75
+ matches.flatten.uniq.map(&:to_s).sort.map { |m| m.gsub('govuk_publishing_components/components/', '') }
76
+ end
77
+
78
+ def component_has_sass_file(component, print_styles)
79
+ print_path = "print/" if print_styles
80
+ Pathname.new(__dir__ + "/../../assets/stylesheets/govuk_publishing_components/components/#{print_path}_#{component}.scss").exist?
81
+ end
82
+
49
83
  def index_breadcrumb
50
84
  {
51
85
  title: GovukPublishingComponents::Config.component_guide_title,
@@ -1,7 +1,8 @@
1
1
  module GovukPublishingComponents
2
2
  # @private
3
3
  class ComponentDocs
4
- def initialize(gem_components: false)
4
+ def initialize(gem_components: false, limit_to: false)
5
+ @limit_to = limit_to
5
6
  @documentation_directory = gem_components ? gem_documentation_directory : app_documentation_directory
6
7
  end
7
8
 
@@ -14,6 +15,10 @@ module GovukPublishingComponents
14
15
  fetch_component_docs.map { |component| build(component) }.sort_by(&:name)
15
16
  end
16
17
 
18
+ def used_in_this_app
19
+ fetch_component_docs.map { |component| build(component) if component_in_use(component[:id]) }.compact.sort_by(&:name)
20
+ end
21
+
17
22
  private
18
23
 
19
24
  def build(component)
@@ -25,6 +30,10 @@ module GovukPublishingComponents
25
30
  Dir[doc_files].sort.map { |file| parse_documentation(file) }
26
31
  end
27
32
 
33
+ def component_in_use(component)
34
+ return true if @limit_to.include?(component)
35
+ end
36
+
28
37
  def fetch_component_doc(id)
29
38
  file = Rails.root.join(@documentation_directory, "#{id}.yml")
30
39
  if !file.exist?
@@ -17,8 +17,44 @@
17
17
  </form>
18
18
 
19
19
  <% unless ENV["MAIN_COMPONENT_GUIDE"] %>
20
- <h2 class="component-doc-h2">Components in this application</h2>
20
+ <h2 class="component-doc-h2">Gem components used by this app (<%= @components_in_use_docs.length %>)</h2>
21
21
 
22
+ <%= render "govuk_publishing_components/components/details", {
23
+ title: "Suggested Sass for this application"
24
+ } do %>
25
+ <%= render "govuk_publishing_components/components/textarea", {
26
+ label: {
27
+ text: "Add this to your application's main scss file"
28
+ },
29
+ name: "main-sass",
30
+ value: @components_in_use_sass
31
+ } %>
32
+ <%= render "govuk_publishing_components/components/textarea", {
33
+ label: {
34
+ text: "Add this to your application's print scss file"
35
+ },
36
+ name: "print-sass",
37
+ value: @components_in_use_print_sass
38
+ } %>
39
+ <% end %>
40
+ <pre>
41
+
42
+ </pre>
43
+
44
+ <ul class="component-list">
45
+ <% @components_in_use_docs.each do |component_doc| %>
46
+ <li>
47
+ <%= link_to component_doc.name, component_doc_path(component_doc.id), class: "govuk-link" %>
48
+ <p>
49
+ <%= component_doc.description %>
50
+ </p>
51
+ </li>
52
+ <% end %>
53
+ </ul>
54
+ <% end %>
55
+
56
+ <% unless ENV["MAIN_COMPONENT_GUIDE"] %>
57
+ <h2 class="component-doc-h2">Components in this application (<%= @component_docs.length %>)</h2>
22
58
  <ul class="component-list">
23
59
  <% @component_docs.each do |component_doc| %>
24
60
  <li>
@@ -30,7 +66,7 @@
30
66
  <% end %>
31
67
  </ul>
32
68
 
33
- <h2 class="component-doc-h2">Components in the gem</h2>
69
+ <h2 class="component-doc-h2">All gem components (<%= @gem_component_docs.length %>)</h2>
34
70
  <% end %>
35
71
 
36
72
  <ul class="component-list">
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '21.25.0'.freeze
2
+ VERSION = '21.26.0'.freeze
3
3
  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: 21.25.0
4
+ version: 21.26.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
@@ -431,6 +431,7 @@ files:
431
431
  - app/assets/stylesheets/component_guide/application.scss
432
432
  - app/assets/stylesheets/govuk_publishing_components/_all_components.scss
433
433
  - app/assets/stylesheets/govuk_publishing_components/_all_components_print.scss
434
+ - app/assets/stylesheets/govuk_publishing_components/component_support.scss
434
435
  - app/assets/stylesheets/govuk_publishing_components/components/_accordion.scss
435
436
  - app/assets/stylesheets/govuk_publishing_components/components/_attachment-link.scss
436
437
  - app/assets/stylesheets/govuk_publishing_components/components/_attachment.scss
@@ -548,6 +549,7 @@ files:
548
549
  - app/assets/stylesheets/govuk_publishing_components/components/print/_textarea.scss
549
550
  - app/assets/stylesheets/govuk_publishing_components/components/print/_title.scss
550
551
  - app/assets/stylesheets/govuk_publishing_components/components/print/_translation-nav.scss
552
+ - app/assets/stylesheets/govuk_publishing_components/govuk_frontend_support.scss
551
553
  - app/controllers/govuk_publishing_components/application_controller.rb
552
554
  - app/controllers/govuk_publishing_components/component_guide_controller.rb
553
555
  - app/helpers/govuk_publishing_components/application_helper.rb