Sfoglia il codice sorgente

Add declaration file for ColorThief

Include declaration for ColorThief since it is written in JavaScript
only.
pull/1/head
parent
commit
ac05503e6c
2 ha cambiato i file con 6 aggiunte e 1 eliminazioni
  1. +5
    -0
      packages/web-kitchensink-reactnext/colorthief.d.ts
  2. +1
    -1
      packages/web-kitchensink-reactnext/src/utils/image.ts

+ 5
- 0
packages/web-kitchensink-reactnext/colorthief.d.ts Vedi File

@@ -0,0 +1,5 @@
declare module 'colorthief' {
export default class ColorThief {
getPalette(image: HTMLImageElement, colorCount: number): Promise<[number, number, number][]>;
}
}

+ 1
- 1
packages/web-kitchensink-reactnext/src/utils/image.ts Vedi File

@@ -1,6 +1,6 @@
import ColorThief from 'colorthief';

export const getImageMetadata = (imageUrl: string) => new Promise<Record<string, string | number>>((resolve, reject) => {
export const getImageMetadata = (imageUrl: string) => new Promise<Record<string, string | number | [number, number, number][]>>((resolve, reject) => {
const image = new Image();
image.addEventListener('load', async (imageLoadEvent) => {
const thisImage = imageLoadEvent.currentTarget as HTMLImageElement;


Caricamento…
Annulla
Salva