Created
July 15, 2022 17:21
-
-
Save mficzel/51ff3b8ebac74af1b07ed49e5a794666 to your computer and use it in GitHub Desktop.
Switch between renderers based on the aspect ratio of a Kaleidoscope image
This file contains hidden or 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
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()} | |
[email protected] = ${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