Add HTML class property for styles?

Created on 22 August 2024, 3 months ago
Updated 23 August 2024, 3 months ago

Problem/Motivation

In UI Suite DaisyUI, one component will be implemented as a style: https://daisyui.com/components/mask/
But there are 2 classes: one for each options, as usual, but also one for the style itself.

class="mask mask-squircle"
class="mask mask-star"
class="mask mask-decagon"
...

Only using mask class is doing nothing. Not using mask class is breaking.

In UI Suite Bootstrap, we have 2 similar cases:

focus-ring focus-ring-primary
focus-ring focus-ring-secondary
focus-ring focus-ring-success
...
ratio ratio-1x1
ratio ratio-4x3
ratio ratio-16x9
ratio ratio-21x9

https://git.drupalcode.org/project/ui_suite_bootstrap/-/blob/5.0.x/ui_su...

But the HTML class is also a definition ID. It is not a plugin ID because options doesn't have their own discovery so they are not plugins. But still it is better they follow the machine_name data type. A space can be confusing and may break some processes.

Proposed resolution

Do we introduce a class for styles ?

ratio_aspect:
  category: "Sizing"
  label: "Aspect ratios"
  description: "Use generated pseudo elements to make an element maintain the aspect ratio of your choosing. Perfect for responsively handling video or slideshow embeds based on the width of the parent."
  class: 'ratio'
  links:
    - 'https://getbootstrap.com/docs/5.3/helpers/ratio/#aspect-ratios'
  options:
    ratio-1x1: "1x1"
    ratio-4x3: "4x3"
    ratio-16x9: "16x9"
    ratio-21x9: "21x9"
  previewed_as: "hidden"

If the style has a class property, and the value is a machine name string, and the value is different from the option ID (to avoid duplicating classes): add both the style class and the option class

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇫🇷France pdureau Paris

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024