-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: revise layout and add bottom spacer option (#903)
* feature: revise layout and add bottom spacer option * feature: update config name
- Loading branch information
1 parent
16b3272
commit 64fc974
Showing
11 changed files
with
411 additions
and
168 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
apps/drupal-default/particle_helper/src/Plugin/Layout/ParticleLayout.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
namespace Drupal\particle_helper\Plugin\Layout; | ||
|
||
/** | ||
* @file | ||
* Contains \Drupal\particle_helper\Plugin\Layout\ParticleLayout. | ||
*/ | ||
|
||
use Drupal\Core\Form\FormStateInterface; | ||
use Drupal\Core\Layout\LayoutDefault; | ||
use Drupal\Core\Plugin\PluginFormInterface; | ||
use Drupal\particle\Particle; | ||
|
||
/** | ||
* Provides a layout options for Layout Builder. | ||
*/ | ||
class ParticleLayout extends LayoutDefault implements PluginFormInterface { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function defaultConfiguration() { | ||
return parent::defaultConfiguration() + [ | ||
'spacer_bottom' => '', | ||
]; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function buildConfigurationForm(array $form, FormStateInterface $form_state) { | ||
$form = parent::buildConfigurationForm($form, $form_state); | ||
$configuration = $this->getConfiguration(); | ||
|
||
$spacings = Particle::SPACING; | ||
$spacer_bottom_options = []; | ||
foreach ($spacings as $key => $value) { | ||
$spacer_bottom_options['mb-' . $key] = $value; | ||
} | ||
$spacer_bottom_options = array_merge(['_none' => $this->t('-None-')], $spacer_bottom_options); | ||
|
||
$form['spacer_bottom'] = [ | ||
'#type' => 'select', | ||
'#options' => $spacer_bottom_options, | ||
'#title' => $this->t('Additional Bottom Spacing'), | ||
'#description' => $this->t('Select a value for additional bottom spacing. These are based on design spacers.'), | ||
'#default_value' => $configuration['spacer_bottom'], | ||
]; | ||
|
||
return $form; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { | ||
parent::submitConfigurationForm($form, $form_state); | ||
$this->configuration['spacer_bottom'] = ($form_state->getValue('spacer_bottom') != '_none') ? $form_state->getValue('spacer_bottom') : ''; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
171 changes: 133 additions & 38 deletions
171
apps/drupal-default/particle_theme/particle.layouts.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,151 @@ | ||
particle_one_col: | ||
label: 'Particle one column' | ||
path: layout/particle-onecol | ||
template: particle-onecol | ||
category: 'Columns: 1' | ||
default_region: content | ||
# Particle Layouts | ||
# @see apps/drupal-default/particle_theme/templates/layout/layout.html.twig | ||
particle_one_column: | ||
label: 'Container Column' | ||
category: 'Particle Columns: 1' | ||
description: A single column layout. | ||
class: '\Drupal\particle_helper\Plugin\Layout\ParticleLayout' | ||
path: layout | ||
template: layout | ||
default_region: main | ||
icon_map: | ||
- [content] | ||
regions: | ||
content: | ||
label: Main Content | ||
particle_two_col: | ||
label: 'Particle two column' | ||
path: layout/particle-twocol | ||
template: particle-twocol | ||
category: 'Columns: 2' | ||
default_region: first | ||
main: | ||
label: Particle Main Content | ||
region_classes: ['layout__region', 'layout__region--main', 'w-full'] | ||
|
||
particle_one_column_breakout: | ||
label: 'Breakout Column' | ||
category: 'Particle Columns: 1' | ||
description: A single column layout that breaks out of the site container. | ||
class: '\Drupal\particle_helper\Plugin\Layout\ParticleLayout' | ||
path: layout | ||
template: layout | ||
default_region: main | ||
icon_map: | ||
- [first, second] | ||
- [content] | ||
regions: | ||
first: | ||
label: First | ||
second: | ||
label: Second | ||
particle_three_col: | ||
label: 'Particle three column' | ||
path: layout/particle-threecol | ||
template: particle-threecol | ||
category: 'Columns: 3' | ||
default_region: first | ||
main: | ||
label: Particle Main Content | ||
region_classes: ['layout__region', 'layout__region--main', 'w-breakout'] | ||
|
||
particle_two_column_3_1: | ||
label: 'Two Columns: 3:1' | ||
category: 'Particle Columns: 2' | ||
description: A two column layout with 2/3 main and 1/3 aside sections. | ||
class: '\Drupal\particle_helper\Plugin\Layout\ParticleLayout' | ||
path: layout | ||
template: layout | ||
default_region: main | ||
icon_map: | ||
- [top] | ||
- [main, main, aside] | ||
- [bottom] | ||
regions: | ||
main: | ||
label: Particle Main | ||
region_classes: | ||
[ | ||
'layout__region', | ||
'layout__region--main', | ||
'w-full', | ||
'md:w-2/3', | ||
'pr-6', | ||
'md:pr-8', | ||
] | ||
aside: | ||
label: Particle Sidebar | ||
region_classes: | ||
['layout__region', 'layout__region--aside', 'w-full', 'md:w-1/3'] | ||
|
||
particle_three_column_1_1: | ||
label: 'Three Columns: 1:1' | ||
category: 'Particle Columns: 3' | ||
description: A three column layout with equal 1/3 width columns. | ||
class: '\Drupal\particle_helper\Plugin\Layout\ParticleLayout' | ||
path: layout | ||
template: layout | ||
default_region: main | ||
icon_map: | ||
- [top] | ||
- [first, second, third] | ||
- [bottom] | ||
regions: | ||
first: | ||
label: First | ||
label: Particle First | ||
region_classes: | ||
[ | ||
'layout__region', | ||
'layout__region--first', | ||
'w-full', | ||
'md:w-1/3', | ||
'pr-6', | ||
'md:pr-8', | ||
] | ||
second: | ||
label: Second | ||
label: Particle Second | ||
region_classes: | ||
[ | ||
'layout__region', | ||
'layout__region--second', | ||
'w-full', | ||
'md:w-1/3', | ||
'pr-6', | ||
'md:pr-8', | ||
] | ||
third: | ||
label: Third | ||
particle_four_col: | ||
label: 'Particle four column' | ||
path: layout/particle-fourcol | ||
template: particle-fourcol | ||
category: 'Columns: 4' | ||
default_region: first | ||
label: Particle Third | ||
region_classes: | ||
['layout__region', 'layout__region--third', 'w-full', 'md:w-1/3'] | ||
|
||
particle_four_column_1_1: | ||
label: 'Four Columns: 1:1' | ||
category: 'Particle Columns: 4' | ||
description: A four column layout with equal 1/4 width columns. | ||
class: '\Drupal\particle_helper\Plugin\Layout\ParticleLayout' | ||
path: layout | ||
template: layout | ||
default_region: main | ||
icon_map: | ||
- [top] | ||
- [first, second, third, fourth] | ||
- [bottom] | ||
regions: | ||
first: | ||
label: First | ||
label: Particle First | ||
region_classes: | ||
[ | ||
'layout__region', | ||
'layout__region--first', | ||
'w-full', | ||
'md:w-1/3', | ||
'pr-6', | ||
'md:pr-8', | ||
] | ||
second: | ||
label: Second | ||
label: Particle Second | ||
region_classes: | ||
[ | ||
'layout__region', | ||
'layout__region--second', | ||
'w-full', | ||
'md:w-1/3', | ||
'pr-6', | ||
'md:pr-8', | ||
] | ||
third: | ||
label: Third | ||
label: Particle Third | ||
region_classes: | ||
[ | ||
'layout__region', | ||
'layout__region--third', | ||
'w-full', | ||
'md:w-1/3', | ||
'pr-6', | ||
'md:pr-8', | ||
] | ||
fourth: | ||
label: Fourth | ||
label: Particle Fourth | ||
region_classes: | ||
['layout__region', 'layout__region--fourth', 'w-full', 'md:w-1/3'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 0 additions & 35 deletions
35
...rupal-default/particle_theme/templates/layout/particle-fourcol/particle-fourcol.html.twig
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
.../drupal-default/particle_theme/templates/layout/particle-onecol/particle-onecol.html.twig
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.