
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
@tokens-studio/configurator
Advanced tools
This repository contains the style-dictionary configurator.
See projects for more info on status.
This project was started from a Style Dictionary Playground fork
Part of the application is a reusable Web Component that can be consumed in other contexts.
For Monaco to work properly, we have to render it to LightDOM, as the consumer you are responsible for slotting in the monaco container divs with 100% height, we'll do the rest!
// Custom Element definition, optionally you can also do:
// import { ConfiguratorElement } from '@tokens-studio/configurator';
// to register it under a different custom element tag name.
import '@tokens-studio/configurator';
<configurator-element>
<div
style="height: 100%"
slot="monaco-config"
></div>
<div
style="height: 100%"
slot="monaco-output"
></div>
</configurator-element>
You'll also need to ensure that WASM bindings are supported in whatever dev server you use. For Vite for example, you will need:
optimizeDeps: {
exclude: ['@rollup/browser'],
}
<configurator-element prevent-init></configurator-element>
Allow prevent-init
attribute to not initialize the configurator-element. Users can call configuratorEl.init()
themselves e.g. after initializing the source files with the replaceSource
utility, since this utility requires the configurator-element
definition to at least be loaded.
This element uses Microsoft Codicons.
For them to render properly, ensure the codicon
font definition is loaded in your app.
We also export some utilities to make it easier to work with this:
import { replaceSource, resizeMonacoLayout, SD_FUNCTIONS_PATH, SD_CONFIG_PATH } from '@tokens-studio/configurator/utils';
window.addEventListener('resize', resizeMonacoLayout);
replaceSource({
[SD_CONFIG_PATH]: '{}',
[SD_FUNCTIONS_PATH]: `import StyleDictionary from 'style-dictionary';
import { register } from '@tokens-studio/sd-transforms';
register(StyleDictionary);`,
'studio.tokens.json': '{}'
}, {
run: true,
clear: 'all'
});
The second param of replaceSource
is an options object with props:
run
-> true
or false
, default value: true
. Whether or not to run Style-Dictionary after replacing the files.clear
-> true
, false
or "all"
, default value: true
. "all"
means all files are cleared first, including the Style-Dictionary config and functions files.Note that your token files cannot match "config.json", "sd.config.json", "config.js", "sd.config.js", "config.mjs", "sd.config.mjs" or "registerSDFunctions.js". These are reserved filenames for the SD Config / Functions files.
There are a couple of events you can listen to on window
:
FUNCTIONS_SAVED_EVENT
-> ev.detail
is the saved contentCONFIG_SAVED_EVENT
-> ev.detail
is the saved contentTOKENS_SAVED_EVENT
-> ev.detail
is the saved contentreplaceSource()
utility - INPUT_FILES_CREATED_EVENT
There's also an event on sdState
you can listen to, which gives you the updated Style-Dictionary object:
import { sdState, SD_CHANGED_EVENT } from '@tokens-studio/configurator/utils';
sdState.addEventListener(SD_CHANGED_EVENT, (ev) => {
console.log(ev.detail); // Style-Dictionary object
})
0.2.2
FAQs
Online IDE for configuring Style-Dictionary
The npm package @tokens-studio/configurator receives a total of 1 weekly downloads. As such, @tokens-studio/configurator popularity was classified as not popular.
We found that @tokens-studio/configurator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.