1.1.0 • Published 4 years ago

figma-color-extract v1.1.0

Weekly downloads
2
License
ISC
Repository
-
Last release
4 years ago

figma-color-extract

Smol function for extracting colors from a Figma document

Installation

npm install figma-color-extract

How to use

import fce from 'figma-color-extract'

fce(document)

figma-color-extract expects a Figma document and takes three optional parameters (nodeType, nameRegex and channelType) and returns an array {name: string, color: {r: number, g: number, b: number}}[] or when providing rgba as the channelTypefce(document, '', '', rgba')->{name: string, color: {r: number, g: number, b: number, a: number}}[]`.

name is the name of the node and color is an rgb representation of the first fill for that node.

Parameters

document - Required

A Figma document as returned by GET/v1/files/:key endpoint.

nodeType - Optional

An array of Figma node types. This will filter the results to only show colors from nodes that match a type in the supplied array.

Default value: ['RECTANGLE']

nameRegex - Optional

If supplied, the function will only return nodes whose name matches the regex.

Default value: /.*/g

1.1.0

4 years ago

1.0.0

5 years ago