-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Syntax is too complex #1
Comments
Thanks for the feedback @gossi! I mention the reason why I avoid this in the DTCG issue.
In this way, the method in which In reality I don't expect folks to be continuously recreating operation sets because I recognize how complex the syntax can get. This is why it was critical to create a sharable, plugin-like ecosystem for importing premade ones. {
"some-token": {
"$type": "color",
"$value": "#fffc00",
"$operations": [
["Import.operations", "./my-ops/opacity-operation.json", "$value", 0.5]
]
}
} |
What you are saying accounts for any string being used in here, even So, instead of having something named But my focus was actually about the execution order of operations. I'm not a mathematician, but this should sit on a stable foundation - in programming very related is functional programming style, based very much on math here, so there is a lot to learn from (see video I liked above from Scott Wlaschin), where you wanna:
.. for which the main input is given as Similar art of this is webpack, rollup or vite plugins/config files. Though the config files are written in js, they can import the function directly. That sort of mapping is what needs to be done in the spec for tokens. |
Rust: Yes, a conscious decision because the result of
I think this is a fairly stable foundation? Each operation is executed in the order provided. Results from each execution are available in memory to be used in later executions. From the const $0 = 42;
const $1 = numbers.seven;
const $2, $value = add($0, $1); Which is fairly foundational to programming, I'd say.
Or it doesn't need to? I don't see this as a requirement. In fact I see it as a detriment. Like you mentioned, it's possible that a token processor could be written in another language and that process would also need to know the implementation of Ultimately, I'm afraid we'll need to agree to disagree about our expectations of responsibility for processing these transformations. In my eyes, I don't want to wait for a tool (eg., Figma) to launch what |
Hey @ddamato,
thank you for taking a test-drive here. I've pioneered operations/transforms (as style-dictionary is calling them) with Theemo. As I'm currently reworking theemo to support variables I also need to touch this. Of course I looked at your post, but also I wrote mine at the same time. We aren't that far off. So I'm aiming to suggest a combination of the both formats to make it a bit more readable on the syntax.
Problem: Using the array for two sort of types (primtive as value + array as function) is overloading. Then it becomes looking like a regex with
$0
and$1
.Solution: Function programming, more exactly: piping + currying (= parameters), see the great video from Scott Wlaschin.
The syntax would change to:
The input to the
opacity
function is$value
the result of that function is put into thehue
function, the result of that is the final value.Going a bit more complex with references and other tokens as input:
Let's say I do have a
opacity25
function (that always add 25% of opacity):That is the operations is an array of a string value (referring to a function) or a tuple with
[functionName, parameters]
. Paramters can be a complex object:Referring to operations as function names, gives them readability, as I know what
hue
oropacity
means, but I've almost never seen an algorithmic representation in json that was readable.About function names:
At the moment, I consider them need to be registered from the tools processing the tokens, such that style dictionary does that. We cannot even assume that the tooling is always using javascript (and therefore the node ecosystem).
Possibly: These function names are actually forward translatable into CSS functions: Which when you do a dev export of tokens (ie. even color palettes), then you can create this fluent theme generator (in a sandbox, not for production).
The text was updated successfully, but these errors were encountered: