feat: some shit
This commit is contained in:
14
src/helpers/colors.ts
Normal file
14
src/helpers/colors.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
// function to turn css rgb() strings to hex
|
||||
export function rgbToHex(rgb: string) {
|
||||
let hex = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
||||
if (!hex) return rgb;
|
||||
return (
|
||||
"#" +
|
||||
hex
|
||||
.slice(1)
|
||||
.map((x) => {
|
||||
return ("0" + parseInt(x).toString(16)).slice(-2);
|
||||
})
|
||||
.join("")
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user