Problem/Motivation
Currently, the only (and default) source for attributes props is AttributesWidget which is not easy to use because it expects to write a full HTML attributes string: class="hidden" title="Lorem ipsum"
Proposed resolution
- Add a new ClassAttributeWidget, which is also a simple textfield.
- The stored data is a simple string:
"foo bar baz" - The data is transformed to a mapping:
class: ['foo', 'bar', 'baz'] - Make this source the default source of AttributesPropType
Issue fork ui_patterns-3477419
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
pdureau commentedComment #5
smovs commentedHi @pdureau
I created a new source plugin for class attributes.
Please review MR !232
Comment #6
pdureau commentedThanks you smos and welcome in the team
Comment #10
pdureau commentedThanks a lot.
I have added a commit to change the wording a bit (Plugin label must follow sentence case for example)
However, the current regex is too strict because more or less limited to ASCII alphanumeric characters. It would be better to list the forbidden characters instead of listing the authorized characters. And also to allow space at the end of the string.
Related issue: #3473621: [2.0.0-beta2] The regex for attribute (values) props should allow all Tailwind allowed special characters
Comment #11
smovs commentedComment #12
smovs commentedI made the regex for class names less strict. Now it allows strings like this one (tested on Tailwind examples):
"bg-blue-500 hover:bg-blue-500 w-1/2 w-1.5 text-[16px]. bg-[#FF5733] [&_img]:rounded [&_>p]:text-primary [&_*]:bg-primary "But still, a class name cannot start with a hyphen followed by a digit or a digit.
@pdureau Please review.
Comment #14
pdureau commentedComment #15
pdureau commentedwaiting auto merge
Comment #17
pdureau commented