Move dashboard resources partial to a component

We're renaming the HTML class (and removing the id attribute, which was
only used in tests) in order to follow our naming conventions.
This commit is contained in:
taitus
2025-06-26 18:02:08 +02:00
committed by Javi Martín
parent 4e129e7d9c
commit 048c8ce917
7 changed files with 67 additions and 62 deletions

View File

@@ -21,6 +21,7 @@
@import "account/**/*"; @import "account/**/*";
@import "budgets/**/*"; @import "budgets/**/*";
@import "comments/**/*"; @import "comments/**/*";
@import "dashboard/**/*";
@import "debates/**/*"; @import "debates/**/*";
@import "devise/**/*"; @import "devise/**/*";
@import "documents/**/*"; @import "documents/**/*";

View File

@@ -2,7 +2,6 @@
// //
// 01. Dashboard global // 01. Dashboard global
// 02. Actions // 02. Actions
// 03. Resources
// 04. Goals // 04. Goals
// 05. Sidebar // 05. Sidebar
// 06. Community // 06. Community
@@ -165,62 +164,6 @@
} }
} }
// 03. Resources
// -------------
.resource-card {
background: #d1f5eb;
border-radius: rem-calc(4);
margin-bottom: $line-height;
min-height: $line-height * 9;
padding: $line-height * 2 $line-height $line-height;
position: relative;
text-align: center;
&.alert {
background: #feeaeb;
&::before {
color: #fb9497;
content: "\74";
}
}
&::before {
border: 2px solid;
border-radius: rem-calc(40);
color: #00cb96;
content: "\6c";
font-family: "icons";
font-size: rem-calc(20);
height: rem-calc(36);
position: absolute;
right: 12px;
top: 12px;
width: rem-calc(36);
}
.label {
left: 0;
position: absolute;
top: 20px;
}
h4 {
margin-top: $line-height;
}
.resource-description {
min-height: $line-height * 4;
}
.button {
background: #00cb96;
color: #000;
font-weight: bold;
}
}
// 04. Goals // 04. Goals
// --------- // ---------

View File

@@ -0,0 +1,54 @@
.dashboard-resources {
.resource-card {
background: #d1f5eb;
border-radius: rem-calc(4);
margin-bottom: $line-height;
min-height: $line-height * 9;
padding: $line-height * 2 $line-height $line-height;
position: relative;
text-align: center;
&.alert {
background: #feeaeb;
&::before {
color: #fb9497;
content: "\74";
}
}
&::before {
border: 2px solid;
border-radius: rem-calc(40);
color: #00cb96;
content: "\6c";
font-family: "icons";
font-size: rem-calc(20);
height: rem-calc(36);
position: absolute;
right: 12px;
top: 12px;
width: rem-calc(36);
}
.label {
left: 0;
position: absolute;
top: 20px;
}
h4 {
margin-top: $line-height;
}
.resource-description {
min-height: $line-height * 4;
}
.button {
background: #00cb96;
color: #000;
font-weight: bold;
}
}
}

View File

@@ -1,4 +1,4 @@
<div id="available-resources-section"> <div class="dashboard-resources">
<h3 class="title"><%= t("dashboard.resources.available_resources") %></h3> <h3 class="title"><%= t("dashboard.resources.available_resources") %></h3>
<div data-equalizer="resources" data-equalize-on="medium"> <div data-equalizer="resources" data-equalize-on="medium">

View File

@@ -0,0 +1,7 @@
class Dashboard::ResourcesComponent < ApplicationComponent
attr_reader :active_resources
def initialize(active_resources)
@active_resources = active_resources
end
end

View File

@@ -38,4 +38,4 @@
<%= render "summary_recommended_actions" %> <%= render "summary_recommended_actions" %>
<% end %> <% end %>
<%= render "resources" %> <%= render Dashboard::ResourcesComponent.new(active_resources) %>

View File

@@ -157,7 +157,7 @@ describe "Proposal's dashboard" do
required_supports: proposal.votes_for.size + 1_000) required_supports: proposal.votes_for.size + 1_000)
visit progress_proposal_dashboard_path(proposal) visit progress_proposal_dashboard_path(proposal)
within "div#available-resources-section" do within ".dashboard-resources" do
expect(page).to have_content("Polls") expect(page).to have_content("Polls")
expect(page).to have_content("E-mail") expect(page).to have_content("E-mail")
expect(page).to have_content("Poster") expect(page).to have_content("Poster")
@@ -204,7 +204,7 @@ describe "Proposal's dashboard" do
required_supports: proposal.votes_for.size + 1_000) required_supports: proposal.votes_for.size + 1_000)
visit progress_proposal_dashboard_path(proposal) visit progress_proposal_dashboard_path(proposal)
within "div#available-resources-section" do within ".dashboard-resources" do
expect(page).to have_content("Polls") expect(page).to have_content("Polls")
expect(page).to have_content("E-mail") expect(page).to have_content("E-mail")
expect(page).to have_content("Poster") expect(page).to have_content("Poster")
@@ -239,7 +239,7 @@ describe "Proposal's dashboard" do
visit progress_proposal_dashboard_path(proposal) visit progress_proposal_dashboard_path(proposal)
within "div#available-resources-section" do within ".dashboard-resources" do
expect(page).to have_content("Polls") expect(page).to have_content("Polls")
expect(page).to have_content("E-mail") expect(page).to have_content("E-mail")
expect(page).to have_content("Poster") expect(page).to have_content("Poster")