Overview

I have modified the theme settings for Olivero to customize the primary color to look like this:

However, when looking at the preview for the site branding, it's still using the default blue:

Steps to reproduce:

  1. Install site with Olivero and XB
  2. Change primary base color in /admin/appearance/settings/olivero
  3. Visit XB to preview the "Site Branding Block" by hovering over it in the library
  4. Observe the block being rendered in the default blue

Proposed resolution

See #2.

User interface changes

Comments

lauriii created an issue. See original summary.

wim leers’s picture

Title: Preview is not accurate for the site branding block » Preview is not accurate for the site branding block: missing Olivero's CSS variables

AFAICT this is because some of Olivero's styles (aka the default theme aka system.theme:default in the screenshot) are not injected into the component's css and/or header_js, for its default_markup.

IOW: \Drupal\experience_builder\Plugin\ExperienceBuilder\ComponentSource\BlockComponent::getClientSideInfo() would need to change

return ['build' => $this->renderComponent([], $component->uuid())];

to something like

$build = $this->renderComponent([], $component->uuid());
// Attach the default theme's …
$build['#attached']['library'][] = …
return ['build' => $build];

Although arguably, this is a bug in \Drupal\system\Plugin\Block\SystemBrandingBlock::build() … but as far as that implementation is concerned, XB's rendering-in-isolation of this block is an unexpected use case.

But I think I see a possible heuristic for this:

$build = $this->renderComponent([], $component->uuid());
if (!empty(array_intersect($build['#cache']['tags'], ['config:system.site', 'config:system.theme'])) {
  // Attach the default theme's …
  $build['#attached']['library'][] = …
}
return ['build' => $build];

Something like that?

wim leers’s picture

Issue summary: View changes
wim leers’s picture

Issue tags: +stable blocker
wim leers’s picture

thoward216’s picture

Had a look into this issue and got the library attached using similar code as shown in #2 but the preview still did not appear to update as expected. Requires further investigation.

wim leers’s picture

Version: 0.x-dev » 1.x-dev
Component: Page builder » Component sources

Thanks, @thoward216!

lauriii’s picture

Since this only impacts the preview before adding components to a page, it doesn't seem this would have to block a stable release. We may still want to look into this since there might be other ways in which the preview is inaccurate.

Project: Experience Builder » Drupal Canvas

Experience Builder has been renamed to Drupal Canvas in preparation for its beta release. You can now track issues on the new project page.