-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
InputControl: Decrease large default padding if has prefix/suffix #42166
Conversation
prefix: <span style={ { marginInlineStart: 8 } }>@</span>, | ||
}; | ||
|
||
export const WithSuffix = Template.bind( {} ); | ||
WithSuffix.args = { | ||
...Default.args, | ||
suffix: <button style={ { marginRight: 4 } }>Send</button>, | ||
suffix: <button style={ { marginInlineEnd: 4 } }>Send</button>, |
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.
Tweaked examples for better RTL.
@@ -18,22 +18,13 @@ type SelectProps = { | |||
|
|||
type InputProps = { | |||
disableUnits?: boolean; | |||
size: SelectSize; |
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.
Unrelated, but minor cleanup of an unused type.
const paddingStyles = ( { disableUnits }: InputProps ) => { | ||
if ( disableUnits ) return ''; | ||
|
||
return css` | ||
${ rtl( { paddingRight: 8 } )() }; | ||
`; | ||
}; | ||
|
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.
CSS override removed 🎉
Btw @aaronrobertshaw: When building BorderControl
, do you remember if there were any blockers to rendering the BorderControlDropdown
as a prefix
on the UnitControl
? I'm wondering if we can remove some CSS overrides in there too if this PR lands.
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.
My memory is failing me on this one, I don't recall any blockers. It might have been as simple as I didn't see the prefix
prop in the UnitControl
readme and didn't follow the props through to the underlying InputControl
.
It also looks like we might need to tweak the UnitControl
types, as attempting to pass the border control dropdown via a prefix
prop on the UnitControl
results in a type error that it expects prefix
to be string | undefined
.
I'd be happy to work on rendering the border control's dropdown as a prefix in a follow up to this PR.
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 sounds great, thanks! It's nice to see things getting less hacky as we converge on common patterns 🙂
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've put together a PR (#42212) that now renders the dropdown via the UnitControl
prefix and attempts to clean up the styles. There could still be more to polish on that control when it comes time to add a large 40px size variant.
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 just left a couple of comments related more to the implementation details of these changes, but the overall direction of the PR looks good, and the changes test well in Storybook!
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 is looking good and tests well for me 👍
✅ With Prefix/Suffix stories maintain 8px
padding regardless of size
variant
✅ Padding functions consistently when in RTL mode
✅ No regressions for UnitControl in Storybook
✅ UnitControl tests pass
packages/components/src/input-control/styles/input-control-styles.tsx
Outdated
Show resolved
Hide resolved
Currently But I agree that it's kind of necessary that the prefix/suffix elements know what the standard padding is for a given size variant. As a follow-up task, I'll see if I can propose something where |
Solution proposed in #42378 👍 This PR can proceed independently of that PR though. |
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.
Given previous conversations and the follow-up already opened in #42378, I believe we can go ahead and merge this one 🚀
What?
Ensures that the padding between the
prefix
/suffix
and the text input doesn't get too big in the large size variant of the component.Why?
The large size variant of the component increases the side paddings of the text input to 16px (previously 8px). In most cases, this is too big when using with a
prefix
orsuffix
element. Some actual examples of this can be seen in the large variants ofUnitControl
andColorPicker
:How?
Added an internal API to specify custom side padding on the
InputField
subcomponent. This API is internal-only for now, and is meant to minimally satisfy the internal customization needs in the components library. Though, I tried to make it generic enough so it would be easy to expose the API externally onInputControl
itself, if we want to do so in the future.Testing Instructions
npm run storybook:dev
size
variant. This should also work in RTL mode.Screenshots or screencast