Skip to content

Conversation

@RobinMalfait
Copy link
Member

@RobinMalfait RobinMalfait commented Feb 10, 2022

This PR will use Tailwind's exposed context.getClassOrder(classes) function instead. This will allow us to have some special cases in Tailwind itself (e.g.: group and peer). But it will also make sure that the actual sorting logic stays in this plugin.

Tailwind will just expose the information required to be able to sort classes correctly. When classes are unknown, the sort order will be set to null.

Fixes: #53

@RobinMalfait RobinMalfait force-pushed the use-tailwind-sortclasslist branch from 4d83ef2 to a398cd2 Compare February 10, 2022 17:11
@RobinMalfait RobinMalfait requested a review from bradlc February 10, 2022 17:30
We have to keep the existing code for now, since the plugin will prefer
the user's tailwind version. Hopefully we can remove this in future
versions.
@RobinMalfait RobinMalfait force-pushed the use-tailwind-sortclasslist branch from 78acda5 to dd6c762 Compare February 16, 2022 11:30
@RobinMalfait RobinMalfait changed the title Use Tailwind's context.sortClassList(classes) Use Tailwind's context.getClassOrder(classes) Feb 16, 2022
This will also add the `group` and `peer` for older versions of Tailwind
CSS
@RobinMalfait RobinMalfait force-pushed the use-tailwind-sortclasslist branch from dd6c762 to d397efe Compare February 16, 2022 12:05
@bradlc bradlc merged commit 90f6536 into main Feb 21, 2022
@bradlc bradlc deleted the use-tailwind-sortclasslist branch February 21, 2022 18:23
bronisMateusz pushed a commit to bronisMateusz/prettier-plugin-tailwindcss-drupal that referenced this pull request Apr 16, 2025
* prefer Tailwind's `context.getClassOrder()` if it exists

We have to keep the existing code for now, since the plugin will prefer
the user's tailwind version. Hopefully we can remove this in future
versions.

* bump tailwindcss dependency

* add full getClassOrder polyfill

This will also add the `group` and `peer` for older versions of Tailwind
CSS

* Update `getClassOrder` polyfill to support all Tailwind v3 releases

* Add "parasite utilities" test

Co-authored-by: Brad Cornes <[email protected]>
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

Successfully merging this pull request may close these issues.

group is sorted before custom classes

3 participants