From 25e1ee26426ee1964aaf0c9ff78c7425c16dbd56 Mon Sep 17 00:00:00 2001 From: Martin Ficzel Date: Wed, 1 Nov 2023 18:32:00 +0100 Subject: [PATCH] TASK: Use @private instead of nested components --- .editorconfig | 22 +++++ .../Private/Fusion/Prototypes/Image.fusion | 51 +++++----- .../Private/Fusion/Prototypes/Picture.fusion | 93 ++++++++----------- composer.json | 4 +- 4 files changed, 85 insertions(+), 85 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..e722f3d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,22 @@ +# editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +# Composer uses 4 spaces itself +[composer.json] +indent_size = 4 + +# PHP should follow the PSR-2 standard +[*.php] +indent_size = 4 + +# fusion uses 4 spaces itself +[*.fusion] +indent_size = 4 diff --git a/Resources/Private/Fusion/Prototypes/Image.fusion b/Resources/Private/Fusion/Prototypes/Image.fusion index 76f5a48..bdd8b06 100644 --- a/Resources/Private/Fusion/Prototypes/Image.fusion +++ b/Resources/Private/Fusion/Prototypes/Image.fusion @@ -127,41 +127,34 @@ prototype(Sitegeist.Kaleidoscope:Image) < prototype(Neos.Fusion:Component) { attributes = Neos.Fusion:DataStructure renderDimensionAttributes = true - renderer = Neos.Fusion:Component { - @if.hasImageSource = ${props.imageSource && Type.instance(props.imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ImageSourceInterface')} + @private { + # detect scalable sources isScalableSource = ${props.imageSource && Type.instance(props.imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ScalableImageSourceInterface')} # apply format, width and height to the imageSource imageSource = ${props.imageSource} + imageSource.@if.hasImageSource = ${props.imageSource && Type.instance(props.imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ImageSourceInterface')} imageSource.@process.applyWidth = ${props.width ? value.withWidth(props.width) : value} imageSource.@process.applyHeight = ${props.height ? value.withHeight(props.height) : value} imageSource.@process.applyFormat = ${props.format ? value.withFormat(props.format) : value} - - srcset = ${props.srcset} - sizes = ${props.sizes} - loading = ${props.loading} - alt = ${props.alt} - title = ${props.title} - class = ${props.class} - attributes = ${props.attributes} - renderDimensionAttributes = ${props.renderDimensionAttributes} - - renderer = afx` - {props.alt - ` } + + renderer = afx` + {props.alt + ` } diff --git a/Resources/Private/Fusion/Prototypes/Picture.fusion b/Resources/Private/Fusion/Prototypes/Picture.fusion index e62892e..b51f54c 100644 --- a/Resources/Private/Fusion/Prototypes/Picture.fusion +++ b/Resources/Private/Fusion/Prototypes/Picture.fusion @@ -78,65 +78,50 @@ prototype(Sitegeist.Kaleidoscope:Picture) < prototype(Neos.Fusion:Component) { __format = ${this.format} } - renderer = Neos.Fusion:Component { - @if.hasImageSource = ${props.imageSource && Type.instance(props.imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ImageSourceInterface')} - + @private { # apply format, width and height to the imageSource imageSource = ${props.imageSource} - imageSource.@process.applyWidth = ${props.width ? value.setWidth(props.width) : value} + imageSource.@if.has = ${props.imageSource && Type.instance(props.imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ImageSourceInterface')} imageSource.@process.applyWidth = ${props.width ? value.setWidth(props.width) : value} imageSource.@process.applyHeight = ${props.height ? value.setHeight(props.height) : value} imageSource.@process.applyFormat = ${props.format ? value.setFormat(props.format) : value} + } - srcset = ${props.srcset} - sizes = ${props.sizes} - loading = ${props.loading} - sources = ${props.sources} - formats = ${props.formats} - alt = ${props.alt} - title = ${props.title} - class = ${props.class} - attributes = ${props.attributes} - imgAttributes = ${props.imgAttributes} - content = ${props.content} - renderDimensionAttributes = ${props.renderDimensionAttributes} - - renderer = afx` - - {props.content} - - - - - - - + {props.content} + + - - ` - } + + + + + + + ` } diff --git a/composer.json b/composer.json index 09c223c..e30ef63 100644 --- a/composer.json +++ b/composer.json @@ -4,8 +4,8 @@ "name": "sitegeist/kaleidoscope", "license": "GPL-3.0-or-later", "require": { - "neos/neos": "^7.0 || ^8.0 || ^9.0 || dev-master", - "neos/fusion-afx": "^7.0 || ^8.0 || ^9.0 || dev-master", + "neos/neos": "^8.3 || ^9.0 || dev-master", + "neos/fusion-afx": "^8.3 || ^9.0 || dev-master", "neos/media": "*", "neos/imagine": "*" },