Problem/Motivation

Often in design systems, it is possible to set multiple classes on one item and those classes are not exclusive. Example: a class to align the class, another one to put it in bold, another one to underline.

But currently as it is only possible to select one item per style, those classes needs to be declared in multiple styles which blotters the UI and add difficulty for the site builder to clearly see what is needed.

Proposed resolution

Be able to select multiple classes by either a multiple select or changing into checkboxes.

Issue fork ui_styles-3263526

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

Grimreaper created an issue. See original summary.

grimreaper’s picture

Title: Be able to select multiple values for one style » Convert select into checkbox when a style has only one option
Assigned: Unassigned » grimreaper

After discussion with @pdureau.

In a first time we will provide a checkbox instead of a select list when a style has only one option.

grimreaper’s picture

Issue tags: +ddd2022
grimreaper’s picture

Assigned: grimreaper » Unassigned
Status: Active » Postponed (maintainer needs more info)
StatusFileSize
new36.77 KB

Discussed with @pdureau.

The problem with checkbox is that the plugin title is used directly has the checkbox label, and no more the value label.

No satisfying solution for the moment.

pdureau’s picture

Title: Convert select into checkbox when a style has only one option » Site builder experience: Add other widgets than select, and add groups

Let's make this more declarative and generic.

Instead of just automatically detecting if style has just one option, we can add 2 keys in ui_styles plugins YMAL descriptions:

  • group: {groupname} (with maybe group types)
  • widget or type: (color|range...))

Widgets/types:

  • color: a color palette, for front or background color for example.
  • range: a numeric range, for padding and amrgin for example

Without breaking the current YAML structure:

background_colors:
  type: color
  label: Background color
  options:
    bg-white: White
    bg-black: Black
    bg-gray: Gray

margin_top:
  type: range
  label: Margin top
  options:
    mt-0: 0
    mt-1: 1
    mt-2: 2
    mt-auto: Auto
  group: margin

Inspirations:

pdureau’s picture

Status: Postponed (maintainer needs more info) » Active
grimreaper’s picture

Title: Site builder experience: Add other widgets than select, and add groups » UX: Add other widgets than select
Issue summary: View changes

Splitting other widgets and groups into separated issues.

pdureau’s picture

  1. Add StyleType plugin type
  2. Add mechanism to guess default types
  3. Add StyleWidget plugin type
  4. Add Widgets plugins: Select, Radio, Checkbox, Number, ColorSelect & Toolbar
sharique’s picture

New widgets will be really helpful.
With new widget options, there is an overlay with layout options in certain scenarios, for example in case of layout paragraphs, we can add same setting either using UI Styles or layout options.

pdureau’s picture

Hi Sharique, the widgets are only bringing improved UX for existing styling features.
Styles are still list of mutually exclusive options. Each option is still a CSS class.

We are not introducing other data types like booleans, integers...
So, if there is an overlap with Layout Options, it must be already the case. Do yo usee it?

sharique’s picture

I see overlap in case of layout paragraphs, because we are using extensively. And this is already in a way. Not sure about other scenarios.
Anyway we can revisit this later.

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

maboy’s picture

Assigned: Unassigned » maboy
thomas.frobieter’s picture

@maboy Nice! Thrilled to use this. Does it make sense to review the status quo now?

pdureau’s picture

In #3375884: Provide more options to drive the display of the UI style form vbouchet has proposed:

Alter the default "-None-" option to another label (for example, for a plugin around "Borders", "No border" makes more sense from a contributor standpoint).

Why not... Maybe a new property like this one from Form API:

#empty_option: (optional) The label to show for the first default option. By default, the label is automatically set to "- Select -" for a required field and "- None -" for an optional field.

Let's credit him if we add this feature.

grimreaper’s picture

Assigned: maboy » grimreaper
Status: Active » Needs work

Reviewing.

Putting into needs work as of current review comments and also needs automated tests.

grimreaper’s picture

Taking care of some review comments during rebase.

grimreaper’s picture

I pushed some refactoring.

I did not had the time to fix coding standards and write tests yet, as there are still some stuff remaining.

Main part will be to update the CSS to work outside of Gin / Gin LB.

@maboy do you want to retake the issue? do you want to see it in pair programming?

grimreaper’s picture

Introduced a lot of tests and converted to PHP attribute discovery.

TODO:
- comment 18
- discuss about the @todo and question marks.
- update CSS to not rely on Gin
- update documentation, examples. Where? In readme? on drupal.org doc pages?

grimreaper’s picture

After discussion with @maboy and @pdureau,

TODO:
- comment 18, @Grimreaper
- Fix the @todo and question marks. @Grimreaper
- take previewed_as hidden into account @Grimreaper
- update CSS to not rely on Gin @maboy

If Gin specific stuff will be needed when using Gin LB, let's see to make an issue and MR on Gin LB.

grimreaper’s picture

grimreaper’s picture

Updated TODO:

- one new review question to answer
- update CSS to not rely on Gin @maboy

grimreaper’s picture

Thanks @maboy for the new CSS. Looks pretty good!

The only thing I wonder now is in term of accessibility if the fake selects are ok. But I guess assistive technologies still see radios buttons.

With Claro:

With Gin and Gin LB:

grimreaper’s picture

Status: Needs work » Needs review

I have created an MR on #3426449: Update styles declaration to use UI Styles sources in WIP with a beginning of icons. This will ease the testing.

grimreaper’s picture

@rajab suggested "Radio Image widget in core" during UI Suite monthly meeting.

grimreaper’s picture

@Rajab Natshah

The only thing in core I found regarding a "radio image widget" in core is core/lib/Drupal/Core/Render/Element/ImageButton.php which is a submit button, so not what we search.

After a quick Google search, I found https://www.drupal.org/project/image_radios, is it what you had in mind?

grimreaper’s picture

With @pdureau we did other testing.

We tried to use the previewed_with also. It gives interesting results. Some previews are better, other are broken. See attached screenshots.

I put some todos in the MR to not forget stuff to explore, we are almost there but we are missing a mechanism to ensure we have nice previews.

Also potentially we will be able to have previews in the admin theme with #3453784: Stylesheet generator + CKE5 usage.

grimreaper’s picture

Note to myself for later :)

/ui_styles/stylesheet.css?prefix=.ui-styles-source-select-plugin: { minified: true }

+ re-adapt stylesheet.

grimreaper’s picture

Assigned: grimreaper » pdureau

@pdureau, if you can give a look at the current state of this issue with testing on ui_suite_bootstrap in #3426449-8: Update styles declaration to use UI Styles sources please?

I will fix tests and coding standards once we will agree on the solution.

grimreaper’s picture

Assigned: pdureau » grimreaper

  • grimreaper committed 8856ed43 on 8.x-1.x authored by maboy
    Issue #3263526 by grimreaper, maboy, pdureau, vbouchet: UX: Add other...
grimreaper’s picture

Assigned: grimreaper » Unassigned
Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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