mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-11-05 08:25:41 -05:00
CSS modules ➡️ Stitches 🧵 (#799)
This commit is contained in:
11
lib/styles/helpers/hex-to-rgba.ts
Normal file
11
lib/styles/helpers/hex-to-rgba.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
// hex -> rgba, pulled from https://github.com/sindresorhus/hex-rgb/blob/main/index.js#L29
|
||||
const hex2rgba = (hex: string, alpha: number) => {
|
||||
const number = Number.parseInt(hex.replace(/^#/, ""), 16);
|
||||
const red = number >> 16;
|
||||
const green = (number >> 8) & 255;
|
||||
const blue = number & 255;
|
||||
|
||||
return `rgba(${red},${green},${blue},${alpha})`;
|
||||
};
|
||||
|
||||
export default hex2rgba;
|
||||
Reference in New Issue
Block a user