Problem/Motivation

UI Suite DSFR need to be able to validate 2 "themes" together, so they are suggesting to introduce a dependency system:

system:
  label: "System"
  key: data-fr-scheme
  target: html

light:
  label: "Light"
  key: data-fr-scheme
  target: html

dark:
  label: "Dark"
  key: data-fr-scheme
  target: html

mourning_system:
  label: "Mourning system"
  key: data-fr-mourning
  target: html
  value: ''
  dependencies:
    - system

mourning_light:
  label: "Mourning light"
  key: data-fr-mourning
  target: html
  value: ''
  dependencies:
    - light

mourning_dark:
  label: "Mourning dark"
  key: data-fr-mourning
  target: html
  value: ''
  dependencies:
    - dark

Proposed resolution

Only one theme is activated by the user, the form element stays a select list.

If a theme with dependencies is activated, the other themes are also activated, so the attributes, meta element & classes of all themes are added to the page markup.

If a dependency is listed but is not found, let's ignore it, process as usual, and push a warning log message.

Issue fork ui_skins-3435933

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

yassrzg created an issue. See original summary.

yassrzg’s picture

Issue summary: View changes
pdureau’s picture

Title: Adding 2 thèmes » Introducing dependencies between themes
Issue summary: View changes
grimreaper’s picture

Status: Needs work » Active

Hi,

Thanks for your interest in UI Skins. This will be a nice addition.

"Needs work" status is for when some patches or MR not ready had been created. If there is no code already shared, it should be "Active".

yassrzg’s picture

Assigned: Unassigned » yassrzg
Status: Active » Needs work
yassrzg’s picture

Status: Needs work » Needs review

pdureau’s picture

Status: Needs review » Needs work

Hello Yassine,

Thanks for your MR.

You worked on Drupal\ui_skins\HookHandler\PreprocessHtml but it would be better to keep thsi class as simple as possible and add the mechanism to the plugin manager.

Instead of duplicated the values:

      $target2 = $plugin_definition2->getComputedTarget();
      $key2 = $plugin_definition2->getKey();
      $value2 = $plugin_definition2->getValue();

You need to set a recursive call which browse the dependency tree. A theme can have multiple dependencies, and those dependencies can have dependencies.

Also, it seems this is missing:

If a dependency is listed but is not found, let's ignore it, process as usual, and push a warning log message.

grimreaper’s picture

Hello,

@yassrzg, a complement of the discussion we had yesterday: the logic of gathering $plugin_definitions recursively should be added in the ui_skins/src/Theme/ThemePluginManager.php and in the interface.

So it can be reused somewhere else.

yassrzg’s picture

Status: Needs work » Needs review
grimreaper’s picture

Assigned: yassrzg » grimreaper
grimreaper’s picture

Version: 1.0.0-alpha6 » 1.1.x-dev
grimreaper’s picture

Assigned: grimreaper » Unassigned
Status: Needs review » Fixed
grimreaper’s picture

Issue tags: +DevDaysBurgas2024

  • Grimreaper committed 8165979a on 1.1.x
    Issue #3435933 by yassrzg, Grimreaper, pdureau: Introducing dependencies...

Status: Fixed » Closed (fixed)

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