Make ImageAnchors downloadable

This commit is contained in:
Andras Schmelczer 2022-09-21 13:45:49 +02:00
parent 1f3c388e94
commit 40b4ed0fdb
No known key found for this signature in database
GPG key ID: 0EA1BC97D0AB076E
2 changed files with 9 additions and 2 deletions

View file

@ -6,15 +6,18 @@ export const generate = ({
href,
svg,
title,
shouldDownload,
}: {
href: url;
svg: url;
title: string;
shouldDownload: boolean;
}): html => `
<a class="image-anchor"
href="${href}"
rel="noopener"
target="_blank"
${shouldDownload ? 'download' : ''}
>
<div class="svgContainer">
${svg}

View file

@ -3,9 +3,13 @@ import { createElement } from '../../../helper/create-element';
import { url } from '../../../types/url';
import { generate } from './image-anchor.html';
export const ImageAnchorFactory = (svg: string, title: string) =>
export const ImageAnchorFactory = (
svg: string,
title: string,
{ shouldDownload = false }: { shouldDownload?: boolean } = {}
) =>
class ImageAnchor extends PageElement {
public constructor(href: url) {
super(createElement(generate({ href, svg, title })));
super(createElement(generate({ href, svg, title, shouldDownload })));
}
};