Merge pull request #4341 from consul/sdg_widget_tags

Add SDG tags to most active feeds
This commit is contained in:
Javi Martín
2021-01-31 14:10:35 +01:00
committed by GitHub
8 changed files with 84 additions and 3 deletions

View File

@@ -2770,7 +2770,7 @@ table {
overflow: visible; overflow: visible;
a { a {
img { .figure-card img {
transition-duration: 0.3s; transition-duration: 0.3s;
transition-property: transform; transition-property: transform;
} }
@@ -2780,12 +2780,13 @@ table {
box-shadow: 0 0 12px 0 rgba(0, 0, 0, 0.2); box-shadow: 0 0 12px 0 rgba(0, 0, 0, 0.2);
text-decoration: none; text-decoration: none;
img { .figure-card img {
transform: scale(1.1); transform: scale(1.1);
} }
} }
p { p,
.sdg-tag-list {
padding: 0 $line-height / 4; padding: 0 $line-height / 4;
} }
} }

View File

@@ -22,6 +22,10 @@
} }
} }
.sdg-tag-list {
margin-top: $line-height / 2;
}
.feed-debates, .feed-debates,
.feed-proposals { .feed-proposals {
@include grid-col; @include grid-col;

View File

@@ -1,3 +1,4 @@
<div class="debate"> <div class="debate">
<strong><%= link_to debate.title, url_for(debate) %></strong> <strong><%= link_to debate.title, url_for(debate) %></strong>
<%= render SDG::TagListComponent.new(debate, limit: 5) %>
</div> </div>

View File

@@ -8,6 +8,7 @@
</figcaption> </figcaption>
</figure> </figure>
<p class="description small"><%= process.summary %></p> <p class="description small"><%= process.summary %></p>
<%= render SDG::TagListComponent.new(process, linkable: false) %>
<p class="small"><%= t("welcome.feed.see_process") %></p> <p class="small"><%= t("welcome.feed.see_process") %></p>
<% end %> <% end %>
</div> </div>

View File

@@ -3,6 +3,7 @@
<%= "medium-6 large-9" if proposal.image.present? %>"> <%= "medium-6 large-9" if proposal.image.present? %>">
<strong><%= link_to proposal.title, url_for(proposal) %></strong><br> <strong><%= link_to proposal.title, url_for(proposal) %></strong><br>
<p><%= proposal.summary %></p> <p><%= proposal.summary %></p>
<%= render SDG::TagListComponent.new(proposal, limit: 5) %>
</div> </div>
<% if proposal.image.present? %> <% if proposal.image.present? %>

View File

@@ -0,0 +1,25 @@
require "rails_helper"
describe Widget::Feeds::DebateComponent, type: :component do
let(:debate) { create(:debate, sdg_goals: [SDG::Goal[1]]) }
let(:component) { Widget::Feeds::DebateComponent.new(debate) }
before do
Setting["feature.sdg"] = true
Setting["sdg.process.debates"] = true
end
it "renders a title with link" do
render_inline component
expect(page).to have_link debate.title, href: "/debates/#{debate.to_param}"
end
it "renders a tag list" do
render_inline component
expect(page).to have_link "1. No Poverty",
title: "See all Debates related to goal 1",
href: "/debates?advanced_search#{CGI.escape("[goal]")}=1"
end
end

View File

@@ -0,0 +1,23 @@
require "rails_helper"
describe Widget::Feeds::ProcessComponent, type: :component do
let(:process) { create(:legislation_process, sdg_goals: [SDG::Goal[1]]) }
let(:component) { Widget::Feeds::ProcessComponent.new(process) }
before do
Setting["feature.sdg"] = true
Setting["sdg.process.legislation"] = true
end
it "renders a card with link" do
render_inline component
expect(page).to have_link href: "/legislation/processes/#{process.to_param}"
end
it "renders a plain tag list" do
render_inline component
expect(page).to have_css("img[alt='1. No Poverty']")
end
end

View File

@@ -0,0 +1,25 @@
require "rails_helper"
describe Widget::Feeds::ProposalComponent, type: :component do
let(:proposal) { create(:proposal, sdg_goals: [SDG::Goal[1]]) }
let(:component) { Widget::Feeds::ProposalComponent.new(proposal) }
before do
Setting["feature.sdg"] = true
Setting["sdg.process.proposals"] = true
end
it "renders a title with link" do
render_inline component
expect(page).to have_link proposal.title, href: "/proposals/#{proposal.to_param}"
end
it "renders a tag list" do
render_inline component
expect(page).to have_link "1. No Poverty",
title: "See all Citizen proposals related to goal 1",
href: "/proposals?advanced_search#{CGI.escape("[goal]")}=1"
end
end