Skip to content

Commit

Permalink
Merge pull request #1409 from alphagov/change-component-guide-sass
Browse files Browse the repository at this point in the history
Change component guide sass
  • Loading branch information
andysellick authored Mar 31, 2020
2 parents 0af465d + c87e6c0 commit e9781b2
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
## Unreleased

* Fix back link arrow rendering in Safari ([PR #1411](https://github.com/alphagov/govuk_publishing_components/pull/1411))
* Change component guide sass ([PR #1409](https://github.com/alphagov/govuk_publishing_components/pull/1409))

## 21.36.0

Expand Down
2 changes: 2 additions & 0 deletions app/assets/stylesheets/component_guide/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
@import "govuk/helpers/all";
@import "govuk/core/all";

@import "govuk_publishing_components/all_components";

$gem-guide-border-width: 1px;

.component-list {
Expand Down
1 change: 1 addition & 0 deletions app/assets/stylesheets/component_guide/print.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import "govuk_publishing_components/all_components_print";
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@
<%= csrf_meta_tags %>
<%= favicon_link_tag "govuk_publishing_components/favicon-production.png" %>

<%= stylesheet_link_tag "#{GovukPublishingComponents::Config.application_stylesheet}" %>
<%= stylesheet_link_tag "component_guide/application", media: "screen" %>

<% if GovukPublishingComponents::Config.application_print_stylesheet %>
<%= stylesheet_link_tag "#{GovukPublishingComponents::Config.application_print_stylesheet}", media: "print" %>
<% end %>
<%= stylesheet_link_tag "component_guide/print", media: "print" %>

<%= javascript_include_tag "govuk_publishing_components/vendor/modernizr" %>
<%= yield :extra_headers %>
Expand Down
1 change: 1 addition & 0 deletions config/initializers/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
component_guide/application.js
component_guide/filter-components.js
component_guide/visual-regression.js
component_guide/print.css
govuk_publishing_components/all_components.js
govuk_publishing_components/modules.js
govuk_publishing_components/vendor/modernizr.js
Expand Down
10 changes: 2 additions & 8 deletions spec/component_guide/component_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
it "includes component guide styles and scripts" do
visit "/component-guide"
expect(page).to have_selector('link[href*="/assets/component_guide/application"]', visible: false)
expect(page).to have_selector('link[href*="/assets/component_guide/print"]', visible: false)
expect(page).to have_selector('script[src*="/assets/component_guide/application"]', visible: false)
end

it "includes the application’s styles and scripts" do
it "includes the application’s scripts" do
visit "/component-guide"
expect(page).to have_selector('link[href*="/assets/application"]', visible: false)
expect(page).to have_selector('script[src*="/assets/application"]', visible: false)
end

Expand All @@ -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 e9781b2

Please sign in to comment.