-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[InputAdornment][material-next] Add InputAdornment component #39722
Conversation
Netlify deploy previewhttps://deploy-preview-39722--material-ui.netlify.app/ @mui/material-next: parsed: +0.54% , gzip: +0.27% Bundle size reportDetails of bundle changes (Toolpad) |
c18b6b3
to
4ff27b0
Compare
Waiting for #39483 to be merged before working on the layout changes involving the label and start adornment |
451c929
to
26718f7
Compare
beb2161
to
2f7a97c
Compare
2f7a97c
to
7e41c33
Compare
03bc8bd
to
d4032a9
Compare
6413e92
to
6662291
Compare
7b0c65b
to
3f66cba
Compare
3f66cba
to
11e584c
Compare
Would like to ask @zanivan & @DiegoAndai for an initial review of the design changes in this PR (details here) I've added some knobs on the experiments page to toggle The code is also close to review-able, it could use an extra round of polish after the design is reviewed and there may be some CSS that could be further tokenized into css variables Demo: https://deploy-preview-39722--material-ui.netlify.app/experiments/md3/inputs/ |
...(ownerState.formControl?.adornedStart && | ||
!ownerState.formControl?.adornedEnd && { | ||
transform: 'translate(52px, 7px) scale(0.75)', | ||
maxWidth: 'calc(133% - 32px - 48px - 8px)', |
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.
When it's in the shrink
state, the correct maxWidth adjustment seems to be "adjust by 48px per adornment, then adjust by another 8px", though I'm not 100% sure if this is a real "pattern" or if my mind is just trying to fill in the gaps 😅
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.
😅 Where do you think the additional 8 might come from?
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.
Overall looks good 😊
Let me know if you need brainstorming on the CSS variables or structure.
I'll do the final review after any design changes required.
|
||
expect(adornment).to.have.class(classes.root); | ||
expect(adornment).to.have.class(classes.positionEnd); | ||
}); | ||
|
||
describe('prop: variant', () => { | ||
it("should inherit the TextField's variant", () => { | ||
// TODO v6: requires material-next/TextField |
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.
// TODO v6: requires material-next/TextField | |
// TODO v7: requires material-next/TextField |
@@ -88,7 +104,9 @@ describe('<InputAdornment />', () => { | |||
expect(adornment).to.have.class(classes.filled); | |||
}); | |||
|
|||
it('should override the inherited variant', () => { | |||
// TODO v6: requires material-next/TextField |
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.
// TODO v6: requires material-next/TextField | |
// TODO v7: requires material-next/TextField |
...(ownerState.formControl?.adornedStart && { | ||
transform: 'translate(52px, 13px) scale(1)', | ||
}), |
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.
Why only for the adornedStart
?
@@ -88,17 +88,61 @@ const InputLabelRoot = styled(FormLabel, { | |||
pointerEvents: 'none', | |||
transform: 'translate(16px, 16px) scale(1)', | |||
maxWidth: 'calc(100% - 24px)', |
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.
What are the base - 24px
for?
...(ownerState.formControl?.adornedStart && | ||
!ownerState.formControl?.adornedEnd && { | ||
transform: 'translate(52px, 7px) scale(0.75)', | ||
maxWidth: 'calc(133% - 32px - 48px - 8px)', |
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.
😅 Where do you think the additional 8 might come from?
color: 'var(--md-comp-input-adornment-color)', | ||
...(ownerState.position === 'start' && { | ||
// Styles applied to the root element if `position="start"`. | ||
marginRight: 16, |
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.
Closes: #39628
Could also fix: #13898
Changes
The positioning of the Label components relative to the InputAdornment has changed from v5 to match the MD3 specs [InputAdornment][material-next] Add InputAdornment component #39628 (comment)
The label is not initially shrunken if there is a startAdornment but no value [TextField][InputAdornment] InputLabel should not start shrunken if TextField has an InputAdornment #13898
I have followed (at least) the PR section of the contributing guide.