Extract component to render help section

This commit is contained in:
Javi Martín
2021-05-18 15:42:40 +02:00
parent fbb40eccff
commit 08318171f0
7 changed files with 76 additions and 92 deletions

View File

@@ -0,0 +1,16 @@
<div class="row section-content">
<div class="small-12 column">
<h3 id="<%= section %>" data-magellan-target="<%= section %>">
<%= t("pages.help.#{section}.title") %>
</h3>
<%= content %>
<% if image_path %>
<figure>
<%= image_tag image_path, alt: t("pages.help.#{section}.image_alt") %>
<figcaption><%= t("pages.help.#{section}.figcaption") %></figcaption>
</figure>
<% end %>
</div>
</div>

View File

@@ -0,0 +1,8 @@
class Pages::Help::SectionComponent < ApplicationComponent
attr_reader :section, :image_path
def initialize(section, image_path = nil)
@section = section
@image_path = image_path
end
end

View File

@@ -1,16 +1,6 @@
<div class="row section-content">
<div class="small-12 column">
<h3 id="budgets" data-magellan-target="budgets">
<%= t("pages.help.budgets.title") %>
</h3>
<p>
<%= sanitize(t("pages.help.budgets.description",
link: link_to(t("pages.help.budgets.link"), budgets_path))) %>
</p>
<figure>
<%= image_tag "help/budgets_#{I18n.locale}.png", alt: t("pages.help.budgets.image_alt") %>
<figcaption><%= t("pages.help.budgets.figcaption") %></figcaption>
</figure>
</div>
</div>
<%= render Pages::Help::SectionComponent.new("budgets", "help/budgets_#{I18n.locale}.png") do %>
<p>
<%= sanitize(t("pages.help.budgets.description",
link: link_to(t("pages.help.budgets.link"), budgets_path))) %>
</p>
<% end %>

View File

@@ -1,25 +1,14 @@
<div class="row section-content">
<div class="small-12 column">
<h3 id="debates" data-magellan-target="debates">
<%= t("pages.help.debates.title") %>
</h3>
<p>
<%= sanitize(t("pages.help.debates.description",
org: setting["org_name"],
link: link_to(t("pages.help.debates.link"),
debates_path))) %>
</p>
<ul class="features">
<li>
<%= sanitize(t("pages.help.debates.feature",
link: link_to(t("pages.help.debates.feature_link", org: setting["org_name"]),
new_user_registration_path))) %>
</li>
</ul>
<figure>
<%= image_tag "help/debates.png", alt: t("pages.help.debates.image_alt") %>
<figcaption><%= t("pages.help.debates.figcaption") %></figcaption>
</figure>
</div>
</div>
<%= render Pages::Help::SectionComponent.new("debates", "help/debates.png") do %>
<p>
<%= sanitize(t("pages.help.debates.description",
org: setting["org_name"],
link: link_to(t("pages.help.debates.link"), debates_path))) %>
</p>
<ul class="features">
<li>
<%= sanitize(t("pages.help.debates.feature",
link: link_to(t("pages.help.debates.feature_link", org: setting["org_name"]),
new_user_registration_path))) %>
</li>
</ul>
<% end %>

View File

@@ -1,16 +1,13 @@
<div class="row section-content">
<div class="small-12 column">
<h3 id="polls" data-magellan-target="polls"><%= t("pages.help.polls.title") %></h3>
<p>
<%= sanitize(t("pages.help.polls.description",
link: link_to(t("pages.help.polls.link"), polls_path))) %>
</p>
<ul class="features">
<li>
<%= sanitize(t("pages.help.polls.feature_1",
link: link_to(t("pages.help.polls.feature_1_link", org_name: setting["org_name"]),
new_user_registration_path))) %>
</li>
</ul>
</div>
</div>
<%= render Pages::Help::SectionComponent.new("polls") do %>
<p>
<%= sanitize(t("pages.help.polls.description",
link: link_to(t("pages.help.polls.link"), polls_path))) %>
</p>
<ul class="features">
<li>
<%= sanitize(t("pages.help.polls.feature_1",
link: link_to(t("pages.help.polls.feature_1_link", org_name: setting["org_name"]),
new_user_registration_path))) %>
</li>
</ul>
<% end %>

View File

@@ -1,19 +1,13 @@
<div class="row section-content">
<div class="small-12 column">
<h3 id="processes" data-magellan-target="processes">
<%= t("pages.help.processes.title") %>
</h3>
<p>
<% link = link_to(t("pages.help.processes.link"), legislation_processes_path) %>
<%= sanitize(t("pages.help.processes.description", link: link)) %>
</p>
<ul class="features">
<li>
<%= sanitize(t("pages.help.processes.feature",
link: link_to(t("pages.help.processes.feature_link", org_name: setting["org_name"]),
new_user_registration_path))) %>
</li>
</ul>
</div>
</div>
<%= render Pages::Help::SectionComponent.new("processes", nil) do %>
<p>
<% link = link_to(t("pages.help.processes.link"), legislation_processes_path) %>
<%= sanitize(t("pages.help.processes.description", link: link)) %>
</p>
<ul class="features">
<li>
<%= sanitize(t("pages.help.processes.feature",
link: link_to(t("pages.help.processes.feature_link", org_name: setting["org_name"]),
new_user_registration_path))) %>
</li>
</ul>
<% end %>

View File

@@ -1,16 +1,6 @@
<div class="row section-content">
<div class="small-12 column">
<h3 id="proposals" data-magellan-target="proposals">
<%= t("pages.help.proposals.title") %>
</h3>
<p>
<%= sanitize(t("pages.help.proposals.description",
link: link_to(t("pages.help.proposals.link"), proposals_path))) %>
</p>
<figure>
<%= image_tag "help/proposals_#{I18n.locale}.png", alt: t("pages.help.proposals.image_alt") %>
<figcaption><%= t("pages.help.proposals.figcaption") %></figcaption>
</figure>
</div>
</div>
<%= render Pages::Help::SectionComponent.new("proposals", "help/proposals_#{I18n.locale}.png") do %>
<p>
<%= sanitize(t("pages.help.proposals.description",
link: link_to(t("pages.help.proposals.link"), proposals_path))) %>
</p>
<% end %>