Discussion: is this module the right approach?

Created on 23 May 2024, about 1 month ago
Updated 22 June 2024, 4 days ago

Trying to put admin theme elements in the front theme is a challenge, and it encounters a lot of side effects.

That's why I am asking myself if this is the right / sustainable approach.

I have not tested https://www.drupal.org/project/lb_plus β†’ yet, but maybe it has a better approach.

Below are some thoughts I want to share for discussion.

Gin LB's scope:

  • I would like to remove the module's impact on the "front" part of Layout Builder form, so limiting Gin LB to the offcanvas (it was also asked in ✨ [V2] Allow configuration enable/disable for some features Active ). Working with design systems in UI Suite, I think the front part should be ported by the front theme for design consistency.
  • Is it the module responsibility to put layout builder form elements (save layout, revert changes, etc) in a custom offcanvas and generate a fake secondary Gin toolbar?

Side effects:

1. template suggestions:

Gin LB provides templates suggestions to ensure its templates that will be used.
If the front theme provides its own template suggestions, as the theme hooks are executed after the module hooks, it will be the theme template suggestions that will take precedence. And that is normal. This requires each front themes a special support of Gin LB. Yesterday I finally had been able to contribute back a generic solution in https://git.drupalcode.org/project/ui_suite_bootstrap/-/tree/5.0.x/start...

2. preprocess/process functions:

If the front theme provides process functions to form elements, it should not be executed in the case of Layout Builder. Each themes have to handle that.
Same, solution in UI Suite Bootstrap starterkit.

3 CSS:

Gin's CSS is relatively ok and scoped to not have side effects. But library dependencies introduce Claro's CSS which is not scoped and provoke side effects on impacted pages.
A solution would be to have a dedicated scoped CSS in Gin (or Gin LB) with everything required but this would require a huge amount of work.

4 JS (I don't think it is fixable):

Example of double ajax spinners: if the front theme provides its own ajax progress theming like https://git.drupalcode.org/project/ui_suite_bootstrap/-/blob/5.0.x/asset..., then there are 2 spinners.
I guess there will also be interference if the front theme is providing modal/dialog API theming too.

Gin LB benefits:

  • For example providing a clean and consistent theming of the media library browser modal. This can be challenging for each themes to do that.
  • The mechanism marking forms as gin_lb: https://git.drupalcode.org/project/gin_lb/-/blob/1.0.x/src/HookHandler/F...
      $form['#gin_lb_form'] = TRUE;
    

    I think this mechanism should be in core for either hook_form_alter and also having hook template suggestions being able to provide suggestions or not.

Other subject: Clarify that the module is intended to be used when Gin is not the current theme displayed:

https://git.drupalcode.org/project/gin_lb/-/blob/1.0.x/src/Service/Conte...

  public function isValidTheme(): bool {
    ...

    $active_theme = $this->themeManager->getActiveTheme();
    if ($active_theme->getName() === 'gin' || \array_key_exists('gin', $active_theme->getBaseThemeExtensions())) {
      $this->isValidTheme = FALSE;
    }

So issues like:

Where the Layout Builder Admin Theme https://www.drupal.org/project/layout_builder_admin_theme β†’ module is used should not be supported.

Need to check if Gin LB checking if the current theme is Gin is impacted or not.

🌱 Plan
Status

Active

Version

1.0

Component

User interface

Created by

πŸ‡«πŸ‡·France Grimreaper France πŸ‡«πŸ‡·

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

Comments & Activities

  • Issue created by @Grimreaper
  • πŸ‡«πŸ‡·France nod_ Lille
  • πŸ‡«πŸ‡·France Grimreaper France πŸ‡«πŸ‡·

    Discussed with @Christian.wiedemann and @nod_.

    In a first time let's try to:
    - make optional the styling of layout builder "front" parts/content
    - discuss with Gin maintainer to see if we can improve SASS/CSS handling
    - create a separated module to make $form['#gin_lb_form'] = TRUE; generic and not necessarily related to Gin and Gin LB, so some base themes like UI Suite Bootstrap could provide directly the support.

  • πŸ‡ΊπŸ‡ΈUnited States michaellander

    So it might be significantly more than this module would want to try and handle, but I was curious if you could instead render layout builder in the admin theme, and then use an iframe for the front end preview. Obviously this creates a new set of challenges, but the trade off would be to keep styles from bleeding over between frontend/backend. Obviously this would be a significant departure from what the module is doing currently, but at least there would be less fighting with non-api theme overrides.

Production build 0.69.0 2024