Skip to content

Commit

Permalink
Update PR review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
mj12albert committed Feb 15, 2023
1 parent 0ea7c3a commit 126a111
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const theme = createTheme({
body2: 'p',
inherit: 'p',
// @ts-ignore
poster: 'h1', // map our new variant to render a <h1> by default
poster: 'h1', // map our new variant to render an <h1> by default
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const theme = createTheme({
body2: 'p',
inherit: 'p',
// @ts-ignore
poster: 'h1', // map our new variant to render a <h1> by default
poster: 'h1', // map our new variant to render an <h1> by default
},
},
},
Expand Down
9 changes: 5 additions & 4 deletions docs/data/material/customization/typography/typography.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ In addition to using the default typography variants, you can add custom ones, o

**Step 1. Update the theme's typography object**

Let's add a variant called "poster", and get rid the "h3" variant:
The code snippet below adds a custom variant to the theme called `poster`, and removes the default `h3` variant:

```js
const theme = createTheme({
Expand All @@ -246,9 +246,10 @@ const theme = createTheme({

**Step 2. (Optional) Set the default semantic element for your new variant**

At this point, you can already use the new `poster` variant, which will render a `<span>` by default with your custom styles. Sometimes you may want to default to a different HTML element for semantic purposes, or to replace the inline `<span>` with a block-level element for styling purposes.
At this point, you can already use the new `poster` variant, which will render a `<span>` by default with your custom styles.
Sometimes you may want to default to a different HTML element for semantic purposes, or to replace the inline `<span>` with a block-level element for styling purposes.

To do this we need to update the `variantMapping` prop of the `Typography` globally in the theme:
To do this, update the `variantMapping` prop of the `Typography` component globally, at the theme level:

```js
const theme = createTheme({
Expand Down Expand Up @@ -324,7 +325,7 @@ declare module '@mui/material/Typography' {
```jsx
<Typography variant="poster">poster</Typography>;

/* This variant is no longer supported, if you are using TypeScript it will give an error */
/* This variant is no longer supported. If you are using TypeScript it will give an error */
<Typography variant="h3">h3</Typography>;
```

Expand Down

0 comments on commit 126a111

Please sign in to comment.