hymhub / css-to-tailwind

Convert CSS code to Tailwindcss syntax in real time
https://hymhub.github.io/css-to-tailwind/
MIT License
372 stars 23 forks source link

Remove `transform` class #11

Closed jorgezreik closed 1 year ago

jorgezreik commented 1 year ago

Context

The translator has code that emits the transform class whenever a transform property (e.g., translate, rotate, or scale) is detected. This is the code responsible:

return canUse ? `transform ${[...new Set(res)].join(' ')}` : `[transform:${getCustomVal(val)}]`;

Here is an example of the Tailwind emitted:

Screenshot 2023-08-04 at 5 40 03 PM

Problem

According to the Tailwind 2 documentation transform is a class that exists in Tailwind 2. However, the Tailwind 3 documentation makes no mention of this class.

Further analysis in the CSS inspector reveals that transform applies the same CSS that the translate, rotate, and scale classes do. Thus, it is not necessary.

Screenshot 2023-08-04 at 5 45 19 PM

Solution

We simply remove the word transform from the output of transform class generation.

return canUse ? `${[...new Set(res)].join(' ')}` : `[transform:${getCustomVal(val)}]`;