Skip to content

Commit a5a4adb

Browse files
[Typography] Less opinionated
1 parent 264c64d commit a5a4adb

File tree

9 files changed

+22
-17
lines changed

9 files changed

+22
-17
lines changed

docs/src/modules/components/AppFrame.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class AppFrame extends React.Component {
200200
<Notifications />
201201
<MarkdownLinks />
202202
<AppBar className={appBarClassName}>
203-
<Typography className={classes.banner} noWrap>
203+
<Typography className={classes.banner} variant="body2" noWrap>
204204
<Interpolate
205205
replacement={{
206206
versionNumber: (

docs/src/pages/style/links/Links.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function Links(props) {
2525
<Link href={dudUrl} color="inherit" className={classes.link}>
2626
{'color="inherit"'}
2727
</Link>
28-
<Link href={dudUrl} variant="body1" className={classes.link}>
28+
<Link href={dudUrl} variant="body2" className={classes.link}>
2929
{'variant="body1"'}
3030
</Link>
3131
</Typography>

packages/material-ui/src/CssBaseline/CssBaseline.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ const useStyles = makeStyles(
1818
},
1919
body: {
2020
margin: 0, // Remove the margin in all browsers.
21+
color: theme.palette.text.primary,
22+
...theme.typography.body2,
2123
backgroundColor: theme.palette.background.default,
2224
'@media print': {
2325
// Save printer ink.
2426
backgroundColor: theme.palette.common.white,
2527
},
26-
...theme.typography.body2,
2728
},
2829
},
2930
}),

packages/material-ui/src/FormHelperText/FormHelperText.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ import withStyles from '../styles/withStyles';
88
export const styles = theme => ({
99
/* Styles applied to the root element. */
1010
root: {
11+
...theme.typography.caption,
1112
color: theme.palette.text.secondary,
12-
fontFamily: theme.typography.fontFamily,
13-
fontSize: theme.typography.pxToRem(12),
1413
textAlign: 'left',
1514
marginTop: 8,
1615
lineHeight: '1em',

packages/material-ui/src/FormLabel/FormLabel.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ import withStyles from '../styles/withStyles';
88
export const styles = theme => ({
99
/* Styles applied to the root element. */
1010
root: {
11-
fontFamily: theme.typography.fontFamily,
1211
color: theme.palette.text.secondary,
13-
fontSize: theme.typography.pxToRem(16),
14-
lineHeight: 1,
12+
...theme.typography.body1,
1513
padding: 0,
1614
'&$focused': {
1715
color: theme.palette.primary[theme.palette.type === 'light' ? 'dark' : 'light'],

packages/material-ui/src/Typography/Typography.d.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ type Style = ThemeStyle | 'srOnly';
77
export interface TypographyProps
88
extends StandardProps<React.HTMLAttributes<HTMLElement>, TypographyClassKey> {
99
align?: PropTypes.Alignment;
10-
color?: PropTypes.Color | 'textPrimary' | 'textSecondary' | 'error';
10+
color?:
11+
| 'initial'
12+
| 'inherit'
13+
| 'primary'
14+
| 'secondary'
15+
| 'textPrimary'
16+
| 'textSecondary'
17+
| 'error';
1118
component?: React.ElementType<TypographyProps>;
1219
display?: 'initial' | 'block' | 'inline';
1320
gutterBottom?: boolean;

packages/material-ui/src/Typography/Typography.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ const Typography = React.forwardRef(function Typography(props, ref) {
147147
classes.root,
148148
{
149149
[classes[variant]]: variant !== 'inherit',
150-
[classes[`color${capitalize(color)}`]]: color !== 'default',
150+
[classes[`color${capitalize(color)}`]]: color !== 'initial',
151151
[classes.noWrap]: noWrap,
152152
[classes.gutterBottom]: gutterBottom,
153153
[classes.paragraph]: paragraph,
@@ -184,13 +184,13 @@ Typography.propTypes = {
184184
* The color of the component. It supports those theme colors that make sense for this component.
185185
*/
186186
color: PropTypes.oneOf([
187-
'default',
188-
'error',
187+
'initial',
189188
'inherit',
190189
'primary',
191190
'secondary',
192191
'textPrimary',
193192
'textSecondary',
193+
'error',
194194
]),
195195
/**
196196
* The component used for the root node.
@@ -249,12 +249,12 @@ Typography.propTypes = {
249249

250250
Typography.defaultProps = {
251251
align: 'inherit',
252-
color: 'default',
252+
color: 'initial',
253253
display: 'initial',
254254
gutterBottom: false,
255255
noWrap: false,
256256
paragraph: false,
257-
variant: 'body2',
257+
variant: 'body1',
258258
variantMapping: defaultVariantMapping,
259259
};
260260

packages/material-ui/src/styles/createTypography.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default function createTypography(palette, typography) {
3232
const coef = fontSize / 14;
3333
const pxToRem = size => `${(size / htmlFontSize) * coef}rem`;
3434
const buildVariant = (fontWeight, size, lineHeight, letterSpacing, casing) => ({
35-
color: palette.text.primary,
35+
// color: palette.text.primary,
3636
fontFamily,
3737
fontWeight,
3838
fontSize: pxToRem(size),

pages/api/typography.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ import Typography from '@material-ui/core/Typography';
2121
| <span class="prop-name">align</span> | <span class="prop-type">enum:&nbsp;'inherit', 'left', 'center', 'right', 'justify'<br></span> | <span class="prop-default">'inherit'</span> | Set the text-align on the component. |
2222
| <span class="prop-name">children</span> | <span class="prop-type">node</span> |   | The content of the component. |
2323
| <span class="prop-name">classes</span> | <span class="prop-type">object</span> |   | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. |
24-
| <span class="prop-name">color</span> | <span class="prop-type">enum:&nbsp;'default', 'error', 'inherit', 'primary', 'secondary', 'textPrimary', 'textSecondary'<br></span> | <span class="prop-default">'default'</span> | The color of the component. It supports those theme colors that make sense for this component. |
24+
| <span class="prop-name">color</span> | <span class="prop-type">enum:&nbsp;'initial', 'inherit', 'primary', 'secondary', 'textPrimary', 'textSecondary', 'error'<br></span> | <span class="prop-default">'initial'</span> | The color of the component. It supports those theme colors that make sense for this component. |
2525
| <span class="prop-name">component</span> | <span class="prop-type">elementType</span> |   | The component used for the root node. Either a string to use a DOM element or a component. By default, it maps the variant to a good default headline component. |
2626
| <span class="prop-name">display</span> | <span class="prop-type">enum:&nbsp;'initial'&nbsp;&#124;<br>&nbsp;'block'&nbsp;&#124;<br>&nbsp;'inline'<br></span> | <span class="prop-default">'initial'</span> | Controls the display type |
2727
| <span class="prop-name">gutterBottom</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, the text will have a bottom margin. |
2828
| <span class="prop-name">noWrap</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, the text will not wrap, but instead will truncate with an ellipsis. |
2929
| <span class="prop-name">paragraph</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, the text will have a bottom margin. |
30-
| <span class="prop-name">variant</span> | <span class="prop-type">enum:&nbsp;'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'subtitle1', 'subtitle2', 'body1', 'body2', 'caption', 'button', 'overline', 'srOnly', 'inherit'<br></span> | <span class="prop-default">'body2'</span> | Applies the theme typography styles. |
30+
| <span class="prop-name">variant</span> | <span class="prop-type">enum:&nbsp;'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'subtitle1', 'subtitle2', 'body1', 'body2', 'caption', 'button', 'overline', 'srOnly', 'inherit'<br></span> | <span class="prop-default">'body1'</span> | Applies the theme typography styles. |
3131
| <span class="prop-name">variantMapping</span> | <span class="prop-type">object</span> | <span class="prop-default">{ h1: 'h1', h2: 'h2', h3: 'h3', h4: 'h4', h5: 'h5', h6: 'h6', subtitle1: 'h6', subtitle2: 'h6', body1: 'p', body2: 'p',}</span> | We are empirically mapping the variant property to a range of different DOM element types. For instance, subtitle1 to `<h6>`. If you wish to change that mapping, you can provide your own. Alternatively, you can use the `component` property. |
3232

3333
Any other properties supplied will be spread to the root element (native element).

0 commit comments

Comments
 (0)