init; collecting some of my commonly used utils

This commit is contained in:
2024-04-01 17:31:33 -05:00
commit a09a7d7337
13 changed files with 322 additions and 0 deletions

21
pkg/dom.ts Normal file
View File

@@ -0,0 +1,21 @@
import React from 'react';
export type PickElementProps<
TElement extends keyof React.JSX.IntrinsicElements,
TProps extends keyof React.ComponentProps<TElement>
> = Pick<React.ComponentProps<TElement>, TProps>;
export function clickVirtualDownloadLink(
url: string,
filename: string,
) {
const a = document.createElement('a');
a.href = url;
a.download = filename;
a.target = "_blank";
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}