Skip to content

pantoken-root / design/figma/src / toFigmaColor

Funció: toFigmaColor() ​

toFigmaColor(hex): FigmaColor | undefined

Experimental

Analitzar #rgb/#rrggbb/#rrggbbaa a un Figma RGBA (0–1), o undefined si no és un color hexadecimal.

Paràmetres ​

hex ​

string

Retorna ​

FigmaColor | undefined

Exemple ​

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

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