Skip to content

Commit

Permalink
Merge pull request #2184 from tf/static-teasers
Browse files Browse the repository at this point in the history
Allow using external links as static teaser list
  • Loading branch information
tf authored Dec 13, 2024
2 parents 8293c22 + 8c43dc1 commit 75d6597
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 24 deletions.
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

0 comments on commit 75d6597

Please sign in to comment.