From 1f7de537859c7036b6f770e483f6e62971abed73 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Wed, 4 Mar 2026 15:39:18 +1100 Subject: [PATCH] Add legacy caption/title compatibility styling for configurable pane --- README.md | 31 +++++++++++++++---- configurable_views_pane.libraries.yml | 6 ++++ css/configurable_views_pane.block.css | 19 ++++++++++++ .../Block/ConfigurableViewsPaneBlock.php | 16 +++++++--- 4 files changed, 62 insertions(+), 10 deletions(-) create mode 100644 configurable_views_pane.libraries.yml create mode 100644 css/configurable_views_pane.block.css diff --git a/README.md b/README.md index 777fd1b..b53de5b 100644 --- a/README.md +++ b/README.md @@ -9,12 +9,28 @@ It lets editors set view target and contextual arguments per block instance, sim ## Install -1. Place this module at: - `web/modules/custom/configurable_views_pane` -2. Enable module: - `drush en configurable_views_pane -y` -3. Rebuild cache: - `drush cr` +Clone into Drupal custom modules and enable: + +```bash +cd /path/to/drupal-root/web/modules/custom +git clone https://git.coadcorp.com/drupal/configurable_views_pane.git configurable_views_pane +cd /path/to/drupal-root +drush en configurable_views_pane -y +drush cr +``` + +For `studyweek11` Docker stack: + +```bash +mkdir -p drupal/web/modules/custom +if [ -d drupal/web/modules/custom/configurable_views_pane/.git ]; then + git -C drupal/web/modules/custom/configurable_views_pane pull --ff-only +else + rm -rf drupal/web/modules/custom/configurable_views_pane + git clone https://git.coadcorp.com/drupal/configurable_views_pane.git drupal/web/modules/custom/configurable_views_pane +fi +docker compose -f docker-compose.yml exec -T php sh -lc 'cd /var/www/html && vendor/bin/drush en configurable_views_pane -y && vendor/bin/drush cr' +``` ## Use in Page Manager @@ -27,3 +43,6 @@ Add block **Configurable Views Pane** and set: ## Notes - This module intentionally keeps plugin id `booking_configurable_views_pane` for compatibility with any existing block config already using that id. +- Includes a small compatibility stylesheet for legacy D7-like output: + - hides `caption > h2.left` headings (for example large `General` captions), + - promotes `.block__title` size for blocks that render this pane. diff --git a/configurable_views_pane.libraries.yml b/configurable_views_pane.libraries.yml new file mode 100644 index 0000000..41638c5 --- /dev/null +++ b/configurable_views_pane.libraries.yml @@ -0,0 +1,6 @@ +block: + version: 1.x + css: + theme: + css/configurable_views_pane.block.css: {} + diff --git a/css/configurable_views_pane.block.css b/css/configurable_views_pane.block.css new file mode 100644 index 0000000..6203b63 --- /dev/null +++ b/css/configurable_views_pane.block.css @@ -0,0 +1,19 @@ +/* + * Legacy D7 view output compatibility tweaks for configurable views pane blocks. + */ + +/* Hide oversized legacy pretty-table caption headings such as "General". */ +.configurable-views-pane-block caption > h2.left { + display: none !important; +} + +/* Match Page Manager block titles to legacy large left-aligned heading style. */ +.block:has(.configurable-views-pane-block) > h2.block__title { + font-size: var(--cvp-legacy-title-size, 2rem) !important; + font-weight: var(--cvp-legacy-title-weight, 700) !important; + line-height: var(--cvp-legacy-title-line-height, 1.2) !important; + text-align: left; + margin: 0 0 0.5rem; + letter-spacing: normal; + text-transform: none; +} diff --git a/src/Plugin/Block/ConfigurableViewsPaneBlock.php b/src/Plugin/Block/ConfigurableViewsPaneBlock.php index a4dd00a..a31fc0c 100644 --- a/src/Plugin/Block/ConfigurableViewsPaneBlock.php +++ b/src/Plugin/Block/ConfigurableViewsPaneBlock.php @@ -68,13 +68,21 @@ final class ConfigurableViewsPaneBlock extends BlockBase { } $args = $this->parseArguments((string) ($this->configuration['arguments'] ?? '')); - $build = $view->buildRenderable($display_id, $args, FALSE); - if (!is_array($build)) { + $view_build = $view->buildRenderable($display_id, $args, FALSE); + if (!is_array($view_build)) { return []; } - $build['#attributes']['class'][] = 'configurable-views-pane-block'; - return $build; + return [ + '#type' => 'container', + '#attributes' => [ + 'class' => ['configurable-views-pane-block'], + ], + 'content' => $view_build, + '#attached' => [ + 'library' => ['configurable_views_pane/block'], + ], + ]; } /**