-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TASK: Use @private instead of nested components #73
Merged
mficzel
merged 3 commits into
main
from
task/avoidNestedComponentsInFavorOfAtPrivateProps
Sep 27, 2024
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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} | ||
[email protected] = ${props.width ? value.withWidth(props.width) : value} | ||
[email protected] = ${props.height ? value.withHeight(props.height) : value} | ||
[email protected] = ${props.imageSource && Type.instance(props.imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ImageSourceInterface')} | ||
[email protected] = ${(props.width && props.height) ? value.withDimensions(props.width, props.height) : value} | ||
[email protected] = ${(props.width && !props.height) ? value.withWidth(props.width) : value} | ||
[email protected] = ${(props.height && !props.width) ? value.withHeight(props.height) : value} | ||
[email protected] = ${props.format ? value.withFormat(props.format) : value} | ||
[email protected] = ${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` | ||
<img | ||
src={props.imageSource.src()} | ||
srcset={props.imageSource.srcset(props.srcset)} | ||
[email protected]={props.isScalableSource && props.srcset} | ||
sizes={props.sizes} | ||
[email protected]={props.isScalableSource && props.sizes} | ||
[email protected]={Type.isArray(value) ? Array.join(value, ', ') : value} | ||
loading={props.loading} | ||
class={props.class} | ||
alt={props.alt || props.imageSource.alt() || ''} | ||
title={props.title || props.imageSource.title()} | ||
width={props.renderDimensionAttributes ? props.imageSource.width() : null} | ||
height={props.renderDimensionAttributes ? props.imageSource.height() : null} | ||
{...props.attributes} | ||
/> | ||
` | ||
} | ||
|
||
renderer = afx` | ||
<img | ||
@if={private.imageSource} | ||
src={private.imageSource.src()} | ||
srcset={private.imageSource.srcset(props.srcset)} | ||
[email protected]={private.isScalableSource && props.srcset} | ||
sizes={props.sizes} | ||
[email protected]={private.isScalableSource && props.sizes} | ||
[email protected]={Type.isArray(value) ? Array.join(value, ', ') : value} | ||
loading={props.loading} | ||
class={props.class} | ||
alt={props.alt || private.imageSource.alt() || ''} | ||
title={props.title || private.imageSource.title()} | ||
width={props.renderDimensionAttributes ? private.imageSource.width() : null} | ||
height={props.renderDimensionAttributes ? private.imageSource.height() : null} | ||
{...props.attributes} | ||
/> | ||
` | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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} | ||
[email protected] = ${props.width ? value.setWidth(props.width) : value} | ||
[email protected] = ${props.height ? value.setHeight(props.height) : value} | ||
[email protected] = ${props.format ? value.setFormat(props.format) : value} | ||
[email protected] = ${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} | ||
[email protected] = ${props.imageSource && Type.instance(props.imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ImageSourceInterface')} | ||
[email protected] = ${(props.width && props.height) ? value.withDimensions(props.width, props.height) : value} | ||
[email protected] = ${(props.width && !props.height) ? value.withWidth(props.width) : value} | ||
[email protected] = ${(props.height && !props.width) ? value.withHeight(props.height) : value} | ||
[email protected] = ${props.format ? value.withFormat(props.format) : value} | ||
[email protected] = ${props.quality ? value.withQuality(props.quality) : value} | ||
} | ||
|
||
renderer = afx` | ||
<picture class={props.class} {...props.attributes}> | ||
{props.content} | ||
<Neos.Fusion:Loop items={props.sources} itemName="source" @if.has={props.sources}> | ||
<Sitegeist.Kaleidoscope:Source | ||
imageSource={source.imageSource ? source.imageSource : props.imageSource} | ||
type={source.type} | ||
media={source.media} | ||
format={source.format} | ||
width={source.width} | ||
height={source.height} | ||
quality={source.quality} | ||
srcset={source.srcset ? source.srcset : props.srcset} | ||
sizes={source.sizes ? source.sizes : props.sizes} | ||
renderDimensionAttributes={props.renderDimensionAttributes} | ||
/> | ||
</Neos.Fusion:Loop> | ||
<Neos.Fusion:Loop | ||
@if.has={props.imageSource && props.formats} | ||
items={Type.isArray(props.formats) ? props.formats : String.split(props.formats, ',')} | ||
itemName="format" | ||
> | ||
<Sitegeist.Kaleidoscope:Source | ||
imageSource={props.imageSource} | ||
format={String.trim(format)} | ||
/> | ||
</Neos.Fusion:Loop> | ||
<Sitegeist.Kaleidoscope:Image | ||
imageSource={props.imageSource} | ||
sizes={props.sizes} | ||
srcset={props.srcset} | ||
loading={props.loading} | ||
alt={props.alt} | ||
title={props.title} | ||
attributes={props.imgAttributes} | ||
renderer = afx` | ||
<picture class={props.class} {...props.attributes} @if.has={private.imageSource}> | ||
{props.content} | ||
<Neos.Fusion:Loop items={props.sources} itemName="source" @if.has={props.sources}> | ||
<Sitegeist.Kaleidoscope:Source | ||
imageSource={source.imageSource ? source.imageSource : private.imageSource} | ||
type={source.type} | ||
media={source.media} | ||
format={source.format} | ||
width={source.width} | ||
height={source.height} | ||
srcset={source.srcset ? source.srcset : props.srcset} | ||
sizes={source.sizes ? source.sizes : props.sizes} | ||
renderDimensionAttributes={props.renderDimensionAttributes} | ||
/> | ||
</picture> | ||
` | ||
} | ||
</Neos.Fusion:Loop> | ||
<Neos.Fusion:Loop | ||
@if.has={private.imageSource && props.formats} | ||
items={Type.isArray(props.formats) ? props.formats : String.split(props.formats, ',')} | ||
itemName="format" | ||
> | ||
<Sitegeist.Kaleidoscope:Source | ||
imageSource={private.imageSource} | ||
format={String.trim(format)} | ||
/> | ||
</Neos.Fusion:Loop> | ||
<Sitegeist.Kaleidoscope:Image | ||
imageSource={private.imageSource} | ||
sizes={props.sizes} | ||
srcset={props.srcset} | ||
loading={props.loading} | ||
alt={props.alt} | ||
title={props.title} | ||
attributes={props.imgAttributes} | ||
renderDimensionAttributes={props.renderDimensionAttributes} | ||
/> | ||
</picture> | ||
` | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,54 +5,54 @@ prototype(Sitegeist.Kaleidoscope:Source) < prototype(Neos.Fusion:Component) { | |
} | ||
|
||
imageSource = null | ||
[email protected] = ${value || __imageSource} | ||
|
||
srcset = null | ||
[email protected] = ${value || __srcset} | ||
|
||
sizes = null | ||
[email protected] = ${value || __sizes} | ||
|
||
width = null | ||
[email protected] = ${value || __width} | ||
|
||
height = null | ||
[email protected] = ${value || __height} | ||
|
||
format = null | ||
[email protected] = ${value || __format} | ||
|
||
quality = null | ||
[email protected] = ${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} | ||
[email protected] = ${width ? value.withWidth(width) : value} | ||
[email protected] = ${height ? value.withHeight(height) : value} | ||
[email protected] = ${format ? value.withFormat(format) : value} | ||
[email protected] = ${quality ? value.withQuality(quality) : value} | ||
|
||
type = ${format ? 'image/' + format : props.type} | ||
srcset = ${srcset} | ||
sizes = ${sizes} | ||
media = ${props.media} | ||
renderDimensionAttributes = ${props.renderDimensionAttributes} | ||
|
||
renderer = afx` | ||
<source @if.has={props.imageSource} | ||
srcset={props.imageSource.srcset(props.srcset)} | ||
sizes={props.sizes} | ||
[email protected]={props.sizes && props.isScalableSource} | ||
[email protected]={Type.isArray(value) ? Array.join(value, ', ') : value} | ||
type={props.type} | ||
media={props.media} | ||
width={props.renderDimensionAttributes ? props.imageSource.currentWidth : null} | ||
height={props.renderDimensionAttributes ? props.imageSource.currentHeight : null} | ||
/> | ||
` | ||
@private { | ||
isScalableSource = ${props.imageSource && Type.instance(props.imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ScalableImageSourceInterface')} | ||
|
||
imageSource = ${props.imageSource} | ||
[email protected] = ${props.imageSource && Type.instance(props.imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ImageSourceInterface')} | ||
[email protected] = ${(props.width && props.height) ? value.withDimensions(props.width, props.height) : value} | ||
[email protected] = ${(props.width && !props.height) ? value.withWidth(props.width) : value} | ||
[email protected] = ${(props.height && !props.width) ? value.withHeight(props.height) : value} | ||
[email protected] = ${props.format ? value.withFormat(props.format) : value} | ||
[email protected] = ${props.quality ? value.withQuality(props.quality) : value} | ||
|
||
type = ${props.format ? 'image/' + props.format : props.type} | ||
} | ||
|
||
renderer = afx` | ||
<source @if.has={private.imageSource} | ||
srcset={private.imageSource.srcset(props.srcset)} | ||
sizes={props.sizes} | ||
[email protected]={props.sizes && private.isScalableSource} | ||
[email protected]={Type.isArray(value) ? Array.join(value, ', ') : value} | ||
type={private.type} | ||
media={props.media} | ||
width={props.renderDimensionAttributes ? private.imageSource.currentWidth : null} | ||
height={props.renderDimensionAttributes ? private.imageSource.currentHeight : null} | ||
/> | ||
` | ||
} |
This file contains 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does this
__imageSource
come from?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is put into context from Picture so you do not have to specify it for every source when you do write sources as children like:
image = afx
<Sitegeist.Kaleidoscope:Picture imageSource={props.source}> <Sitegeist.Kaleidoscope:Source format="webp" /> <Sitegeist.Kaleidoscope:Source format="png" /> </Sitegeist.Kaleidoscope:Picture>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does Eel interpret
||
? What happens if value isfalse
ornull
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
value
is not null (exactly php falsy) the expression will yieldvalue
otherwise__imageSource