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

Allow using external links as static teaser list #2184

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -37,9 +37,7 @@ export const SidebarEditLinkView = Marionette.Layout.extend({
var thumbnailAspectRatio = this.options.contentElement.configuration.get('thumbnailAspectRatio');

configurationEditor.tab('edit_link', function () {
this.input('url', TextInputView, {
required: true
});
this.input('url', TextInputView);
this.input('open_in_new_tab', CheckBoxInputView);
this.input('thumbnail', FileInputView, {
collection: 'image_files',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,20 @@ export function ExternalLink(props) {
}

return (
<a className={classNames(styles.item,
styles[`textPosition-${props.textPosition}`],
styles[`thumbnailSize-${props.thumbnailSize}`],
styles[`textSize-${props.textSize}`],
{[styles.invert]: props.invert})}
href={url || 'about:blank'}
title={props.textPosition === 'title' ?
[props.title, props.description].filter(Boolean).join("\n") :
null}
onClick={onClick}
onMouseLeave={onMouseLeave}
target={props.open_in_new_tab ? '_blank' : '_self'}
rel={props.open_in_new_tab ? 'noopen noreferrer' : undefined}>
<LinkOrDiv
className={classNames(styles.item,
styles[`textPosition-${props.textPosition}`],
styles[`thumbnailSize-${props.thumbnailSize}`],
styles[`textSize-${props.textSize}`],
{[styles.invert]: props.invert})}
href={url}
title={props.textPosition === 'title' ?
[props.title, props.description].filter(Boolean).join("\n") :
null}
onClick={onClick}
onMouseLeave={onMouseLeave}
target={props.open_in_new_tab ? '_blank' : '_self'}
rel={props.open_in_new_tab ? 'noopen noreferrer' : undefined}>
<div className={styles.thumbnail}>
<Thumbnail imageFile={thumbnailImageFile}
aspectRatio={props.thumbnailAspectRatio}
Expand All @@ -84,12 +85,29 @@ export function ExternalLink(props) {
</div>
</div>
{renderNewTabTooltip()}
</a>
</LinkOrDiv>
);
}

function LinkOrDiv({children, ...props}) {
if (props.href) {
return (
<a {...props}>
{children}
</a>
);
}
else {
return (
<div className={props.className}
title={props.title}>
{children}
</div>
);
}
}
function ensureAbsolute(url) {
if (url.match(/^(https?:)?\/\//)) {
if (!url || url.match(/^(https?:)?\/\//)) {
return url;
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
composes: textPosition-below;
}

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

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

.item:hover .link_title {
a.item:hover .link_title {
text-decoration: underline;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
justify-content: center;
}

.list > a {
.list > * {
margin: 2% 0;
width: calc((100% - var(--gap) * (var(--columns) - 1)) / var(--columns));
}
Expand All @@ -45,7 +45,7 @@
}

@container (max-width: 699px) {
.linkWidth-m > a {
.linkWidth-m > * {
max-width: 300px;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
justify-content: center;
}

.list > a {
.list > * {
width: 100%;
margin: 2% 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,24 @@ storiesOfContentElement(module, {
}
}
}
},
{
name: 'Without link urls',
configuration: {
links: [
{
id: '1',
title: 'Static Teaser',
thumbnail: filePermaId('imageFiles', 'turtle'),
description: 'This is description'
},
{
id: '2',
title: 'Other item',
description: 'This is pageflowio link'
}
]
},
}
],
inlineFileRights: true
Expand Down
Loading