You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011
  1. export const hexToRGB = (hex, opacity) => {
  2. var r = parseInt(hex.slice(1, 3), 16),
  3. g = parseInt(hex.slice(3, 5), 16),
  4. b = parseInt(hex.slice(5, 7), 16);
  5. if (opacity) {
  6. return `rgba(${r}, ${g}, ${b}, ${opacity})`;
  7. } else {
  8. return `rgb(${r}, ${g}, ${b})`;
  9. }
  10. }