Use a component to render poll results

We're also renaming the `poll-results-stats` class to `poll-results`.
The former name was confusing because it had nothing to do with stats.
This commit is contained in:
Javi Martín
2024-10-23 00:22:23 +02:00
parent 8ca941ab02
commit 22b0c04cf4
5 changed files with 33 additions and 24 deletions

View File

@@ -1409,7 +1409,8 @@
// 09. Polls results and stats
// ---------------------------
.polls-results-stats {
.polls-results,
.polls-stats {
table {
table-layout: fixed;

View File

@@ -0,0 +1,22 @@
<% provide :title, poll.name %>
<div class="polls-results">
<%= render Polls::PollHeaderComponent.new(poll) %>
<%= render "poll_subnav" %>
<div class="row margin" data-equalizer data-equalize-on="medium">
<div class="small-12 medium-3 column sidebar" data-equalizer-watch>
<p><strong><%= t("polls.show.results.title") %></strong></p>
<ul class="menu vertical">
<%- poll.questions.each do |question| %>
<li><%= link_to question.title, "##{question.title.parameterize}" %></li>
<% end %>
</ul>
</div>
<div class="small-12 medium-9 column" data-equalizer-watch>
<%= render Polls::Results::QuestionComponent.with_collection(poll.questions) %>
</div>
</div>
</div>

View File

@@ -0,0 +1,7 @@
class Polls::ResultsComponent < ApplicationComponent
attr_reader :poll
def initialize(poll)
@poll = poll
end
end

View File

@@ -1,22 +1 @@
<% provide :title, @poll.name %>
<div class="polls-results-stats">
<%= render Polls::PollHeaderComponent.new(@poll) %>
<%= render "poll_subnav" %>
<div class="row margin" data-equalizer data-equalize-on="medium">
<div class="small-12 medium-3 column sidebar" data-equalizer-watch>
<p><strong><%= t("polls.show.results.title") %></strong></p>
<ul class="menu vertical">
<%- @poll.questions.each do |question| %>
<li><%= link_to question.title, "##{question.title.parameterize}" %></li>
<% end %>
</ul>
</div>
<div class="small-12 medium-9 column" data-equalizer-watch>
<%= render Polls::Results::QuestionComponent.with_collection(@poll.questions) %>
</div>
</div>
</div>
<%= render Polls::ResultsComponent.new(@poll) %>

View File

@@ -1,6 +1,6 @@
<% provide :title, @poll.name %>
<div class="participation-stats polls-results-stats">
<div class="participation-stats polls-stats">
<%= render Polls::PollHeaderComponent.new(@poll) %>
<%= render "poll_subnav" %>