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/.github/workflows/build.yml b/.github/workflows/build.yml index f2e50bc..fa1e195 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,13 +13,9 @@ jobs: strategy: fail-fast: false matrix: - php-versions: ['8.0', '8.1'] + php-versions: ['8.0', '8.1', '8.2', '8.3'] neos-versions: ['8.3'] - include: - - php-versions: '7.4' - neos-versions: '7.3' - - php-versions: '8.0' - neos-versions: '8.0' + runs-on: ubuntu-latest steps: diff --git a/Resources/Private/Fusion/Prototypes/Image.fusion b/Resources/Private/Fusion/Prototypes/Image.fusion index b9ca0b6..e02e8b4 100644 --- a/Resources/Private/Fusion/Prototypes/Image.fusion +++ b/Resources/Private/Fusion/Prototypes/Image.fusion @@ -128,42 +128,36 @@ 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.@process.applyWidth = ${props.width ? value.withWidth(props.width) : value} - imageSource.@process.applyHeight = ${props.height ? value.withHeight(props.height) : value} + imageSource.@if.hasImageSource = ${props.imageSource && Type.instance(props.imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ImageSourceInterface')} + imageSource.@process.applyDimensions = ${(props.width && props.height) ? value.withDimensions(props.width, props.height) : value} + imageSource.@process.applyWidth = ${(props.width && !props.height) ? value.withWidth(props.width) : value} + imageSource.@process.applyHeight = ${(props.height && !props.width) ? value.withHeight(props.height) : value} imageSource.@process.applyFormat = ${props.format ? value.withFormat(props.format) : value} imageSource.@process.applyQuality = ${props.quality ? value.withQuality(props.quality) : 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 43fb779..c53595b 100644 --- a/Resources/Private/Fusion/Prototypes/Picture.fusion +++ b/Resources/Private/Fusion/Prototypes/Picture.fusion @@ -80,67 +80,53 @@ prototype(Sitegeist.Kaleidoscope:Picture) < prototype(Neos.Fusion:Component) { __quality = ${this.quality} } - 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.@process.applyHeight = ${props.height ? value.setHeight(props.height) : value} - imageSource.@process.applyFormat = ${props.format ? value.setFormat(props.format) : value} - imageSource.@process.applyQuality = ${props.quality ? value.setQuality(props.quality) : 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} + imageSource.@if.has = ${props.imageSource && Type.instance(props.imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ImageSourceInterface')} + imageSource.@process.applyDimensions = ${(props.width && props.height) ? value.withDimensions(props.width, props.height) : value} + imageSource.@process.applyWidth = ${(props.width && !props.height) ? value.withWidth(props.width) : value} + imageSource.@process.applyHeight = ${(props.height && !props.width) ? value.withHeight(props.height) : value} + imageSource.@process.applyFormat = ${props.format ? value.withFormat(props.format) : value} + imageSource.@process.applyQuality = ${props.quality ? value.withQuality(props.quality) : value} + } - renderer = afx` - - {props.content} - - - - - - - + {props.content} + + - - ` - } + + + + + + + ` } diff --git a/Resources/Private/Fusion/Prototypes/Source.fusion b/Resources/Private/Fusion/Prototypes/Source.fusion index abf914f..bc86161 100644 --- a/Resources/Private/Fusion/Prototypes/Source.fusion +++ b/Resources/Private/Fusion/Prototypes/Source.fusion @@ -5,54 +5,54 @@ prototype(Sitegeist.Kaleidoscope:Source) < prototype(Neos.Fusion:Component) { } imageSource = null + imageSource.@process.contextFallback = ${value || __imageSource} + srcset = null + srcset.@process.contextFallback = ${value || __srcset} + sizes = null + sizes.@process.contextFallback = ${value || __sizes} + width = null + width.@process.contextFallback = ${value || __width} + height = null + height.@process.contextFallback = ${value || __height} + format = null + format.@process.contextFallback = ${value || __format} + quality = null + quality.@process.contextFallback = ${value || __quality} + type = null media = null renderDimensionAttributes = true - renderer = Neos.Fusion:Component { - - @context { - imageSource = ${props.imageSource || __imageSource} - format = ${props.format || __format} - quality = ${props.quality || __quality} - width = ${props.width || __width} - height = ${props.height || __height} - srcset = ${props.srcset || __srcset} - sizes = ${props.sizes || __sizes} - } - - @if.hasImageSource = ${imageSource && Type.instance(imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ImageSourceInterface')} - isScalableSource = ${imageSource && Type.instance(imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ScalableImageSourceInterface')} - - imageSource = ${imageSource} - imageSource.@process.applyWidth = ${width ? value.withWidth(width) : value} - imageSource.@process.applyHeight = ${height ? value.withHeight(height) : value} - imageSource.@process.applyFormat = ${format ? value.withFormat(format) : value} - imageSource.@process.applyQuality = ${quality ? value.withQuality(quality) : value} - - type = ${format ? 'image/' + format : props.type} - srcset = ${srcset} - sizes = ${sizes} - media = ${props.media} - renderDimensionAttributes = ${props.renderDimensionAttributes} - - renderer = afx` - - ` + @private { + isScalableSource = ${props.imageSource && Type.instance(props.imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ScalableImageSourceInterface')} + + imageSource = ${props.imageSource} + imageSource.@if.hasImageSource = ${props.imageSource && Type.instance(props.imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ImageSourceInterface')} + imageSource.@process.applyDimensions = ${(props.width && props.height) ? value.withDimensions(props.width, props.height) : value} + imageSource.@process.applyWidth = ${(props.width && !props.height) ? value.withWidth(props.width) : value} + imageSource.@process.applyHeight = ${(props.height && !props.width) ? value.withHeight(props.height) : value} + imageSource.@process.applyFormat = ${props.format ? value.withFormat(props.format) : value} + imageSource.@process.applyQuality = ${props.quality ? value.withQuality(props.quality) : value} + + type = ${props.format ? 'image/' + props.format : props.type} } + + renderer = afx` + + ` } 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": "*" },