@cobalt-ui/plugin-json
Advanced tools
Comparing version 0.1.0 to 0.2.0
# @cobalt-ui/plugin-json | ||
## 0.2.0 | ||
### Minor Changes | ||
- 26bfb4c: Convert to JSON, follow design tokens spec | ||
## 0.1.0 | ||
### Minor Changes | ||
- 5748e72: Use JSON to align with the Design Tokens W3C spec |
@@ -15,3 +15,3 @@ import type { Plugin, Token } from '@cobalt-ui/core'; | ||
/** output file (default: "./tokens/tokens.json") */ | ||
filename?: string; | ||
fileName?: string; | ||
/** modify values */ | ||
@@ -18,0 +18,0 @@ transformValue?: (token: Token, mode?: string) => any; |
export default function json(options) { | ||
let fileName = options?.filename || './tokens.json'; | ||
let fileName = options?.fileName || './tokens.json'; | ||
let transform = options?.transformValue; | ||
return { | ||
name: '@cobalt-ui/plugin-json', | ||
async build({ schema }) { | ||
async build({ tokens }) { | ||
return [ | ||
{ | ||
fileName, | ||
contents: JSON.stringify(schema, (_, token) => { | ||
contents: JSON.stringify(tokens, (_, token) => { | ||
// apply transformValue() | ||
@@ -27,1 +27,2 @@ if (transform && typeof token.type == 'string') { | ||
} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@cobalt-ui/plugin-json", | ||
"description": "JSON builder for Cobalt UI design tokens", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"author": { | ||
@@ -21,3 +21,3 @@ "name": "Drew Powers", | ||
"devDependencies": { | ||
"@cobalt-ui/core": "^0.1.0" | ||
"@cobalt-ui/core": "^0.2.0" | ||
}, | ||
@@ -24,0 +24,0 @@ "scripts": { |
@@ -20,3 +20,3 @@ import type { BuildResult, Plugin, Token } from '@cobalt-ui/core'; | ||
/** output file (default: "./tokens/tokens.json") */ | ||
filename?: string; | ||
fileName?: string; | ||
/** modify values */ | ||
@@ -27,3 +27,3 @@ transformValue?: (token: Token, mode?: string) => any; | ||
export default function json(options?: Options): Plugin { | ||
let fileName = options?.filename || './tokens.json'; | ||
let fileName = options?.fileName || './tokens.json'; | ||
let transform = options?.transformValue; | ||
@@ -33,3 +33,3 @@ | ||
name: '@cobalt-ui/plugin-json', | ||
async build({ schema }): Promise<BuildResult[]> { | ||
async build({ tokens }): Promise<BuildResult[]> { | ||
return [ | ||
@@ -39,3 +39,3 @@ { | ||
contents: JSON.stringify( | ||
schema, | ||
tokens, | ||
(_, token) => { | ||
@@ -42,0 +42,0 @@ // apply transformValue() |
6607
8