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

[Tooltip] Improve handling of small vs. touch screens #26097

Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 16 additions & 23 deletions packages/material-ui/src/Tooltip/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ const TooltipTooltip = experimentalStyled(
},
},
)(({ theme, styleProps }) => ({
/* Styles applied to the tooltip (label wrapper) element. */
oliviertassinari marked this conversation as resolved.
Show resolved Hide resolved
backgroundColor: alpha(theme.palette.grey[700], 0.92),
borderRadius: theme.shape.borderRadius,
color: theme.palette.common.white,
Expand All @@ -129,49 +128,43 @@ const TooltipTooltip = experimentalStyled(
margin: 2,
wordWrap: 'break-word',
fontWeight: theme.typography.fontWeightMedium,
/* Styles applied to the tooltip (label wrapper) element if `arrow={true}`. */
...(styleProps.arrow && {
position: 'relative',
margin: 0,
}),
/* Styles applied to the tooltip (label wrapper) element if the tooltip is opened by touch. */
...(styleProps.touch && {
padding: '8px 16px',
fontSize: theme.typography.pxToRem(14),
lineHeight: `${round(16 / 14)}em`,
fontWeight: theme.typography.fontWeightRegular,
}),
/* Styles applied to the tooltip (label wrapper) element if `placement` contains "left". */
[`.${tooltipClasses.popper}[data-popper-placement*="left"] &`]: {
transformOrigin: 'right center',
marginRight: '24px',
[theme.breakpoints.up('sm')]: {
marginRight: '14px',
},
marginRight: '14px',
...(styleProps.touch && {
marginRight: '24px',
}),
},
/* Styles applied to the tooltip (label wrapper) element if `placement` contains "right". */
[`.${tooltipClasses.popper}[data-popper-placement*="right"] &`]: {
transformOrigin: 'left center',
marginLeft: '24px',
[theme.breakpoints.up('sm')]: {
marginLeft: '14px',
},
marginLeft: '14px',
...(styleProps.touch && {
marginLeft: '24px',
}),
},
/* Styles applied to the tooltip (label wrapper) element if `placement` contains "top". */
[`.${tooltipClasses.popper}[data-popper-placement*="top"] &`]: {
transformOrigin: 'center bottom',
marginBottom: '24px',
[theme.breakpoints.up('sm')]: {
marginBottom: '14px',
},
marginBottom: '14px',
...(styleProps.touch && {
marginBottom: '24px',
}),
},
/* Styles applied to the tooltip (label wrapper) element if `placement` contains "bottom". */
[`.${tooltipClasses.popper}[data-popper-placement*="bottom"] &`]: {
transformOrigin: 'center top',
marginTop: '24px',
[theme.breakpoints.up('sm')]: {
marginTop: '14px',
},
marginTop: '14px',
...(styleProps.touch && {
marginTop: '24px',
}),
},
}));

Expand Down