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:

Steps to reproduce
Proposed resolution
Provide the following building blocks in a drowl_paragraphs_styles_ui submodule:
- JavaScript classes UI (like in the screendesign), writing its classes into the existings Expert settings > classes field
- 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.
- 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.
styleshas been renamed consistently tostyleDefinitions, 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
| Comment | File | Size | Author |
|---|---|---|---|
| drowl_paragraphs_styles_ui.png | 50.54 KB | anybody |
Issue fork drowl_paragraphs-3346661
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
Comment #2
anybodyComment #3
anybodyComment #4
anybodyComment #6
anybody@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:)
styleshas been renamed consistently tostyleDefinitions, but please check the console.log first, if it's correctly passed from PHPComment #7
anybodyComment #9
anybodyComment #11
anybodyMerged! :)
Nice work @thomas.frobieter!