feat: add possibility to change image size at text image element

This commit is contained in:
2024-12-14 23:50:42 +01:00
parent ee73d44aaf
commit bed54e120b
5 changed files with 62 additions and 32 deletions

View File

@@ -8,14 +8,10 @@ RTE {
TCEFORM { TCEFORM {
pages { pages {
} }
tt_content { tt_content {
} }
} }
TCEMAIN { TCEMAIN {
} }

View File

@@ -2,7 +2,6 @@
margin: 2rem 0; margin: 2rem 0;
} }
/* Mobile-first: column layout by default */
.textimage-container { .textimage-container {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@@ -13,32 +12,48 @@
width: 100%; width: 100%;
} }
.textimage-header {
font-size: 1.5rem;
font-weight: bold;
margin-bottom: 1rem;
}
.textimage-text { .textimage-text {
font-size: 1rem; font-size: 1rem;
line-height: 1.5; line-height: 1.5;
} }
.textimage-image-wrapper { .textimage-image-wrapper {
width: 100%;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} }
.textimage-picture {
display: block;
max-width: 100%;
}
.textimage-image { .textimage-image {
max-width: 100%; max-width: 100%;
height: auto; height: auto;
border-radius: 0.5rem; border-radius: 0.5rem;
display: block;
} }
/* Image positions: 25 = left, 26 = right /* Image positions: 25 = left, 26 = right */
On larger screens, adjust the layout */ .textimage-container.image-pos-25 {
flex-direction: column;
}
.textimage-container.image-pos-26 {
flex-direction: column;
}
/* Size classes apply at all viewports */
.textimage-image-wrapper.size-25 .textimage-picture {
max-width: 300px;
}
.textimage-image-wrapper.size-50 .textimage-picture {
max-width: 600px;
}
/* On larger screens, arrange horizontally for image position settings */
@media (min-width: 768px) { @media (min-width: 768px) {
.textimage-container.image-pos-25 { .textimage-container.image-pos-25 {
flex-direction: row; flex-direction: row;
@@ -48,8 +63,7 @@
flex-direction: row-reverse; flex-direction: row-reverse;
} }
.textimage-wrapper, .textimage-wrapper {
.textimage-image-wrapper { flex: 1;
flex: 1 1 50%;
} }
} }

View File

@@ -1,11 +1,12 @@
name: cloonar/textimage name: cloonar/textimage
typeName: cloonar_textimage typeName: cloonar_textimage
group: default group: default
prefixFields: true prefixFields: false
prefixType: full
fields: fields:
- identifier: header - identifier: header
useExistingField: true useExistingField: true
- identifier: subheader
useExistingField: true
- identifier: bodytext - identifier: bodytext
type: Textarea type: Textarea
enableRichtext: true enableRichtext: true
@@ -17,3 +18,12 @@ fields:
useExistingField: true useExistingField: true
- identifier: imageorient - identifier: imageorient
useExistingField: true useExistingField: true
- identifier: imagesize
type: Select
renderType: selectSingle
default: 2
items:
- label: 25%
value: 1
- label: 50%
value: 2

View File

@@ -1,14 +1,23 @@
<f:layout name="Default" /> <f:layout name="Default" />
<f:section name="Header" /> <f:section name="Header"></f:section>
<f:section name="Main"> <f:section name="Main">
<f:asset.css identifier="CBTextImage" href="{cb:assetPath()}/frontend.css" /> <f:asset.css identifier="CBTextImage" href="{cb:assetPath()}/frontend.css" />
<!-- Determine size class based on imagesize field -->
<f:variable name="sizeClass" value="" />
<f:if condition="{data.imagesize} == 1">
<f:then><f:variable name="sizeClass" value="size-25" /></f:then>
</f:if>
<f:if condition="{data.imagesize} == 2">
<f:then><f:variable name="sizeClass" value="size-50" /></f:then>
</f:if>
<div class="textimage-container image-pos-{data.imageorient}"> <div class="textimage-container image-pos-{data.imageorient}">
<div class="textimage-image-wrapper"> <div class="textimage-image-wrapper {sizeClass}">
<f:if condition="{data.image}"> <f:if condition="{data.image}">
<f:then> <f:then>
<picture> <picture class="textimage-picture">
<source <source
srcset=" srcset="
{f:uri.image(image:data.image.0, width:'320c', cropVariant:'default')} 320w, {f:uri.image(image:data.image.0, width:'320c', cropVariant:'default')} 320w,
@@ -21,9 +30,9 @@
image="{data.image.0}" image="{data.image.0}"
treatIdAsReference="1" treatIdAsReference="1"
cropVariant="default" cropVariant="default"
width="1024c"
alt="{data.header}" alt="{data.header}"
class="textimage-image" /> class="textimage-image"
/>
</picture> </picture>
</f:then> </f:then>
<f:else> <f:else>
@@ -34,6 +43,7 @@
<div class="textimage-wrapper"> <div class="textimage-wrapper">
<f:if condition="{data.header}"> <f:if condition="{data.header}">
<h2 class="textimage-header">{data.header}</h2> <h2 class="textimage-header">{data.header}</h2>
<h3 class="textimage-subheader">{data.subheader}</h3>
</f:if> </f:if>
<f:if condition="{data.bodytext}"> <f:if condition="{data.bodytext}">
<div class="textimage-text"> <div class="textimage-text">

View File

@@ -6,17 +6,17 @@ $nav-height: 60px; // Adjust as needed
// Ensure this path is correct for your TYPO3 installation. // Ensure this path is correct for your TYPO3 installation.
// Typically: /typo3conf/ext/<extension_key>/Resources/Public/Images/... // Typically: /typo3conf/ext/<extension_key>/Resources/Public/Images/...
header { body > header {
width: 100%; width: 100%;
height: $nav-height; height: $nav-height;
line-height: $nav-height; line-height: $nav-height;
background: url('../Images/background.jpg') repeat;
position: sticky; position: sticky;
top: 0; top: 0;
z-index: 1000; z-index: 1000;
} }
.main-nav { .main-nav {
background: url('../Images/background.jpg') repeat;
.container { .container {
display: flex; display: flex;