-
Notifications
You must be signed in to change notification settings - Fork 163
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
[Fix] inputClassName, containerClassName, and toggleClassName accept functions... #80
Conversation
… functions to override component className (onesine#64)
@giero, I think we are starting to have too many props for classes. We can group them all in the classNames props. But we'll have to leave the ones that are there so that those who already use the library with these props won't have problems with updates. Thank you for this PR |
If you want I could adapt |
OK, that would be great. |
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.
The same problem can occur if the user uses strings on the inputClassName
, containerClassName
and toggleClassName
props.
src/components/Input.tsx
Outdated
return typeof toggleClassName === "function" | ||
? toggleClassName(defaultToggleClassName) | ||
: typeof toggleClassName === "string" | ||
? `${defaultToggleClassName} ${toggleClassName}` |
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.
Same thing for this line
src/components/Datepicker.tsx
Outdated
typeof containerClassName === "function" | ||
? containerClassName(defaultContainerClassName) | ||
: typeof containerClassName === "string" | ||
? `${defaultContainerClassName} ${containerClassName}` |
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.
I think there will always be problems with this line.
If in containerClassName
we have text-red-400
then it will conflict with text-gray-700
of defaultContainerClassname
.
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.
Yes, and that's why I offered to use tailwind-merge to solve this issue in #68. To avoid adding it to the library, containerClassName (and other "class names") became functions to allow users to use twMerge (or other library) outside the datepicker.
But yes - if containerClassName is a string there still will be issue with this ... I left this to avoid BC break.
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.
In case containerClassName is a
- string we want to style the container with only its own utility classes then we don't need twMerge
- function we want to add utility classes to the existing ones, then we may need twMerge to avoid conflicts.
When containerClassName is not defined, we use the default style.
src/components/Input.tsx
Outdated
return typeof inputClassName === "function" | ||
? inputClassName(defaultInputClassName) | ||
: typeof inputClassName === "string" | ||
? `${defaultInputClassName} ${inputClassName}` |
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.
Same thing for this line
Whats the latest with this because I do not want to use your theming classes... |
In case containerClassName is a
When containerClassName is not defined, we use the default style. |
… functions to override component className (onesine#64)
@onesine I updated this PR to apply your suggested changes. So providing |
I should see this but I couldn't. So sorry @giero . You can resolve the conflicts and republish. |
Conflicts: src/components/Datepicker.tsx src/types/index.ts
… to override component className (#64)
This is another (i think better) approach after #68.
Now we will be able to do sth like this:
and twMerge is no longer needed inside react-tailwindcss-datepicker :)
Also fixed some minor bugs and removed unnecessary code.