From 300fd35461356662b51801226cec60c5c229b5db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Juh=C3=A9=20Lluveras?= Date: Thu, 4 May 2023 17:02:03 +0200 Subject: [PATCH] Make sure classic themes have a Mini Cart contents width value set up --- assets/js/base/components/drawer/style.scss | 2 ++ src/BlockTypes/MiniCartContents.php | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/assets/js/base/components/drawer/style.scss b/assets/js/base/components/drawer/style.scss index a3b5cd275a3..25812f579f0 100644 --- a/assets/js/base/components/drawer/style.scss +++ b/assets/js/base/components/drawer/style.scss @@ -1,4 +1,6 @@ :root { + /* This value might be overridden in PHP based on the attribute set by the user. */ + --drawer-width: 480px; --neg-drawer-width: calc(var(--drawer-width) * -1); } diff --git a/src/BlockTypes/MiniCartContents.php b/src/BlockTypes/MiniCartContents.php index 2c746a1ccc7..8560c2413c0 100644 --- a/src/BlockTypes/MiniCartContents.php +++ b/src/BlockTypes/MiniCartContents.php @@ -110,8 +110,10 @@ protected function enqueue_assets( array $attributes ) { ), ); - $drawer_width = array_key_exists( 'width', $attributes ) ? $attributes['width'] : '480px'; - $parsed_style = ':root{--drawer-width: ' . esc_html( $drawer_width ) . '}'; + $parsed_style = ''; + if ( array_key_exists( 'width', $attributes ) ) { + $parsed_style .= ':root{--drawer-width: ' . esc_html( $attributes['width'] ) . '}'; + } foreach ( $styles as $style ) { $selector = is_array( $style['selector'] ) ? implode( ',', $style['selector'] ) : $style['selector'];