Get error when using Swift plugin
Versions
"@terrazzo/cli": "^0.7.2", "@terrazzo/plugin-css": "^0.7.2", "@terrazzo/plugin-sass": "^0.7.2", "@terrazzo/plugin-swift": "^0.0.1"
Node.js version
22.14.0
OS + version
15.4.1
Description
Getting the following error when using Swift plugin
✗ Can’t convert color {"$value":{"colorSpace":"srgb","components":[0,0,0],"alpha":1},"originalValue":"rgba(0,0,0)","source":{"loc":"file:///Users/kovalju/Documents/Projects/tokens/tokens/base/color.json"}} to Culori color
Here's my config:
import { defineConfig } from "@terrazzo/cli";
import css from "@terrazzo/plugin-css";
import sass from "@terrazzo/plugin-sass";
import swift from "@terrazzo/plugin-swift"
export default defineConfig({
tokens: [
'./tokens/base/animation.json',
'./tokens/base/breakpoint.json',
...
],
outDir: './dist/key',
plugins: [
css({
modeSelectors: [
{
mode: "light",
selectors: [
'[data-mode="light"]',
],
},
{
mode: "dark",
selectors: [
'[data-mode="dark"]',
],
},
],
}),
sass({
filename: "index.scss",
}),
swift({
catalogName: "Tokens",
}),
],
lint: {
/** @see https://terrazzo.app/docs/cli/lint */
rules: {
"core/consistent-naming": ["error", { format: "kebab-case" }],
}
},
});
Token file
{
"color": {
"black": {
"$type": "color",
"$value": "rgba(0,0,0)"
},
"white": {
"$type": "color",
"$value": "rgba(255, 255, 255)"
},
"transparent": {
"black-20": {
"$type": "color",
"$value": "rgba(0, 0, 0, .2)"
},
"white-10": {
"$type": "color",
"$value": "rgba(255, 255, 255, .2)"
},
"white-0": {
"$type": "color",
"$value": "rgba(255, 255, 255, 0)"
}
}
}
}
Reproduction
Adding the Swift Plugin
Expected result
Compile
Extra
- [ ] I’m willing to open a PR (see CONTRIBUTING.md)
Thanks for reporting! The Swift plugin is not really in a great state at the moment. If you’ve worked with tokens in Swift before, do you have any thoughts about the overall design patterns? Would there be a more usable one instead? Would love to talk more about what would be useful for your usecase (and we can either go with a different approach, or simply fix up the current one)
Also, just re-released the plugin to npm, which may have been stale. Give it a try with 0.0.2 and the latest version of @terrazzo/cli again to see if you have the same error
Thank you I'll check it out. No I don't have much experience with Swift but something our DS will have to support soon.