Problem/Motivation

When using the Gin theme & Gin Toolbar the environment indictor is not very obvious at first glance. It also changes the colours of links which can make it look wrong compared with the theme in use.

Steps to reproduce

  1. Install Gin & set as administration theme
  2. Install & enable Gin Toolbar
  3. Install & enable Environment Indicator
  4. Configure at least one environment
  5. Make sure Gin theme is using at least horizontal or vertical menu

Proposed resolution

Increase the size of the environment status bar for Gin and don't apply colour to text links.
For this example I had the following colours / settings used:

$config['environment_indicator.indicator']['bg_color'] = 'pink';
$config['environment_indicator.indicator']['fg_color'] = 'orange';

See images attached.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Eli.Stone created an issue. See original summary.

3li’s picture

Created a patch to improve the look.

3li’s picture

Also can colour the default icon based upon the background colour, idea from #3156863.

3li’s picture

Resolving an issue that caused extra space on the vertical style making it harder to hover over to the sub menu items.

3li’s picture

Version: 4.0.3 » 4.x-dev
Status: Active » Needs review
dpacassi’s picture

Using the patch mentioned in #4, can confirm that everything works with Drupal 9.3.0 and that the additional spacing is indeed quite nice.

giuseppe87’s picture

+1 to the patch, it's much easier to understand the enviroment.

idiaz.roncero’s picture

+1 to this. Works perfect with 4.x-dev branch.

3li’s picture

Status: Needs review » Reviewed & tested by the community

Marking this as RTBC based on the above comments.

jrb’s picture

FYI, you can also change the entire Gin color scheme in a settings.local.php file along with (or instead of) this patch. For example, we use something like this for our local dev environments:

$config['environment_indicator.indicator']['bg_color'] = '#114502';
$config['environment_indicator.indicator']['name'] = 'Local';

To also change the Gin color scheme locally, you could add this:

$config['gin.settings']['preset_accent_color'] = 'custom';
$config['gin.settings']['accent_color'] = '#114502';

The preset_accent_color color options are:

  • blue
  • light_blue
  • dark_purple
  • purple
  • teal
  • green
  • pink
  • red
  • orange
  • yellow
  • neutral
  • custom

So, in production, you could use the red scheme like this:

$config['gin.settings']['preset_accent_color'] = 'red';

While on a staging server, you could use blue:

$config['gin.settings']['preset_accent_color'] = 'blue';
idiaz.roncero’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new10.29 KB

Sorry to say the problem is back with latest Gin 3.x-dev version

Screenshot

idiaz.roncero’s picture

Status: Needs work » Needs review

I've created a MR that integrates the solution from patch #4 and slightly modifies the logic. The backgroundColor joins the text and will be only used when GIN is not active:

        // Only apply text and background color color if not using gin_toolbar
        if (!$('body').hasClass('gin--vertical-toolbar') && !$('body').hasClass('gin--horizontal-toolbar')) {
          $('#toolbar-bar', context).css('background-color', settings.environmentIndicator.bgColor);
          $('#toolbar-bar .toolbar-item, #toolbar-bar .toolbar-item a', context).css('color', settings.environmentIndicator.fgColor);
        }

This works as a quick-and-easy solution.

For a perfect solution, I think including all of this logic inside "environment-indicator.js" should be avoided. If every admin theme will need to add its own lines of code inside that file order to support their quirks, we will end up with an unmaintainable file prone to bugs.

Also, checking the body classes ($('body').hasClass('gin--vertical-toolbar') && !$('body').hasClass('gin--horizontal-toolbar')) is prone to regressions as gin maintaniners could change them anytime.

I think a better solution could be to check for the admin theme name on a hook_preprocess_page or hook_attachments_alter or similar and conditionally load a custom library (environment_indicator/gin) that will include just the CSS and JS needed for Gin to work with Environment Indicator. This way, we could:

  1. 1 - Avoid loading unneded javascript on non-gin themes, as they will not use the library at all
  2. 2 - Move some overrides to the CSS, where they belong, instead of solving everything on the JS side
dpacassi’s picture

Thanks @idiaz.roncero!
I can confirm that the new MR5 works just fine with the latest releases of Gin, Gin Toolbar and Environment Indicator.
Adding a patch file in case that the MR would get updated.

dpacassi’s picture

Status: Needs review » Reviewed & tested by the community
e0ipso’s picture

  • e0ipso committed f4a30fd on 4.x authored by idiaz.roncero
    Issue #3247637 by 3li, idiaz.roncero, dpacassi, Giuseppe87, jrb, e0ipso...
e0ipso’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.