Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
@tokens-studio/sd-transforms
Advanced tools
Custom transforms for Style-Dictionary, to work with Design Tokens that are exported from Tokens Studio
This library is currently in beta.
This package contains custom transforms for Style-Dictionary, to work with Design Tokens that are exported from Tokens Studio:
px
as a unit when missing (transitive)%
to em
%
to unitless (150% -> 1.5)rgba()
formatattribute/cti
, name/cti/camelCase
for naming purposes, as a transform group called tokens-studio
With NPM:
npm install @tokens-studio/sd-transforms
import { registerTransforms } from '@tokens-studio/sd-transforms';
// will register them on StyleDictionary object
// that is installed as a dependency of this package,
// in most case this will be npm install deduped with your installation,
// thus being the same object as you use
registerTransforms();
// or pass your own StyleDictionary object to it in case the former doesn't work
registerTransforms(sdObject);
In your Style-Dictionary config:
{
"source": ["**/*.tokens.json"],
"platforms": {
"js": {
"transformGroup": "tokens-studio",
"buildPath": "build/js/",
"files": [
{
"destination": "variables.js",
"format": "javascript/es6"
}
]
},
"css": {
"transforms": [
"ts/descriptionToComment",
"ts/resolveMath",
"ts/size/px",
"ts/size/letterspacing",
"ts/size/lineheight",
"ts/type/fontWeight",
"ts/color/hexrgba",
"ts/typography/css/shorthand",
"ts/shadow/shorthand",
"attribute/cti",
"name/cti/kebab"
],
"buildPath": "build/css/",
"files": [
{
"destination": "variables.css",
"format": "css/variables"
}
]
}
}
}
More fine-grained control:
import module from 'module';
import { transformDimension } from '@tokens-studio/sd-transforms';
const require = module.createRequire(import.meta.url);
const StyleDictionary = require('style-dictionary');
StyleDictionary.registerTransform({
name: 'my/size/px',
type: 'value',
transitive: true,
matcher: token => ['fontSizes', 'dimension', 'borderRadius', 'spacing'].includes(token.type),
transformer: token => transformDimension(token.value),
});
If you use CommonJS, no problem, you can use this package as CommonJS, if your tooling supports package entry points (a.k.a. exports map)!
const { registerTransforms } = require('@tokens-studio/sd-transforms');
0.4.1
FAQs
Custom transforms for Style-Dictionary, to work with Design Tokens that are exported from Tokens Studio
The npm package @tokens-studio/sd-transforms receives a total of 13,885 weekly downloads. As such, @tokens-studio/sd-transforms popularity was classified as popular.
We found that @tokens-studio/sd-transforms demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.