Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #46 from pavelkeyzik/fix-import-scale-with-no-colors
Browse files Browse the repository at this point in the history
Add error message when import scale with empty array
  • Loading branch information
colebemis authored Jun 27, 2022
2 parents 5932c59 + 1b7a132 commit 3fd0ea8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/components/import-scales.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export function ImportScales({onImport}: ImportScalesProps) {
const scales: Scale[] = Object.entries(parsedCode).map(([name, scale]) => {
const id = uniqueId()
const scaleArray = isArray(scale) ? scale : [scale]

if (scaleArray.length === 0) {
throw new Error(`Please provide at least one color for ${name} scale`)
}

return {id, name, colors: scaleArray.map(hexToColor), curves: {}}
})

Expand Down

0 comments on commit 3fd0ea8

Please sign in to comment.