mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-07-27 02:14:50 +10:00
fix: issue with color format handling, resolves #3104
This commit is contained in:
@@ -2,10 +2,17 @@ import type { ColorResult } from "@uiw/color-convert";
|
||||
import { hsvaToHex, rgbaStringToHsva } from "@uiw/color-convert";
|
||||
|
||||
export function rgbaStringToHex(rgba: string): string {
|
||||
const color = parseColorString(rgba);
|
||||
if (color) return `#${toHexComponent(color.r)}${toHexComponent(color.g)}${toHexComponent(color.b)}`;
|
||||
|
||||
const hsva = rgbaStringToHsva(rgba);
|
||||
return hsvaToHex(hsva);
|
||||
}
|
||||
|
||||
function toHexComponent(value: number): string {
|
||||
return Math.max(0, Math.min(255, value)).toString(16).padStart(2, "0");
|
||||
}
|
||||
|
||||
export function parseColorString(value: string): ColorResult["rgba"] | null {
|
||||
const trimmed = value.trim();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user