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 {
|
.proposal h3 {
|
||||||
font-size: rem-calc(20);
|
font-size: rem-calc(20);
|
||||||
margin-top: 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -385,41 +385,53 @@
|
|||||||
|
|
||||||
@include breakpoint(medium) {
|
@include breakpoint(medium) {
|
||||||
min-height: $line-height * 15;
|
min-height: $line-height * 15;
|
||||||
|
|
||||||
.with-image > .row {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.budget-investments-list .budget-investment,
|
.debates-list,
|
||||||
.proposals-list .proposal,
|
.proposals-list,
|
||||||
.legislation-proposals .proposal {
|
.budget-investments-list,
|
||||||
|
.legislation-proposals {
|
||||||
@include breakpoint(medium) {
|
|
||||||
|
|
||||||
.panel {
|
.panel {
|
||||||
|
column-gap: calc(rem-calc(map-get($grid-column-gutter, medium)) * 3 / 4);
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
|
||||||
|
> * {
|
||||||
|
flex-grow: 1;
|
||||||
|
}
|
||||||
|
|
||||||
&.with-image {
|
&.with-image {
|
||||||
padding: 0 calc($line-height / 2) 0 0;
|
padding-bottom: 0;
|
||||||
}
|
padding-top: 0;
|
||||||
}
|
|
||||||
|
|
||||||
.column:first-child {
|
.panel-image {
|
||||||
overflow: hidden;
|
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);
|
padding-top: calc($line-height / 2);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
height: 100%;
|
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"
|
proposals_current_view == "default" ? "minimal" : "default"
|
||||||
end
|
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?
|
def show_proposal_votes?
|
||||||
params[:selected].blank?
|
params[:selected].blank?
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,19 +2,12 @@
|
|||||||
<div class="panel <%= ("with-image" if feature?(:allow_images) && investment.image.present?) %>">
|
<div class="panel <%= ("with-image" if feature?(:allow_images) && investment.image.present?) %>">
|
||||||
|
|
||||||
<% if feature?(:allow_images) && investment.image.present? %>
|
<% if feature?(:allow_images) && investment.image.present? %>
|
||||||
<div class="row">
|
<div class="panel-image">
|
||||||
|
|
||||||
<div class="small-12 medium-3 large-2 column text-center">
|
|
||||||
<%= image_tag investment.image.variant(:thumb), alt: investment.image.title.unicode_normalize %>
|
<%= image_tag investment.image.variant(:thumb), alt: investment.image.title.unicode_normalize %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="small-12 medium-6 large-7 column">
|
|
||||||
<% else %>
|
|
||||||
<div class="row">
|
|
||||||
<div class="small-12 medium-9 column">
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="budget-investment-content">
|
|
||||||
|
|
||||||
|
<div class="budget-investment-content">
|
||||||
<% cache [locale_and_user_status(investment), "index", investment, investment.author] do %>
|
<% cache [locale_and_user_status(investment), "index", investment, investment.author] do %>
|
||||||
<h3><%= link_to investment.title, namespaced_budget_investment_path(investment) %></h3>
|
<h3><%= link_to investment.title, namespaced_budget_investment_path(investment) %></h3>
|
||||||
|
|
||||||
@@ -27,18 +20,14 @@
|
|||||||
<%= render "shared/tags", taggable: investment, limit: 5 %>
|
<%= render "shared/tags", taggable: investment, limit: 5 %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<% unless investment.unfeasible? %>
|
<% unless investment.unfeasible? %>
|
||||||
|
|
||||||
<% if investment.should_show_votes? %>
|
<% if investment.should_show_votes? %>
|
||||||
<div id="<%= dom_id(investment) %>_votes"
|
<div id="<%= dom_id(investment) %>_votes">
|
||||||
class="small-12 medium-3 column text-center">
|
|
||||||
<%= render Budgets::Investments::VotesComponent.new(investment) %>
|
<%= render Budgets::Investments::VotesComponent.new(investment) %>
|
||||||
</div>
|
</div>
|
||||||
<% elsif investment.should_show_vote_count? %>
|
<% elsif investment.should_show_vote_count? %>
|
||||||
<div id="<%= dom_id(investment) %>_votes"
|
<div id="<%= dom_id(investment) %>_votes">
|
||||||
class="small-12 medium-3 column text-center">
|
|
||||||
<div class="supports">
|
<div class="supports">
|
||||||
<span class="total-supports no-button">
|
<span class="total-supports no-button">
|
||||||
<%= t("budgets.investments.investment.supports",
|
<%= t("budgets.investments.investment.supports",
|
||||||
@@ -47,16 +36,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% elsif investment.should_show_ballots? && !management_controller? %>
|
<% elsif investment.should_show_ballots? && !management_controller? %>
|
||||||
<div id="<%= dom_id(investment) %>_ballot"
|
<div id="<%= dom_id(investment) %>_ballot">
|
||||||
class="small-12 medium-3 column text-center">
|
|
||||||
<%= render "/budgets/investments/ballot",
|
<%= render "/budgets/investments/ballot",
|
||||||
investment: investment,
|
investment: investment,
|
||||||
investment_ids: investment_ids,
|
investment_ids: investment_ids,
|
||||||
ballot: ballot %>
|
ballot: ballot %>
|
||||||
</div>
|
</div>
|
||||||
<% elsif investment.should_show_price? %>
|
<% elsif investment.should_show_price? %>
|
||||||
<div id="<%= dom_id(investment) %>_price"
|
<div id="<%= dom_id(investment) %>_price" class="supports">
|
||||||
class="supports small-12 medium-3 column text-center">
|
|
||||||
<div class="supports">
|
<div class="supports">
|
||||||
<span class="total-supports no-button">
|
<span class="total-supports no-button">
|
||||||
<%= investment.formatted_price %>
|
<%= investment.formatted_price %>
|
||||||
@@ -66,5 +53,4 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
<div id="<%= dom_id(investment) %>" class="budget-investment minimal clear">
|
<div id="<%= dom_id(investment) %>" class="budget-investment minimal clear">
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<div class="row">
|
|
||||||
<div class="small-12 column">
|
|
||||||
<div class="budget-investment-content">
|
<div class="budget-investment-content">
|
||||||
<% cache [locale_and_user_status(investment), "index_minimal", investment, investment.author] do %>
|
<% cache [locale_and_user_status(investment), "index_minimal", investment, investment.author] do %>
|
||||||
<h3><%= link_to investment.title, namespaced_budget_investment_path(investment) %></h3>
|
<h3><%= link_to investment.title, namespaced_budget_investment_path(investment) %></h3>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
<% cache [locale_and_user_status, debate, current_user&.voted_as_when_voted_for(debate)] do %>
|
<% 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 id="<%= dom_id(debate) %>" class="debate clear" data-type="debate">
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<div class="row">
|
|
||||||
|
|
||||||
<div class="small-12 medium-9 column">
|
|
||||||
<div class="debate-content">
|
<div class="debate-content">
|
||||||
<h3><%= link_to debate.title, debate %></h3>
|
<h3><%= link_to debate.title, debate %></h3>
|
||||||
<p class="debate-info">
|
<p class="debate-info">
|
||||||
@@ -46,13 +43,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<%= render "shared/tags", taggable: debate, limit: 5 %>
|
<%= render "shared/tags", taggable: debate, limit: 5 %>
|
||||||
</div>
|
</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) %>
|
<%= render Debates::VotesComponent.new(debate) %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
<div id="<%= dom_id(debate) %>" class="debate minimal clear" data-type="debate">
|
<div id="<%= dom_id(debate) %>" class="debate minimal clear" data-type="debate">
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<div class="row">
|
|
||||||
<div class="small-12 column">
|
|
||||||
<div class="debate-content">
|
<div class="debate-content">
|
||||||
<% cache [locale_and_user_status,
|
<% cache [locale_and_user_status,
|
||||||
"index_minimal", debate, current_user&.voted_as_when_voted_for(debate)] do %>
|
"index_minimal", debate, current_user&.voted_as_when_voted_for(debate)] do %>
|
||||||
@@ -9,6 +7,4 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -7,16 +7,12 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if proposal.image.present? %>
|
<% if proposal.image.present? %>
|
||||||
<div class="row">
|
<div class="panel-image">
|
||||||
<div class="small-12 medium-3 large-2 column text-center">
|
|
||||||
<%= image_tag proposal.image.variant(:thumb),
|
<%= image_tag proposal.image.variant(:thumb),
|
||||||
alt: proposal.image.title.unicode_normalize %>
|
alt: proposal.image.title.unicode_normalize %>
|
||||||
</div>
|
</div>
|
||||||
<div class="small-12 medium-6 large-7 column margin-top">
|
|
||||||
<% else %>
|
|
||||||
<div class="row">
|
|
||||||
<div class="small-12 medium-9 column">
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="proposal-content">
|
<div class="proposal-content">
|
||||||
<% cache [locale_and_user_status(proposal), "index", proposal, proposal.author] do %>
|
<% 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>
|
<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 %>
|
<%= render "shared/tags", taggable: proposal, limit: 5 %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</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) %>
|
<%= render Legislation::Proposals::VotesComponent.new(proposal) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -7,17 +7,12 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if proposal.image.present? %>
|
<% if proposal.image.present? %>
|
||||||
<div class="row">
|
<div class="panel-image">
|
||||||
<div class="small-12 medium-3 large-2 column text-center">
|
|
||||||
<%= image_tag proposal.image.variant(:thumb),
|
<%= image_tag proposal.image.variant(:thumb),
|
||||||
alt: proposal.image.title.unicode_normalize %>
|
alt: proposal.image.title.unicode_normalize %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="<%= css_for_proposal_info_row(proposal) %>">
|
|
||||||
<% else %>
|
|
||||||
<div class="row">
|
|
||||||
<div class="<%= css_for_proposal_info_row(proposal) %>">
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="proposal-content">
|
<div class="proposal-content">
|
||||||
<% cache [locale_and_user_status(proposal), "index", proposal, proposal.author] do %>
|
<% cache [locale_and_user_status(proposal), "index", proposal, proposal.author] do %>
|
||||||
<h3><%= link_to proposal.title, namespaced_proposal_path(proposal) %></h3>
|
<h3><%= link_to proposal.title, namespaced_proposal_path(proposal) %></h3>
|
||||||
@@ -68,19 +63,17 @@
|
|||||||
<%= render "shared/tags", taggable: proposal, limit: 5 %>
|
<%= render "shared/tags", taggable: proposal, limit: 5 %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<% if show_proposal_votes? %>
|
<% if show_proposal_votes? %>
|
||||||
<div id="<%= dom_id(proposal) %>_votes"
|
<div id="<%= dom_id(proposal) %>_votes" class="supports-container">
|
||||||
class="small-12 medium-3 column supports-container">
|
|
||||||
<% if proposal.successful? %>
|
<% if proposal.successful? %>
|
||||||
<div class="padding">
|
<div class="padding">
|
||||||
<div class="supports text-center">
|
<div class="supports">
|
||||||
<%= render "proposals/supports", proposal: proposal %>
|
<%= render "proposals/supports", proposal: proposal %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% elsif proposal.archived? %>
|
<% elsif proposal.archived? %>
|
||||||
<div class="padding text-center">
|
<div class="padding">
|
||||||
<strong><%= t("proposals.proposal.supports", count: proposal.total_votes) %></strong>
|
<strong><%= t("proposals.proposal.supports", count: proposal.total_votes) %></strong>
|
||||||
<p><%= t("proposals.proposal.archived") %></p>
|
<p><%= t("proposals.proposal.archived") %></p>
|
||||||
</div>
|
</div>
|
||||||
@@ -89,7 +82,5 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
<div id="<%= dom_id(proposal) %>" class="proposal minimal clear" data-type="proposal">
|
<div id="<%= dom_id(proposal) %>" class="proposal minimal clear" data-type="proposal">
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<div class="row">
|
|
||||||
<div class="small-12 column">
|
|
||||||
<div class="proposal-content">
|
<div class="proposal-content">
|
||||||
<% cache [locale_and_user_status(proposal),
|
<% cache [locale_and_user_status(proposal),
|
||||||
"index_minimal", proposal, proposal.author] do %>
|
"index_minimal", proposal, proposal.author] do %>
|
||||||
@@ -9,6 +7,4 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user