Skip to content

Commit

Permalink
fix: adjust popup image-colours utils object
Browse files Browse the repository at this point in the history
  • Loading branch information
cdrani committed Dec 22, 2023
1 parent a31c0ea commit 663031b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/utils/image-colours.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,12 @@ function getImageBackgroundAndTextColours(imageElement) {
const sortedPalette = sortColoursByProximityAndLuminance(palette.slice())

const background = sortedPalette.at(0)
const filteredPalette = sortedPalette.slice(1).filter(({ color, percentage }) => percentage > 0 && color != 'rgb(0, 0, 0)')
const nextPrimary = findElementWithMaxDistance(background.base, filteredPalette.reverse())
const filteredPalette = sortedPalette.slice(1).filter(({ colour, percentage }) => percentage > 0 && colour != 'rgb(0, 0, 0)')
const nextPrimary = findElementWithMaxDistance(background.base, filteredPalette)

return {
backgroundColour: background.colour ,
textColour: nextPrimary?.color ?? getContrastColour(background.base, nextPrimary?.base ?? [ 255, 255, 255 ]),
textColour: getContrastColour(background.base, nextPrimary?.base ?? [ 255, 255, 255 ]),
}
}

Expand Down

0 comments on commit 663031b

Please sign in to comment.