diff --git a/app/assets/stylesheets/admin.scss b/app/assets/stylesheets/admin.scss index 5b2a19228..261cbe0c5 100644 --- a/app/assets/stylesheets/admin.scss +++ b/app/assets/stylesheets/admin.scss @@ -31,14 +31,6 @@ $table-header: #ecf1f6; .admin { @include admin-layout; - > header { - border-bottom: 1px solid #eee; - - > * { - @include full-width-background($adjust-margin: false, $adjust-padding: true); - } - } - h2 { font-weight: 100; margin-bottom: $line-height; @@ -60,86 +52,6 @@ $table-header: #ecf1f6; float: none; } - .top-links { - - a { - line-height: rem-calc($line-height * 1.5); - } - } - - .top-bar { - height: auto; - padding-top: $line-height / 2; - - @include breakpoint(small only) { - - .top-bar-left ul { - display: inline-block; - } - - .top-bar-right { - - > ul { - border-bottom: 0; - padding-bottom: 0; - margin-bottom: 0; - } - - .submenu { - position: initial; - } - - a { - font-weight: normal; - } - } - - [class^="icon-"] { - display: none; - } - } - - [class^="icon-"] { - font-size: $base-font-size; - } - - h1 { - margin-top: $line-height / 2; - margin-bottom: 0; - - @include breakpoint(medium) { - margin-top: 0; - } - - small { - color: inherit; - text-transform: uppercase; - } - - a { - color: inherit; - display: inline-block; - font-family: "Lato" !important; - font-size: rem-calc(24); - font-weight: lighter; - line-height: 1; - } - } - } - - .top-bar .menu > li { - - @include breakpoint(medium) { - height: auto !important; - } - } - - .title-bar { - color: inherit; - position: absolute; - right: 12px; - } - .notifications.unread-notifications::after { color: $admin-color; } diff --git a/app/assets/stylesheets/layout/admin_header.scss b/app/assets/stylesheets/layout/admin_header.scss new file mode 100644 index 000000000..758f1782a --- /dev/null +++ b/app/assets/stylesheets/layout/admin_header.scss @@ -0,0 +1,89 @@ +.admin { + > header { + border-bottom: 1px solid #eee; + + > * { + @include full-width-background($adjust-margin: false, $adjust-padding: true); + } + } + + .top-links { + + a { + line-height: rem-calc($line-height * 1.5); + } + } + + .top-bar { + height: auto; + padding-top: $line-height / 2; + + @include breakpoint(small only) { + + .top-bar-left ul { + display: inline-block; + } + + .top-bar-right { + + > ul { + border-bottom: 0; + padding-bottom: 0; + margin-bottom: 0; + } + + .submenu { + position: initial; + } + + a { + font-weight: normal; + } + } + + [class^="icon-"] { + display: none; + } + } + + [class^="icon-"] { + font-size: $base-font-size; + } + + h1 { + margin-top: $line-height / 2; + margin-bottom: 0; + + @include breakpoint(medium) { + margin-top: 0; + } + + small { + color: inherit; + text-transform: uppercase; + } + + a { + color: inherit; + display: inline-block; + font-family: "Lato" !important; + font-size: rem-calc(24); + font-weight: lighter; + line-height: 1; + } + } + } + + .top-bar .menu > li { + + @include breakpoint(medium) { + height: auto !important; + } + } + + .title-bar { + color: inherit; + position: absolute; + right: 12px; + } +} diff --git a/app/views/layouts/_admin_header.html.erb b/app/components/layout/admin_header_component.html.erb similarity index 92% rename from app/views/layouts/_admin_header.html.erb rename to app/components/layout/admin_header_component.html.erb index f8cd11365..359f98387 100644 --- a/app/views/layouts/_admin_header.html.erb +++ b/app/components/layout/admin_header_component.html.erb @@ -34,13 +34,13 @@ <% end %> - <% if show_admin_menu?(current_user) || namespace != "management" %> + <% if show_admin_menu?(user) || namespace != "management" %>
diff --git a/app/components/layout/admin_header_component.rb b/app/components/layout/admin_header_component.rb new file mode 100644 index 000000000..b1e84a73e --- /dev/null +++ b/app/components/layout/admin_header_component.rb @@ -0,0 +1,20 @@ +class Layout::AdminHeaderComponent < ApplicationComponent + attr_reader :user + delegate :namespace, :namespaced_root_path, :show_admin_menu?, to: :helpers + + def initialize(user) + @user = user + end + + private + + def namespaced_header_title + if namespace == "moderation/budgets" + t("moderation.header.title") + elsif namespace == "management" + t("management.dashboard.index.title") + else + t("#{namespace}.header.title") + end + end +end diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index 1ec467ead..b89b4533a 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -3,16 +3,6 @@ module AdminHelper "/#{namespace}" end - def namespaced_header_title - if namespace == "moderation/budgets" - t("moderation.header.title") - elsif namespace == "management" - t("management.dashboard.index.title") - else - t("#{namespace}.header.title") - end - end - def official_level_options options = [["", 0]] (1..5).each do |i| diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index 48ad4426d..e8514de96 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -6,7 +6,7 @@ - <%= render "layouts/admin_header" %> + <%= render Layout::AdminHeaderComponent.new(current_user) %>