Skip to content

Commit

Permalink
Temp - idea to load app component styles from /flows
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-kirwan committed Dec 14, 2022
1 parent 4ed99a1 commit 6eb1a11
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 29 deletions.
9 changes: 5 additions & 4 deletions app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
//= link application.css
//= link print.css
//= link govuk_publishing_components/components/_radio.css
//= link govuk_publishing_components/components/_date-input.css
//= link govuk_publishing_components/components/_fieldset.css
//= link govuk_publishing_components/components/_summary-list.css

//= link components/_result-card.css
//= link components/_result-item.css
//= link components/_result-sections.css

//= link visualise.css
//= link joint.css
//= link application.js
Expand Down
6 changes: 3 additions & 3 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ $govuk-include-default-font-face: false;
// @import "govuk_publishing_components/components/warning-text";

@import "components/autocomplete";
@import "components/result-card";
@import "components/result-item";
@import "components/result-sections";
// @import "components/result-card";
// @import "components/result-item";
// @import "components/result-sections";
// @import "smart_answers";

.desktop-min-height {
Expand Down
2 changes: 2 additions & 0 deletions app/assets/stylesheets/components/_result-card.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import "govuk_publishing_components/govuk_frontend_support";

.app-c-result-card {
position: relative;
padding: govuk-spacing(5) govuk-spacing(4);
Expand Down
2 changes: 2 additions & 0 deletions app/assets/stylesheets/components/_result-item.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import "govuk_publishing_components/govuk_frontend_support";

.app-c-result-item {
@include govuk-font($size: 19);
padding-top: govuk-spacing(6);
Expand Down
2 changes: 2 additions & 0 deletions app/assets/stylesheets/components/_result-sections.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import "govuk_publishing_components/govuk_frontend_support";

.app-c-result-sections {
margin-bottom: govuk-spacing(7) * 2;
}
Expand Down
17 changes: 9 additions & 8 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
class ApplicationController < ActionController::Base
include Slimmer::Template

before_action do
begin
@individual_stylesheets = GovukPublishingComponents::AppHelpers::AssetHelper.new
rescue NameError
logger.warn("The version of the components gem being used doesn't support individual asset loading.")
end
end

rescue_from GdsApi::TimedOutException, with: :error_503
rescue_from GdsApi::HTTPForbidden, with: :error_403
rescue_from ActionController::UnknownFormat, with: :error_404
Expand All @@ -23,6 +15,15 @@ class ApplicationController < ActionController::Base

slimmer_template :gem_layout

before_action do
begin
@individual_stylesheets = GovukPublishingComponents::AppHelpers::AssetHelper.new
puts @individual_stylesheets.inspect
rescue NameError
logger.warn("The version of the components gem being used doesn't support individual asset loading.")
end
end

protected

def debug?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<% text_for :stylesheets do%>
<%= %w[result_card] %>
<% end %>

<% text_for :body do %>
<% if calculator.number_of_benefits > 0 %>
<p class="govuk-body">Based on your answers, you may be eligible for the following <span style="font-weight: bold"><%= calculator.number_of_benefits %> things</span>.</p>
Expand Down
4 changes: 4 additions & 0 deletions app/flows/check_uk_visa_flow/outcomes/outcome_work_y.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<% text_for :stylesheets do%>
<%= %w[result_card] %>
<% end %>

<% text_for :title do %>
<%= calculator.outcome_title %>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
======================================================================
%>

<% text_for :stylesheets do%>
<%= %w[result_sections] %>
<% end %>

<% text_for :title do %>
Next steps for your limited company
<% end %>
Expand Down
4 changes: 4 additions & 0 deletions app/presenters/outcome_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ def title
@renderer.content_for(:title)
end

def stylesheets
@renderer.content_for(:stylesheets)
end

def description
@renderer.content_for(:description)
end
Expand Down
14 changes: 1 addition & 13 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,12 @@
<meta name="govuk:section" content="<%= @meta_section %>">
<% end %>

<%
# puts "1"
# puts @individual_stylesheets.inspect
# if defined? @individual_stylesheets
# puts "2"
# @individual_stylesheets.get_stylesheets.map do |component|
# puts "component".upcase!
# puts component
# end
# end
%>
<%=
if defined? @individual_stylesheets
puts "@individual_stylesheets".upcase!
puts @individual_stylesheets.inspect
list_of_stylesheets = @individual_stylesheets.get_stylesheets.map do | component |
puts "component"
puts component
puts "component:".upcase! + component
stylesheet_link_tag(component, integrity: false)
end
raw(list_of_stylesheets.join(""))
Expand Down
8 changes: 8 additions & 0 deletions app/views/smart_answers/custom_result.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<% # this custom result template is currently tested on the next-steps-for-your-business flow %>
custom_result.html
<% @individual_stylesheets.add_gem_component("govspeak") %>
<% outcome = @presenter.current_node %>
<%= debug(outcome.stylesheets) %>
<%= outcome.stylesheets == '[&quot;result_sections&quot;]' ? "1" : "2" %>
<% @individual_stylesheets.add_component("result-card") if outcome.stylesheets == "[&quot;result_card&quot;]" %>
<% @individual_stylesheets.add_component("result-sections") if outcome.stylesheets == "[&quot;result_sections&quot;]" %>
<% @individual_stylesheets.add_component("result-item") if outcome.stylesheets == "[&quot;result_sections&quot;]" %>

<% content_for :outcome_title do %>
<% if outcome.title.present? %><%= outcome.title %><% else %>Outcome<% end %>
<% end %>
Expand Down
7 changes: 7 additions & 0 deletions app/views/smart_answers/custom_result_full_width.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
custom_result_full_width
<% @individual_stylesheets.add_gem_component("govspeak") %>
<% outcome = @presenter.current_node %>
<%= debug(outcome.stylesheets) %>
<%= outcome.stylesheets == '[&quot;result_card&quot;]' ? "1" : "2" %>
<% @individual_stylesheets.add_component("result-card") if outcome.stylesheets == "[&quot;result_card&quot;]" %>
<% @individual_stylesheets.add_component("result-sections") if outcome.stylesheets == "[&quot;result_sections&quot;]" %>
<% @individual_stylesheets.add_component("result-item") if outcome.stylesheets == "[&quot;result_sections&quot;]" %>

<%= outcome.banner %>

Expand Down
8 changes: 7 additions & 1 deletion app/views/smart_answers/result.html.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
<% @individual_stylesheets.add_gem_component("govspeak") %>

<% outcome = @presenter.current_node %>
<%= debug(outcome.stylesheets) %>
<%= outcome.stylesheets == '[&quot;result_card&quot;]' ? "1" : "2" %>
<% @individual_stylesheets.add_component("result-card") if outcome.stylesheets == "[&quot;result_card&quot;]" %>
<% @individual_stylesheets.add_component("result-sections") if outcome.stylesheets == "[&quot;result_sections&quot;]" %>

<% content_for :outcome_title do %>
<% if outcome.title.present? %><%= outcome.title %><% else %>Outcome<% end %>
<% end %>
<% content_for :head do %>
<meta name="robots" content="noindex">
<% end %>

<%= debug(@individual_stylesheets) %>

<div class="govuk-grid-row">

<div
Expand Down

0 comments on commit 6eb1a11

Please sign in to comment.