-
Notifications
You must be signed in to change notification settings - Fork 808
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
Resolves #37695 - Use clsx instead of classnames #37708
Conversation
cd2abf7
to
7fd3546
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable to me. A few suggestions for simplifying the dedupe replacement inline.
projects/plugins/jetpack/extensions/blocks/videopress/deprecated/v2/utils.js
Outdated
Show resolved
Hide resolved
projects/plugins/jetpack/extensions/blocks/videopress/deprecated/v2/utils.js
Outdated
Show resolved
Hide resolved
Co-authored-by: Brad Jorsch <anomiex@users.noreply.github.com>
Co-authored-by: Brad Jorsch <anomiex@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Not hitting "Approve" just yet to give Agora a chance to review.
Just a quick drive-by comment, I was the one who originally started this transition and was personally responsible for the Gutenberg PR. I managed to replace the dedupe usages without much complex logic or the new dependency you're using here. The code affected seems very similar, probably copy-pasted. I suggest you take a look at what I did there in case it helps you simplify this PR and achieve better consistency. Note that I don't remember the exact approach I took, but I might have decided to simply not dedupe at all in some cases, since it doesn't really affect any functionality and the trade-off of doing the computation is probably not worth it in the first place. Just a suggestion :) thanks for applying this transition here <3 |
You may want to double-check that.
|
Ah, yep I replaced that behavior with a very very simple alternative. If you dig in my PR you'll find my approach. With that sentence in my comment I meant cases where the resulting class name is something like "class class". |
Glancing at your PR, the following seem likely to be broken to me
Also, in https://github.com/WordPress/gutenberg/blob/200f7c7a210c35eb9c004da9a3e4f1062f471d57/packages/block-library/src/embed/util.js#L191-L193 you might mangle things if a class in |
The one
I can't speak to the origin of the code, but in this case it was an independent refactor; looking now at that other PR it seems the goal is slightly different, but luckily it isn't too complex! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just got an eyes on VideoPress and AI stuffs. LGTM
* Add rule to disallow `classnames` * Initial pass * `classnames/dedupe` → `@wordpress/token-list` * Add changelog * Use valid changelog types * Remove file from eslint exclusions * Change post-rebase use of classnames * More changelog format compliance fixes * Bump versions
Internal announcement: pdWQjU-Mt-p2 |
Resolves #37695 - Use clsx instead of classnames
Proposed changes:
clsx
is faster and smaller thanclassnames
. Also, it is now used in Calypso (Automattic/wp-calypso#91408), in Gutenberg (WordPress/gutenberg#61138), and in@wordpress
packages.For consistency, this PR matches those changes:
classnames
: 6b5518dclassnames
was replaced withclsx
: b45ef16classnames/dedupe
does not have an equivalent (a dedupe version? lukeed/clsx#13), so its one use was refactored using@wordpress/token-list
: a060f54Caveats:
jetpack-mu-wpcom
has its own implementation ofclassNames
; I've left that intact for now. If desired, we can take a look in a separate PR.@automattic/social-previews
is a dependency, and the latest published version (2.0.1-beta.13
) still has aclassnames
dependency. This was removed in the aforementioned Calypso PR, but as of yet has not been published.Internal reference: p4TIVU-aYc-p2
Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
Check the code for any typos or mistakes. Pay particularly close attention to the dedupe refactor.