Problem/Motivation

When using UI Skins module, we have access to the global theme settings (dark/light).
Currently some overrides are done that did not respect this value:

  • Navbar (page.html.twig)
  • Maintenance page navbar (maintenance.html.twig)
  • Layout builder
  • Media library (media--media-library.html.twig) + add media list
  • Mark (mark.html.twig)

Would be great to allow this to work.

Proposed resolution

Add a global theme variable in all templates with ui_suite_bootstrap_preprocess().

Get theme setting for layout builder and media library.

For mark, because it's a reverse style, probably better to change to success.

Remaining tasks

Seems we could achieve something for CKeditor, but this need to add a ckeditor5-stylesheets in the main theme.
Here is the CKeditor documentation on variables for a dark theme.

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

mogtofu33 created an issue. See original summary.

mogtofu33’s picture

Status: Active » Needs review
grimreaper’s picture

Assigned: Unassigned » grimreaper

Thanks a lot for the feature request and the MR.

I will give a look and test.

grimreaper’s picture

Assigned: grimreaper » pdureau
pdureau’s picture

Assigned: pdureau » grimreaper
Status: Needs review » Needs work

Can we move...

The declaration in some YAML files?

in order to be authorable by front developers.

For example, naive proposal in ui_suite_bootstrap.ui_skins.themes:

# No target because scopable.
# No value because same as plugin ID.
dark:
  label: "Dark"
  label_context: "color"
  key: "data-bs-theme"
  bg_utility:
    - bg-dark
  fg_utility:
    - text-bg-dark

# No target because scopable.
# No value because same as plugin ID.
light:
  label: "Light"
  label_context: "color"
  key: "data-bs-theme"
  bg_utility:
    - bg-light
  fg_utility:
    - text-bg-light

This proposal is just a first draft, let's think about a better way of doing that

The Bootstrap::getThemeMapping() logic in UI Skins?

We can keep the apply in the ui_suite_bootstrap PHP code for now, so those function will call the new UI Skins API:

  • PreprocessPage::preprocess()
  • PreprocessMediaMediaLibrary::preprocess()
  • FormMediaLibraryAddFormAlter
  • ElementPreRenderLayoutBuilder
  • ...
pdureau’s picture

grimreaper’s picture

UI Skins issue created #3500562: Theme definition: link to utility classes.

I will isolate generic stuff unrelated to theme selection in another MR to merge it right now.

  • grimreaper committed e231dd81 on 5.1.x
    Issue #3499985 by mogtofu33, grimreaper, pdureau: Transversal...
grimreaper’s picture

Assigned: grimreaper » Unassigned
Status: Needs work » Postponed

Merged what was independent from UI Skins.

First MR rebased, so it is clearer what needs to be made generic.

Postponing until UI Skins issue is done.

grimreaper’s picture

Title: Support for UI Skins theme setting » UI Skins: support theme setting

mogtofu33’s picture

Status: Postponed » Needs review

Seems like just removing the specific light classes is enough for the dark theme support!

grimreaper’s picture

Version: 5.1.x-dev » 5.2.x-dev

grimreaper changed the visibility of the branch 3499985-extract to hidden.

grimreaper’s picture

Assigned: Unassigned » grimreaper
grimreaper’s picture

Assigned: grimreaper » Unassigned
Status: Needs review » Needs work

Found missing spots.

JS:
- assets/js/text/text.js
- assets/js/misc/tabledrag.js

Some btn-outline-dark, so I think the theme class should be made available in a drupalSettings.

src/Utility/Element.php:

// Find a class based on the value of "value", "title" or "button_type".
    if (!$class) {
      $themeClass = Bootstrap::getThemeMapping();
      $value = $this->getProperty('value', $this->getProperty('title', ''));
      /** @var string $button_type */
      $button_type = $this->getProperty('button_type', 'outline-' . $themeClass);
      $class = "{$prefix}-" . Bootstrap::cssClassFromString($value, $button ? $button_type : 'outline-' . $themeClass);
    }

src/HookHandler/PreprocessMenuLocalAction.php:

$class = Bootstrap::cssClassFromString($link['title'], 'outline-dark');

On PHP side, maybe for both, but at least for PreprocessMenuLocalAction, the problem is that it is the opposite that needs to be gathered. When in dark mode, we need outline-light.

So, more complex than a simple mode/class pair only.

grimreaper’s picture

Status: Needs work » Postponed

Need to wait for UI Styles 2 (/UI Skins 2), the theme settings will be changed.