Use a flex layout to render participation processes lists
This way we simplify the HTML, which had some `if...else` blocks that were hard to follow because there were opening tags inside these blocks while the closing tags were outside these blocks. We're also making the CSS container-dependent instead of window-dependent. Since there are between one and three elements inside the panel, we accomplish this by making the element with the content take its own line if the width of the panel is smaller than 35rem. Note we're trying to keep the layout similar to what it was; since we're no longer using negative margins (like the ones in the `.row` selector), the votes element now gets a width of 22.5% instead of 25%. Also note we're using the column-gap property for flexbox because the `flex-with-gap` mixin doesn't work so well with elements that have borders. Since the column-gap property for flexbox is now supperted by more than 98% of the browsers (which wasn't the case when we started using the `flex-with-gap` mixin), the `flex-with-gap` mixin has become obsolete. Finally, note we're removing the `max-width: 12rem` rule in the images. I'm not sure why we introduced this rule in the first place, and it didn't play so well to the new layout. I considered using code like `max-width: min(100%, 12rem)`, but, since I'm not sure why `12rem` was there in the first place, I'm not sure whether this approach was better, and it sure made things more complex.
This commit is contained in:
@@ -812,7 +812,6 @@
|
||||
|
||||
.proposal h3 {
|
||||
font-size: rem-calc(20);
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -385,41 +385,53 @@
|
||||
|
||||
@include breakpoint(medium) {
|
||||
min-height: $line-height * 15;
|
||||
|
||||
.with-image > .row {
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.budget-investments-list .budget-investment,
|
||||
.proposals-list .proposal,
|
||||
.legislation-proposals .proposal {
|
||||
|
||||
@include breakpoint(medium) {
|
||||
.debates-list,
|
||||
.proposals-list,
|
||||
.budget-investments-list,
|
||||
.legislation-proposals {
|
||||
|
||||
.panel {
|
||||
column-gap: calc(rem-calc(map-get($grid-column-gutter, medium)) * 3 / 4);
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
||||
> * {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
&.with-image {
|
||||
padding: 0 calc($line-height / 2) 0 0;
|
||||
}
|
||||
}
|
||||
padding-bottom: 0;
|
||||
padding-top: 0;
|
||||
|
||||
.column:first-child {
|
||||
overflow: hidden;
|
||||
}
|
||||
.panel-image {
|
||||
margin-#{$global-left}: rem-calc(-12);
|
||||
text-align: center;
|
||||
|
||||
.column:nth-child(2) {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.column:last-child:not(:first-child) {
|
||||
~ * {
|
||||
padding-top: calc($line-height / 2);
|
||||
}
|
||||
}
|
||||
|
||||
img {
|
||||
height: 100%;
|
||||
max-width: 12rem;
|
||||
}
|
||||
}
|
||||
|
||||
.debate-content,
|
||||
.budget-investment-content,
|
||||
.proposal-content {
|
||||
flex-basis: calc((35rem - 100%) * 999);
|
||||
flex-grow: 1000;
|
||||
max-width: 50rem;
|
||||
|
||||
+ * {
|
||||
flex-basis: 22.5%;
|
||||
flex-shrink: 0;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,22 +64,6 @@ module ProposalsHelper
|
||||
proposals_current_view == "default" ? "minimal" : "default"
|
||||
end
|
||||
|
||||
def css_for_proposal_info_row(proposal)
|
||||
if proposal.image.present?
|
||||
if params[:selected].present?
|
||||
"small-12 medium-9 column"
|
||||
else
|
||||
"small-12 medium-6 large-7 column"
|
||||
end
|
||||
else
|
||||
if params[:selected].present?
|
||||
"small-12 column"
|
||||
else
|
||||
"small-12 medium-9 column"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def show_proposal_votes?
|
||||
params[:selected].blank?
|
||||
end
|
||||
|
||||
@@ -2,19 +2,12 @@
|
||||
<div class="panel <%= ("with-image" if feature?(:allow_images) && investment.image.present?) %>">
|
||||
|
||||
<% if feature?(:allow_images) && investment.image.present? %>
|
||||
<div class="row">
|
||||
|
||||
<div class="small-12 medium-3 large-2 column text-center">
|
||||
<div class="panel-image">
|
||||
<%= image_tag investment.image.variant(:thumb), alt: investment.image.title.unicode_normalize %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-6 large-7 column">
|
||||
<% else %>
|
||||
<div class="row">
|
||||
<div class="small-12 medium-9 column">
|
||||
<% end %>
|
||||
<div class="budget-investment-content">
|
||||
|
||||
<div class="budget-investment-content">
|
||||
<% cache [locale_and_user_status(investment), "index", investment, investment.author] do %>
|
||||
<h3><%= link_to investment.title, namespaced_budget_investment_path(investment) %></h3>
|
||||
|
||||
@@ -27,18 +20,14 @@
|
||||
<%= render "shared/tags", taggable: investment, limit: 5 %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% unless investment.unfeasible? %>
|
||||
|
||||
<% if investment.should_show_votes? %>
|
||||
<div id="<%= dom_id(investment) %>_votes"
|
||||
class="small-12 medium-3 column text-center">
|
||||
<div id="<%= dom_id(investment) %>_votes">
|
||||
<%= render Budgets::Investments::VotesComponent.new(investment) %>
|
||||
</div>
|
||||
<% elsif investment.should_show_vote_count? %>
|
||||
<div id="<%= dom_id(investment) %>_votes"
|
||||
class="small-12 medium-3 column text-center">
|
||||
<div id="<%= dom_id(investment) %>_votes">
|
||||
<div class="supports">
|
||||
<span class="total-supports no-button">
|
||||
<%= t("budgets.investments.investment.supports",
|
||||
@@ -47,16 +36,14 @@
|
||||
</div>
|
||||
</div>
|
||||
<% elsif investment.should_show_ballots? && !management_controller? %>
|
||||
<div id="<%= dom_id(investment) %>_ballot"
|
||||
class="small-12 medium-3 column text-center">
|
||||
<div id="<%= dom_id(investment) %>_ballot">
|
||||
<%= render "/budgets/investments/ballot",
|
||||
investment: investment,
|
||||
investment_ids: investment_ids,
|
||||
ballot: ballot %>
|
||||
</div>
|
||||
<% elsif investment.should_show_price? %>
|
||||
<div id="<%= dom_id(investment) %>_price"
|
||||
class="supports small-12 medium-3 column text-center">
|
||||
<div id="<%= dom_id(investment) %>_price" class="supports">
|
||||
<div class="supports">
|
||||
<span class="total-supports no-button">
|
||||
<%= investment.formatted_price %>
|
||||
@@ -67,4 +54,3 @@
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
<div id="<%= dom_id(investment) %>" class="budget-investment minimal clear">
|
||||
<div class="panel">
|
||||
<div class="row">
|
||||
<div class="small-12 column">
|
||||
<div class="budget-investment-content">
|
||||
<% cache [locale_and_user_status(investment), "index_minimal", investment, investment.author] do %>
|
||||
<h3><%= link_to investment.title, namespaced_budget_investment_path(investment) %></h3>
|
||||
@@ -9,5 +7,3 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
<% cache [locale_and_user_status, debate, current_user&.voted_as_when_voted_for(debate)] do %>
|
||||
<div id="<%= dom_id(debate) %>" class="debate clear" data-type="debate">
|
||||
<div class="panel">
|
||||
<div class="row">
|
||||
|
||||
<div class="small-12 medium-9 column">
|
||||
<div class="debate-content">
|
||||
<h3><%= link_to debate.title, debate %></h3>
|
||||
<p class="debate-info">
|
||||
@@ -46,13 +43,10 @@
|
||||
</div>
|
||||
<%= render "shared/tags", taggable: debate, limit: 5 %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="<%= dom_id(debate) %>_votes" class="small-12 medium-3 column">
|
||||
<div id="<%= dom_id(debate) %>_votes">
|
||||
<%= render Debates::VotesComponent.new(debate) %>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
<div id="<%= dom_id(debate) %>" class="debate minimal clear" data-type="debate">
|
||||
<div class="panel">
|
||||
<div class="row">
|
||||
<div class="small-12 column">
|
||||
<div class="debate-content">
|
||||
<% cache [locale_and_user_status,
|
||||
"index_minimal", debate, current_user&.voted_as_when_voted_for(debate)] do %>
|
||||
@@ -10,5 +8,3 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -7,16 +7,12 @@
|
||||
<% end %>
|
||||
|
||||
<% if proposal.image.present? %>
|
||||
<div class="row">
|
||||
<div class="small-12 medium-3 large-2 column text-center">
|
||||
<div class="panel-image">
|
||||
<%= image_tag proposal.image.variant(:thumb),
|
||||
alt: proposal.image.title.unicode_normalize %>
|
||||
</div>
|
||||
<div class="small-12 medium-6 large-7 column margin-top">
|
||||
<% else %>
|
||||
<div class="row">
|
||||
<div class="small-12 medium-9 column">
|
||||
<% end %>
|
||||
|
||||
<div class="proposal-content">
|
||||
<% cache [locale_and_user_status(proposal), "index", proposal, proposal.author] do %>
|
||||
<h3><%= link_to proposal.title, legislation_process_proposal_path(proposal.legislation_process_id, proposal) %></h3>
|
||||
@@ -71,11 +67,9 @@
|
||||
<%= render "shared/tags", taggable: proposal, limit: 5 %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="<%= dom_id(proposal) %>_votes" class="small-12 medium-3 column">
|
||||
<div id="<%= dom_id(proposal) %>_votes">
|
||||
<%= render Legislation::Proposals::VotesComponent.new(proposal) %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -7,17 +7,12 @@
|
||||
<% end %>
|
||||
|
||||
<% if proposal.image.present? %>
|
||||
<div class="row">
|
||||
<div class="small-12 medium-3 large-2 column text-center">
|
||||
<div class="panel-image">
|
||||
<%= image_tag proposal.image.variant(:thumb),
|
||||
alt: proposal.image.title.unicode_normalize %>
|
||||
</div>
|
||||
|
||||
<div class="<%= css_for_proposal_info_row(proposal) %>">
|
||||
<% else %>
|
||||
<div class="row">
|
||||
<div class="<%= css_for_proposal_info_row(proposal) %>">
|
||||
<% end %>
|
||||
|
||||
<div class="proposal-content">
|
||||
<% cache [locale_and_user_status(proposal), "index", proposal, proposal.author] do %>
|
||||
<h3><%= link_to proposal.title, namespaced_proposal_path(proposal) %></h3>
|
||||
@@ -68,19 +63,17 @@
|
||||
<%= render "shared/tags", taggable: proposal, limit: 5 %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if show_proposal_votes? %>
|
||||
<div id="<%= dom_id(proposal) %>_votes"
|
||||
class="small-12 medium-3 column supports-container">
|
||||
<div id="<%= dom_id(proposal) %>_votes" class="supports-container">
|
||||
<% if proposal.successful? %>
|
||||
<div class="padding">
|
||||
<div class="supports text-center">
|
||||
<div class="supports">
|
||||
<%= render "proposals/supports", proposal: proposal %>
|
||||
</div>
|
||||
</div>
|
||||
<% elsif proposal.archived? %>
|
||||
<div class="padding text-center">
|
||||
<div class="padding">
|
||||
<strong><%= t("proposals.proposal.supports", count: proposal.total_votes) %></strong>
|
||||
<p><%= t("proposals.proposal.archived") %></p>
|
||||
</div>
|
||||
@@ -89,7 +82,5 @@
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
<div id="<%= dom_id(proposal) %>" class="proposal minimal clear" data-type="proposal">
|
||||
<div class="panel">
|
||||
<div class="row">
|
||||
<div class="small-12 column">
|
||||
<div class="proposal-content">
|
||||
<% cache [locale_and_user_status(proposal),
|
||||
"index_minimal", proposal, proposal.author] do %>
|
||||
@@ -10,5 +8,3 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user