-
Notifications
You must be signed in to change notification settings - Fork 0
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(TextInput): adding new prop: rightElementClassName #710
feat(TextInput): adding new prop: rightElementClassName #710
Conversation
WalkthroughThe Changes
Possibly related PRs
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
Bundle Size (components)
Overall bundle size: 84.39 KB (+1 B 0.00%) Bundle Size (fingerprint)
Overall bundle size: 48.28 KB Bundle Size (form components)
Overall bundle size: 50.14 KB (+14 B +0.03%) Bundle Size (system)
Overall bundle size: 49.11 KB |
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (4)
packages/ui-textinput/src/components/TextInput/TextInputTypes.d.ts (1)
68-71
: LGTM with a minor suggestion for the JSDoc comment.The addition of the
rightElementClassName
property is well-implemented and provides useful functionality for styling the right element container. The property is correctly typed as an optional string, maintaining backward compatibility.Consider slightly modifying the JSDoc comment to be more specific:
/** - * Extra classes to add to the right element container. + * Additional CSS classes to apply to the right element container. */This change makes it clearer that these are CSS classes specifically for the container of the right element.
packages/ui-textinput/src/components/TextInput/TextInput.tsx (1)
Line range hint
1-158
: Summary of TextInput component changesThe changes to the TextInput component successfully introduce the new
rightElementClassName
prop. However, there are a couple of points that require verification:
- The implementation of
getTextInputClasses
should be checked to ensure it correctly handles the newrightElementClassName
prop.- The application of
rightElementClassName
to the right element should be verified, as there are no visible changes in the component's JSX for this.Overall, the changes align with the PR objectives, but these verifications will ensure the complete and correct implementation of the new feature.
packages/ui-textinput/src/components/TextInput/utilities.ts (1)
220-222
: LGTM with a suggestion for improvementThe implementation of
rightElementClassName
is correct and consistent with the PR objective. However, consider making the positioning more flexible:Consider separating the positioning class from the
rightElement
definition to allow more flexibility in positioning the right element. You could add a new prop likerightElementPosition
with a default value:const rightElementPosition = "absolute right-3"; const rightElement = raw ? undefined : clsx(rightElementPosition, rightElementClassName);This way, users can override the default positioning if needed.
packages/ui-textinput/src/components/TextInput/__tests__/TextInput.test.tsx (1)
263-275
: LGTM: New test case for rightElementClassNameThe new test case effectively verifies the functionality of the new
rightElementClassName
prop, which aligns with the PR objective. It correctly checks for both the custom class and the 'absolute' class on the right element.A minor suggestion for improvement:
Consider adding an assertion to verify that the input element's padding has been adjusted to account for the right element's width. This would ensure that the layout changes are also being tested. For example:
const input = screen.getByLabelText('toto'); expect(input).toHaveStyle('padding-right: /* expected value */');Replace
/* expected value */
with the actual expected padding value based on your implementation.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (4)
- packages/ui-textinput/src/components/TextInput/TextInput.tsx (2 hunks)
- packages/ui-textinput/src/components/TextInput/TextInputTypes.d.ts (1 hunks)
- packages/ui-textinput/src/components/TextInput/tests/TextInput.test.tsx (2 hunks)
- packages/ui-textinput/src/components/TextInput/utilities.ts (3 hunks)
🔇 Additional comments (9)
packages/ui-textinput/src/components/TextInput/TextInputTypes.d.ts (1)
Line range hint
1-71
: Verify changes against PR objectives and assess overall impact.The changes in this file align perfectly with the PR objective of adding a new prop
rightElementClassName
to the TextInput component. The implementation:
- Adds the new optional property to the
TextInputProps
type.- Provides appropriate JSDoc documentation for the new property.
- Maintains backward compatibility by making the property optional.
The addition enhances the component's flexibility for styling the right element container without affecting existing functionality.
To ensure consistency across the codebase, let's verify the usage of this new prop:
This script will help us verify that the new prop is properly implemented in the component, covered in tests, and documented if necessary.
packages/ui-textinput/src/components/TextInput/TextInput.tsx (3)
32-32
: LGTM: New proprightElementClassName
addedThe addition of the
rightElementClassName
prop is in line with the PR objective and is correctly placed in the component's prop list.
Line range hint
141-146
: Verify application ofrightElementClassName
The
rightElementClassName
prop has been added, but there are no visible changes to the rendering of the right element. Please ensure that the new class is being correctly applied to the right element.To verify the correct application of
rightElementClassName
, please check the implementation ofgetTextInputClasses
and confirm that it's correctly incorporating this new prop into therightElement
class. You can use the following script to inspect the relevant code:#!/bin/bash # Description: Verify the handling of rightElementClassName in getTextInputClasses # Test: Search for rightElement class generation in getTextInputClasses rg --type typescript -A 5 'rightElement.*Class' packages/ui-textinput/src/components/TextInput/utilities.tsIf the
rightElementClassName
is not being applied, consider updating the component to use it directly:{rightElement && ( <div ref={rightElementRef} - className={textInputClassName.rightElement} + className={`${textInputClassName.rightElement} ${rightElementClassName || ''}`} > {rightElement} </div> )}
66-66
: LGTM:rightElementClassName
added togetTextInputClasses
The
rightElementClassName
prop is correctly passed to thegetTextInputClasses
function, which is necessary for incorporating the new styling capability.To ensure the
getTextInputClasses
function is correctly implemented to handle this new prop, please run the following script:packages/ui-textinput/src/components/TextInput/utilities.ts (3)
22-22
: LGTM: New property added correctlyThe addition of
rightElementClassName
as an optional string property is consistent with the PR objective and follows the existing pattern for className properties.
158-158
: LGTM: Function parameter added correctlyThe
rightElementClassName
parameter has been correctly added to thegetTextInputClasses
function, maintaining consistency with the type definition and PR objective.
Line range hint
1-233
: Summary: Implementation successfully adds new rightElementClassName propThe changes in this file successfully implement the new
rightElementClassName
prop for the TextInput component. The implementation is consistent, well-typed, and integrates smoothly with the existing code structure. A minor suggestion was made to improve flexibility in positioning, but overall, the changes meet the PR objective and maintain good code quality.packages/ui-textinput/src/components/TextInput/__tests__/TextInput.test.tsx (2)
Line range hint
237-262
: LGTM: Improved test case namingThe change in the test case name from "should render a text input with an input class" to "should render a text input with a custom input class" improves clarity. It better describes the specific scenario being tested, which is the application of a custom class to the input element.
Line range hint
1-375
: Summary: Improved test coverage for TextInput componentThe changes in this file effectively address the PR objective of adding support for the new
rightElementClassName
prop. The additions and modifications to the test cases enhance the overall test coverage of the TextInput component. Specifically:
- The renaming of an existing test case improves clarity.
- The new test case for
rightElementClassName
ensures that the new functionality is properly tested.These changes contribute to maintaining the reliability and robustness of the TextInput component. Good job on keeping the test suite up-to-date with the component's evolving functionality.
🚀 Automated Release --- <details><summary>ui-form: 1.6.12</summary> ## [1.6.12](ui-form-v1.6.11...ui-form-v1.6.12) (2024-09-30) ### Dependencies * The following workspace dependencies were updated * dependencies * @versini/ui-textinput bumped to 1.2.0 </details> <details><summary>ui-textinput: 1.2.0</summary> ## [1.2.0](ui-textinput-v1.1.6...ui-textinput-v1.2.0) (2024-09-30) ### Features * **TextInput:** adding new prop: rightElementClassName ([#710](#710)) ([0374ebe](0374ebe)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: aversini <[email protected]>
Summary by CodeRabbit
rightElementClassName
, for enhanced styling of the right element in the TextInput component.