11/* eslint-disable react/prop-types */
22import React , { Fragment , useEffect , useState , useRef } from 'react' ;
3- import Grid from '@material-ui/core /Grid' ;
4- import { makeStyles } from '@material-ui/core /styles' ;
5- import Typography from '@material-ui/core /Typography' ;
6- import Link from '@material-ui/core /Link' ;
7- import Box from '@material-ui/core /Box' ;
8- import CodeIcon from '@material-ui /icons/Code' ;
9- import Accordion from '@material-ui/core /Accordion' ;
10- import AccordionSummary from '@material-ui/core /AccordionSummary' ;
3+ import Grid from '@mui/material /Grid' ;
4+ import { styled } from '@mui/material /styles' ;
5+ import Typography from '@mui/material /Typography' ;
6+ import Link from '@mui/material /Link' ;
7+ import Box from '@mui/material /Box' ;
8+ import CodeIcon from '@mui /icons-material /Code' ;
9+ import Accordion from '@mui/material /Accordion' ;
10+ import AccordionSummary from '@mui/material /AccordionSummary' ;
1111import PropTypes from 'prop-types' ;
12- import AccordionDetails from '@material-ui/core /AccordionDetails' ;
13- import Paper from '@material-ui/core /Paper' ;
12+ import AccordionDetails from '@mui/material /AccordionDetails' ;
13+ import Paper from '@mui/material /Paper' ;
1414import clsx from 'clsx' ;
15- import grey from '@material-ui/core/colors/grey' ;
16- import IconButton from '@material-ui/core/IconButton' ;
15+ import IconButton from '@mui/material/IconButton' ;
1716import { getParameters } from 'codesandbox/lib/api/define' ;
18- import Tooltip from '@material-ui/core /Tooltip' ;
17+ import Tooltip from '@mui/material /Tooltip' ;
1918import dynamic from 'next/dynamic' ;
2019import { useRouter } from 'next/router' ;
21-
2220import GhIcon from './common/gh-svg-icon' ;
21+
2322import CodesandboxIcon from './common/code-sandbox-svg-icon' ;
2423import CodeEditor from './code-editor' ;
2524import { headerToId } from '../helpers/list-of-contents' ;
2625import ShareButton from './mdx/share-button' ;
26+ import { grey } from '@mui/material/colors' ;
2727
28- const useHeadingStyles = makeStyles ( ( theme ) => ( {
29- anchor : {
28+ const HeadingRoot = styled ( 'div' ) ( ( { theme } ) => ( {
29+ '& . anchor' : {
3030 textDecoration : 'none' ,
3131 color : 'inherit' ,
3232 fontWeight : 'inherit' ,
3333 } ,
34- wrapper : {
34+ '&. wrapper' : {
3535 flexGrow : 1 ,
3636 display : 'flex' ,
3737 } ,
38- heading : {
38+ '& . heading' : {
3939 paddingTop : 4 ,
4040 fontSize : theme . typography . pxToRem ( 20 ) ,
4141 fontWeight : theme . typography . fontWeightRegular ,
@@ -52,44 +52,44 @@ const useHeadingStyles = makeStyles((theme) => ({
5252
5353export const Heading = ( { level, children, component } ) => {
5454 const router = useRouter ( ) ;
55- const classes = useHeadingStyles ( ) ;
5655 const id = headerToId ( children ) ;
5756 const path = `${ router . asPath } #${ id } ` ;
5857 return (
59- < div id = { id } className = { classes . wrapper } data-scroll = "true" >
60- < Typography id = { `heading-${ id } ` } className = { classes . heading } variant = { `h${ level } ` } component = { component } >
61- < a href = { path } className = { classes . anchor } data-mdlink = "md-heading" >
58+ < HeadingRoot id = { id } className = { ' wrapper' } data-scroll = "true" >
59+ < Typography id = { `heading-${ id } ` } className = { ' heading' } variant = { `h${ level } ` } component = { component } >
60+ < a href = { path } className = { ' anchor' } data-mdlink = "md-heading" >
6261 { children }
6362 < ShareButton path = { path } />
6463 </ a >
6564 </ Typography >
66- </ div >
65+ </ HeadingRoot >
6766 ) ;
6867} ;
6968
70- const useStyles = makeStyles ( ( theme ) => ( {
71- container : {
72- [ theme . breakpoints . down ( 'sm ' ) ] : {
69+ const ExampleRoot = styled ( Grid ) ( ( { theme } ) => ( {
70+ '&. container' : {
71+ [ theme . breakpoints . down ( 'md ' ) ] : {
7372 maxWidth : 'calc(100vw - 64px)' ,
7473 } ,
7574 } ,
76- codeWrapper : {
75+ '& . codeWrapper' : {
7776 background : '#1D1F21' ,
7877 paddingTop : 16 ,
7978 paddingBottom : 16 ,
8079 borderRadius : 4 ,
8180 } ,
82- componentPanel : {
81+ '& . componentPanel' : {
8382 padding : 16 ,
8483 } ,
85- accordion : {
84+ '& . accordion' : {
8685 border : 'none' ,
8786 boxShadow : 'none' ,
8887 background : 'none' ,
8988 padding : 0 ,
9089 } ,
91- accordionSummary : {
90+ '& . accordionSummary' : {
9291 padding : 0 ,
92+ width : '100%' ,
9393 } ,
9494} ) ) ;
9595
@@ -134,8 +134,8 @@ const getPayload = (code, sourceFiles = {}) =>
134134 dependencies : {
135135 '@data-driven-forms/mui-component-mapper' : 'latest' ,
136136 '@data-driven-forms/react-form-renderer' : 'latest' ,
137- '@material-ui/core ' : 'latest' ,
138- '@material-ui /icons' : 'latest' ,
137+ '@mui/material ' : 'latest' ,
138+ '@mui /icons-material ' : 'latest' ,
139139 react : '16.12.0' ,
140140 'react-dom' : '16.12.0' ,
141141 'react-scripts' : '3.0.1' ,
@@ -179,17 +179,16 @@ const CodeExample = ({ source, mode }) => {
179179 setCodeSource ( file . default ) ;
180180 } ) ;
181181 } , [ source ] ) ;
182- const classes = useStyles ( ) ;
183182 if ( mode === 'preview' ) {
184183 return (
185- < Grid container spacing = { 0 } className = { clsx ( 'DocRawComponent' , classes . container ) } >
184+ < ExampleRoot container spacing = { 0 } className = { clsx ( 'DocRawComponent' , ' container' ) } >
186185 < Grid item xs = { 12 } >
187- < Accordion className = { classes . accordion } >
186+ < Accordion className = { ' accordion' } >
188187 < AccordionSummary
189- className = { classes . accordionSummary }
188+ className = { ' accordionSummary' }
190189 expandIcon = {
191190 < Tooltip title = "Expand code example" >
192- < IconButton >
191+ < IconButton size = "large" >
193192 < CodeIcon />
194193 </ IconButton >
195194 </ Tooltip >
@@ -204,7 +203,7 @@ const CodeExample = ({ source, mode }) => {
204203 < form action = "https://codesandbox.io/api/v1/sandboxes/define" method = "POST" target = "_blank" >
205204 < input type = "hidden" name = "parameters" value = { getPayload ( codeSource , sourceFiles ) } />
206205 < Tooltip title = "Edit in codesandbox" >
207- < IconButton disableFocusRipple type = "submit" onClick = { ( event ) => event . stopPropagation ( ) } >
206+ < IconButton disableFocusRipple type = "submit" onClick = { ( event ) => event . stopPropagation ( ) } size = "large" >
208207 < CodesandboxIcon />
209208 </ IconButton >
210209 </ Tooltip >
@@ -216,31 +215,31 @@ const CodeExample = ({ source, mode }) => {
216215 onClick = { ( event ) => event . stopPropagation ( ) }
217216 >
218217 < Tooltip title = "View source on github" >
219- < IconButton >
218+ < IconButton size = "large" >
220219 < GhIcon style = { { color : grey [ 700 ] } } />
221220 </ IconButton >
222221 </ Tooltip >
223222 </ Link >
224223 </ Box >
225224 </ AccordionSummary >
226- < AccordionDetails className = { clsx ( classes . accordionDetail , classes . codeWrapper ) } >
225+ < AccordionDetails className = { clsx ( ' accordionDetail' , ' codeWrapper' ) } >
227226 < CodeEditor value = { codeSource } inExample />
228227 </ AccordionDetails >
229228 </ Accordion >
230229 </ Grid >
231230 { Component && (
232- < Grid className = { classes . formContainer } item xs = { 12 } >
233- < Paper className = { classes . componentPanel } >
231+ < Grid className = { ' formContainer' } item xs = { 12 } >
232+ < Paper className = { ' componentPanel' } >
234233 < Component />
235234 </ Paper >
236235 </ Grid >
237236 ) }
238- </ Grid >
237+ </ ExampleRoot >
239238 ) ;
240239 }
241240
242241 return (
243- < Grid container spacing = { 0 } className = "DocRawComponent" >
242+ < ExampleRoot container spacing = { 0 } className = "DocRawComponent" >
244243 < Grid item xs = { 12 } >
245244 < Box display = "flex" justifyContent = "flex-end" >
246245 < Link
@@ -253,10 +252,10 @@ const CodeExample = ({ source, mode }) => {
253252 </ Link >
254253 </ Box >
255254 </ Grid >
256- < Grid item xs = { 12 } className = { classes . codeWrapper } >
255+ < Grid item xs = { 12 } className = { ' codeWrapper' } >
257256 < CodeEditor value = { codeSource } />
258257 </ Grid >
259- </ Grid >
258+ </ ExampleRoot >
260259 ) ;
261260} ;
262261
0 commit comments