Problem/Motivation
Breakpoints is a design system artifact with YAML plugin discovery.
There are some in Core modules:
- toolbar.narrow
- toolbar.standard
- toolbar.wide
- responsive_image.viewport_sizing
But they are mostly found in themes:
- 7 breakpoints in Umami
- 8 breakpoints in Olivero
- 10 breakpoints in UI Suite Bootstrap
- 10 breakpoints in UI Suite USWDS
- 2 breakpoints in GCDS
- 6 breakpoints in Bootstrap
- ...
So, they need to be leverage by display builder, like we already do with Icons, SDC, Styles...
Proposed resolution
We can add a Viewport switcher, in Builder & Preview panels, using those breakpoints, like Chrome is doing:

Notes:
- Default value = no values = no breakpoint = fluid
- Zoom in/out is out of the scope of this issue (and not planned yet as a feature)
- Available breakpoints are configurable in the display builder profile (not in islands because they will be used in at least 2 islands): by default, all breakpoints from theme are enabled, all breakpoints from modules are disabled
- When switching viewport, the change is impacting all islands leveraging this mechanism
- We may need to use
iframeHTML element in those islands, in order to let the browser recalculate the viewport dimension. Careful about performance issue and implementation complexity, especially related to HTMX. - Do we also add a handler for free resizing?
- If no breakpoints plugins are found, do we hide the viewport switcher or do we provide a 2 default value switch?
- If no breakpoints are enabled, we hide the viewport switcher.
Let's keep the implementation as simple as possible. It it goes out of control, we can postpone it.
| Comment | File | Size | Author |
|---|
Issue fork display_builder-3538435
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
pdureau commentedComment #3
pdureau commentedThe MR is open with a first commit.
After one day of experiment, the plan have changed :)
We introduce a new
ViewportSwitcherbutton island with the select. This select will dynamically resize (with a nice animation) all the main wrapper, without caring about what panels are inside.So, breakpoints providers are configurable in the display builder profile, yes, but from the
ViewportSwitcherform: by default, all themes are enabled, all modules are disabled.If a breakpoint don't have a max-width (careful, there are many way of expressing it) it is skipped, if a provider hes no breakpoints after those skipped, it is hidden.
We don't add a handler for free resizing.
We keep those rules:
So, this issue is only focused on the breakpoints management part with the new island.
Let's move the second part, about viewports recalculation, to a follow-up issue: We may need to use iframe HTML element in those islands, in order to let the browser recalculate the viewport dimension:
A commit was already pushed in a dedicated branch: https://git.drupalcode.org/issue/display_builder-3538435/-/tree/iframes
Comment #5
pdureau commentedReady for review.
What about the dependency to
breakpointCore module? Do we make it explicit? Implcit? how?Some warnings:
ComponentLibraryPaneltoPluginProvidersTraitto avoid duplication.sdc_develbut any attempt to have a better JSON schema is missing with SDC loader (I guesss...) and remove the key from some mappingsAs said in a previous comment, this is only the first smallest part, a follow-up issue will deal with iframes. I have already did good progress on this.
But we are lucky it is a cleanly self-defined, fully implemented feature, so it makes sense to merge it before.
Comment #6
pdureau commentedAdded: https://git.drupalcode.org/project/display_builder/-/merge_requests/75/d...
Comment #7
pdureau commentedFollow-up issue has been created #3542003: Responsive viewports with iframes
Comment #8
pdureau commentedI do some of the threads
Comment #9
pdureau commentedI resvoled all of them
Comment #11
mogtofu33 commentedFixed the js to not be called multiple times, fixed a but of jsdoc.
Fixed missing schema.
Add a compact mode, update the select twig.
Add e2e test.