-
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
fix(TextInput): misaligned label and helper text at different sizes #695
fix(TextInput): misaligned label and helper text at different sizes #695
Conversation
WalkthroughThe changes introduce a new story for the Changes
Possibly related PRs
Suggested labels
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
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
|
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: 3
🧹 Outside diff range and nitpick comments (3)
packages/ui-styles/src/plugins/tailwindcss/components/textInput.ts (1)
11-11
: Approved: Label position adjustment improves alignmentThe change from -37px to -33px for the label's vertical translation when focused or not empty is a good adjustment to improve the visual alignment of the text input component. This aligns well with the PR objective of fixing misaligned labels.
Consider adding a comment explaining the purpose of this adjustment, e.g.:
[`.av-text-input:focus + label[aria-hidden="true"], .av-text-input:not(:placeholder-shown) + label[aria-hidden="true"]`]: { + /* Adjust label position for better alignment when input is focused or not empty */ transform: "translate(12px, var(--av-text-input-label, -33px)) scale(0.75)", },
This will help future developers understand the reasoning behind this specific value.
packages/documentation/src/Form/TextInput.stories.tsx (1)
69-93
: Great addition of the AllSizes story!This new story effectively demonstrates the TextInput component in various sizes, which aligns well with the PR objective of addressing misaligned label and helper text at different sizes. The consistent use of helperText and label across all sizes provides a good basis for comparison.
Consider improving responsiveness
While the current implementation works, the use of fixed-height divs (h-28) for each input might limit responsiveness. Consider using a more flexible layout approach that adapts to the content size.
You could replace the fixed height with a flexible padding or margin:
- <div className="h-28"> + <div className="py-4">This change would allow the container to adapt to the content size while still providing visual separation between inputs.
packages/ui-textinput/src/components/TextInput/TextInput.tsx (1)
74-129
: Consider handling size-based styles with CSS classesDirectly manipulating styles in JavaScript can affect maintainability and performance. Consider moving size-dependent styles to CSS classes or styled-components to leverage CSS capabilities.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (5)
- packages/documentation/src/Form/TextInput.stories.tsx (1 hunks)
- packages/ui-styles/src/plugins/tailwindcss/components/textInput.ts (1 hunks)
- packages/ui-textinput/src/components/TextInput/TextInput.tsx (5 hunks)
- packages/ui-textinput/src/components/TextInput/tests/TextInput.test.tsx (1 hunks)
- packages/ui-textinput/src/components/TextInput/utilities.ts (2 hunks)
🔇 Additional comments (5)
packages/ui-textinput/src/components/TextInput/utilities.ts (1)
Line range hint
167-193
: Improved separation of concerns for height and paddingThe renaming of
sizeClass
toheightClass
and the separation of height and padding concerns are good improvements. This change enhances code readability and allows for more flexible styling options.packages/ui-textinput/src/components/TextInput/TextInput.tsx (4)
3-3
: Added necessary React hooksThe imports of
useLayoutEffect
anduseRef
are correctly added to support the new functionality.
43-45
: Initialize refs for label and helper text elementsCreating
labelRef
andhelperTextRef
usinguseRef
is appropriate for accessing DOM elements.
155-158
: AttachlabelRef
to the visible label elementAdding
ref={labelRef}
to the label element is necessary for theuseLayoutEffect
to adjust its styles.
166-169
: AttachhelperTextRef
to the helper text elementAdding
ref={helperTextRef}
to the helper text div allows for dynamic adjustment of its styles based onsize
.
packages/ui-textinput/src/components/TextInput/__tests__/TextInput.test.tsx
Show resolved
Hide resolved
Bundle Size (components)
Overall bundle size: 84.28 KB (-13 B -0.02%) Bundle Size (fingerprint)
Overall bundle size: 48.28 KB (-1 B 0.00%) Bundle Size (form components)
Overall bundle size: 50.11 KB (+216 B +0.42%) Bundle Size (system)
Overall bundle size: 50.35 KB |
🚀 Automated Release --- <details><summary>ui-anchor: 1.1.5</summary> ## [1.1.5](ui-anchor-v1.1.4...ui-anchor-v1.1.5) (2024-09-26) ### Dependencies * The following workspace dependencies were updated * dependencies * @versini/ui-button bumped to 1.1.5 * devDependencies * @versini/ui-styles bumped to 1.10.2 </details> <details><summary>ui-bubble: 1.0.5</summary> ## [1.0.5](ui-bubble-v1.0.4...ui-bubble-v1.0.5) (2024-09-26) ### Dependencies * The following workspace dependencies were updated * dependencies * @versini/ui-button bumped to 1.1.5 * @versini/ui-icons bumped to 1.12.6 * @versini/ui-private bumped to 1.4.14 * devDependencies * @versini/ui-styles bumped to 1.10.2 </details> <details><summary>ui-button: 1.1.5</summary> ## [1.1.5](ui-button-v1.1.4...ui-button-v1.1.5) (2024-09-26) ### Dependencies * The following workspace dependencies were updated * dependencies * @versini/ui-private bumped to 1.4.14 * devDependencies * @versini/ui-icons bumped to 1.12.6 * @versini/ui-styles bumped to 1.10.2 </details> <details><summary>ui-card: 1.0.5</summary> ## [1.0.5](ui-card-v1.0.4...ui-card-v1.0.5) (2024-09-26) ### Dependencies * The following workspace dependencies were updated * dependencies * @versini/ui-private bumped to 1.4.14 * devDependencies * @versini/ui-styles bumped to 1.10.2 </details> <details><summary>ui-components: 5.31.6</summary> ## [5.31.6](ui-components-v5.31.5...ui-components-v5.31.6) (2024-09-26) ### Dependencies * The following workspace dependencies were updated * dependencies * @versini/ui-anchor bumped to 1.1.5 * @versini/ui-button bumped to 1.1.5 * @versini/ui-bubble bumped to 1.0.5 * @versini/ui-card bumped to 1.0.5 * @versini/ui-footer bumped to 1.0.5 * @versini/ui-header bumped to 1.0.5 * @versini/ui-icons bumped to 1.12.6 * @versini/ui-main bumped to 1.0.5 * @versini/ui-menu bumped to 1.0.5 * @versini/ui-panel bumped to 1.0.5 * @versini/ui-pill bumped to 1.0.5 * @versini/ui-private bumped to 1.4.14 * @versini/ui-spinner bumped to 1.0.5 * @versini/ui-table bumped to 1.0.5 * devDependencies * @versini/ui-styles bumped to 1.10.2 </details> <details><summary>ui-footer: 1.0.5</summary> ## [1.0.5](ui-footer-v1.0.4...ui-footer-v1.0.5) (2024-09-26) ### Dependencies * The following workspace dependencies were updated * dependencies * @versini/ui-private bumped to 1.4.14 * devDependencies * @versini/ui-styles bumped to 1.10.2 </details> <details><summary>ui-form: 1.6.5</summary> ## [1.6.5](ui-form-v1.6.4...ui-form-v1.6.5) (2024-09-26) ### Dependencies * The following workspace dependencies were updated * dependencies * @versini/ui-textarea bumped to 1.0.4 * @versini/ui-textinput bumped to 1.1.0 * @versini/ui-toggle bumped to 1.0.4 * @versini/ui-private bumped to 1.4.14 * devDependencies * @versini/ui-button bumped to 1.1.5 * @versini/ui-icons bumped to 1.12.6 * @versini/ui-styles bumped to 1.10.2 </details> <details><summary>ui-header: 1.0.5</summary> ## [1.0.5](ui-header-v1.0.4...ui-header-v1.0.5) (2024-09-26) ### Dependencies * The following workspace dependencies were updated * dependencies * @versini/ui-private bumped to 1.4.14 * devDependencies * @versini/ui-styles bumped to 1.10.2 </details> <details><summary>ui-icons: 1.12.6</summary> ## [1.12.6](ui-icons-v1.12.5...ui-icons-v1.12.6) (2024-09-26) ### Dependencies * The following workspace dependencies were updated * dependencies * @versini/ui-private bumped to 1.4.14 * devDependencies * @versini/ui-private bumped to 1.4.14 </details> <details><summary>ui-main: 1.0.5</summary> ## [1.0.5](ui-main-v1.0.4...ui-main-v1.0.5) (2024-09-26) ### Dependencies * The following workspace dependencies were updated * dependencies * @versini/ui-private bumped to 1.4.14 * devDependencies * @versini/ui-styles bumped to 1.10.2 </details> <details><summary>ui-menu: 1.0.5</summary> ## [1.0.5](ui-menu-v1.0.4...ui-menu-v1.0.5) (2024-09-26) ### Dependencies * The following workspace dependencies were updated * devDependencies * @versini/ui-button bumped to 1.1.5 * @versini/ui-icons bumped to 1.12.6 * @versini/ui-styles bumped to 1.10.2 </details> <details><summary>ui-panel: 1.0.5</summary> ## [1.0.5](ui-panel-v1.0.4...ui-panel-v1.0.5) (2024-09-26) ### Dependencies * The following workspace dependencies were updated * dependencies * @versini/ui-button bumped to 1.1.5 * @versini/ui-icons bumped to 1.12.6 * @versini/ui-private bumped to 1.4.14 * devDependencies * @versini/ui-styles bumped to 1.10.2 </details> <details><summary>ui-pill: 1.0.5</summary> ## [1.0.5](ui-pill-v1.0.4...ui-pill-v1.0.5) (2024-09-26) ### Dependencies * The following workspace dependencies were updated * dependencies * @versini/ui-private bumped to 1.4.14 * devDependencies * @versini/ui-styles bumped to 1.10.2 </details> <details><summary>ui-private: 1.4.14</summary> ## [1.4.14](ui-private-v1.4.13...ui-private-v1.4.14) (2024-09-26) ### Dependencies * The following workspace dependencies were updated * devDependencies * @versini/ui-styles bumped to 1.10.2 </details> <details><summary>ui-spinner: 1.0.5</summary> ## [1.0.5](ui-spinner-v1.0.4...ui-spinner-v1.0.5) (2024-09-26) ### Dependencies * The following workspace dependencies were updated * dependencies * @versini/ui-private bumped to 1.4.14 * devDependencies * @versini/ui-styles bumped to 1.10.2 </details> <details><summary>ui-styles: 1.10.2</summary> ## [1.10.2](ui-styles-v1.10.1...ui-styles-v1.10.2) (2024-09-26) ### Bug Fixes * **TextInput:** misaligned label and helper text at different sizes ([#695](#695)) ([9ff6fa1](9ff6fa1)) </details> <details><summary>ui-system: 1.4.15</summary> ## [1.4.15](ui-system-v1.4.14...ui-system-v1.4.15) (2024-09-26) ### Dependencies * The following workspace dependencies were updated * dependencies * @versini/ui-private bumped to 1.4.14 * devDependencies * @versini/ui-button bumped to 1.1.5 * @versini/ui-styles bumped to 1.10.2 </details> <details><summary>ui-table: 1.0.5</summary> ## [1.0.5](ui-table-v1.0.4...ui-table-v1.0.5) (2024-09-26) ### Dependencies * The following workspace dependencies were updated * dependencies * @versini/ui-button bumped to 1.1.5 * @versini/ui-icons bumped to 1.12.6 * @versini/ui-private bumped to 1.4.14 * devDependencies * @versini/ui-styles bumped to 1.10.2 </details> <details><summary>ui-textarea: 1.0.4</summary> ## [1.0.4](ui-textarea-v1.0.3...ui-textarea-v1.0.4) (2024-09-26) ### Dependencies * The following workspace dependencies were updated * dependencies * @versini/ui-private bumped to 1.4.14 * devDependencies * @versini/ui-styles bumped to 1.10.2 </details> <details><summary>ui-textinput: 1.1.0</summary> ## [1.1.0](ui-textinput-v1.0.3...ui-textinput-v1.1.0) (2024-09-26) ### Features * **TextInput:** adding size prop ([#693](#693)) ([397d22f](397d22f)) ### Bug Fixes * **TextInput:** misaligned label and helper text at different sizes ([#695](#695)) ([9ff6fa1](9ff6fa1)) ### Dependencies * The following workspace dependencies were updated * dependencies * @versini/ui-private bumped to 1.4.14 * devDependencies * @versini/ui-button bumped to 1.1.5 * @versini/ui-icons bumped to 1.12.6 * @versini/ui-styles bumped to 1.10.2 </details> <details><summary>ui-toggle: 1.0.4</summary> ## [1.0.4](ui-toggle-v1.0.3...ui-toggle-v1.0.4) (2024-09-26) ### Dependencies * The following workspace dependencies were updated * dependencies * @versini/ui-private bumped to 1.4.14 * devDependencies * @versini/ui-styles bumped to 1.10.2 </details> <details><summary>ui-truncate: 1.0.2</summary> ## [1.0.2](ui-truncate-v1.0.1...ui-truncate-v1.0.2) (2024-09-26) ### Dependencies * The following workspace dependencies were updated * dependencies * @versini/ui-button bumped to 1.1.5 * devDependencies * @versini/ui-styles bumped to 1.10.2 </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
New Features
TextInput
component showcasing various sizes: "xs", "sm", "md", "lg", and "xl".Improvements
TextInput
component when focused or not empty.Bug Fixes
TextInput
component tests to ensure consistency.