Skip to content

Instantly share code, notes, and snippets.

@carina-akaia
Created July 20, 2020 11:19
Show Gist options
  • Save carina-akaia/8c67137d39a2cf46695268a0be1b77c8 to your computer and use it in GitHub Desktop.
Save carina-akaia/8c67137d39a2cf46695268a0be1b77c8 to your computer and use it in GitHub Desktop.
Playing with colors
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);
}
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