Skip to content

Commit

Permalink
Remove guide components from suggested sass
Browse files Browse the repository at this point in the history
- these components were previously added to the suggested sass feature because they were used by the guide but potentially not by the application, meaning that the guide wouldn't be styled properly if they weren't included
- this followed a change to remove all component sass from the guide sass in order to prevent duplicate CSS being loaded in the guide, because the guide loads both its own styles and the parent application styles
- however this doesn't work: limiting the component sass to only those used by the application plus those used by the guide itself means that there will still be some components shown in the guide that aren't styled
  • Loading branch information
andysellick committed Mar 30, 2020
1 parent b7e375a commit 68388af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def components_in_use_sass(print_styles)
additional_files = "@import 'govuk_publishing_components/govuk_frontend_support';\n"
additional_files << "@import 'govuk_publishing_components/component_support';\n" unless print_styles

components = components_in_use("#{@application_path}/app/views/")
components = components_in_use
extra_components = []

components.each do |component|
Expand All @@ -55,7 +55,6 @@ def components_in_use_sass(print_styles)
end

components << extra_components.compact
components << components_used_by_component_guide.compact
components = components.flatten.uniq.sort

components.map { |component|
Expand All @@ -74,13 +73,13 @@ def gem_component_docs
end

def components_in_use_docs
@components_in_use_docs ||= ComponentDocs.new(gem_components: true, limit_to: components_in_use("#{@application_path}/app/views/"))
@components_in_use_docs ||= ComponentDocs.new(gem_components: true, limit_to: components_in_use)
end

def components_in_use(path)
def components_in_use
matches = []

files = Dir[path + "**/*.html.erb"]
files = Dir["#{@application_path}/app/views/**/*.html.erb"]
files.each do |file|
data = File.read(file)
matches << data.scan(/(govuk_publishing_components\/components\/[a-z_-]+)/)
Expand Down Expand Up @@ -113,10 +112,5 @@ def component_breadcrumb(component_doc, component_example = nil)
h[:url] = component_doc_path(component_doc.id) if component_example
end
end

def components_used_by_component_guide
components = components_in_use("#{@component_gem_path}/app/views/govuk_publishing_components/component_guide/")
components << components_in_use("#{@component_gem_path}/app/views/layouts/")
end
end
end
6 changes: 0 additions & 6 deletions spec/component_guide/component_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
@import 'govuk_publishing_components/component_support';
@import 'govuk_publishing_components/components/_breadcrumbs';
@import 'govuk_publishing_components/components/_contextual-sidebar';
@import 'govuk_publishing_components/components/_details';
@import 'govuk_publishing_components/components/_error-message';
@import 'govuk_publishing_components/components/_error-summary';
@import 'govuk_publishing_components/components/_govspeak';
Expand All @@ -59,15 +58,12 @@
@import 'govuk_publishing_components/components/_layout-footer';
@import 'govuk_publishing_components/components/_layout-for-admin';
@import 'govuk_publishing_components/components/_layout-header';
@import 'govuk_publishing_components/components/_lead-paragraph';
@import 'govuk_publishing_components/components/_related-navigation';
@import 'govuk_publishing_components/components/_search';
@import 'govuk_publishing_components/components/_skip-link';
@import 'govuk_publishing_components/components/_step-by-step-nav';
@import 'govuk_publishing_components/components/_step-by-step-nav-header';
@import 'govuk_publishing_components/components/_step-by-step-nav-related';
@import 'govuk_publishing_components/components/_tabs';
@import 'govuk_publishing_components/components/_textarea';
@import 'govuk_publishing_components/components/_title';"

expect(page).to have_selector(".component-doc-h2", text: "Gem components used by this app (12)")
Expand All @@ -82,11 +78,9 @@
@import 'govuk_publishing_components/components/print/_govspeak';
@import 'govuk_publishing_components/components/print/_layout-footer';
@import 'govuk_publishing_components/components/print/_layout-header';
@import 'govuk_publishing_components/components/print/_search';
@import 'govuk_publishing_components/components/print/_skip-link';
@import 'govuk_publishing_components/components/print/_step-by-step-nav';
@import 'govuk_publishing_components/components/print/_step-by-step-nav-header';
@import 'govuk_publishing_components/components/print/_textarea';
@import 'govuk_publishing_components/components/print/_title';"

expect(page.find(:css, 'textarea[name="print-sass"]', visible: false).value).to eq(expected_print_sass)
Expand Down

0 comments on commit 68388af

Please sign in to comment.