From 37869640b3692e3f63ab351a5e05f6ca21304f7f Mon Sep 17 00:00:00 2001 From: Sebastian Helzle Date: Wed, 26 Jul 2023 14:58:29 +0200 Subject: [PATCH] FEATURE: Allow setting variable stage widths Relates: #500 --- .../RenameAndUpdatePropertyTransformation.php | 59 +++++++++++++++++++ .../Version20230726143110.yaml | 17 ++++++ .../Neos.NeosIo/NodeTypes/Content/Stage.yaml | 16 +++-- .../Private/Fusion/Content/Stage/Stage.fusion | 4 +- .../Private/Scss/Organisms/_Stage.scss | 6 +- 5 files changed, 95 insertions(+), 7 deletions(-) create mode 100644 DistributionPackages/Neos.NeosIo/Classes/ContentRepository/Transformations/RenameAndUpdatePropertyTransformation.php create mode 100644 DistributionPackages/Neos.NeosIo/Migrations/ContentRepository/Version20230726143110.yaml diff --git a/DistributionPackages/Neos.NeosIo/Classes/ContentRepository/Transformations/RenameAndUpdatePropertyTransformation.php b/DistributionPackages/Neos.NeosIo/Classes/ContentRepository/Transformations/RenameAndUpdatePropertyTransformation.php new file mode 100644 index 00000000..3769a8ba --- /dev/null +++ b/DistributionPackages/Neos.NeosIo/Classes/ContentRepository/Transformations/RenameAndUpdatePropertyTransformation.php @@ -0,0 +1,59 @@ +oldPropertyName = $oldPropertyName; + } + + public function setTo(string $newPropertyName): void + { + $this->newPropertyName = $newPropertyName; + } + + public function setOldValue(mixed $oldValue): void + { + $this->oldValue = $oldValue; + } + + public function setNewValue(mixed $newValue): void + { + $this->newValue = $newValue; + } + + /** + * Returns true if the given node has a property with the name to work on + * and does not yet have a property with the name to rename that property to. + */ + public function isTransformable(NodeData $node): bool + { + return ($node->hasProperty($this->oldPropertyName) && !$node->hasProperty($this->newPropertyName)); + } + + /** + * Renames the configured property to the new name if it's value matches, if not it is removed + */ + public function execute(NodeData $node): void + { + $oldPropertyValue = $node->getProperty($this->oldPropertyName); + if ($oldPropertyValue === $this->oldValue) { + $node->setProperty($this->newPropertyName, $this->newValue); + } + $node->removeProperty($this->oldPropertyName); + } +} diff --git a/DistributionPackages/Neos.NeosIo/Migrations/ContentRepository/Version20230726143110.yaml b/DistributionPackages/Neos.NeosIo/Migrations/ContentRepository/Version20230726143110.yaml new file mode 100644 index 00000000..677b8dc3 --- /dev/null +++ b/DistributionPackages/Neos.NeosIo/Migrations/ContentRepository/Version20230726143110.yaml @@ -0,0 +1,17 @@ +up: + comments: 'Adjust max width property for stages' + migration: + - filters: + - type: 'NodeType' + settings: + nodeType: 'Neos.NeosIo:Stage' + withSubTypes: true + transformations: + - type: 'Neos\NeosIo\ContentRepository\Transformations\RenameAndUpdatePropertyTransformation' + settings: + from: 'isContentFullWidth' + to: 'contentWidth' + oldValue: true + newValue: 'full' +down: + comments: 'No down migration available' diff --git a/DistributionPackages/Neos.NeosIo/NodeTypes/Content/Stage.yaml b/DistributionPackages/Neos.NeosIo/NodeTypes/Content/Stage.yaml index b34b59d7..efd9bc0e 100644 --- a/DistributionPackages/Neos.NeosIo/NodeTypes/Content/Stage.yaml +++ b/DistributionPackages/Neos.NeosIo/NodeTypes/Content/Stage.yaml @@ -61,14 +61,22 @@ label: 'Create more padding around the contents' inspector: group: content - isContentFullWidth: - type: boolean - defaultValue: false + contentWidth: + type: string ui: reloadIfChanged: true - label: 'Set content to full width (without padding)' + label: 'Maximum content width' inspector: group: content + editor: Neos.Neos/Inspector/Editors/SelectBoxEditor + editorOptions: + allowEmpty: true + placeholder: 'Default (1000px)' + values: + wide: + label: 'Wide (1800px)' + full: + label: 'Full-width (100%)' padding: type: string ui: diff --git a/DistributionPackages/Neos.NeosIo/Resources/Private/Fusion/Content/Stage/Stage.fusion b/DistributionPackages/Neos.NeosIo/Resources/Private/Fusion/Content/Stage/Stage.fusion index 833fcfb7..b90ab2e4 100644 --- a/DistributionPackages/Neos.NeosIo/Resources/Private/Fusion/Content/Stage/Stage.fusion +++ b/DistributionPackages/Neos.NeosIo/Resources/Private/Fusion/Content/Stage/Stage.fusion @@ -7,7 +7,7 @@ prototype(Neos.NeosIo:Stage) < prototype(Neos.Neos:ContentComponent) { alternativeText = ${q(node).property('alternativeText')} title = ${q(node).property('title')} isContentExtraPadded = ${q(node).property('isContentExtraPadded') || this.backgroundImage != null} - isContentFullWidth = ${q(node).property('isContentFullWidth')} + contentWidth = ${q(node).property('contentWidth')} padding = ${q(node).property('padding')} editableTitle = Neos.Neos:Editable { @@ -17,7 +17,7 @@ prototype(Neos.NeosIo:Stage) < prototype(Neos.Neos:ContentComponent) { renderer = afx`
-
+

{props.editableTitle}

diff --git a/DistributionPackages/Neos.NeosIo/Resources/Private/Scss/Organisms/_Stage.scss b/DistributionPackages/Neos.NeosIo/Resources/Private/Scss/Organisms/_Stage.scss index baa39a1e..73fe5172 100644 --- a/DistributionPackages/Neos.NeosIo/Resources/Private/Scss/Organisms/_Stage.scss +++ b/DistributionPackages/Neos.NeosIo/Resources/Private/Scss/Organisms/_Stage.scss @@ -160,11 +160,15 @@ max-width: 9999px; } - &.stage__contents--fullWidth { + &.stage__contents--full { max-width: 100%; padding: 7.5vh 0; } + &.stage__contents--wide { + max-width: 1800px; + } + > h2 { margin-bottom: 2rem; }