Manage breakpoints & add viewports switcher

Created on 28 July 2025, about 1 month ago

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 iframe HTML 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.

Feature request
Status

Active

Version

1.0

Component

UI/UX/Islands

Created by

🇫🇷France pdureau Paris

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @pdureau
  • 🇫🇷France pdureau Paris

    The MR is open with a first commit.

    After one day of experiment, the plan have changed :)

    We introduce a new ViewportSwitcher button island with the select. This select will dynamically resize 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 ViewportSwitcher form: 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 keep those rules:

    • 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)
    • If no breakpoints are loaded, we hide the viewport switcher.

    Let's move this 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. Careful about performance issue and implementation complexity, especially related to HTMX. So, the related Theming Display Builder Active issue will also be postponed.
    • Do we also add a handler for free resizing?
  • 🇫🇷France pdureau Paris

    Ready for review.

    What about the dependency to breakpoint Core module? Do we make it explicit? Implcit? how?

    Some warnings:

    • Aside the additions, the biggest change is the move of some logic from ComponentLibraryPanel to PluginProvidersTrait to avoid duplication.
    • the new "select" shoelace component raise a warning with sdc_devel but any attempt to have a better JSON schema is missing with SDC loader (I guesss...) and remove the key from some mappings
    • There is no Drupal behaviour for the added JS, but I saw not all JS have behaviours so I don't know if it is mandatory

    As said in a previous comment, this is only the first smallest part, a follow-up issue will deal with iframes. But we are lucky it is a cleanly self-defined, fully implemented feature, so it makes sens to merge it before.

  • 🇫🇷France pdureau Paris

    missing all the phpdoc, for next functions as well.

    Added: https://git.drupalcode.org/project/display_builder/-/merge_requests/75/d...

  • 🇫🇷France pdureau Paris

    Follow-up issue has been created Responsive viewports with iframes Active

  • 🇫🇷France pdureau Paris

    I do some of the threads

  • 🇫🇷France pdureau Paris

    Did all of them

  • First commit to issue fork.
  • 🇫🇷France mogtofu33

    Fixed 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.

    • pdureau committed 9cc99337 on 1.0.x
      Issue #3538435 by pdureau: Manage breakpoints & add viewports switcher
      
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024