From aa471974bdfcf3daab96ce962264f229ece0a0ab Mon Sep 17 00:00:00 2001 From: Alessandro Cuoghi Date: Wed, 21 Jun 2017 16:43:08 +0200 Subject: [PATCH] Use different image versions on responsive sizes --- app/assets/stylesheets/participation.scss | 38 +++++++++++++++++++ app/models/budget/investment.rb | 5 +-- .../budgets/investments/_investment.html.erb | 27 ++++++------- 3 files changed, 52 insertions(+), 18 deletions(-) diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index 6665d8508..205347798 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -653,6 +653,44 @@ } } +.budget-investments-list { + .budget-investment{ + @include breakpoint(medium) { + .panel{ + padding:0 0.75rem 0 0; + } + h3{ + font-size: 1.4rem; + } + .column:first-child{ + overflow: hidden; + } + .column:nth-child(2){ + float: left; + } + .column:last-child:not(:first-child){ + padding-top:0.75rem; + } + img{ + max-width: 12rem; + } + .budget-investment-content{ + ul{ + margin-bottom:0; + } + } + } + @include breakpoint(small) { + h3{ + font-size: 1.3rem; + } + .column:first-child{ + text-align: center; + } + } + } +} + .debate, .proposal, .investment-project, diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index ada8e986a..4533ff631 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -16,9 +16,8 @@ class Budget acts_as_votable acts_as_paranoid column: :hidden_at include ActsAsParanoidAliases - - # TODO: ROCK&ROR: Set image versions sizes acordingly to enhance page load - has_attached_file :image, styles: { large: "600x600>", medium: "300x300>", thumb: "100x100>" } + + has_attached_file :image, styles: { large: "600x600>", medium: "300x300#", thumb: "140x245#" } belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id' belongs_to :heading diff --git a/app/views/budgets/investments/_investment.html.erb b/app/views/budgets/investments/_investment.html.erb index 46732d1d9..9c5db65a9 100644 --- a/app/views/budgets/investments/_investment.html.erb +++ b/app/views/budgets/investments/_investment.html.erb @@ -1,27 +1,27 @@
- - -
+
<% if investment.image.exists? %> - <%= image_tag investment.image.url(:thumb), - title: investment.image_title, - alt: investment.image_title, class: "th" %> + + + <%= investment.image_description %> + <% else %> - + <% end %>
- -
+
- <% cache [locale_and_user_status(investment), 'index', investment, investment.author] do %>

<%= link_to investment.title, namespaced_budget_investment_path(investment) %>

- <%= l investment.created_at.to_date %> - <% if investment.author.hidden? || investment.author.erased? %>  •  @@ -39,7 +39,6 @@ <% end %> <% end %> -  •  <%= investment.heading.name %>

@@ -53,7 +52,6 @@
<% unless investment.unfeasible? %> - <% if investment.should_show_votes? %>
@@ -90,7 +88,6 @@

<% end %> - <% end %>