Skip to content
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

Adding props to Checkbox component #1371

Merged
merged 49 commits into from
Jul 6, 2023
Merged

Conversation

xman343
Copy link
Contributor

@xman343 xman343 commented Jun 20, 2023

Changes

Adding the option for customizable wrapper props to be added to the Checkbox component. Issue: #1368

Testing

React unit testing and visual testing undertaken.

Docs

Docs will be updated to outline wrapperProps utility.

@xman343 xman343 self-assigned this Jun 21, 2023
@xman343 xman343 changed the title Adding wrapper props to Checkbox component Adding props to Checkbox component Jun 21, 2023
@xman343 xman343 marked this pull request as ready for review June 22, 2023 18:05
@xman343 xman343 requested review from a team as code owners June 22, 2023 18:05
@xman343 xman343 requested review from gretanausedaite and adamhock and removed request for a team June 22, 2023 18:05
@xman343
Copy link
Contributor Author

xman343 commented Jun 22, 2023

Just remembered I need to update the entry in Docs - I'll do that very soon!

Copy link
Contributor

@adamhock adamhock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure you add a changeset and link the issue number that this PR is referencing in the PR description

@xman343
Copy link
Contributor Author

xman343 commented Jun 28, 2023

Make sure you add a changeset and link the issue number that this PR is referencing in the PR description

Done

'@itwin/itwinui-react': major
---

Added wrapperProps to allow for styling of CheckBox wrapper.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update changeset with all changes you've made

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

as='span'
className={
(cx('iui-checkbox-label'),
labelClassName ? labelClassName : className)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this code, if user has labeled checkbox and adds custom-classname, but not labelClassName/wrapperClassName, html structure would be this:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote it like that so that the label and wrapper would share a className with the parent component by default, unless the user goes out of their way to specify custom classNames for label and wrapper. Should their classNames both be different by default?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why they need to share className?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They don't have to, I just figured some users might want them to. If they shouldn't share classNames by default, then I'll change the code so they don't

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If user wants to add styles to certain part of component, they need to use props for that part of component.
Remove this check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified "Should isomorphically apply class on %s" to only test input, and also removed the final failing test.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is no longer isomorphic so it's not testing anything special and can be removed

imo you should have a single unit test that tests adding separate custom classes all three elements (className, labelProps, wrapperProps)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're only testing two cases in there, missing a test for className which gets applied on the input.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

Copy link
Contributor

@adamhock adamhock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few nitpicky comments about the unit tests, but other than that, things look good to me!

Copy link
Contributor

@adamhock adamhock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once the changeset description changes, it's ready to go! 🎉 Great work

@xman343 xman343 added this pull request to the merge queue Jul 6, 2023
@xman343 xman343 removed this pull request from the merge queue due to a manual request Jul 6, 2023
@xman343
Copy link
Contributor Author

xman343 commented Jul 6, 2023

Once the changeset description changes, it's ready to go! 🎉 Great work

done!

@xman343 xman343 enabled auto-merge July 6, 2023 17:34
@xman343 xman343 added this pull request to the merge queue Jul 6, 2023
Merged via the queue into dev with commit af35094 Jul 6, 2023
@xman343 xman343 deleted the adding-input-props-to-components branch July 6, 2023 17:55
@mayank99 mayank99 mentioned this pull request Jul 6, 2023
32 tasks
@imodeljs-admin imodeljs-admin mentioned this pull request Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants