Closed (duplicate)
Project:
Experience Builder
Version:
0.x-dev
Component:
Data model
Priority:
Major
Category:
Task
Assigned:
Issue tags:
Reporter:
Created:
18 Jul 2024 at 06:25 UTC
Updated:
7 Nov 2024 at 20:26 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
wim leersThinking about this some more, after having created two issues with very granular first steps towards multiple component types:
Then looking at this issue made me realize that #3469610 is seemingly at odds with this issue. (Postponing that issue on getting a conclusion in this issue.)
Do we want to expose all of those as SDCs (meaning: wrap anything that is not an SDC into an SDC), or do we want to expose them as their own thing?
This is a crucial decision, both from a product level POV ("everything is an SDC" is nice and simple, likely helping facilitate a consistent UX) and an architectural POV!
We only need #3469610: Prepare for multiple component types: prefix Component config entity IDs with `sdc` if we make the latter choice. That's the direction I imagined this to be going. But this is proposing something different. (I know I gave a thumbs up at #3454519-22: [META] Support component types other than SDC, block, and code components for
ComponentSourceInterfaceand this direction, but thinking about it more makes me wonder whether that is truly feasible.)However … if we truly could model everything as SDCs, that'd be very interesting+elegant, of course! 🤠
I'm just not sure if that's realistic, per #3454519: [META] Support component types other than SDC, block, and code components. For example, for blocks:
block.settings.*)IOW: AFAICT block plugins can do more than SDCs, which is why "wrapping an SDC in a block plugin" seems easy (hence: https://www.drupal.org/project/sdc_block), but the inverse (which is being proposed here) seems hard?
That's exactly why I started the table in the issue summary at #3454519: [META] Support component types other than SDC, block, and code components, and why the + columns are so important. We didn't expand that table yet for Paragraphs.
Are we really confident that we'll be able to do this too for Paragraphs, for which we have product requirement
42. Paragraphs migration? In https://git.drupalcode.org/project/experience_builder/-/merge_requests/68, you seemed to convey confidence about this, @larowlan, but we didn't discuss that in detail.So: let's double-check before we go down this path. I'd love for this to be true though, and would love to close #3469610: Prepare for multiple component types: prefix Component config entity IDs with `sdc` :)
Comment #3
wim leersDiscussed #2 with @f.mazeikis and @lauriii. No outcomes, just made them aware, to ensure they start thinking about this and participate here 😊
Comment #4
pdureau commentedCan we keep SDC API for pure UI Components (card, button, menu, slider, steps, breadcrumb...), as designed by UI & UX designers, published in design systems and implemented by the front developer, instead of trying to fit everything as SDCs?
As a product, XB will benefit of keeping its use of SDC as a clean, single purpose and well defined API, which is doing one thing and is doing it well, without application state nor business logic.
Comment #5
wim leers#4: That's the direction I'm thinking would be best too. It's why I tried to capture the consequences (pros and cons) of going with @larowlan's proposal (if I understood it correctly) in #2.
It's why I'm leaning towards #3469610: Prepare for multiple component types: prefix Component config entity IDs with `sdc`.
Comment #6
larowlanThis is where my approach of adding a component source plugin to the config entity came from. We add one for each type (Block, paragraph, SDC) much like media types. Maybe we revisit that?
Comment #7
effulgentsia commentedWhat do you mean by the "SDC API" in that comment? For example, a key way of using an SDC is in a render array:
Why should
'#type' => 'component'mean only an SDC? Why not be able to think of a menu block as a component and render it like:I mostly like this. I just don't like it being coupled to XB. But perhaps it makes sense to start with this and later see how we can abstract the concept of a "component" somewhere more centrally so that "component" can mean any kind of component, and SDC is just one kind of component?
Comment #8
wim leers#7: because
componentmeans "SDC" as in "Single-Directory component".The pseudo code you posted in #7 would mean "menu block represented as an SDC", i.e. the inverse of https://www.drupal.org/project/sdc_block.
Auto-transforming block plugin's settings' config schema +
::defaultConfiguration()to SDC props with schemaI think for that particular example it's feasible (see what I wrote ~3 weeks ago in #2: ), because we could indeed auto-convert the menu block config schema to a JSON schema that would represent each of the key-value pairs in the block settings as SDC props.
The only problem would be the absence of default values.
We could requireWe can get that information fromblock.settings.*schema to be enriched to provide that information.::defaultConfiguration(). For example,\Drupal\system\Plugin\Block\SystemMenuBlock::defaultConfiguration():i.e. we could auto-transform
SystemMenuBlock::defaultConfiguration()+to
Immediate UX consequences
🚨 That will inevitably lead to less-than-great UX because actually:
levelmay not make sense because onlySystemMenuBlock::blockForm()knows that it should inspect$this->menuTree->maxDepth()to determine what the actually valid range for this menu block's menu is!depth: same exact challenge.The UX inside XB (based on the SDC metadata) would be that any integer can be specified, including negative integers (which would never make sense) as well as e.g.
3as the level even if it's a menu that has no hierarchy at all. Which points to another problem: neitherlevelnordepthnorexpand_all_itemsmake sense for "tagging"-style vocabularies, where there simply is no hierarchy!Extrapolated UX consequences
Because the existing block system has different restrictions (fewer), boundaries, different trade-offs, it is a huge challenge to make the UX inside XB for placing blocks as simple as that for placing SDCs.
What does it mean to "be an SDC"?
IMHO the two most defining characteristics of SDCS are:
Representing blocks as SDCs would violate both:
context_definitions:in Drupal core — see https://www.drupal.org/node/3016699 and https://www.drupal.org/node/3029856)::build()might "consume" those inputs (i.e. they may simply not appear in the AST at all!)Consequences:
level,depth,expand_all_items) in that logic. That is actually the case forSee how complex
\Drupal\system\Plugin\Block\SystemMenuBlock::build()is for example — it calls many other services and then returns a render array like this:It's also why the inverse direction is totally feasible: https://www.drupal.org/project/sdc_block is trivial because SDCs are defined in more detail and have fewer capabilities (mostly: zero logic), so exposing SDCs as blocks takes only ~20 LoC.
Now, it may be acceptable that real-time preview updates are impossible for "Block components", i.e. that a server round-trip is required. But that still leaves the first UX consequence.
Comment #9
pdureau commentedThanks Wim for this deep and helpful analysis.
Block plugins are stateful, context-aware, applicative objects.
SDC components are stateless, context agnostic, UI objects.
Different beasts.
Comment #10
wim leersLet's re-assess this after #3475584: Add support for Blocks as Components.
Comment #11
larowlan#3475584: Add support for Blocks as Components handled this