Overview

Experience Builder depends on the SDC for developers to define components. There has been some work to define the ways to build components with SDC:#3446083: Document supported component modeling approaches. There's also #3452397: Allow specifying default props values when opting an SDC in for XB has started working towards allowing to opt-in individual components to unblock the development of the frontend application. However, these are not taking into account all of the aspects of the intended UX/DX, or limitations of SDC. We need to define both how we want SDCs to be integrated with XB, but also what are the changes needed to SDC to make this happen.

XB has been complementing SDC's functionality by introducing a Component config entity (#3444417: "Developer-created components": mark which SDCs should be exposed in XB) and adding "missing information" there (e.g. field type + widget + default value #3452397: Allow specifying default props values when opting an SDC in for XB). But eventually the goal is that SDCs truly do contain all the information that XB needs for SDC to be usable in XB, to ensure that the original DX for SDCs remains: "drop in a directory and that's it", not "… oh and also go and modify this configuration".

This is the list of additional metadata/functionality that XB needs, which SDC does not yet provide:

thing SDC core issue (+ XB sibling issue) confirmed by @lauriii?
enums values do not have (translatable) labels #3493070: SDC `enum` props should have translatable labels: use `meta:enum` (#3516602: SDC `enum` props should have human-readable labels: use `meta:enum`)
props have no (translatable) labels #3493076: Props have no (translatable) labels
example images: #3461499-17: Support complex SDC prop shapes: introduce (Storable)PropShape to compute field type storage settings ✅ Solved in XB: #3501902: Adding the Image component results in a state considered invalid
default values for slot #3493077: Default values for slot
component tagging/categorization: #3459088: Every XB `Component` config entity should have a `category` property #3474533: ComponentPluginManager must implement CategorizingPluginManagerInterface
per-slot tag/category-based restrictions #3514072: SDC slots can set expectations and cardinality ✅ (#3446083-3: Document supported component modeling approaches)
SDC development mode: #3463999-9: Auto-create/update Component config entities for all discovered SDCs that meet XB's minimum criteria #3464388: SDC *.component.yml metadata is cached aggressively, gets in the way of component development
repeatable/undefined number of slots, e.g. a dynamic columns component where users could place 1–n columns #3493079: repeatable/undefined number of slots
component variants #3390712: Add component variants to SDC + #3532397: Add support for SDC variants
🐛 embedded slots #3446933: SDC incorrectly throws an exception about embedded slots
schema references #3352063: Allow schema references in Single Directory Component prop schemas
SVG icons (#3462074: Option to change the (SVG) icon for components on the page hierarchy display) — in addition to the thumbnail.png support (ComponentMetadata::getThumbnailPath()) #3493081: SVG icons
🐛 SDC does not respect default — see #19 and #3492368: Setting default value of `false` does NOT work for boolean props #3493082: SDC does not respect JSON Schema validation
conditional(ly required) props (f.e.: if the {type: boolean} cta.enabled prop is true, also require the cta.text and cta.url props) #3493083: Conditionally required props
🐛 SDC DX disallows invalid prop names #3465228: Twig disallows dashes in variable names, so SDC should disallow it in prop names and slots
🐛 SDC DX does not inform about duplicate SDC plugin IDs — #3467972-13: Unable to save node article form — remove obsolete TwoTerribleTextAreasWidget + fix duplicate `XB:image` SDC #3468881: ComponentPluginManager should detect if an extension provides two different components that resolve to the same plugin ID
🐛 SDC DX does not inform about invalid JSON schemas — (e.g. non-existing props being marked as required: #3454125-53: Implement temporary design system for the DrupalCon Barcelona demo + [#https://www.drupal.org/project/experience_builder/issues/3469436]) #3493086: SDC DX does not inform about invalid JSON schemas
🐛 SDC DX does not complain when using the wrong/stale $schema (#3470003: Update components to use core metadata.schema.json instead of old SDC module one) #3493087: SDC DX does not complain when using the wrong/stale $schema
required slots (i.e. components with slots that MUST NOT be empty) context none yet 🚫
Json Schema equivalents for props to be able to use input[type=color] and input[type=range] XB issue: #3518105: Support other format for string and integer: color and range 🚫

Proposed resolution

Requirements that must be met for XB to allow an SDC to be used:

  1. Every required prop must have >=1 example — the first example value will be used as the default when
  2. every required prop must have >=1 example. (to be reconciled with #19's addition of default support)
  3. every prop (optional or required) must have a title → surfaced by #3467162: Follow-up for #3461422: display SDC prop's human-readable name (`title`), not its machine name

(Future criteria: SDC's status must/must not be a certain value, enum values must have labels, etc.)

Consequences for choices of how XB uses SDCs:

  1. Changing the default value requires changing that prop's examples in the *.component.yml file. Because XB wants to use SDCs unchanged
  2. Consequently, using an existing component but wanting a different default and the site is already using this component requires replacing the component (using the site's default theme), because that keeps the component ID unchanged.
  3. To be able to do that, we must be able to have config-defined SDCs (at which point that name is a bit odd) in addition to code-defined SDCs. These must be exportable to actual (code-defined) SDCs, but the config-defined ones allow a Site Builder to modify defaults on a live site, without needing code deployment.

User interface changes

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

    lauriii created an issue. See original summary.

    wim leers’s picture

    Issue summary: View changes
    Status: Active » Needs work

    I'm working to gather an overview of all the feature requests and/or mismatches between XB's needs and what SDC offers today. My goal is to make this list complete by the end of the week.

    Wim Leers credited tedbow.

    wim leers’s picture

    Issue summary: View changes
    wim leers’s picture

    Issue summary: View changes
    wim leers’s picture

    Issue summary: View changes
    lauriii’s picture

    Issue summary: View changes
    wim leers’s picture

    Issue summary: View changes
    wim leers’s picture

    Issue summary: View changes
    wim leers’s picture

    Issue summary: View changes
    lauriii’s picture

    Issue summary: View changes

    Marked the "per-slot tag/category-based restrictions" as ✅ since this is needed to implement a design system using the Paragraphs use case.

    I believe we can get away without required slots for now because it is possible to compose smaller components into bigger components, which allows defining them as required. This is the purple scenario from #3446083: Document supported component modeling approaches.

    lauriii’s picture

    Issue summary: View changes

    Looks like #11 was already part of the issue summary as "Schema references". Marking it as confirmed.

    lauriii’s picture

    Issue summary: View changes
    wim leers’s picture

    Issue summary: View changes

    One more for @lauriii to review 🤓

    wim leers’s picture

    Issue summary: View changes
    wim leers’s picture

    Issue summary: View changes

    Another new one, with explicit +1 from @lauriii (and @larowlan!) at #3462074-9: Option to change the (SVG) icon for components on the page hierarchy display.

    wim leers’s picture

    Issue summary: View changes
    wim leers’s picture

    Issue summary: View changes
    wim leers’s picture

    Issue summary: View changes

    TIL thanks to #3446722: Introduce an example set of representative SDC components; transition from "component list" to "component tree" that default is another thing in addition to examples: https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validati...

    But only a single place in the SDC infrastructure uses it:

        scrollAmount:
          type: number
          title: Scroll Amount
          description: Amount of scrolling at each interval in pixels.
          default: 6
          examples:
            - 6
            - 12
    

    modules/contrib/sdc_examples/components/my-marquee/my-marquee.component.yml

    I think it'd make sense to consider making this required — that'd be better than examples?

    wim leers’s picture

    Issue summary: View changes
    wim leers’s picture

    Issue summary: View changes
    wim leers’s picture

    Issue summary: View changes
    wim leers’s picture

    Issue summary: View changes
    wim leers’s picture

    Issue summary: View changes
    wim leers’s picture

    Issue summary: View changes
    pdureau’s picture

    We are already doing in UI Patterns 2.x some stuff listed in the issue summary, and it would be nice to do it the same way in order to stay compatible.

    schema references

    Both projects use the same mechanism with different stream wrappers:

    In theory, they can coexist in a Drupal instance. Let's check that in a few weeks.

    component variants

    As described in #3390712: Add component variants to SDC, UI Patterns 2 has a new root level variant property

    name:  Card
    variants:
      primary:
        title: Primary
        description: ...
      secondary:
        title: Secondary
        description: ...
      inverted:
        title: Inverted
        description: ...
    props: {}
    slots: {}
    

    Which is translated as this prop on component loading:

        variant:
          type: string
          enum:
            - primary
            - secondary
            - inverted
    

    variant & attributes are the 2 magical props: they have defined machine name and a defined type, so they don't need to be defined in among the other props.

    component tagging/categorization

    UI Patterns 2 uses tags and group:

    name: Foo
    description: Testing component
    group: Testing
    tags:
      - tests
    status: experimental
    slots: {...}
    props: {...}
    

    "tags" and "group" are used only for documentation and organization purpose. There is no processing or rendering logic applied to them.

    "group" is used in UI Patterns 2 implementation of CategorizingPluginManagerInterface

    enums values do not have (translatable) labels

    We use "meta:enum" which is not an official standard but supported by some popular projects:

    props:
      type: object
      properties:
        position:
          type: string
          enum:
            - top
            - bottom
          "meta:enum":
            top: Top
            bottom: Bottom
    

    See: #3456335: [2.0.0-alpha3] EnumPropType: Labelled enumerations

    SDC does not respect default — see #19

    UI Patterns 2 uses default when building the form, as #default_value.

    default must not be used in the rendering process (sending default value if prop value is missing or empty) because:

    • sometimes we want a default value in forms while allowing the user to set empty or missing value
    • the |default() Twig filter is the expected too for such an enforcement
    wim leers’s picture

    Title: [SPIKE] Comprehensive plan for integrating with SDC » [META] Missing features in SDC needed for XB
    Assigned: wim leers » lauriii
    Issue tags: +Needs upstream bugfix, +Needs upstream feature

    Discussed with @effulgentsia & @lauriii. We consider this spike completed.

    About 20 missing features (and bugs) have been identified that we need to land/fix upstream.

    #26 by @pdureau is encouraging: UI Patterns 2 ran into many of the same challenges and already has some decisions/proposals for how to deal with those gaps. I see no reason why XB cannot use the exact same solutions.

    (Although I defer to @lauriii WRT groups vs tags — IIRC the Acquia UX team was doing user testing around that?)

    It's likely that the work on #3454125: Implement temporary design system for the DrupalCon Barcelona demo will surface additional things.

    wim leers’s picture

    Version: » 0.x-dev
    Issue summary: View changes
    lauriii’s picture

    Issue summary: View changes

    Sorting the table based on priority.

    lauriii’s picture

    Issue summary: View changes
    wim leers’s picture

    Issue summary: View changes
    pdureau’s picture

    repeatable/undefined number of slots, e.g. a dynamic columns component where users could place 1–n columns

    This must not be a new SDC feature. A dynamic number of "columns" is a single slot where we are looping on the slot content.

    Example with items slot:

       {% for item in items %}
        <div class="grid__item">
          {{ item }}
        </div>
      {% endfor %}

    Also, it can be safer to check if there is a single renderable and wrap it into a sequence before looping:

    {% set items = items and items is not sequence ? [items] : items %}
    
    wim leers’s picture

    Issue summary: View changes
    wim leers’s picture

    Status: Needs work » Needs review
    Issue tags: +Needs product manager review

    #32: that's not what @lauriii has been stating, so flagging as needing input from him.

    luke.leber’s picture

    Testing out the idea #32 is probably blocked by https://www.drupal.org/project/experience_builder/issues/3491021.

    I did play around with the latest work in #3491021, but it was too unstable confirm without any doubt that the approach is viable. From the limited experimentation I've performed, I think there's a good chance it'll be workable as #3491021 wraps up though.

    pdureau’s picture

    Testing out the idea #32 is probably blocked by https://www.drupal.org/project/experience_builder/issues/3491021.

    When looping on slot values to get the "dynamic columns" effect, it is better to not use the Twig block system for the slot. Because, AFAIK, it is not possible to loop on them. You can use a normal Twig variable instead.

    In general, I would advice against Twig blocks for slots. I know this method is currently highlighted in the SDC documentation, but I have created an issue to change this: #3484727: Complete and clarify SDC documentation

    griffynh’s picture

    Issue summary: View changes
    griffynh’s picture

    Issue summary: View changes
    griffynh’s picture

    Issue summary: View changes
    griffynh’s picture

    Issue summary: View changes
    griffynh’s picture

    Issue summary: View changes
    wim leers’s picture

    wim leers’s picture

    Issue summary: View changes
    wim leers’s picture

    FYI: met with @pdureau at DrupalCon Atlanta just now and we went over everything in this issue, to identify things to collaborate on 😄

    Results:

    1. #3471454-22: [Meta] List of related core issues
    2. Closed #3493078: per-slot tag/category-based restrictions in favor of #3514072: SDC slots can set expectations and cardinality . (And updated in issue summary.)

    Some of the things in this list, @pdureau strongly disagrees with, like #3493079: repeatable/undefined number of slots, but then again it's not yet well-defined on the XB side yet. So let's start with the things where there's clearly convergence! 🤝

    wim leers’s picture

    Issue summary: View changes
    wim leers’s picture

    @lauriii: thoughts on #3516359: ComponentValidator ignores the set validator and creates a new one, which would allow us to switch from our use of $ref to format, because it allows us to define custom formats? 😄

    lauriii’s picture

    Committed, so I expect us to now use format instead of $ref 🤓

    penyaskito’s picture

    Issue summary: View changes
    wim leers’s picture

    penyaskito’s picture

    Not sure it's a strict requirement, but we might want to track #3519917: Disable additionalProperties in slots in SDC json schema

    wim leers’s picture

    Assigned: lauriii » Unassigned
    Status: Needs review » Active

    I don't think this being assigned to @lauriii for #34 is highly relevant anymore.

    @penyaskito has been leading the effort on the XB team to get as many SDC improvements into core as possible. I see he's got #3519917: Disable additionalProperties in slots in SDC json schema to RTBC too 🤩🥳

    @penyaskito Could you take on #46 + #47 on the XB side too? 😇🙏

    penyaskito’s picture

    Issue summary: View changes

    Created #3532397: Add support for SDC variants and added to the table.

    Project: Experience Builder » Drupal Canvas
    Version: 0.x-dev » 1.x-dev

    Experience Builder has been renamed to Drupal Canvas in preparation for its beta release. You can now track issues on the new project page.