Skip to content
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 25 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
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 Nov 22, 2023
6710548
BUGFIX: Update path to ImageCollage ts in Main.ts
bbehrendt-mm Feb 20, 2024
ef6ab6a
TASK: Wait for images to load before placing them & adjust positionin…
bbehrendt-mm Feb 20, 2024
ddcf3f6
Merge branch 'rebrand' into task/image-collage-organism
jonnitto Feb 20, 2024
4f54997
TASK: Register data directly on component
jonnitto Feb 20, 2024
06013f6
TASK: Refactor alpine js function
jonnitto Feb 20, 2024
f1c7628
TASK: Update position on resize
jonnitto Feb 20, 2024
7fd04d4
TASK: Add squareIcons
bbehrendt-mm Feb 20, 2024
4e77e14
Merge branch 'rebrand' into task/image-collage-organism
jonnitto Feb 20, 2024
34a7a42
TASK: Redo overlap check, allow icons to overlap images
bbehrendt-mm Feb 20, 2024
6f1d9fa
Merge remote-tracking branch 'rtp-cgs/task/image-collage-organism' in…
bbehrendt-mm Feb 20, 2024
3b462cc
TASK: Render collage with full screen height
bbehrendt-mm Feb 21, 2024
4135ab8
TASK: Use dummy image sources
bbehrendt-mm Feb 21, 2024
aa9846d
BUGFIX: Rendering order and prevent extreme overlap of elements with …
bbehrendt-mm Feb 21, 2024
0aca487
TASK: Add atropos, add sensible srcsets
bbehrendt-mm Feb 21, 2024
d2943a3
TASK: Remove case images
jonnitto Feb 21, 2024
09e9899
TASK: Use z-10 instead of z-[10]
jonnitto Feb 21, 2024
af3ea4c
Merge branch 'rebrand' into task/image-collage-organism
jonnitto Feb 22, 2024
539e6b0
Fix: Import of css
jonnitto Feb 22, 2024
0c80ebf
Task: Apply Atropos to each element individually
bbehrendt-mm Feb 22, 2024
213e6cc
TASK: Reduce shadow a bit
jonnitto Feb 22, 2024
e2af39b
TASK: Add class entry point for square icon
jonnitto Feb 22, 2024
99401ab
TASK: Prettier file
jonnitto Feb 22, 2024
8004b05
Merge branch 'rebrand' into task/image-collage-organism
jonnitto Feb 22, 2024
9f2b1c8
TASK: Move import
jonnitto Feb 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import intersect from "@alpinejs/intersect";
import collapse from "@alpinejs/collapse";
import clipboard from "@ryangjchandler/alpine-clipboard";
import typewriter from "@marcreichel/alpine-typewriter";
import ImageCollage from "./Organism/ImageCollage/ImageCollage";

// @ts-ignore
Alpine.plugin([
Expand All @@ -18,4 +19,6 @@ Alpine.plugin([

window.Alpine = Alpine;

Alpine.data('ImageCollage', ImageCollage);
Copy link
Member

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


Alpine.start();
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>
`
}
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);
}
}
},
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.