Closed Razinsky closed 3 weeks ago
Latest commit: c8e5203477aeffc795e36b514441700906f1c0af
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Great! I cleaned things up a bit:
Thanks for contributing!
Excellent 👌 Thanks @jorenbroekema ! It's great to see your additions, this will be helpful for my next contribution ;)
Quick question: what is your stance regarding the use of the options
object? I was under the impression that this was the right way to go when it comes to adding custom "options" to our Style Dictionary config. I see that you pull the new variable out to be at the same level as the rest of the config.
Ah now that you mention it, it should probably be this:
transform: (token, platform) => checkAndEvaluateMath(token, platform.mathFractionDigits),
The current code also happens to work because platform options tend to be put on the config.options object, but it's not exactly its intention to use it like that, if readonly props were a thing in javascript then this would be one.
https://github.com/tokens-studio/sd-transforms/pull/295 fixing it here
Fixes #289
This PR adds a new platform config option called
mathFractionDigits
to control the rounding of values when resolving math.The current hardcoded value found here is
3
and one could potentially need this value to be any number.⚠️ I suggest making the default value
4
as it tends to make more sense when trying to convertpx
toem
andrem
, but this is debatable. We might prefer to avoid breaking changes and keep3
as default.The variable name
mathFractionDigits
was borrowed from the.toFixed()
function whose first argument isfractionDigits
to which I prependedmath
for better context in relationship with the TS transformresolveMath
. This is also to be discussed.Usage