-
Notifications
You must be signed in to change notification settings - Fork 43
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: Image collage with randomly positioned images #553
Merged
Merged
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
e8a7eca
[TASK] WIP - First draft of image collage with randomly positioned im…
rtp-cgs 6710548
BUGFIX: Update path to ImageCollage ts in Main.ts
bbehrendt-mm ef6ab6a
TASK: Wait for images to load before placing them & adjust positionin…
bbehrendt-mm ddcf3f6
Merge branch 'rebrand' into task/image-collage-organism
jonnitto 4f54997
TASK: Register data directly on component
jonnitto 06013f6
TASK: Refactor alpine js function
jonnitto f1c7628
TASK: Update position on resize
jonnitto 7fd04d4
TASK: Add squareIcons
bbehrendt-mm 4e77e14
Merge branch 'rebrand' into task/image-collage-organism
jonnitto 34a7a42
TASK: Redo overlap check, allow icons to overlap images
bbehrendt-mm 6f1d9fa
Merge remote-tracking branch 'rtp-cgs/task/image-collage-organism' in…
bbehrendt-mm 3b462cc
TASK: Render collage with full screen height
bbehrendt-mm 4135ab8
TASK: Use dummy image sources
bbehrendt-mm aa9846d
BUGFIX: Rendering order and prevent extreme overlap of elements with …
bbehrendt-mm 0aca487
TASK: Add atropos, add sensible srcsets
bbehrendt-mm d2943a3
TASK: Remove case images
jonnitto 09e9899
TASK: Use z-10 instead of z-[10]
jonnitto af3ea4c
Merge branch 'rebrand' into task/image-collage-organism
jonnitto 539e6b0
Fix: Import of css
jonnitto 0c80ebf
Task: Apply Atropos to each element individually
bbehrendt-mm 213e6cc
TASK: Reduce shadow a bit
jonnitto e2af39b
TASK: Add class entry point for square icon
jonnitto 99401ab
TASK: Prettier file
jonnitto 8004b05
Merge branch 'rebrand' into task/image-collage-organism
jonnitto 9f2b1c8
TASK: Move import
jonnitto 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
48 changes: 48 additions & 0 deletions
48
...ages/Neos.Presentation/Resources/Private/Fusion/Organism/ImageCollage/ImageCollage.fusion
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,48 @@ | ||
prototype(Neos.Presentation:Module.ImageCollage) < prototype(Neos.Fusion:Component) { | ||
|
||
@styleguide { | ||
title = "Image Collage" | ||
props { | ||
headline.text = 'Projects created with Neos CMS' | ||
description.text = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.' | ||
squareIcons = Neos.Fusion:Array | ||
images = Neos.Fusion:Map { | ||
items = ${['allplan', 'berchtesgadener', 'heineken', 'hitachi', 'hoerbiger', 'hogast', 'kvh', 'siga', 't3n']} | ||
itemName = 'item' | ||
itemRenderer = Neos.Fusion:DataStructure { | ||
src = ${StaticResource.uri('Neos.Presentation', 'Public/Assets/Styleguide/cases/' + item + '.png')} | ||
alternativeText = ${'Case ' + props.item} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@propTypes { | ||
headline = PropTypes:DataStructure | ||
description = PropTypes:DataStructure | ||
squareIcons = PropTypes:Array | ||
images = PropTypes:Array { | ||
type = PropTypes:DataStructure { | ||
src = PropTypes:String | ||
alternativeText = PropTypes:String | ||
} | ||
} | ||
} | ||
|
||
renderer = afx` | ||
<Neos.Presentation:Background variant="gradient"> | ||
<Neos.Presentation:Spacing size y> | ||
<div class="grid md:grid-cols-2 items-center"> | ||
<Neos.Presentation:Headline {...props.headline} display="headline-lg" /> | ||
<Neos.Presentation:Paragraph {...props.description} display="lead" /> | ||
</div> | ||
|
||
<div class="image-collage relative h-[1400px]" x-data="ImageCollage"> | ||
<Neos.Fusion:Loop items={props.images}> | ||
<img class="hidden absolute w-[128px] h-[160px]" src={item.src} alt={item.alternativeText} /> | ||
</Neos.Fusion:Loop> | ||
</div> | ||
</Neos.Presentation:Spacing> | ||
</Neos.Presentation:Background> | ||
` | ||
} |
54 changes: 54 additions & 0 deletions
54
...Packages/Neos.Presentation/Resources/Private/Fusion/Organism/ImageCollage/ImageCollage.ts
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,54 @@ | ||
export default () => ({ | ||
imgPoss: [], | ||
imgRendered: [], | ||
maxX: 0, | ||
maxY: 0, | ||
padding: 30, | ||
placeImg(imageTag) { | ||
const { random: r } = Math; | ||
const x = r() * this.maxX; | ||
const y = r() * this.maxY; | ||
|
||
let imageSize = { x: imageTag.clientWidth, y: imageTag.clientHeight }; | ||
|
||
if (!this.isOverlap(x, y, imageSize)) { | ||
imageTag.style.setProperty('left', x + 'px'); | ||
imageTag.style.setProperty('top', y + 'px'); | ||
imageTag.classList.remove('hidden'); | ||
|
||
this.imgPoss.push({ x, y }); | ||
this.imgRendered.push(imageTag); | ||
} | ||
}, | ||
isOverlap(x, y, imageSize) { | ||
// return true if overlapping | ||
for (const imgPos of this.imgPoss) { | ||
if ( | ||
x > imgPos.x - imageSize.x && | ||
x < imgPos.x + imageSize.x && | ||
y > imgPos.y - imageSize.y && | ||
y < imgPos.y + imageSize.y | ||
) | ||
return true; | ||
} | ||
console.log({ x, y }); | ||
console.log(this.imgPoss); | ||
return false; | ||
}, | ||
initializeMaxValues($el) { | ||
this.maxX = $el.clientWidth - 128; | ||
this.maxY = $el.clientHeight - 160; | ||
}, | ||
init() { | ||
console.log('ImageCollage'); | ||
this.initializeMaxValues(this.$el); | ||
let imageTags = this.$el.querySelectorAll('img'); | ||
|
||
for (let i = 0; i < imageTags.length; ++i) { | ||
let image = imageTags[i]; | ||
while (!this.imgRendered.includes(image)) { | ||
setInterval(this.placeImg(image), 10); | ||
} | ||
} | ||
}, | ||
}); |
Binary file added
BIN
+3.64 MB
...Packages/Neos.Presentation/Resources/Public/Assets/Styleguide/cases/allplan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.31 MB
.../Neos.Presentation/Resources/Public/Assets/Styleguide/cases/berchtesgadener.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.1 MB
...ackages/Neos.Presentation/Resources/Public/Assets/Styleguide/cases/heineken.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.79 MB
...Packages/Neos.Presentation/Resources/Public/Assets/Styleguide/cases/hitachi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.05 MB
...ckages/Neos.Presentation/Resources/Public/Assets/Styleguide/cases/hoerbiger.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.19 MB
...nPackages/Neos.Presentation/Resources/Public/Assets/Styleguide/cases/hogast.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.53 MB
...tionPackages/Neos.Presentation/Resources/Public/Assets/Styleguide/cases/kvh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.83 MB
...ionPackages/Neos.Presentation/Resources/Public/Assets/Styleguide/cases/siga.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.46 MB
...tionPackages/Neos.Presentation/Resources/Public/Assets/Styleguide/cases/t3n.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.
Please set
Alpine.data()
directly in the ImageCollage file