Skip to content

pantoken / design/figma/src / toFigmaColor

Fonction: toFigmaColor()

toFigmaColor(hex): FigmaColor | undefined

Expérimental

Analyser #rgb/#rrggbb/#rrggbbaa en une couleur Figma RGBA (0–1), ou undefined si ce n’est pas une couleur hexadécimale.

Paramètres

hex

string

Retourne

FigmaColor | undefined

Exemple

ts
import { toFigmaColor } from "@pantoken/figma";

toFigmaColor("#ff0000"); // { r: 1, g: 0, b: 0, a: 1 }
toFigmaColor("not-a-color"); // undefined