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:
Proposed resolution
Requirements that must be met for XB to allow an SDC to be used:
- Every required prop must have >=1 example — the first example value will be used as the default when
- every required prop must have >=1 example. (to be reconciled with #19's addition of
defaultsupport) - 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:
- Changing the default value requires changing that prop's
examplesin the*.component.ymlfile. Because XB wants to use SDCs unchanged - 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.
- 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
Issue fork experience_builder-3462705
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
wim leersI'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.
Comment #4
wim leersComment #5
wim leersComment #6
wim leersComment #7
lauriiiComment #8
wim leersComment #9
wim leersComment #10
wim leersComment #11
lauriiiMarked 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.
Comment #12
lauriiiLooks like #11 was already part of the issue summary as "Schema references". Marking it as confirmed.
Comment #13
lauriiiComment #14
wim leersOne more for @lauriii to review 🤓
Comment #15
wim leersComment #16
wim leersAnother 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.
Comment #17
wim leersComment #18
wim leersComment #19
wim leersTIL thanks to #3446722: Introduce an example set of representative SDC components; transition from "component list" to "component tree" that
defaultis another thing in addition toexamples: https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validati...But only a single place in the SDC infrastructure uses it:
—
modules/contrib/sdc_examples/components/my-marquee/my-marquee.component.ymlI think it'd make sense to consider making this required — that'd be better than
examples?Comment #20
wim leersComment #21
wim leersComment #22
wim leersComment #23
wim leersComment #24
wim leersComment #25
wim leersComment #26
pdureau commentedWe 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
variantpropertyWhich is translated as this prop on component loading:
variant&attributesare 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
tagsandgroup:"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:
See: #3456335: [2.0.0-alpha3] EnumPropType: Labelled enumerations
SDC does not respect default — see #19
UI Patterns 2 uses
defaultwhen building the form, as#default_value.defaultmust not be used in the rendering process (sending default value if prop value is missing or empty) because:Comment #27
wim leersDiscussed 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.
Comment #28
wim leersAdded to the issue summary: #3474533: ComponentPluginManager must implement CategorizingPluginManagerInterface.
Comment #29
lauriiiSorting the table based on priority.
Comment #30
lauriiiComment #31
wim leersComment #32
pdureau commentedThis 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
itemsslot:Also, it can be safer to check if there is a single renderable and wrap it into a sequence before looping:
Comment #33
wim leersComment #34
wim leers#32: that's not what @lauriii has been stating, so flagging as needing input from him.
Comment #35
luke.leberTesting 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.
Comment #36
pdureau commentedWhen 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
Comment #37
griffynh commentedComment #38
griffynh commentedComment #39
griffynh commentedComment #40
griffynh commentedComment #41
griffynh commentedComment #42
wim leers#3507641: Allow components containing non-required images and no examples to be placed straddles the line here. If core would do this, then XB wouldn't have to.
Comment #43
wim leersComment #44
wim leersFYI: met with @pdureau at DrupalCon Atlanta just now and we went over everything in this issue, to identify things to collaborate on 😄
Results:
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! 🤝
Comment #45
wim leersArticulated a detailed plan for the top-priority issue here (see #3493070-11: SDC `enum` props should have translatable labels: use `meta:enum`), plus XB sibling issue (#3493070: SDC `enum` props should have translatable labels: use `meta:enum`)
Comment #46
wim leers@lauriii: thoughts on #3516359: ComponentValidator ignores the set validator and creates a new one, which would allow us to switch from our use of
$reftoformat, because it allows us to define custom formats? 😄Comment #47
lauriiiCommitted, so I expect us to now use
formatinstead of$ref🤓Comment #48
penyaskitoComment #49
wim leersAdded #3518105: Support other format for string and integer: color and range.
Comment #50
penyaskitoNot sure it's a strict requirement, but we might want to track #3519917: Disable additionalProperties in slots in SDC json schema
Comment #51
wim leersI 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? 😇🙏
Comment #52
penyaskitoCreated #3532397: Add support for SDC variants and added to the table.