style-dictionary icon indicating copy to clipboard operation
style-dictionary copied to clipboard

Feature request: transforms = transforms + transformGroups

Open funyapu opened this issue 2 years ago • 3 comments

Use case

If user want a transform addition to transformGroup, he needs to list all of the transforms in preset as well. And if he set both, no warning but just ignoring transformGroup.

Current

{ transforms: ['attribute/color'],  transformGroup: 'css' }
=> ['attribute/color'],

Expect

{ transforms: ['attribute/color'],  transformGroup: 'css' }
=> ['attribute/cti',' attribute/color', 'color/css', 'size/rem', 'name/cti/kebab' ],

It took me a while to notice this behavior....

funyapu avatar Apr 20 '22 10:04 funyapu

Thanks for bringing this up, I agree there should be a warning if a user attempts to include a transform and a transformGroup to notify them that the behavior may be different than expected.

404tonynotfound avatar Apr 28 '22 21:04 404tonynotfound

Additionally, we could add information about how this behaves to the documentation.

404tonynotfound avatar Apr 28 '22 21:04 404tonynotfound

Hi @funyapu thanks for your comment.

I believe that are correct in you assessment here and we had not considered the case in which someone tries to use both transforms and transformGroups. I believe that what happens is that the system either prioritizes transforms over transformGroups or uses whichever is the "Last In" of the two.

As for using both... unfortunately transforms are not commutative; the order of operation matters. We might do one of the following:

  1. Combine into a single configuration property that allows for both transforms and transformGroups and process them in the order provided.
  2. Add more specific documentation about not using them both at the same time and output a warning when they are

Lastly, while it might be a bit tedious, you can always register your own transform group. You can use a mixture both of custom transforms (registered via registerTransform) and existing within the library. This allows you to explicitly specify how you want to combine your transforms.

Hopefully that last platform helps you get what you need for now.

chazzmoney avatar Apr 28 '22 21:04 chazzmoney

Added to the v4 branch

jorenbroekema avatar Mar 27 '24 00:03 jorenbroekema