Add functional form for classNames#533
Closed
rhdeck wants to merge 15 commits into
Closed
Conversation
Owner
|
Hey @rhdeck, I'm currently testing your changes. I never used tailwind but I've always wanted to 😄. You just gave me a good excuse to do so. Thank you for the quality of the PR, really appreciate that. |
fkhadra
requested changes
Oct 15, 2020
Owner
fkhadra
left a comment
There was a problem hiding this comment.
Currently, we pass the type and the default classes. Shouldn't we pass the position as well, what do you think ?
…ion that Toastcontainer is resolving the function
…nly shows the useful arguments
Contributor
Author
|
Implemented requested fixes, updated the PR overview to reflect it, and made two additional improvements:
|
fkhadra
approved these changes
Oct 22, 2020
Owner
fkhadra
left a comment
There was a problem hiding this comment.
I'll merge it during the week end. Thanks for the work !
Owner
|
Your PR landed in v6.1.0 |
|
I think the docs still need to be updated, but this has made styling react-toastify so much easier! 🚀 |
Owner
|
Yeah indeed. I'll try to update it this week. |
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.
Summary
Disconnect react-toastify from its SCSS classes by passing replacement className props as functions that contain context.
Problem
If one wants to use a utility class framework (Tailwind!)
Solution
Three props get changed to a function - or - string API:
Toast.classNameToast.bodyClassName(andToastContainer.toastClassName)Toast.progressBarClassName(andToastContainer.progressBarClassName)The string API works as it did before - class(es) added through this prop are mixed via
cxwith the toastify classes compiled from CSSThe functional API takes an arrow function (or
useCallbackreturn value) to set the string based on contextual informationThe
ToastContainer.classNamealso takes a functional form, though without thetypeprop:The functional API takes an arrow function (or
useCallbackreturn value) to set the string based on contextual informationThis allows one to create code flows that determine which string to draw based on the type, and choose whether to mix in the default classes.
Example
A tailwind CSS/UI styled notification, without editiing SCSS.
Checklist:
@raydeck/react-toastifyuntil this gets merged)Next steps post-merge
DONE Most likely other context args should get pulled in for a more powerful API. RTL? Position?
Before submitting a pull request, please make sure the following is done:
master.yarnin the repository root.yarn test).yarn startto test your changes in the playground.yarn prettier-all).yarn lint:fix).Learn more about contributing here