Skip to content

Commit 4be6164

Browse files
committed
Fixed layout containment and added an option to select if the LB layout should be contained.
1 parent 442ff13 commit 4be6164

12 files changed

+509
-14
lines changed

package-lock.json

Lines changed: 442 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dependencies": {
3+
"@civictheme/uikit": "github:civictheme/uikit#main"
4+
}
5+
}

web/themes/contrib/civictheme/civictheme.layouts.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ civictheme_three_columns:
44
template: layout--three-columns
55
library: civictheme/layouts
66
category: 'CivicTheme Layouts'
7+
class: '\Drupal\civictheme\Plugin\Layout\ThreeColumnsLayout'
78
default_region: content
89
icon_map:
910
- [first_above, main, second_above]

web/themes/contrib/civictheme/config/install/core.entity_view_display.node.civictheme_event.default.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ third_party_settings:
3333
layout_id: civictheme_three_columns
3434
layout_settings:
3535
label: Main
36+
is_contained: false
3637
context_mapping: { }
3738
components:
3839
93c254ec-abeb-461a-b464-5247fd0083da:

web/themes/contrib/civictheme/config/install/core.entity_view_display.node.civictheme_page.default.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ third_party_settings:
4141
layout_id: civictheme_three_columns
4242
layout_settings:
4343
label: 'CivicTheme Three Columns'
44+
is_contained: false
4445
context_mapping: { }
4546
components:
4647
5cf72ad7-c313-4cf3-9d4e-0573bbfa84a0:

web/themes/contrib/civictheme/config/schema/civictheme.schema.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,3 +388,11 @@ civictheme.settings:
388388
optouts:
389389
type: mapping
390390
label: 'Opt-out flags'
391+
392+
layout_plugin.settings.civictheme_three_columns:
393+
type: layout_plugin.settings
394+
label: 'CivicTheme Three Columns Layout Settings'
395+
mapping:
396+
is_contained:
397+
type: boolean
398+
label: 'Is Contained'

web/themes/contrib/civictheme/includes/page.inc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ function _civictheme_preprocess_page(array &$variables): void {
2323
// For nodes this is set to false via _civictheme_preprocess_page_node as
2424
// layout is controlled via layout templates.
2525
$variables['page']['content_contained'] = $variables['page']['content_contained'] ?? TRUE;
26-
$variables['page']['is_contained'] = $variables['page']['content_contained'] ?? TRUE;
27-
$variables['page']['is_contained'] = $variables['page']['is_contained'] ?? TRUE;
2826
}
2927

3028
/**
@@ -41,17 +39,18 @@ function _civictheme_preprocess_page__node(array &$variables): void {
4139
return;
4240
}
4341

44-
// Layout determines whether a node is contained and what it's layout is.
45-
$variables['page']['content_contained'] = FALSE;
46-
$variables['page']['is_contained'] = FALSE;
47-
4842
$variables['vertical_spacing'] = civictheme_get_field_value($node, 'field_c_n_vertical_spacing');
4943

5044
// @todo Add support for hiding of the right sidebar through a node field.
5145
$variables['hide_sidebar_left'] = civictheme_get_field_value($node, 'field_c_n_hide_sidebar') ?? FALSE;
5246

5347
$layout_builder_settings_per_view_mode = civictheme_get_layout_builder_settings_per_view_mode($node->getEntityTypeId(), $node->bundle());
5448
if (!empty($layout_builder_settings_per_view_mode)) {
49+
// Layout builder determines whether a node is contained and what it's
50+
// layout is, so we set as not contained to allow layout builder to
51+
// span edge-to-edge.
52+
$variables['page']['content_contained'] = FALSE;
53+
5554
$variables['#cache']['contexts'] = Cache::mergeContexts(
5655
$variables['#cache']['contexts'] ?? [],
5756
$node->getCacheContexts(),

web/themes/contrib/civictheme/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace Drupal\civictheme\Plugin\Layout;
4+
5+
use Drupal\Core\Form\FormStateInterface;
6+
use Drupal\Core\Layout\LayoutDefault;
7+
use Drupal\Core\Plugin\PluginFormInterface;
8+
9+
class ThreeColumnsLayout extends LayoutDefault implements PluginFormInterface {
10+
11+
/**
12+
* {@inheritdoc}
13+
*/
14+
public function defaultConfiguration() {
15+
$configuration = parent::defaultConfiguration();
16+
17+
return $configuration + ['is_contained' => FALSE];
18+
}
19+
20+
/**
21+
* {@inheritdoc}
22+
*/
23+
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
24+
$form['is_contained'] = [
25+
'#type' => 'checkbox',
26+
'#title' => $this->t('Contained'),
27+
'#default_value' => $this->configuration['is_contained'],
28+
'#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.'),
29+
];
30+
31+
return parent::buildConfigurationForm($form, $form_state);
32+
}
33+
34+
/**
35+
* {@inheritdoc}
36+
*/
37+
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
38+
parent::submitConfigurationForm($form, $form_state);
39+
$this->configuration['is_contained'] = $form_state->getValue('is_contained');
40+
}
41+
42+
}

web/themes/contrib/civictheme/templates/layout/layout--single-column-contained.html.twig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
*
66
* Available variables:
77
* - content: The content for this layout.
8-
* - is_contained: Whether the content should be contained
98
* - modifier_class: CSS modifying class
10-
* - region_attributes: HTML attributes for the layout <div>.
119
*
1210
* @deprecated in CivicTheme 1.8.0, will be removed in CivicTheme 1.9.0. Use
1311
* layout--three-columns.html.twig instead.

0 commit comments

Comments
 (0)