Problem/Motivation

We need to restore this feature used by Layout Builder:

  $layout = new LayoutDefinition($definition);
    if (isset($component['icon_map'])) {
      $layout->setIconMap($component['icon_map']);
    }
    if (isset($component['thumbnailPath'])) {
      $layout->setIconPath($component['icon_path']);
    }
    if (isset($component['icon_path'])) {
      $layout->setIconPath($component['icon_path']);
    }

Example of icon_map in a component definiton:

  icon_map:
    - [top]
    - [first, second]
    - [bottom]

And it is also the opportunity of leveraging thumbnailPath in layout builder:

  1. if you put a file named thumbnail.png in your component folder, SDC is setting thumbnailPath property in definition
  2. if we have thumbnailPath and not icon_path in the definition, icon_path = thumbnailPath

Proposal:

  $layout = new LayoutDefinition($definition);
    if (isset($component['icon_map'])) {
      $layout->setIconMap($component['icon_map']);
    }
    if (isset($component['thumbnailPath'])) {
      $layout->setIconPath($component['icon_path']);
    }
    if (isset($component['icon_path'])) {
      $layout->setIconPath($component['icon_path']);
    }

Related issue, but for component selector instead of layout builder #3469795: [2.2.0] Component selector: use SDC's thumbnailPath?

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

pdureau created an issue. See original summary.

pdureau’s picture

Did we lost other mechanisms when we moved from hook alter to deriver?

just_like_good_vibes made their first commit to this issue’s fork.

just_like_good_vibes’s picture

Assigned: just_like_good_vibes » pdureau
Status: Active » Needs review

done

pdureau’s picture

Assigned: pdureau » just_like_good_vibes
Status: Needs review » Needs work
  • icon_path: OK
  • icon_map: OK
  • thumbnail.png : OK

However:

modules/ui_patterns_layouts/src/Plugin/Derivative/ComponentLayout.php:50 CyclomaticComplexity The method getDerivativeDefinitions() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.

just_like_good_vibes’s picture

Assigned: just_like_good_vibes » Unassigned
Status: Needs work » Fixed
pdureau’s picture

Status: Fixed » Closed (fixed)