1
1
/* eslint-disable react/prop-types */
2
2
import 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' ;
11
11
import 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' ;
14
14
import 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' ;
17
16
import { getParameters } from 'codesandbox/lib/api/define' ;
18
- import Tooltip from '@material-ui/core /Tooltip' ;
17
+ import Tooltip from '@mui/material /Tooltip' ;
19
18
import dynamic from 'next/dynamic' ;
20
19
import { useRouter } from 'next/router' ;
21
-
22
20
import GhIcon from './common/gh-svg-icon' ;
21
+
23
22
import CodesandboxIcon from './common/code-sandbox-svg-icon' ;
24
23
import CodeEditor from './code-editor' ;
25
24
import { headerToId } from '../helpers/list-of-contents' ;
26
25
import ShareButton from './mdx/share-button' ;
26
+ import { grey } from '@mui/material/colors' ;
27
27
28
- const useHeadingStyles = makeStyles ( ( theme ) => ( {
29
- anchor : {
28
+ const HeadingRoot = styled ( 'div' ) ( ( { theme } ) => ( {
29
+ '& . anchor' : {
30
30
textDecoration : 'none' ,
31
31
color : 'inherit' ,
32
32
fontWeight : 'inherit' ,
33
33
} ,
34
- wrapper : {
34
+ '&. wrapper' : {
35
35
flexGrow : 1 ,
36
36
display : 'flex' ,
37
37
} ,
38
- heading : {
38
+ '& . heading' : {
39
39
paddingTop : 4 ,
40
40
fontSize : theme . typography . pxToRem ( 20 ) ,
41
41
fontWeight : theme . typography . fontWeightRegular ,
@@ -52,44 +52,44 @@ const useHeadingStyles = makeStyles((theme) => ({
52
52
53
53
export const Heading = ( { level, children, component } ) => {
54
54
const router = useRouter ( ) ;
55
- const classes = useHeadingStyles ( ) ;
56
55
const id = headerToId ( children ) ;
57
56
const path = `${ router . asPath } #${ id } ` ;
58
57
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" >
62
61
{ children }
63
62
< ShareButton path = { path } />
64
63
</ a >
65
64
</ Typography >
66
- </ div >
65
+ </ HeadingRoot >
67
66
) ;
68
67
} ;
69
68
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 ' ) ] : {
73
72
maxWidth : 'calc(100vw - 64px)' ,
74
73
} ,
75
74
} ,
76
- codeWrapper : {
75
+ '& . codeWrapper' : {
77
76
background : '#1D1F21' ,
78
77
paddingTop : 16 ,
79
78
paddingBottom : 16 ,
80
79
borderRadius : 4 ,
81
80
} ,
82
- componentPanel : {
81
+ '& . componentPanel' : {
83
82
padding : 16 ,
84
83
} ,
85
- accordion : {
84
+ '& . accordion' : {
86
85
border : 'none' ,
87
86
boxShadow : 'none' ,
88
87
background : 'none' ,
89
88
padding : 0 ,
90
89
} ,
91
- accordionSummary : {
90
+ '& . accordionSummary' : {
92
91
padding : 0 ,
92
+ width : '100%' ,
93
93
} ,
94
94
} ) ) ;
95
95
@@ -134,8 +134,8 @@ const getPayload = (code, sourceFiles = {}) =>
134
134
dependencies : {
135
135
'@data-driven-forms/mui-component-mapper' : 'latest' ,
136
136
'@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' ,
139
139
react : '16.12.0' ,
140
140
'react-dom' : '16.12.0' ,
141
141
'react-scripts' : '3.0.1' ,
@@ -179,17 +179,16 @@ const CodeExample = ({ source, mode }) => {
179
179
setCodeSource ( file . default ) ;
180
180
} ) ;
181
181
} , [ source ] ) ;
182
- const classes = useStyles ( ) ;
183
182
if ( mode === 'preview' ) {
184
183
return (
185
- < Grid container spacing = { 0 } className = { clsx ( 'DocRawComponent' , classes . container ) } >
184
+ < ExampleRoot container spacing = { 0 } className = { clsx ( 'DocRawComponent' , ' container' ) } >
186
185
< Grid item xs = { 12 } >
187
- < Accordion className = { classes . accordion } >
186
+ < Accordion className = { ' accordion' } >
188
187
< AccordionSummary
189
- className = { classes . accordionSummary }
188
+ className = { ' accordionSummary' }
190
189
expandIcon = {
191
190
< Tooltip title = "Expand code example" >
192
- < IconButton >
191
+ < IconButton size = "large" >
193
192
< CodeIcon />
194
193
</ IconButton >
195
194
</ Tooltip >
@@ -204,7 +203,7 @@ const CodeExample = ({ source, mode }) => {
204
203
< form action = "https://codesandbox.io/api/v1/sandboxes/define" method = "POST" target = "_blank" >
205
204
< input type = "hidden" name = "parameters" value = { getPayload ( codeSource , sourceFiles ) } />
206
205
< 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" >
208
207
< CodesandboxIcon />
209
208
</ IconButton >
210
209
</ Tooltip >
@@ -216,31 +215,31 @@ const CodeExample = ({ source, mode }) => {
216
215
onClick = { ( event ) => event . stopPropagation ( ) }
217
216
>
218
217
< Tooltip title = "View source on github" >
219
- < IconButton >
218
+ < IconButton size = "large" >
220
219
< GhIcon style = { { color : grey [ 700 ] } } />
221
220
</ IconButton >
222
221
</ Tooltip >
223
222
</ Link >
224
223
</ Box >
225
224
</ AccordionSummary >
226
- < AccordionDetails className = { clsx ( classes . accordionDetail , classes . codeWrapper ) } >
225
+ < AccordionDetails className = { clsx ( ' accordionDetail' , ' codeWrapper' ) } >
227
226
< CodeEditor value = { codeSource } inExample />
228
227
</ AccordionDetails >
229
228
</ Accordion >
230
229
</ Grid >
231
230
{ 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' } >
234
233
< Component />
235
234
</ Paper >
236
235
</ Grid >
237
236
) }
238
- </ Grid >
237
+ </ ExampleRoot >
239
238
) ;
240
239
}
241
240
242
241
return (
243
- < Grid container spacing = { 0 } className = "DocRawComponent" >
242
+ < ExampleRoot container spacing = { 0 } className = "DocRawComponent" >
244
243
< Grid item xs = { 12 } >
245
244
< Box display = "flex" justifyContent = "flex-end" >
246
245
< Link
@@ -253,10 +252,10 @@ const CodeExample = ({ source, mode }) => {
253
252
</ Link >
254
253
</ Box >
255
254
</ Grid >
256
- < Grid item xs = { 12 } className = { classes . codeWrapper } >
255
+ < Grid item xs = { 12 } className = { ' codeWrapper' } >
257
256
< CodeEditor value = { codeSource } />
258
257
</ Grid >
259
- </ Grid >
258
+ </ ExampleRoot >
260
259
) ;
261
260
} ;
262
261
0 commit comments