I have an idea which "maybe" solves the theming issues.
Currently Display Builder is using the current "default" theme. This makes it hard to theme panels, menus etc independent of the frontend theme. You know all the issues.
Proposed resolution
I build a small demo project to test out the best way to isolate the css and javascript and I which leads me to following idea.
https://github.com/JuppiterFred/web-components-css
Main Idea:
1. The panels etc. are themed by seperated completly independent theme. So the main display builder page is not rendered with default theme instead it uses the "display builder theme". (The theme is of course changeable.)
2. The "content" is loaded via htmx/js inside a seperate web component which also cares about CSS and JS. This isolates CSS and JS.
Maybe we can discuss this tommorow.
Issue fork display_builder-3535999
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
christian.wiedemann commentedComment #3
pdureau commentedSo, the idea is to load preview and builder in web components with custom element & shadow dom.
Comment #4
pdureau commentedComment #5
pdureau commentedComment #6
pdureau commentedI will have a little look. It may be related to #3542003: Responsive viewports with iframes
Comment #7
pdureau commentedComment #8
pdureau commentedI move to beta2 to explore the declarative shadow dom idea following JohnAlbin talk :https://www.youtube.com/watch?v=04YKlSNf89o
Let's be careful about JS events in and out the sandbox.
If it works, we will have 2 proposals:
We can do both, it will allow us:
Comment #9
pdureau commentedVery exciting but too ambitious for beta2.
Comment #10
pdureau commentedOngoing investigations.
We can't easily wrap a single island in
db-isolate, maybe because of AJAX / Behaviours / HTMX swapping.But we can wrap full regions, and we have 2 ways of doing that:
The current proposal in the MR is doing the second with the addition of a
DeclarativeShadowDomRendererservice wrapping in adb-isolateWeb component:DeclarativeShadowDomRendererbut in the islands' HTMX swap response)Comment #12
pdureau commentedComment #13
pdureau commentedProposal nearly finished:
DeclarativeShadowDomRenderer⚠️ but we don't render script_bottom asset librariesdb-isolate webcomponent) >> ✅ DRAFTED inProfileViewbuilderDisplayBuilderEventsSubscriber⚠️ but we miss the asset library specific to the islands (example: UI Styles widgets)There may be a cleaner and more generic way of doing that, but it works already well.
Comment #14
pdureau commentedIt works now: we can apply declarative shadow dom island by island!
Thanks to this, we have a simpler logic fixing the previous issues:
DeclarativeShadowDomRenderer⚠️ but we don't render script_bottom asset librariesdb-isolate webcomponent) >> ✅ DONE inDisplayBuilderEventsSubscriberRemaining work
not much...
Playwright tests:
Add a specific
theme: adminattribute inDrupal\display_builder\Attribute\Instance?Comment #15
pdureau commentedComment #16
pdureau commentedIt doesn't work anymore since we merged #3529064: Follow Core 11.3's HTMX integration
Comment #17
pdureau commentedWorks again after new rebase from 1.0.x.
Tested with Gin & Claro.
Jean, do you want to have a look? It is not a proper review because the pipeline is not green yet and because there is some subjects to discuss before, but it would be great to have your opinion.
Comment #18
pdureau commentedI have added a CSS zoom property to address the issue of admin theme spacing VS available space in drawer.
Comment #19
pdureau commentedLet's compare https://caniuse.com/declarative-shadow-dom with https://www.drupal.org/docs/getting-started/system-requirements/browser-...
Comment #20
pdureau commentedPipeline is green :)
Comment #21
pdureau commentedComment #22
pdureau commented2 thoughts:
wysiwyg_fixes.js 😉DeclarativeShadowDomRenderer. See snippet.Comment #23
mogtofu33 commentedWysiwig problems and part of
wysiwyg_fixesseems related to ajax as there is more problems now it can not fix #3561474: WYSIWYG block behavior problems with ajax.Will review today to see if it help.
Comment #25
mogtofu33 commented