Skip to content

Instantly share code, notes, and snippets.

@lcguida
Forked from seanlinsley/active_admin.scss
Last active June 27, 2017 08:29
Show Gist options
  • Save lcguida/7f5d4d1534ee009ba15575853ecdd806 to your computer and use it in GitHub Desktop.
Save lcguida/7f5d4d1534ee009ba15575853ecdd806 to your computer and use it in GitHub Desktop.
Make Active Admin's primary color change between dev/staging/production
// 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; }
if config.respond_to?(:sass)
require "#{config.root}/lib/sass_ext.rb"
end
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