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.
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
feat: [sc-25878] Implement Checkbox Component in NameKit React #453
feat: [sc-25878] Implement Checkbox Component in NameKit React #453
Changes from 21 commits
c9733c2
a9e4ea5
2dbdc1f
2f91c7e
f40de57
1a4637d
5023c12
1ccd60f
549f14e
d06a0fe
12dce64
9e68b88
521c11c
88f9e64
3fd741f
808ee4e
bd470b8
5bb25cb
a227968
d3524e8
8237d32
870fe0b
8bed736
c5d18fa
9d14070
0608340
a36383a
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
@eduramme This story isn't working for me. I can't check the checkbox. Can you please investigate?
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.
@eduramme This story isn't working for me. I can't uncheck the checkbox. Can you please investigate?
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.
@eduramme Hey I don't think we should make the "advanced children" part of the area that toggles the checkbox in this story. We should have the UX in this story work similar to how everything works in the NameGuard settings modal.
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'm not sure what the best practice is here. It's interesting for me how children isn't required to be a single node? For example, here I see
children
defined as twonodes that are siblings. Can you please advise if this is ok, or if we should change anything so that
children
is always a single node? For example, force someone to wrap two siblingnodes in a parent
children
?Appreciate your advice 👍
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 children prop is not restricted to a single node. It can be a single node, multiple nodes, or even a string. This flexibility allows for more dynamic and composable UI structures. Having two node elements as children of the Checkbox component is perfectly fine.
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 don't think it's best that we would also make the descriptive text here as part of the hover / click area for the checkbox. Only the label for the textbox "Trim whitespace" should be part of the hover / click area. "Remove any leading or trailing whitespace characters before performing inspection." should not be part of the hover / click area and shouldn't be a child of
<Checkbox>
.What do you think? Appreciate your advice 👍
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.
Sounds good. We will have that empty space, that will be covered by some padding or margin. Do you think it's a bad idea to create a "description" prop for the Checkbox component?
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.
This way, we could ensure that text is alined with the label
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'm thinking it's best that we not apply any classes to the
children
insideCheckbox
. It seems better composability to me to just pass in {children} without any classes at all. This includes for the "disabled" case. If someone wants to apply special logic for disabled on children, they should manually implement that in their own child styles.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.
@lightwalker-eth Any styles the user applies to the label will replace the default ones we set. Adding classes to the checkbox’s children can make things easier, especially if the user just passes a simple string (which is probably what most people will do).
Also, keep in mind that the label and checkbox are separate HTML elements. If the user wants, they can create a custom setup like this:
The main benefit of including the label inside the checkbox component is that it’s already styled, so the user doesn’t have to think much about it (it just works out of the box).
Makes sense?
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.
@eduramme Appreciate this perspective. I've been thinking differently, but will approved to unblock this goal for us 👍 Thanks
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.
A few questions here:
namekit-react
, should we update this documentation in the README.md file in the root of our monorepo?namekit/README.md
Lines 518 to 522 in 85c8370
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.
This instruction only needs to be followed if the user imports our
Input
component fromnamekit-react
. Other components, like our checkbox, are already compatible with the@tailwindcss/forms
reset, so no additional configuration is needed for them. However, if the user imports theInput
component and applies a global CSS reset (such as@tailwindcss/forms
or similar), it may cause unintended styling issues with theInput
component.To avoid these issues, users who import our
Input
component should follow the instructions to configure@tailwindcss/forms
with the class strategy, or alternatively, we could add the reset class directly to theInput
component to ensure it displays correctly in any setup.The
@tailwindcss/forms
plugin is basically a CSS reset focused on form elements. Browsers come with their own default styles for things like checkboxes, inputs, and textareas, which can make it tough to get a consistent look with Tailwind. This plugin wipes those defaults, making it easier to style form components the way we want.We added
@tailwindcss/forms
tonamekit-react
because our checkbox component already depends on that reset to look right. But ourInput
component doesn’t account for this reset yet. So, if someone using our package applies a global CSS reset on form elements, it can make ourInput
look weird.One way to handle this and get rid of the warning is to add the
@tailwindcss/forms
reset class directly to ourInput
component. That way, even if the user has a global CSS reset, ourInput
won’t be affected.This isn’t just a
@tailwindcss/forms
issue, it could happen with any CSS reset. We just noticed it specifically with@tailwindcss/forms
because we were using it globally on Nameguard, which made theInput
component look weird in forms there.To wrap things up, this is a very specific issue, it only occurs if the user imports the
Input
component fromnamekit-react
and has a CSS reset applied globally to form elements. Given how specific this is, I believe we have three options:A: Remove the comment and let the user figure it out independently if that rare scenario happens.
B: Add the
@tailwindcss/forms
reset to ourInput
component.C: Include a more generic warning, such as:
"This package includes custom styles that may be affected by other CSS resets or frameworks (e.g., Tailwind CSS forms). If you encounter unexpected styling issues, consider checking for conflicts with any global or opinionated CSS resets in your project."
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.
That's what happens with our contact form, for example
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.
@lightwalker-eth I’ve added a few reset classes to our Input component and removed the warning about Tailwind forms.
870fe0b