Skip to content

Commit 75d6597

Browse files
authored
Merge pull request #2184 from tf/static-teasers
Allow using external links as static teaser list
2 parents 8293c22 + 8c43dc1 commit 75d6597

File tree

6 files changed

+58
-24
lines changed

6 files changed

+58
-24
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ export const SidebarEditLinkView = Marionette.Layout.extend({
3737
var thumbnailAspectRatio = this.options.contentElement.configuration.get('thumbnailAspectRatio');
3838

3939
configurationEditor.tab('edit_link', function () {
40-
this.input('url', TextInputView, {
41-
required: true
42-
});
40+
this.input('url', TextInputView);
4341
this.input('open_in_new_tab', CheckBoxInputView);
4442
this.input('thumbnail', FileInputView, {
4543
collection: 'image_files',

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

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,20 @@ export function ExternalLink(props) {
5555
}
5656

5757
return (
58-
<a className={classNames(styles.item,
59-
styles[`textPosition-${props.textPosition}`],
60-
styles[`thumbnailSize-${props.thumbnailSize}`],
61-
styles[`textSize-${props.textSize}`],
62-
{[styles.invert]: props.invert})}
63-
href={url || 'about:blank'}
64-
title={props.textPosition === 'title' ?
65-
[props.title, props.description].filter(Boolean).join("\n") :
66-
null}
67-
onClick={onClick}
68-
onMouseLeave={onMouseLeave}
69-
target={props.open_in_new_tab ? '_blank' : '_self'}
70-
rel={props.open_in_new_tab ? 'noopen noreferrer' : undefined}>
58+
<LinkOrDiv
59+
className={classNames(styles.item,
60+
styles[`textPosition-${props.textPosition}`],
61+
styles[`thumbnailSize-${props.thumbnailSize}`],
62+
styles[`textSize-${props.textSize}`],
63+
{[styles.invert]: props.invert})}
64+
href={url}
65+
title={props.textPosition === 'title' ?
66+
[props.title, props.description].filter(Boolean).join("\n") :
67+
null}
68+
onClick={onClick}
69+
onMouseLeave={onMouseLeave}
70+
target={props.open_in_new_tab ? '_blank' : '_self'}
71+
rel={props.open_in_new_tab ? 'noopen noreferrer' : undefined}>
7172
<div className={styles.thumbnail}>
7273
<Thumbnail imageFile={thumbnailImageFile}
7374
aspectRatio={props.thumbnailAspectRatio}
@@ -84,12 +85,29 @@ export function ExternalLink(props) {
8485
</div>
8586
</div>
8687
{renderNewTabTooltip()}
87-
</a>
88+
</LinkOrDiv>
8889
);
8990
}
9091

92+
function LinkOrDiv({children, ...props}) {
93+
if (props.href) {
94+
return (
95+
<a {...props}>
96+
{children}
97+
</a>
98+
);
99+
}
100+
else {
101+
return (
102+
<div className={props.className}
103+
title={props.title}>
104+
{children}
105+
</div>
106+
);
107+
}
108+
}
91109
function ensureAbsolute(url) {
92-
if (url.match(/^(https?:)?\/\//)) {
110+
if (!url || url.match(/^(https?:)?\/\//)) {
93111
return url;
94112
}
95113
else {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@
2727
composes: textPosition-below;
2828
}
2929

30-
.textPosition-below:hover {
30+
a.textPosition-below:hover {
3131
transform: scale(var(--theme-external-links-card-hover-scale, 1.05));
3232
}
3333

34-
.textPosition-right:hover {
34+
a.textPosition-right:hover {
3535
transform: scale(var(--theme-external-links-card-hover-scale, 1.02));
3636
}
3737

38-
.item:hover .link_title {
38+
a.item:hover .link_title {
3939
text-decoration: underline;
4040
}
4141

entry_types/scrolled/package/src/contentElements/externalLinkList/frontend/textPositons/below.module.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
justify-content: center;
2020
}
2121

22-
.list > a {
22+
.list > * {
2323
margin: 2% 0;
2424
width: calc((100% - var(--gap) * (var(--columns) - 1)) / var(--columns));
2525
}
@@ -45,7 +45,7 @@
4545
}
4646

4747
@container (max-width: 699px) {
48-
.linkWidth-m > a {
48+
.linkWidth-m > * {
4949
max-width: 300px;
5050
}
5151
}

entry_types/scrolled/package/src/contentElements/externalLinkList/frontend/textPositons/right.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
justify-content: center;
99
}
1010

11-
.list > a {
11+
.list > * {
1212
width: 100%;
1313
margin: 2% 0;
1414
}

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,24 @@ storiesOfContentElement(module, {
113113
}
114114
}
115115
}
116+
},
117+
{
118+
name: 'Without link urls',
119+
configuration: {
120+
links: [
121+
{
122+
id: '1',
123+
title: 'Static Teaser',
124+
thumbnail: filePermaId('imageFiles', 'turtle'),
125+
description: 'This is description'
126+
},
127+
{
128+
id: '2',
129+
title: 'Other item',
130+
description: 'This is pageflowio link'
131+
}
132+
]
133+
},
116134
}
117135
],
118136
inlineFileRights: true

0 commit comments

Comments
 (0)