1
- import React from ' react'
2
- import ReactDOM from ' react-dom'
3
- import Button from ' ./Button'
4
- import { CloseIcon } from ' ./Icons'
5
- import CodePreview from ' ./CodePreview'
6
- import { SnippetType } from ' ../types'
7
- import slugify from ' ../utils/slugify'
8
- import useEscapeKey from ' ../hooks/useEscapeKey'
1
+ import React from " react" ;
2
+ import ReactDOM from " react-dom" ;
3
+ import Button from " ./Button" ;
4
+ import { CloseIcon } from " ./Icons" ;
5
+ import CodePreview from " ./CodePreview" ;
6
+ import { SnippetType } from " ../types" ;
7
+ import slugify from " ../utils/slugify" ;
8
+ import useEscapeKey from " ../hooks/useEscapeKey" ;
9
9
10
10
type Props = {
11
- snippet : SnippetType
12
- language : string
13
- handleCloseModal : ( ) => void
14
- }
11
+ snippet : SnippetType ;
12
+ language : string ;
13
+ handleCloseModal : ( ) => void ;
14
+ } ;
15
15
16
16
const SnippetModal : React . FC < Props > = ( {
17
17
snippet,
18
18
language,
19
19
handleCloseModal,
20
20
} ) => {
21
- const modalRoot = document . getElementById ( ' modal-root' )
22
- if ( ! modalRoot ) return null
23
- useEscapeKey ( handleCloseModal )
21
+ const modalRoot = document . getElementById ( " modal-root" ) ;
22
+ if ( ! modalRoot ) return null ;
23
+ useEscapeKey ( handleCloseModal ) ;
24
24
25
25
return ReactDOM . createPortal (
26
- < div className = ' modal-overlay' >
27
- < div className = ' modal | flow' data-flow-space = 'lg' >
28
- < div className = ' modal__header' >
29
- < h2 className = ' section-title' > { snippet . title } </ h2 >
26
+ < div className = " modal-overlay" >
27
+ < div className = " modal | flow" data-flow-space = "lg" >
28
+ < div className = " modal__header" >
29
+ < h2 className = " section-title" > { snippet . title } </ h2 >
30
30
< Button isIcon = { true } onClick = { handleCloseModal } >
31
31
< CloseIcon />
32
32
</ Button >
@@ -37,27 +37,27 @@ const SnippetModal: React.FC<Props> = ({
37
37
{ snippet . description }
38
38
</ p >
39
39
< p >
40
- Contributed by{ ' ' }
40
+ Contributed by{ " " }
41
41
< a
42
42
href = { `https://github.com/${ snippet . author } ` }
43
- target = ' _blank'
44
- rel = ' noopener noreferrer'
45
- className = ' styled-link'
43
+ target = " _blank"
44
+ rel = " noopener noreferrer"
45
+ className = " styled-link"
46
46
>
47
47
@{ snippet . author }
48
48
</ a >
49
49
</ p >
50
- < ul role = ' list' className = ' modal__tags' >
50
+ < ul role = " list" className = " modal__tags" >
51
51
{ snippet . tags . map ( ( tag ) => (
52
- < li key = { tag } className = ' modal__tag' >
52
+ < li key = { tag } className = " modal__tag" >
53
53
{ tag }
54
54
</ li >
55
55
) ) }
56
56
</ ul >
57
57
</ div >
58
58
</ div > ,
59
59
modalRoot
60
- )
61
- }
60
+ ) ;
61
+ } ;
62
62
63
- export default SnippetModal
63
+ export default SnippetModal ;
0 commit comments