Make ImageAnchors downloadable
This commit is contained in:
parent
1f3c388e94
commit
40b4ed0fdb
2 changed files with 9 additions and 2 deletions
|
|
@ -6,15 +6,18 @@ export const generate = ({
|
||||||
href,
|
href,
|
||||||
svg,
|
svg,
|
||||||
title,
|
title,
|
||||||
|
shouldDownload,
|
||||||
}: {
|
}: {
|
||||||
href: url;
|
href: url;
|
||||||
svg: url;
|
svg: url;
|
||||||
title: string;
|
title: string;
|
||||||
|
shouldDownload: boolean;
|
||||||
}): html => `
|
}): html => `
|
||||||
<a class="image-anchor"
|
<a class="image-anchor"
|
||||||
href="${href}"
|
href="${href}"
|
||||||
rel="noopener"
|
rel="noopener"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
|
${shouldDownload ? 'download' : ''}
|
||||||
>
|
>
|
||||||
<div class="svgContainer">
|
<div class="svgContainer">
|
||||||
${svg}
|
${svg}
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,13 @@ import { createElement } from '../../../helper/create-element';
|
||||||
import { url } from '../../../types/url';
|
import { url } from '../../../types/url';
|
||||||
import { generate } from './image-anchor.html';
|
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 {
|
class ImageAnchor extends PageElement {
|
||||||
public constructor(href: url) {
|
public constructor(href: url) {
|
||||||
super(createElement(generate({ href, svg, title })));
|
super(createElement(generate({ href, svg, title, shouldDownload })));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue