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,
|
||||
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}
|
||||
|
|
|
|||
|
|
@ -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 })));
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue