Create custom theme based on the existing styles.

Created on 22 November 2023, 7 months ago

Problem/Motivation

We want to change some styles for the LB block forms, and probably this will cause huge changes.

I found that in the \Drupal\bootstrap_styles\Form\SettingsForm::buildForm() hardcoded options for the theme selector.

    // Layout builder theme toggler.
    $options = [
      'dark' => $this->t('Dark'),
      'light' => $this->t('Light'),
    ];

After that, according to the values from this form, it will attach a library for different themes in the bootstrap_styles_page_attachments_alter()

  // Attach the libraries only in the layout route.
  if (in_array($route_match->getRouteName(), $layout_routes)) {
    // Attach the layout builder form styles.
    $page['#attached']['library'][] = 'bootstrap_styles/layout_builder_form_style';

    if ($settings->get('layout_builder_theme') && $settings->get('layout_builder_theme') == 'light') {
      $page['#attached']['library'][] = 'bootstrap_styles/theme.light';
    }
    else {
      // Attach the default dark theme.
      $page['#attached']['library'][] = 'bootstrap_styles/theme.dark';
    }
  }

Question.

We want to create a separate custom theme based on the styles for the dark theme but change some things. Do we just need to add the option to the form and then attach the library with styles if this setting is selected?
Or does it require some more effort which I missed?

πŸ’¬ Support request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine _shY Lutsk

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

Comments & Activities

Production build 0.69.0 2024