Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #3476600: Adding a layout setting for controlling space around the layout. #1305

Merged
merged 4 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading