Created
July 20, 2020 11:19
-
-
Save akaia-shadowfox/8c67137d39a2cf46695268a0be1b77c8 to your computer and use it in GitHub Desktop.
Playing with colors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tinycolor from 'tinycolor2'; | |
export const darken = (color, degree = 10) => { | |
if (0 <= degree && degree <= 100) { | |
return tinycolor(color) | |
.darken(degree) | |
.toString(); | |
} else { | |
throw new RangeError('The color darken degree must be between 0 and 100.'); | |
} | |
}; | |
import { toPairs } from 'ramda'; | |
import { colors } from './palette'; | |
const step = 10; | |
for (const [key, color] of toPairs(colors)) { | |
const sheet = [ | |
`${key} -- ` + color, | |
`${key} dark ` + darken(color, step), | |
`${key} darkest ` + darken(color, step * 2) | |
]; | |
console.log(sheet); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const colors = { | |
primary: '#008859', | |
secondary: '#554854', | |
accent: '#FF6600', | |
widget: '#4690D1', | |
alarm: '#CF4444' | |
}; | |
export const { primary, secondary, accent, widget, alarm } = colors; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment