summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-04-23 17:30:41 -0400
committerRobert Speicher <rspeicher@gmail.com>2015-04-25 14:03:40 -0400
commitc597b5d09d7ce9d91d6e4e171302611298f59d35 (patch)
tree3c0e3802d9ac23008e82529e696b5a0c2112d284 /lib
parent3f2f40aa43b0c6cad18a8ea0c002da0e4e9a44df (diff)
downloadgitlab-ce-c597b5d09d7ce9d91d6e4e171302611298f59d35.tar.gz
Fix Profile > Design live-updating
`ui_blue` wasn't added to the list of classes to remove, so if a user changed to that theme, any subsequent changes wouldn't be live-updated. This change refactors Gitlab::Theme a bit to make it harder for this to happen in the future with new themes.
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/theme.rb39
1 files changed, 25 insertions, 14 deletions
diff --git a/lib/gitlab/theme.rb b/lib/gitlab/theme.rb
index 43093c7d27e..f0e61aa2e81 100644
--- a/lib/gitlab/theme.rb
+++ b/lib/gitlab/theme.rb
@@ -7,33 +7,44 @@ module Gitlab
COLOR = 5 unless const_defined?(:COLOR)
BLUE = 6 unless const_defined?(:BLUE)
- def self.css_class_by_id(id)
- themes = {
- BASIC => "ui_basic",
- MARS => "ui_mars",
- MODERN => "ui_modern",
- GRAY => "ui_gray",
- COLOR => "ui_color",
- BLUE => "ui_blue"
+ def self.classes
+ @classes ||= {
+ BASIC => 'ui_basic',
+ MARS => 'ui_mars',
+ MODERN => 'ui_modern',
+ GRAY => 'ui_gray',
+ COLOR => 'ui_color',
+ BLUE => 'ui_blue'
}
+ end
+ def self.css_class_by_id(id)
id ||= Gitlab.config.gitlab.default_theme
-
- themes[id]
+ classes[id]
end
- def self.type_css_class_by_id(id)
- types = {
+ def self.types
+ @types ||= {
BASIC => 'light_theme',
MARS => 'dark_theme',
MODERN => 'dark_theme',
GRAY => 'dark_theme',
- COLOR => 'dark_theme'
+ COLOR => 'dark_theme',
+ BLUE => 'light_theme'
}
+ end
+ def self.type_css_class_by_id(id)
id ||= Gitlab.config.gitlab.default_theme
-
types[id]
end
+
+ # Convenience method to get a space-separated String of all the theme
+ # classes that mighty be applied to the `body` element
+ #
+ # Returns a String
+ def self.body_classes
+ (classes.values + types.values).uniq.join(' ')
+ end
end
end