Skip to content

Commit

Permalink
fix: type
Browse files Browse the repository at this point in the history
  • Loading branch information
qq15725 committed May 9, 2023
1 parent 9c8d982 commit bc7b2d0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/add-sample.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { loadImage, srgbToOklab } from './utils'
import { isImageElement, loadImage, srgbToOklab } from './utils'
import type { Context } from './context'

interface AddSampleOptions {
Expand Down Expand Up @@ -35,7 +35,7 @@ export function addSample(
options,
)
})
} else if (source instanceof HTMLImageElement) {
} else if (isImageElement(source)) {
if (!context2d) return
context2d.canvas.width = source.width
context2d.canvas.height = source.height
Expand Down
2 changes: 1 addition & 1 deletion src/create-palette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { Context } from './context'
import type { Palette } from './palette'
import type { Options } from './options'

export function createPalette(options: Options | Context): Palette {
export function createPalette(options?: Options | Context): Palette {
const context = orCreateContext(options)

const {
Expand Down
1 change: 1 addition & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { ColorSample, Oklab, Sort } from './types'

export const IN_BROWSER = typeof window !== 'undefined'
export const isImageElement = (node: any): node is HTMLImageElement => node && typeof node === 'object' && node.nodeType === 1 && node.tagName === 'IMG'

const K = (1 << 16) - 1
const K2 = K * K
Expand Down

1 comment on commit bc7b2d0

@vercel
Copy link

@vercel vercel bot commented on bc7b2d0 May 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

modern-palette – ./

modern-palette.vercel.app
modern-palette-git-main-qq15725.vercel.app
modern-palette-qq15725.vercel.app

Please sign in to comment.