Rename dynamic display to carousel size

This commit is contained in:
taitus
2017-07-26 15:52:13 +02:00
parent c913687be5
commit b6d5be3df0
4 changed files with 11 additions and 13 deletions

View File

@@ -36,19 +36,17 @@ module WelcomeHelper
end end
def calculate_centered(debates, proposals, budget_investments) def calculate_centered(debates, proposals, budget_investments)
centered = "" if debates.blank? && proposals.blank? && budget_investments.any? ||
if debates.blank? && proposals.blank? || debates.blank? && proposals.any? && budget_investments.blank? ||
debates.blank? && budget_investments.blank? || debates.any? && proposals.blank? && budget_investments.blank?
proposals.blank? && budget_investments.blank?
centered = "medium-centered large-centered" centered = "medium-centered large-centered"
end end
centered
end end
def calculate_centered_and_size_class(debates, proposals, budget_investments) def calculate_carousel_size(debates, proposals, budget_investments)
size = calculate_size(debates, proposals, budget_investments) size = calculate_size(debates, proposals, budget_investments)
centered = calculate_centered(debates, proposals, budget_investments) centered = calculate_centered(debates, proposals, budget_investments)
"#{size} #{centered if centered.present?}" "#{size} #{centered if centered}"
end end
def display_recommendeds(debates, proposals, budget_investments) def display_recommendeds(debates, proposals, budget_investments)

View File

@@ -4,14 +4,14 @@
<h2 class="text-center"><%= t("welcome.recommended.title") %></h2> <h2 class="text-center"><%= t("welcome.recommended.title") %></h2>
<!-- Add the carousel-image class to show the pictures --> <!-- Add the carousel-image class to show the pictures -->
<div class="small-12 column carousel-image"> <div class="small-12 column carousel-image">
<% centered_and_size_class = calculate_centered_and_size_class(recommended_debates, recommended_proposals, recommended_budget_investments) %> <% carousel_size = calculate_carousel_size(recommended_debates, recommended_proposals, recommended_budget_investments) %>
<% if recommended_debates.any? %> <% if recommended_debates.any? %>
<%= render "recommended_carousel", recommendeds: recommended_debates, <%= render "recommended_carousel", recommendeds: recommended_debates,
key: "debates", key: "debates",
image_field: nil, image_field: nil,
image_version: nil, image_version: nil,
image_default: "https://dummyimage.com/600x400/000/fff", image_default: "https://dummyimage.com/600x400/000/fff",
dynamic_display: centered_and_size_class %> carousel_size: carousel_size %>
<% end %> <% end %>
<% if recommended_proposals.any? %> <% if recommended_proposals.any? %>
@@ -20,7 +20,7 @@
image_field: nil, image_field: nil,
image_version: nil, image_version: nil,
image_default: "https://dummyimage.com/600x400/000/fff", image_default: "https://dummyimage.com/600x400/000/fff",
dynamic_display: centered_and_size_class %> carousel_size: carousel_size %>
<% end %> <% end %>
<% if recommended_budget_investments.any? %> <% if recommended_budget_investments.any? %>
@@ -29,7 +29,7 @@
image_field: nil, #example value :image (PR#1691) image_field: nil, #example value :image (PR#1691)
image_version: nil, #example value :thumb (PR#1691) image_version: nil, #example value :thumb (PR#1691)
image_default: "https://dummyimage.com/600x400/000/fff", image_default: "https://dummyimage.com/600x400/000/fff",
dynamic_display: centered_and_size_class %> carousel_size: carousel_size %>
<% end %> <% end %>
</div> </div>

View File

@@ -1,4 +1,4 @@
<div class="small-12 <%= dynamic_display %> column text-center <%= key %> "> <div class="small-12 <%= carousel_size %> column text-center <%= key %> ">
<div class="card small-centered <%= key %>-inner"> <div class="card small-centered <%= key %>-inner">
<h4><%= t("welcome.recommended.#{key.underscore}.title") %></h4> <h4><%= t("welcome.recommended.#{key.underscore}.title") %></h4>

View File

@@ -88,7 +88,7 @@ feature "Home" do
expect(page).not_to have_content "Recommendations that may interest you" expect(page).not_to have_content "Recommendations that may interest you"
end end
feature 'Dynamic display' do feature 'Carousel size' do
scenario 'Display debates centered when there are not proposals and investments' do scenario 'Display debates centered when there are not proposals and investments' do
debate = create(:debate) debate = create(:debate)