mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 20:26:49 +00:00
Abstract Libs
This commit is contained in:
16
lib/colors.ts
Normal file
16
lib/colors.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { random } from 'lodash'
|
||||
|
||||
export function getRandomPairOfColors() {
|
||||
const colors = ['#37B679', '#DA3C3C', '#3291FF', '#7928CA', '#79FFE1']
|
||||
const getRandomIdx = () => random(0, colors.length - 1)
|
||||
let idx = getRandomIdx()
|
||||
let idx2 = getRandomIdx()
|
||||
|
||||
// Has to be a different color
|
||||
while (idx2 === idx) {
|
||||
idx2 = getRandomIdx()
|
||||
}
|
||||
|
||||
// Returns a pair of colors
|
||||
return [colors[idx], colors[idx2]]
|
||||
}
|
Reference in New Issue
Block a user