Skip to content

Commit

Permalink
feat: improve getRandomColor function
Browse files Browse the repository at this point in the history
  • Loading branch information
PancakePhilarmonych committed Nov 21, 2023
1 parent 5953636 commit 942d53d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ const mainColors = [
Colors.EMPTY,
];

export const getRandomColor = () => {
const index = Math.floor(Math.random() * mainColors.length);
return mainColors[index];
export const getRandomColor = (excludeEmpty = false) => {
const colors = excludeEmpty ? mainColors.filter(color => color !== Colors.EMPTY) : mainColors;
const index = Math.floor(Math.random() * colors.length);
return colors[index];
}


Expand Down

0 comments on commit 942d53d

Please sign in to comment.