Implement color palette in Vue (#2047)

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Chenlei Hu
2024-12-25 21:41:48 -05:00
committed by GitHub
parent f1eee96ebc
commit db572a4085
29 changed files with 501 additions and 608 deletions

View File

@@ -110,11 +110,7 @@ export async function addStylesheet(
})
}
/**
* @param { string } filename
* @param { Blob } blob
*/
export function downloadBlob(filename, blob) {
export function downloadBlob(filename: string, blob: Blob) {
const url = URL.createObjectURL(blob)
const a = $el('a', {
href: url,
@@ -129,6 +125,20 @@ export function downloadBlob(filename, blob) {
}, 0)
}
export function uploadFile(accept: string) {
return new Promise<File>((resolve, reject) => {
const input = document.createElement('input')
input.type = 'file'
input.accept = accept
input.onchange = (e) => {
const file = (e.target as HTMLInputElement).files?.[0]
if (!file) return reject(new Error('No file selected'))
resolve(file)
}
input.click()
})
}
export function prop<T>(
target: object,
name: string,