Skip to content

Commit

Permalink
BUGFIX: Make it possible to properly align images again
Browse files Browse the repository at this point in the history
No float this time
  • Loading branch information
Sebobo committed Aug 11, 2023
1 parent d59634a commit 558f2d3
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ prototype(Neos.NeosIo:SemanticSection) < prototype(Neos.Neos:ContentComponent) {
isLast = ${iterator.isLast}

renderer = afx`
<section>
<section class="semantic-section">
<Neos.Neos:ContentCollection />
<hr @if={!props.isLast} />
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ prototype(Neos.NodeTypes:Image) < prototype(Neos.Neos:ContentComponent) {
}

image = ${q(node).property('image')}
imageClassName = Neos.Fusion:DataStructure {
className = Neos.Fusion:DataStructure {
main = 'neos-nodetypes-image'

alignment = ${'neos-alignment-' + q(node).property('alignment')}
alignment.@if.isSet = ${q(node).property('alignment')}

Expand Down Expand Up @@ -54,22 +56,38 @@ prototype(Neos.NodeTypes:Image) < prototype(Neos.Neos:ContentComponent) {
renderer.@context.image = Neos.Fusion:Case {
default {
condition = ${props.image}
renderer = Neos.Neos:ImageTag {
asset = ${props.image}
title = ${props.title}
maximumHeight = ${props.maximumHeight}
maximumWidth = ${props.maximumWidth}
allowUpScaling = ${props.allowUpScaling}
allowCropping = ${props.allowCropping}
width = ${props.width}
height = ${props.height}
async = true
attributes.alt = ${props.alternativeText}
attributes.loading = ${props.loading}
attributes.style = Neos.Fusion:Join {
maxHeight = ${'max-height: ' + props.maximumHeight + 'px;'}
maxHeight.@if.set = ${props.maximumHeight}
renderer = Neos.Fusion:Component {
@apply.props = ${props}

thumbnail = ${Neos.Seo.Image.createThumbnail(
props.image,
null,
props.width,
props.maximumWidth,
props.height,
props.maximumHeight,
props.allowCropping,
props.allowUpScaling,
true
)}

renderer.@process.debug = Neos.Fusion:Debug.Console {
value = ${props}
}

renderer = afx`
<img
title={props.title}
alt={props.alternativeText}
style={'max-height: ' + props.maximumHeight + 'px;'}
style.@if={props.maximumHeight}
width={props.thumbnail.width || props.width}
height={props.thumbnail.height || props.height}
loading={props.loading}
>
<Neos.Fusion:ResourceUri resource={props.thumbnail.resource} @path='attributes.src'/>
</img>
`
}
}
fallback {
Expand All @@ -87,8 +105,8 @@ prototype(Neos.NodeTypes:Image) < prototype(Neos.Neos:ContentComponent) {
}

renderer = afx`
<div class="neos-nodetypes-image">
<figure class={props.imageClassName}>
<div class={props.className}>
<figure>
<a
href={props.link}
href.@if.live={!node.context.inBackend}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ prototype(Neos.NodeTypes:TextWithImage) < prototype(Neos.NodeTypes:Image) {
property = 'text'
}

className.main = 'neos-nodetypes-textwithimage'

renderer {
attributes.class = 'neos-nodetypes-textwithimage'
content.@process.appendText = ${value + props.text}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
*/

p {
margin: 0 0 rs($basic-spacing);
margin: 0;

& + * {
margin-top: rs($basic-spacing);
}
}

b,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
@import "Molecules/_EventList";
@import "Molecules/_VidoeEmbed";
@import "Molecules/_FormBuilder";
@import "Molecules/_SemanticSection";

// Organisms
@import "Organisms/_SiteHeader";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
.neos-nodetypes-textwithimage,
.neos-nodetypes-image {
@include u-cf();
display: flex;
gap: rs($half-spacing, $unit: rem) rs($basic-spacing, $unit: rem);
flex-direction: column;
align-items: start;

figure {
--background-color: none;
--color: currentColor;
background-color: var(--background-color);
color: var(--color);
display: flex;
flex-direction: column;

& + * {
margin-top: 1em;
img {
display: block;
}

figcaption {
Expand Down Expand Up @@ -76,17 +81,17 @@
}

.neos-alignment-left {
text-align: left;
flex-direction: row;
}

.neos-alignment-center {
text-align: center;
align-items: center;
}

.neos-alignment-right {
text-align: right;
}
flex-direction: row-reverse;

.neos-nodetypes-image {
margin-bottom: rs($basic-spacing, $unit: rem);
figure {
justify-content: end;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.semantic-section {
> .neos-contentcollection {
display: flex;
flex-direction: column;
gap: rs($basic-spacing, $unit: rem);
}
}

0 comments on commit 558f2d3

Please sign in to comment.