Skip to content
This repository has been archived by the owner on Sep 13, 2021. It is now read-only.

emit data.download event if someone clicks the download link #54

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
8 changes: 8 additions & 0 deletions lib/blocks/GetTheData.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<script>
// external props
import PostEvent from '@datawrapper/shared/postEvent';

export let props;
const { get, __, purifyHtml } = props;
$: ({ chart, theme } = props);

function onDownload() {
const postEvent = PostEvent(chart.id);
postEvent('data.download');
}

// internal props
$: getTheData = get(theme, 'data.options.footer.getTheData', { enabled: false });
</script>
Expand All @@ -12,6 +19,7 @@
<a
class="dw-data-link"
aria-label="{__(getTheData.caption)}: {purifyHtml(chart.title, '')}"
on:click={onDownload}
href="data">
{__(getTheData.caption)}
</a>
Expand Down