Skip to content
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

Implement some functionality to translate any kind of value to the correct export format #10

Open
apresmoi opened this issue Dec 2, 2022 · 2 comments
Assignees

Comments

@apresmoi
Copy link
Collaborator

apresmoi commented Dec 2, 2022

As pointed out in #8, every format that we currently allow to export have different limitations and ways to represent the data.

For example, the DTCG format only allows "duration" kind of tokens to be expressed as miliseconds (ms), on the other hand CSS or SASS also allows you to use seconds/miliseconds.

So, for this specific case, duration in the app should allow seconds/miliseconds.

Screen Shot 2022-12-02 at 13 34 04

But when you export to DTCG should look something like:

"Duration": {
  "$type": "duration",
  "slow": {
    "$value": "3000ms"
  },
  "fast": {
    "$value": "500ms"
  }
}

We have some other differences. For exampe for the cubicBezier token type in the DTCG format. While in CSS/SCSS we can export easing functions as linear | cubic-bezier | steps-function the DTCG format only allows you to use cubic-bezier.

In the case we have something like the following:

Screen Shot 2022-12-02 at 13 47 09

We should export these tokens with the correct type for each:

"Easing": {
  "easeStep": {
    "$type": "string",
    "$value": "steps(10, end)"
  },
  "easeLinear": {
    "$type": "string",
    "$value": "linear"
  },
  "easeInSine": {
    "$type": "cubicBezier",
    "$value": [0.12, 0, 0.39, 0]
  }
}

The type for the token should be obtained from the actual value of the token in the UI, and then properly translated every format.

Let's say that we have several tokens in a group and all those tokens share the same token type, we should set the type in the group and not directly in the token, like so:

Screen Shot 2022-12-02 at 14 13 52

"Easing": {
  "$type": "cubicBezier",
  "easeInSine": {
    "$value": [0.12, 0, 0.39, 0]
  },
  "easeOutSine": {
    "$value": [0.61, 1, 0.88, 1]
  }
}
@mhechavarria
Copy link
Contributor

Can I give this a try?

@apresmoi
Copy link
Collaborator Author

apresmoi commented Dec 2, 2022

Of course @mhechavarria ! I'll assign it to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants