Move admin index to a component
This way we make it easier to modify. Note that, since the title of the page is "Administration" and it's in the "Admin" section, we're adding an option to the `header` method in order to avoid having a confusing title like "Administration - Admin". Also note that, by removing the `title` HTML class, we avoid inheriting styles from the `dashboard.scss` stylesheet, and now the heading is displayed in the position it was meant to. Finally, the concept of using a `main-class` for the current page comes from a branch (currently in development) which will replace the <div> tag with the `admin-content` class with a `main` tag.
This commit is contained in:
@@ -38,10 +38,6 @@ $table-header: #ecf1f6;
|
||||
small {
|
||||
color: $text-medium;
|
||||
}
|
||||
|
||||
&.title {
|
||||
text-transform: uppercase;
|
||||
}
|
||||
}
|
||||
|
||||
h3 {
|
||||
|
||||
6
app/assets/stylesheets/admin/dashboard/index.scss
Normal file
6
app/assets/stylesheets/admin/dashboard/index.scss
Normal file
@@ -0,0 +1,6 @@
|
||||
.admin-dashboard-index {
|
||||
> header h2 {
|
||||
text-transform: uppercase;
|
||||
border-bottom: 1px solid $border;
|
||||
}
|
||||
}
|
||||
4
app/components/admin/dashboard/index_component.html.erb
Normal file
4
app/components/admin/dashboard/index_component.html.erb
Normal file
@@ -0,0 +1,4 @@
|
||||
<% provide :main_class, "admin-dashboard-index" %>
|
||||
<%= header(skip_section_title: true) %>
|
||||
|
||||
<p><%= t("admin.dashboard.index.description", org: setting["org_name"]) %></p>
|
||||
7
app/components/admin/dashboard/index_component.rb
Normal file
7
app/components/admin/dashboard/index_component.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class Admin::Dashboard::IndexComponent < ApplicationComponent
|
||||
include Header
|
||||
|
||||
def title
|
||||
t("admin.dashboard.index.title")
|
||||
end
|
||||
end
|
||||
@@ -1,10 +1,10 @@
|
||||
module Header
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def header(before: nil, &block)
|
||||
def header(before: nil, skip_section_title: false, &block)
|
||||
provide(:title) do
|
||||
[
|
||||
t("#{namespace}.header.title", default: ""),
|
||||
(t("#{namespace}.header.title", default: "") unless skip_section_title),
|
||||
strip_tags(title),
|
||||
setting["org_name"]
|
||||
].reject(&:blank?).join(" - ")
|
||||
|
||||
@@ -1,3 +1 @@
|
||||
<h2 class="title inline-block"><%= t("admin.dashboard.index.title") %></h2>
|
||||
|
||||
<p><%= t("admin.dashboard.index.description", org: setting["org_name"]) %></p>
|
||||
<%= render Admin::Dashboard::IndexComponent.new %>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<% end %>
|
||||
</nav>
|
||||
|
||||
<div class="admin-content">
|
||||
<div class="admin-content <%= yield(:main_class) %>">
|
||||
<%= label_tag :show_menu, t("admin.menu.admin"),
|
||||
"aria-hidden": true, class: "button hollow expanded" %>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user