New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@six7/figma-tokens-helpers

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@six7/figma-tokens-helpers

Helper functions for using Figma Tokens data

  • 0.0.6
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

Figma Tokens Helpers

Exposes functions that utilize Figma Tokens shared plugin data.

How to use

Import the functions you need into your plugin.

Available helpers

getTokensStoredOnDocument

Returns all tokens stored on document as an object containing token sets that each contain tokens as an array.

Caution: These tokens are unresolved meaning they could use aliases. To get the resolved value according to what token sets were used, see getResolvedTokens

Example usage:

getTokensStoredOnDocument()

Result:

{
    "global": {
        [
            {name: 'colors.white', value: '#ffffff', type: 'color'},
            {name: 'fg.default', value: '{colors.white}', type: 'color'}
        ]
    }
}

getResolvedTokens

Reads all tokens stored on the document and the last used token sets and returns an array of tokens with their resolved value according to the set combination.

getResolvedTokens()

Result:

[
    {name: 'colors.white', value: '#ffffff', type: 'color', internal__Parent: '_scale/light', rawValue: '#ffffff'}, {name: 'bg.default', value: '#ffffff', type: 'color', internal__Parent: 'light/default', rawValue: '{colors.white}'}
]

getUsedTokenSetsOnDocument

Returns the used token sets in the document as they were last used, e.g. if a set was toggled active/set as source or disabled. This has an impact on what values each token has.

getUsedTokenSetsOnDocument()

Result:

{
    'global': 'source', 'light': 'disabled', 'dark': 'enbabled' 
}

getTokensOnNode

Returns all tokens stored on a node.

getTokensOnNode(figma.currentPage.selection[0])

Result:

{
    "fill": "colors.black",
    "sizing": "sizing.md"
}

getTokensByKey

Returns the stored token on a node for a given key

getTokensByKey(figma.currentPage.selection[0], "fill")

Result:

"colors.black"

mergeTokens

Merges given tokens with given token sets. This function is being used in getResolvedTokens, but with this function you can feed it custom sets or tokens.

mergeTokens(tokens, sets)

Result:

[
    {name: 'colors.white', value: '#ffffff', type: 'color', internal__Parent: '_scale/light', rawValue: '#ffffff'}, {name: 'bg.default', value: '#ffffff', type: 'color', internal__Parent: 'light/default', rawValue: '{colors.white}'}
]

FAQs

Package last updated on 15 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc