Skip to content

Commit cd812a3

Browse files
authored
Merge pull request #2220 from tf/teaser-text-on-image
Add teaser list text position to place text on image
2 parents 14df304 + 10b62e3 commit cd812a3

File tree

6 files changed

+74
-23
lines changed

6 files changed

+74
-23
lines changed

entry_types/scrolled/config/locales/new/ext-link-options.de.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@ de:
2828
values:
2929
below: "Unter dem Bild"
3030
right: "Rechts neben dem Bild"
31+
overlay: "Auf dem Bild"
3132
none: "Keine"
33+
overlayOpacity:
34+
label: Abblendung
35+
inline_help: |-
36+
Intensität des Farbverlaufs, der hinter den Text
37+
gelegt wird, um den Kontrast auf unruhigen
38+
Hintergründen zu verbessern.
3239
thumbnailSize:
3340
label: "Thumbnail-Breite"
3441
inline_help: |-

entry_types/scrolled/config/locales/new/ext-link-options.en.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ en:
2727
values:
2828
below: "Below image"
2929
right: "Right from image"
30+
overlay: "On Image"
3031
none: "None"
32+
overlayOpacity:
33+
label: Shadow opacity
34+
inline_help: |-
35+
Intensity of the color gradient that is placed behind
36+
the text to improve contrast on busy backgrounds
3137
thumbnailSize:
3238
label: "Thumbnail width"
3339
inline_help: |-

entry_types/scrolled/package/src/contentElements/externalLinkList/editor/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,15 @@ editor.contentElementTypes.register('externalLinkList', {
4343

4444
this.input('textPosition', SelectInputView, {
4545
values: features.isEnabled('external_links_options') ?
46-
['below', 'right', 'none'] :
46+
['below', 'right', 'overlay', 'none'] :
4747
['below', 'none']
4848
});
4949
this.group('ContentElementVariant', {entry});
50+
this.input('overlayOpacity', SliderInputView, {
51+
defaultValue: 70,
52+
visibleBinding: 'textPosition',
53+
visibleBindingValue: 'overlay'
54+
});
5055
this.view(SeparatorView);
5156
this.group('ContentElementPosition');
5257
this.view(SeparatorView);

entry_types/scrolled/package/src/contentElements/externalLinkList/frontend/ExternalLink.module.css

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,41 +79,68 @@
7979
width: 66%;
8080
}
8181

82+
.textPosition-overlay .thumbnail {
83+
width: 100%;
84+
}
85+
8286
.background {
8387
--padding-inline: var(--theme-external-links-card-padding-inline, 15px);
84-
flex: 1;
85-
color: var(--theme-external-links-card-text-color, darkContentTextColor);
8688
--content-text-color: var(--theme-external-links-card-text-color, darkContentTextColor);
87-
background-color: var(--theme-external-links-card-surface-color, lightContentSurfaceColor);
89+
--card-surface-color: var(--theme-external-links-card-surface-color, lightContentSurfaceColor);
90+
color: var(--content-text-color);
91+
background-color: var(--card-surface-color);
92+
flex: 1;
8893
padding-left: min(var(--padding-inline), 5px);
8994
padding-right: min(var(--padding-inline), 5px);
9095
}
9196

97+
.invert > .background {
98+
--card-surface-color: var(--theme-external-links-card-surface-color, darkContentSurfaceColor);
99+
--content-text-color: var(--theme-external-links-card-text-color, lightContentTextColor);
100+
}
101+
102+
.textPosition-overlay .background {
103+
position: absolute;
104+
bottom: 0;
105+
width: 100%;
106+
background: transparent;
107+
z-index: 1;
108+
}
109+
110+
.textPosition-overlay .background::after {
111+
content: "";
112+
position: absolute;
113+
z-index: -1;
114+
top: -2rem;
115+
left: 0;
116+
right: 0;
117+
bottom: 0;
118+
background: linear-gradient(0deg, var(--card-surface-color), transparent);
119+
opacity: calc(0.9 * var(--overlay-opacity, 0.7));
120+
}
121+
122+
92123
.textPosition-none .background {
93124
display: none;
94125
}
95126

96-
.textPosition-below .details {
127+
.textPosition-below .details,
128+
.textPosition-overlay .details {
97129
padding-top: 15px;
98130
padding-bottom: 20px;
99131
padding-left: calc(var(--padding-inline) - 5px);
100132
padding-right: calc(var(--padding-inline) - 5px);
101133
}
102134

103-
.textPosition-below .details:first-child {
135+
.textPosition-below .details:first-child,
136+
.textPosition-overlay .details:first-child {
104137
padding-top: 20px;
105138
}
106139

107140
.textPosition-right .details {
108141
padding: 10px 10px 10px 15px;
109142
}
110143

111-
.invert > .background {
112-
background-color: var(--theme-external-links-card-surface-color, darkContentSurfaceColor);
113-
color: var(--theme-external-links-card-text-color, lightContentTextColor);
114-
--content-text-color: var(--theme-external-links-card-text-color, lightContentTextColor);
115-
}
116-
117144
.tagline {
118145
composes: typography-externalLinkTagline from global;
119146
line-height: 1.3;
@@ -127,6 +154,10 @@
127154
margin: 0 0 1rem;
128155
}
129156

157+
.textPosition-overlay .title:last-child {
158+
margin-bottom: 0;
159+
}
160+
130161
.details p {
131162
margin-bottom: 0;
132163
}

entry_types/scrolled/package/src/contentElements/externalLinkList/frontend/ExternalLinkList.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export function ExternalLinkList(props) {
8888
textPositionStyles[`linkAlignment-${props.configuration.linkAlignment}`],
8989
textPositionStyles[`textPosition-${textPosition}`]
9090
)}
91+
style={{'--overlay-opacity': (props.configuration.overlayOpacity || 70) / 100}}
9192
onClick={handleListClick}>
9293
{linkList.map((link, index) =>
9394
<ExternalLink {...link}

entry_types/scrolled/package/src/contentElements/externalLinkList/stories.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -204,19 +204,19 @@ storiesOfContentElement(module, {
204204
inlineFileRights: true
205205
});
206206

207-
[['below', 6], ['right', 3]].forEach(([textPosition, linkCount]) =>
207+
[['below'], ['right'], ['overlay', 'square']].forEach(([textPosition, thumbnailAspectRatio]) =>
208208
storiesOf(`Content Elements/externalLinkList`, module)
209209
.add(
210210
`Text Position - ${textPosition}`,
211-
() => (
212-
<RootProviders seed={exampleSeed({textPosition, linkCount})}>
213-
<Entry />
214-
</RootProviders>
215-
)
211+
() => (
212+
<RootProviders seed={exampleSeed({textPosition, thumbnailAspectRatio})}>
213+
<Entry />
214+
</RootProviders>
215+
)
216216
)
217217
);
218218

219-
function exampleSeed({textPosition, linkCount}) {
219+
function exampleSeed({textPosition, thumbnailAspectRatio}) {
220220
const sectionConfiguration = {
221221
transition: 'scroll'
222222
};
@@ -255,9 +255,9 @@ function exampleSeed({textPosition, linkCount}) {
255255
}
256256
],
257257
contentElements: [
258-
...exampleContentElements(1, 'left', textPosition, linkCount),
259-
...exampleContentElements(2, 'center', textPosition, linkCount),
260-
...exampleContentElements(3, 'right', textPosition, linkCount),
258+
...exampleContentElements(1, 'left', textPosition, thumbnailAspectRatio),
259+
...exampleContentElements(2, 'center', textPosition, thumbnailAspectRatio),
260+
...exampleContentElements(3, 'right', textPosition, thumbnailAspectRatio),
261261
]
262262
});
263263
}
@@ -274,7 +274,7 @@ function linkCount({layout, textPosition, width, linkWidth}) {
274274
}
275275
}
276276

277-
function exampleContentElements(sectionId, layout, textPosition) {
277+
function exampleContentElements(sectionId, layout, textPosition, thumbnailAspectRatio) {
278278
return [
279279
exampleHeading({sectionId, text: `Layout ${layout}`}),
280280
...([
@@ -293,6 +293,7 @@ function exampleContentElements(sectionId, layout, textPosition) {
293293
textPosition,
294294
width,
295295
linkWidth,
296+
thumbnailAspectRatio,
296297
...links({
297298
count: linkCount({layout, textPosition, width, linkWidth})
298299
})

0 commit comments

Comments
 (0)