Implement getClassOrder instead of sortClassList#7459
Merged
RobinMalfait merged 3 commits intomasterfrom Feb 16, 2022
Merged
Conversation
getSortOrder instead of sortClassListgetClassOrder instead of sortClassList
2352979 to
c6ebd5b
Compare
c6ebd5b to
b1fd1dd
Compare
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))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements a
getClassOrderinstead ofsortClassList.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-tailwindcssif 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
getSortOrderthat will return a list of tuples with the className and the order it appears in the final css when we generate it.Now the
prettier-plugin-tailwindcsscan sort the classes based on configuration settings in the plugin and using the information we expose via thegetClassOrder.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 nameRenamed it togetSortOrdergood, or do we prefer something likegetClassOrder(similar to the already existinggetClassList)?getClassOrder