Skip to content

Instantly share code, notes, and snippets.

@mficzel
Created July 15, 2022 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mficzel/51ff3b8ebac74af1b07ed49e5a794666 to your computer and use it in GitHub Desktop.
Save mficzel/51ff3b8ebac74af1b07ed49e5a794666 to your computer and use it in GitHub Desktop.
Switch between renderers based on the aspect ratio of a Kaleidoscope image
prototype(Vendor.Site:TestImageFormatSwitch) < prototype(Neos.Fusion:Component) {
@styleguide {
title = "Test Image Format Switch"
props {
imageSource = Sitegeist.Kaleidoscope:DummyImageSource
}
useCases {
square {
props.imageSource = Sitegeist.Kaleidoscope:DummyImageSource {
baseWidth = 400
baseHeight = 400
}
}
wide.props.imageSource = Sitegeist.Kaleidoscope:DummyImageSource {
baseWidth = 800
baseHeight = 400
}
high.props.imageSource = Sitegeist.Kaleidoscope:DummyImageSource {
baseWidth = 400
baseHeight = 800
}
}
}
imageSource = null
renderer = Neos.Fusion:Component {
aspect = ${props.imageSource.width() / props.imageSource.height()}
aspect.@if.hasWidhAndHeight = ${props.imageSource.width() && props.imageSource.height()}
imageSource = ${props.imageSource}
renderer = Neos.Fusion:Case {
wide {
condition = ${props.aspect >= 1.1}
renderer = afx`
<div style="background-color: burlywood"> wide <Sitegeist.Kaleidoscope:Image imageSource={props.imageSource} width="200" /></div>
`
}
high {
condition = ${props.aspect <= 0.9}
renderer = afx`
<div style="background-color: burlywood"> high <Sitegeist.Kaleidoscope:Image imageSource={props.imageSource} width="200" /></div>
`
}
square {
condition = ${props.aspect < 1.1 && props.aspect > 0.9 }
renderer = afx`
<div style="background-color: burlywood"> wide <Sitegeist.Kaleidoscope:Image imageSource={props.imageSource} width="200" /></div>
`
}
unknown {
condition = true
renderer = afx`
<div style="background-color: burlywood"> unknown dimension</div>
`
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment