Problem/Motivation

Entering classes for more complex styles manually isn't user-friendly.

Instead, predefined styles should be simply selectable in the UI. @thomas.frobieter prepared this wonderful screendesign:
drowl_paragraphs_styles_ui

Steps to reproduce

Proposed resolution

Provide the following building blocks in a drowl_paragraphs_styles_ui submodule:

  1. JavaScript classes UI (like in the screendesign), writing its classes into the existings Expert settings > classes field
  2. Provide an array / JS Object defined in the module which provides the styles definitions like this:
    $styleDefinitions = [
      'boxStyleBlack' => [
        'label' => $this->t('Box Style: Black'),
        'classesString' => 'box-style box-style--black',
        'description' => $this->t('Lorem ipsum dolar sit'),
        'iconPath' => 'images/boxStyleBlack.svg',
      ];
    ];
    

    Provide this as setting (Json) for the JS.

  3. Make the array alterable via an alter hook, so the definition can be adjusted (added, modified, removed) project-specific

In the future this may become obsolete, once we decide to switch to https://www.drupal.org/project/style_options

Remaining tasks

  • [x] Add css and make it scoped on the widget
  • [x] JS:
    • Update the JS with your latest code, but only within the START - END.
    • Note that the functions are internal due to the nesting. If they can not be called, please contact me to rewrite the syntax.
    • styles has been renamed consistently to styleDefinitions, but please check the console.log first, if it's correctly passed from PHP
    • The classes-field query selector must be relative to the UI initialized and the UI must be scoped for each paragraph settings form, as of course it should work with * paragraph settings forms opened.
  • [x] PHP:
    • Define all default styles provided by the module in drowl_paragraphs_styles_ui.module
    • The iconPath needs to be provided absolute. See .api.php for examples, when implementing a hook in your theme. But be careful, it's also untested yet!

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
drowl_paragraphs_styles_ui.png50.54 KBanybody
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

Anybody created an issue. See original summary.

anybody’s picture

Issue summary: View changes
anybody’s picture

Issue summary: View changes
anybody’s picture

Title: Add drowl_paragraphs_styles complex style selector as classes ui » Add drowl_paragraphs_styles_ui complex style selector as classes ui
Issue summary: View changes

anybody’s picture

Assigned: Unassigned » thomas.frobieter
Status: Active » Needs work

@thomas.frobieter: This should be more or less ready! :)

I didn't test it, as setting it up in this state wouldn't make much sense, so please first finish the implementation and then let's have a look again together.

Important to consider:
(I've put these into the issue summary to check:)

  • [ ] Add css and make it scoped on the widget
  • [ ] JS:
    • Update the JS with your latest code, but only within the START - END.
    • Note that the functions are internal due to the nesting. If they can not be called, please contact me to rewrite the syntax.
    • styles has been renamed consistently to styleDefinitions, but please check the console.log first, if it's correctly passed from PHP
    • The classes-field query selector must be relative to the UI initialized and the UI must be scoped for each paragraph settings form, as of course it should work with * paragraph settings forms opened.
  • [ ] PHP:
    • Define all default styles provided by the module in drowl_paragraphs_styles_ui.module
    • The iconPath needs to be provided absolute. See .api.php for examples, when implementing a hook in your theme. But be careful, it's also untested yet!
anybody’s picture

Issue summary: View changes

thomas.frobieter made their first commit to this issue’s fork.

anybody’s picture

Assigned: thomas.frobieter » Unassigned
Issue summary: View changes
Status: Needs work » Needs review

  • Anybody committed 3f8d59b7 on 4.x
    Issue #3346661: Add drowl_paragraphs_styles_ui complex style selector as...
anybody’s picture

Status: Needs review » Fixed

Merged! :)
Nice work @thomas.frobieter!

Status: Fixed » Closed (fixed)

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