From f06f69b9da81337db14324783b45ea5f55fcf735 Mon Sep 17 00:00:00 2001 From: Drew Blessing Date: Sun, 14 Dec 2014 19:01:59 -0600 Subject: [PATCH] Add theme type css class --- app/helpers/application_helper.rb | 4 ++++ app/views/layouts/admin.html.haml | 2 +- app/views/layouts/application.html.haml | 2 +- app/views/layouts/errors.html.haml | 2 +- app/views/layouts/explore.html.haml | 2 +- app/views/layouts/group.html.haml | 2 +- app/views/layouts/navless.html.haml | 2 +- app/views/layouts/profile.html.haml | 2 +- app/views/layouts/project_settings.html.haml | 2 +- app/views/layouts/projects.html.haml | 2 +- app/views/layouts/public_group.html.haml | 2 +- app/views/layouts/public_projects.html.haml | 2 +- app/views/layouts/public_users.html.haml | 2 +- app/views/layouts/search.html.haml | 2 +- app/views/profiles/update.js.erb | 4 ++-- lib/gitlab/theme.rb | 14 ++++++++++++++ 16 files changed, 33 insertions(+), 15 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 021bd0a494c..01aa4a60d4c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -114,6 +114,10 @@ module ApplicationHelper Gitlab::Theme.css_class_by_id(current_user.try(:theme_id)) end + def theme_type + Gitlab::Theme.type_css_class_by_id(current_user.try(:theme_id)) + end + def user_color_scheme_class COLOR_SCHEMES[current_user.try(:color_scheme_id)] if defined?(current_user) end diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index 207ab22f4c7..744ecaa0297 100644 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml @@ -1,7 +1,7 @@ !!! 5 %html{ lang: "en"} = render "layouts/head", title: "Admin area" - %body{class: "#{app_theme} admin", :'data-page' => body_data_page} + %body{class: "#{app_theme} #{theme_type} admin", :'data-page' => body_data_page} = render "layouts/broadcast" = render "layouts/head_panel", title: "Admin area" %nav.main-nav.navbar-collapse.collapse diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 7d0819aa93e..e35a3915d0e 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -1,7 +1,7 @@ !!! 5 %html{ lang: "en"} = render "layouts/head", title: "Dashboard" - %body{class: "#{app_theme} application", :'data-page' => body_data_page } + %body{class: "#{app_theme} #{theme_type} application", :'data-page' => body_data_page } = render "layouts/broadcast" = render "layouts/head_panel", title: "Dashboard" %nav.main-nav.navbar-collapse.collapse diff --git a/app/views/layouts/errors.html.haml b/app/views/layouts/errors.html.haml index 16df9c10fbb..e7d875173e6 100644 --- a/app/views/layouts/errors.html.haml +++ b/app/views/layouts/errors.html.haml @@ -1,7 +1,7 @@ !!! 5 %html{ lang: "en"} = render "layouts/head", title: "Error" - %body{class: "#{app_theme} application"} + %body{class: "#{app_theme} #{theme_type} application"} = render "layouts/head_panel", title: "" if current_user .container.navless-container = render "layouts/flash" diff --git a/app/views/layouts/explore.html.haml b/app/views/layouts/explore.html.haml index d023846c5eb..9813d846542 100644 --- a/app/views/layouts/explore.html.haml +++ b/app/views/layouts/explore.html.haml @@ -2,7 +2,7 @@ !!! 5 %html{ lang: "en"} = render "layouts/head", title: page_title - %body{class: "#{app_theme} application", :'data-page' => body_data_page} + %body{class: "#{app_theme} #{theme_type} application", :'data-page' => body_data_page} = render "layouts/broadcast" - if current_user = render "layouts/head_panel", title: page_title diff --git a/app/views/layouts/group.html.haml b/app/views/layouts/group.html.haml index f22fb236cb5..6ad285e2468 100644 --- a/app/views/layouts/group.html.haml +++ b/app/views/layouts/group.html.haml @@ -1,7 +1,7 @@ !!! 5 %html{ lang: "en"} = render "layouts/head", title: group_head_title - %body{class: "#{app_theme} application", :'data-page' => body_data_page} + %body{class: "#{app_theme} #{theme_type} application", :'data-page' => body_data_page} = render "layouts/broadcast" = render "layouts/head_panel", title: "group: #{@group.name}" %nav.main-nav.navbar-collapse.collapse diff --git a/app/views/layouts/navless.html.haml b/app/views/layouts/navless.html.haml index 2c5fffe384f..730f3d09277 100644 --- a/app/views/layouts/navless.html.haml +++ b/app/views/layouts/navless.html.haml @@ -1,7 +1,7 @@ !!! 5 %html{ lang: "en"} = render "layouts/head", title: @title - %body{class: "#{app_theme} application", :'data-page' => body_data_page} + %body{class: "#{app_theme} #{theme_type} application", :'data-page' => body_data_page} = render "layouts/broadcast" = render "layouts/head_panel", title: @title .container.navless-container diff --git a/app/views/layouts/profile.html.haml b/app/views/layouts/profile.html.haml index 1d0ab84d26f..c57047bb1f3 100644 --- a/app/views/layouts/profile.html.haml +++ b/app/views/layouts/profile.html.haml @@ -1,7 +1,7 @@ !!! 5 %html{ lang: "en"} = render "layouts/head", title: "Profile" - %body{class: "#{app_theme} profile", :'data-page' => body_data_page} + %body{class: "#{app_theme} #{theme_type} profile", :'data-page' => body_data_page} = render "layouts/broadcast" = render "layouts/head_panel", title: "Profile" %nav.main-nav.navbar-collapse.collapse diff --git a/app/views/layouts/project_settings.html.haml b/app/views/layouts/project_settings.html.haml index c8b8f4ba971..fd233452215 100644 --- a/app/views/layouts/project_settings.html.haml +++ b/app/views/layouts/project_settings.html.haml @@ -1,7 +1,7 @@ !!! 5 %html{ lang: "en"} = render "layouts/head", title: @project.name_with_namespace - %body{class: "#{app_theme} project", :'data-page' => body_data_page, :'data-project-id' => @project.id } + %body{class: "#{app_theme} #{theme_type} project", :'data-page' => body_data_page, :'data-project-id' => @project.id } = render "layouts/broadcast" = render "layouts/head_panel", title: project_title(@project) = render "layouts/init_auto_complete" diff --git a/app/views/layouts/projects.html.haml b/app/views/layouts/projects.html.haml index 8ad2f165946..fb64c40e8bb 100644 --- a/app/views/layouts/projects.html.haml +++ b/app/views/layouts/projects.html.haml @@ -1,7 +1,7 @@ !!! 5 %html{ lang: "en"} = render "layouts/head", title: project_head_title - %body{class: "#{app_theme} project", :'data-page' => body_data_page, :'data-project-id' => @project.id } + %body{class: "#{app_theme} #{theme_type} project", :'data-page' => body_data_page, :'data-project-id' => @project.id } = render "layouts/broadcast" = render "layouts/head_panel", title: project_title(@project) = render "layouts/init_auto_complete" diff --git a/app/views/layouts/public_group.html.haml b/app/views/layouts/public_group.html.haml index a289b784725..b97b0cf92cb 100644 --- a/app/views/layouts/public_group.html.haml +++ b/app/views/layouts/public_group.html.haml @@ -1,7 +1,7 @@ !!! 5 %html{ lang: "en"} = render "layouts/head", title: group_head_title - %body{class: "#{app_theme} application", :'data-page' => body_data_page} + %body{class: "#{app_theme} #{theme_type} application", :'data-page' => body_data_page} = render "layouts/broadcast" = render "layouts/public_head_panel", title: "group: #{@group.name}" %nav.main-nav.navbar-collapse.collapse diff --git a/app/views/layouts/public_projects.html.haml b/app/views/layouts/public_projects.html.haml index 2a9230244f8..4819b9b135f 100644 --- a/app/views/layouts/public_projects.html.haml +++ b/app/views/layouts/public_projects.html.haml @@ -1,7 +1,7 @@ !!! 5 %html{ lang: "en"} = render "layouts/head", title: @project.name_with_namespace - %body{class: "#{app_theme} application", :'data-page' => body_data_page} + %body{class: "#{app_theme} #{theme_type} application", :'data-page' => body_data_page} = render "layouts/broadcast" = render "layouts/public_head_panel", title: project_title(@project) %nav.main-nav.navbar-collapse.collapse diff --git a/app/views/layouts/public_users.html.haml b/app/views/layouts/public_users.html.haml index 4aa258fea0d..fdba0f099a9 100644 --- a/app/views/layouts/public_users.html.haml +++ b/app/views/layouts/public_users.html.haml @@ -1,7 +1,7 @@ !!! 5 %html{ lang: "en"} = render "layouts/head", title: @title - %body{class: "#{app_theme} application", :'data-page' => body_data_page} + %body{class: "#{app_theme} #{theme_type} application", :'data-page' => body_data_page} = render "layouts/broadcast" = render "layouts/public_head_panel", title: @title .container.navless-container diff --git a/app/views/layouts/search.html.haml b/app/views/layouts/search.html.haml index 084ff7ec830..6d001e7ee1c 100644 --- a/app/views/layouts/search.html.haml +++ b/app/views/layouts/search.html.haml @@ -1,7 +1,7 @@ !!! 5 %html{ lang: "en"} = render "layouts/head", title: "Search" - %body{class: "#{app_theme} application", :'data-page' => body_data_page} + %body{class: "#{app_theme} #{theme_type} application", :'data-page' => body_data_page} = render "layouts/broadcast" = render "layouts/head_panel", title: "Search" .container.navless-container diff --git a/app/views/profiles/update.js.erb b/app/views/profiles/update.js.erb index 04b5cf4827d..e664ac2a52a 100644 --- a/app/views/profiles/update.js.erb +++ b/app/views/profiles/update.js.erb @@ -1,6 +1,6 @@ // Remove body class for any previous theme, re-add current one -$('body').removeClass('ui_basic ui_mars ui_modern ui_gray ui_color') -$('body').addClass('<%= app_theme %>') +$('body').removeClass('ui_basic ui_mars ui_modern ui_gray ui_color light_theme dark_theme') +$('body').addClass('<%= app_theme %> <%= theme_type %>') // Re-render the header to reflect the new theme $('header').html('<%= escape_javascript(render("layouts/head_panel", title: "Profile")) %>') diff --git a/lib/gitlab/theme.rb b/lib/gitlab/theme.rb index b7c50cb734d..a7c83a880f6 100644 --- a/lib/gitlab/theme.rb +++ b/lib/gitlab/theme.rb @@ -19,5 +19,19 @@ module Gitlab return themes[id] end + + def self.type_css_class_by_id(id) + types = { + BASIC => 'light_theme', + MARS => 'dark_theme', + MODERN => 'dark_theme', + GRAY => 'dark_theme', + COLOR => 'dark_theme' + } + + id ||= Gitlab.config.gitlab.default_theme + + types[id] + end end end