Skip to content

Commit

Permalink
Merge branch 'develop' into feature/form-elements-enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
richardgaunt authored Oct 7, 2024
2 parents d449c87 + 3060e31 commit b3a923e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions web/themes/contrib/civictheme/civictheme.theme
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ require_once __DIR__ . '/includes/iframe.inc';
require_once __DIR__ . '/includes/image.inc';
require_once __DIR__ . '/includes/link.inc';
require_once __DIR__ . '/includes/automated_list.inc';
require_once __DIR__ . '/includes/layout.inc';
require_once __DIR__ . '/includes/local_tasks.inc';
require_once __DIR__ . '/includes/libraries.inc';
require_once __DIR__ . '/includes/map.inc';
Expand Down
16 changes: 16 additions & 0 deletions web/themes/contrib/civictheme/includes/layout.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/**
* @file
* Layout related functions.
*/

declare(strict_types=1);

/**
* Implements hook_preprocess_HOOK().
*/
function civictheme_preprocess_layout__three_columns(array &$variables): void {
$variables['is_contained'] = $variables['settings']['is_contained'] ?? FALSE;
$variables['vertical_spacing'] = $variables['settings']['vertical_spacing'] ?? 'auto';
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
'#description' => $this->t('Check if the layout elements should be contained. Leave unchecked for edge-to-edge width. If sidebar regions are present - the layout will be contained regardless of this setting.'),
];

$form['vertical_spacing'] = [
'#type' => 'select',
'#title' => $this->t('Vertical spacing'),
'#default_value' => $this->configuration['vertical_spacing'],
'#options' => [
'none' => $this->t('None'),
'top' => $this->t('Top'),
'bottom' => $this->t('Bottom'),
'both' => $this->t('Both'),
'auto' => $this->t('Automatic'),
],
];

return parent::buildConfigurationForm($form, $form_state);
}

Expand All @@ -37,6 +50,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::submitConfigurationForm($form, $form_state);
$this->configuration['is_contained'] = $form_state->getValue('is_contained');
$this->configuration['vertical_spacing'] = $form_state->getValue('vertical_spacing');
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@
{% set has_sidebar_left = (content.sidebar_top_left is not empty or content.sidebar_bottom_left is not empty) and not hide_sidebar_left|default(false) %}
{% set has_sidebar_right = (content.sidebar_top_right is not empty or content.sidebar_bottom_right is not empty) and not hide_sidebar_right|default(false) %}

{% set is_contained = settings.is_contained %}
{% set is_contained = is_contained or has_sidebar_left or has_sidebar_right %}

{% set vertical_spacing = has_sidebar_left or has_sidebar_right ? 'top' : vertical_spacing %}
{% set vertical_spacing = vertical_spacing != 'auto' ? vertical_spacing : has_sidebar_left or has_sidebar_right ? 'top' : '' %}

{% set no_sidebar_left_class = hide_sidebar_left ? 'ct-layout--no-sidebar-left' : '' %}
{% set no_sidebar_right_class = hide_sidebar_right ? 'ct-layout--no-sidebar-right' : '' %}
Expand Down

0 comments on commit b3a923e

Please sign in to comment.