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 getClassOrder instead of sortClassList #7459

Merged
merged 3 commits into from Feb 16, 2022
Merged

Conversation

RobinMalfait
Copy link
Contributor

@RobinMalfait RobinMalfait commented Feb 14, 2022

This PR implements a getClassOrder instead of sortClassList.

Had a conversation with @bradlc and while sorting in Tailwind itself works, it can happen that instead of placing unknown classes in the front that you want to put it in the back. This is an option that we can expose in the prettier-plugin-tailwindcss if we event want to do that. But if we want those options in Tailwind itself then we have to keep an options object into account or even more unknown complex scenarios.
So instead we will expose a getSortOrder that will return a list of tuples with the className and the order it appears in the final css when we generate it.

  • Note: the order value is a bigint and the first value in the css will be the lowest number, the last value in the css will be the highest number. Those numbers are not per se consecutive.

Now the prettier-plugin-tailwindcss can sort the classes based on configuration settings in the plugin and using the information we expose via the getClassOrder .

When a class is passed to the function that doesn't exist, then the sort value will be set to null.

If we in the future want to change the sort algorithm internally, then we can expose the same list but maybe with different numbers as long as they stay in order.

Remaining questions:

  • Is the name getSortOrder good, or do we prefer something like getClassOrder (similar to the already existing getClassList)? Renamed it to getClassOrder

@RobinMalfait RobinMalfait changed the title Implement getSortOrder instead of sortClassList Implement getClassOrder instead of sortClassList Feb 15, 2022
@RobinMalfait RobinMalfait merged commit 63537aa into master Feb 16, 2022
@RobinMalfait RobinMalfait deleted the get-sort-order branch February 16, 2022 10:03
tmattio added a commit to tmattio/opam-repository that referenced this pull request Apr 9, 2022
CHANGES:

### Fixed

- Remove opacity variables from `:visited` pseudo class ([tmattio/opam-tailwindcss#7458](tailwindlabs/tailwindcss#7458))
- Support arbitrary values + calc + theme with quotes ([tmattio/opam-tailwindcss#7462](tailwindlabs/tailwindcss#7462))
- Don't duplicate layer output when scanning content with variants + wildcards ([tmattio/opam-tailwindcss#7478](tailwindlabs/tailwindcss#7478))
- Implement `getClassOrder` instead of `sortClassList` ([tmattio/opam-tailwindcss#7459](tailwindlabs/tailwindcss#7459))
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.

None yet

1 participant