-
-
Save lcguida/7f5d4d1534ee009ba15575853ecdd806 to your computer and use it in GitHub Desktop.
Make Active Admin's primary color change between dev/staging/production
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SASS variable overrides must be declared before loading up Active Admin's styles. | |
// | |
// To view the variables that Active Admin provides, take a look at | |
// `app/assets/stylesheets/active_admin/mixins/_variables.css.scss` in the | |
// Active Admin source. | |
// | |
// For example, to change the sidebar width: | |
// $sidebar-width: 242px; | |
$primary-color: dynamic_active_admin_color(); | |
// Active Admin's got SASS! | |
@import "active_admin/mixins"; | |
@import "active_admin/base"; | |
// Overriding any non-variable SASS must be done after the fact. | |
// For example, to change the default status-tag color: | |
// | |
// .status_tag { background: #6090DB; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if config.respond_to?(:sass) | |
require "#{config.root}/lib/sass_ext.rb" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Sass::Script::Functions | |
module ActiveAdminEnvColor | |
def dynamic_active_admin_color | |
color = case Rails.env | |
when 'production' then [0x5e, 0x64, 0x69] # grey (default AA) | |
when 'staging' then [0x45, 0x77, 0x4b] # green | |
when 'development' then [0x84, 0x4c, 0x62] # red | |
end | |
Sass::Script::Color.new color | |
end | |
end | |
include ActiveAdminEnvColor | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment