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

[Button] Fix vertical text alignment by reducing padding #13931

Merged
merged 2 commits into from
Dec 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions docs/src/pages/demos/buttons/CustomizedButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ import purple from '@material-ui/core/colors/purple';
import green from '@material-ui/core/colors/green';

const styles = theme => ({
container: {
display: 'flex',
flexWrap: 'wrap',
},
margin: {
margin: theme.spacing.unit,
},
Expand Down Expand Up @@ -69,7 +65,7 @@ function CustomizedInputs(props) {
const { classes } = props;

return (
<div className={classes.container}>
<div>
<Button
variant="contained"
color="primary"
Expand Down
12 changes: 6 additions & 6 deletions packages/material-ui/src/Button/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ import { capitalize } from '../utils/helpers';
export const styles = theme => ({
/* Styles applied to the root element. */
root: {
lineHeight: 1.3125, // To remove with v4.
...theme.typography.button,
boxSizing: 'border-box',
minWidth: 64,
minHeight: 36,
padding: '8px 16px',
padding: '6px 16px',
borderRadius: theme.shape.borderRadius,
color: theme.palette.text.primary,
transition: theme.transitions.create(['background-color', 'box-shadow', 'border'], {
Expand Down Expand Up @@ -47,7 +48,7 @@ export const styles = theme => ({
},
/* Styles applied to the root element if `variant="text"`. */
text: {
padding: theme.spacing.unit,
padding: '6px 8px',
},
/* Styles applied to the root element if `variant="text"` and `color="primary"`. */
textPrimary: {
Expand Down Expand Up @@ -207,16 +208,15 @@ export const styles = theme => ({
},
/* Styles applied to the root element if `size="small"`. */
sizeSmall: {
padding: '7px 8px',
padding: '4px 8px',
minWidth: 64,
minHeight: 32,
minHeight: 31,
fontSize: theme.typography.pxToRem(13),
},
/* Styles applied to the root element if `size="large"`. */
sizeLarge: {
padding: '8px 24px',
minWidth: 112,
minHeight: 40,
minHeight: 42,
fontSize: theme.typography.pxToRem(15),
},
/* Styles applied to the root element if `fullWidth={true}`. */
Expand Down
10 changes: 7 additions & 3 deletions packages/material-ui/src/ListItemText/ListItemText.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function ListItemText(props) {
primaryTypographyProps,
secondary: secondaryProp,
secondaryTypographyProps,
theme,
...other
} = props;

Expand All @@ -62,8 +63,7 @@ function ListItemText(props) {
if (primary != null && primary.type !== Typography && !disableTypography) {
primary = (
<Typography
variant="subheading"
internalDeprecatedVariant
variant={theme.typography.useNextVariants ? 'body1' : 'subheading'}
className={classNames(classes.primary, { [classes.textDense]: dense })}
component="span"
{...primaryTypographyProps}
Expand Down Expand Up @@ -153,11 +153,15 @@ ListItemText.propTypes = {
* (as long as disableTypography is not `true`).
*/
secondaryTypographyProps: PropTypes.object,
/**
* @ignore
*/
theme: PropTypes.object.isRequired,
};

ListItemText.defaultProps = {
disableTypography: false,
inset: false,
};

export default withStyles(styles, { name: 'MuiListItemText' })(ListItemText);
export default withStyles(styles, { name: 'MuiListItemText', withTheme: true })(ListItemText);
4 changes: 2 additions & 2 deletions packages/material-ui/src/ListItemText/ListItemText.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('<ListItemText />', () => {
const listItemText = findOutermostIntrinsic(wrapper);
const typography = listItemText.find(Typography);
assert.strictEqual(typography.exists(), true);
assert.strictEqual(typography.props().variant, 'subheading');
assert.strictEqual(typography.props().variant, 'body1');
assert.strictEqual(wrapper.text(), 'This is the primary text');
});

Expand Down Expand Up @@ -109,7 +109,7 @@ describe('<ListItemText />', () => {
assert.strictEqual(texts.length, 2);

const primaryText = texts.first();
assert.strictEqual(primaryText.props().variant, 'subheading');
assert.strictEqual(primaryText.props().variant, 'body1');
assert.strictEqual(primaryText.text(), 'This is the primary text');

const secondaryText = texts.last();
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/styles/createTypography.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default function createTypography(palette, typography) {
subtitle2: buildVariant(fontWeightMedium, 14, 1.57, 0.1),
body1Next: buildVariant(fontWeightRegular, 16, 1.5, 0.15),
body2Next: buildVariant(fontWeightRegular, 14, 1.5, 0.15),
buttonNext: buildVariant(fontWeightMedium, 14, 1.5, 0.4, caseAllCaps),
buttonNext: buildVariant(fontWeightMedium, 14, 1.3125, 0.4, caseAllCaps),
captionNext: buildVariant(fontWeightRegular, 12, 1.66, 0.4),
overline: buildVariant(fontWeightRegular, 12, 2.66, 1, caseAllCaps),
};
Expand Down