Skip to content

pantoken / design/figma/src / toFigmaColor

Función: toFigmaColor()

toFigmaColor(hex): FigmaColor | undefined

Experimental

Analiza #rgb/#rrggbb/#rrggbbaa a un RGBA de Figma (0–1), o undefined si no es un color hexadecimal.

Parámetros

hex

string

Devuelve

FigmaColor | undefined

Ejemplo

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

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