Extract components for feeds
This commit is contained in:
14
app/components/widgets/feeds/debates_component.html.erb
Normal file
14
app/components/widgets/feeds/debates_component.html.erb
Normal file
@@ -0,0 +1,14 @@
|
||||
<div id="feed_debates" class="small-12 column margin-top
|
||||
<%= "medium-4" if feed_debates_and_proposals_enabled? %>">
|
||||
<div class="feed-content" data-equalizer-watch>
|
||||
<h3 class="title"><%= t("welcome.feed.most_active.#{feed.kind}") %></h3>
|
||||
|
||||
<% feed.items.each do |item| %>
|
||||
<div class="<%= item.class.to_s.parameterize(separator: "_") %>">
|
||||
<strong><%= link_to item.title, url_for(item) %></strong>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<%= link_to t("welcome.feed.see_all_debates"), debates_path, class: "see-all" %>
|
||||
</div>
|
||||
8
app/components/widgets/feeds/debates_component.rb
Normal file
8
app/components/widgets/feeds/debates_component.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
class Widgets::Feeds::DebatesComponent < ApplicationComponent
|
||||
include FeedsHelper
|
||||
attr_reader :feed
|
||||
|
||||
def initialize(feed)
|
||||
@feed = feed
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
<div class="row margin-bottom feeds-list feeds-participation" data-equalizer data-equalize-on="medium">
|
||||
<% feeds.each do |feed| %>
|
||||
<% if feed_proposals?(feed) %>
|
||||
<%= render Widgets::Feeds::ProposalsComponent.new(feed) %>
|
||||
<% end %>
|
||||
|
||||
<% if feed_debates?(feed) %>
|
||||
<%= render Widgets::Feeds::DebatesComponent.new(feed) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
17
app/components/widgets/feeds/participation_component.rb
Normal file
17
app/components/widgets/feeds/participation_component.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
class Widgets::Feeds::ParticipationComponent < ApplicationComponent
|
||||
attr_reader :feeds
|
||||
|
||||
def initialize(feeds)
|
||||
@feeds = feeds
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def feed_debates?(feed)
|
||||
feed.kind == "debates"
|
||||
end
|
||||
|
||||
def feed_proposals?(feed)
|
||||
feed.kind == "proposals"
|
||||
end
|
||||
end
|
||||
21
app/components/widgets/feeds/processes_component.html.erb
Normal file
21
app/components/widgets/feeds/processes_component.html.erb
Normal file
@@ -0,0 +1,21 @@
|
||||
<div class="card small-12 column margin-bottom">
|
||||
<div class="feed-content">
|
||||
<h3 class="title"><%= t("welcome.feed.most_active.#{feed.kind}") %></h3>
|
||||
|
||||
<% feed.items.each do |item| %>
|
||||
<%= link_to url_for(item) do %>
|
||||
<figure class="figure-card <%= item.class.to_s.parameterize(separator: "_") %>">
|
||||
<%= image_tag("welcome_process.png", alt: "") %>
|
||||
<figcaption>
|
||||
<span><%= t("welcome.feed.process_label") %></span><br>
|
||||
<h3><%= item.title %></h3>
|
||||
</figcaption>
|
||||
</figure>
|
||||
<p class="description small"><%= item.summary %></p>
|
||||
<p class="small"><%= t("welcome.feed.see_process") %></p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%= link_to t("welcome.feed.see_all_processes"), legislation_processes_path, class: "float-right see-all" %>
|
||||
</div>
|
||||
</div>
|
||||
7
app/components/widgets/feeds/processes_component.rb
Normal file
7
app/components/widgets/feeds/processes_component.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class Widgets::Feeds::ProcessesComponent < ApplicationComponent
|
||||
attr_reader :feed
|
||||
|
||||
def initialize(feed)
|
||||
@feed = feed
|
||||
end
|
||||
end
|
||||
26
app/components/widgets/feeds/proposals_component.html.erb
Normal file
26
app/components/widgets/feeds/proposals_component.html.erb
Normal file
@@ -0,0 +1,26 @@
|
||||
<div id="feed_proposals" class="feed-proposals small-12 column margin-top
|
||||
<%= "medium-8" if feed_debates_and_proposals_enabled? %>">
|
||||
<div class="feed-content" data-equalizer-watch>
|
||||
<h3 class="title"><%= t("welcome.feed.most_active.#{feed.kind}") %></h3>
|
||||
|
||||
<% feed.items.each do |item| %>
|
||||
<div class="<%= item.class.to_s.parameterize(separator: "_") %> row">
|
||||
<div class="feed-description small-12 column
|
||||
<%= "medium-6 large-9" if item.image.present? %>">
|
||||
<strong><%= link_to item.title, url_for(item) %></strong><br>
|
||||
<p><%= item.summary %></p>
|
||||
</div>
|
||||
<% if item.image.present? %>
|
||||
<div class="small-12 medium-6 large-3 column">
|
||||
<div class="feed-image">
|
||||
<%= image_tag item.image_url(:thumb),
|
||||
alt: item.image.title.unicode_normalize %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<%= link_to t("welcome.feed.see_all_proposals"), proposals_path, class: "see-all" %>
|
||||
</div>
|
||||
8
app/components/widgets/feeds/proposals_component.rb
Normal file
8
app/components/widgets/feeds/proposals_component.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
class Widgets::Feeds::ProposalsComponent < ApplicationComponent
|
||||
include FeedsHelper
|
||||
attr_reader :feed
|
||||
|
||||
def initialize(feed)
|
||||
@feed = feed
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user