@@ -3,16 +3,16 @@ import ReactDOM from "react-dom";
33import { useNavigate , useParams } from "react-router-dom" ;
44import { LanguageData , SnippetType } from "../types" ;
55import { getSnippetByTitleAndCategory } from "../utils/filters" ;
6+ import { CloseIcon } from "./Icons" ;
7+ import Button from "./Button" ;
68
79const SnippetModal = ( ) => {
8- console . log ( "hello modal" ) ;
910 const modalRoot = document . getElementById ( "modal-root" ) ;
1011 if ( ! modalRoot ) return null ;
1112
1213 const { language, category, snippet_title } = useParams ( ) ;
1314 const [ snippet , setSnippet ] = useState < SnippetType | null > ( null ) ;
1415 const navigate = useNavigate ( ) ;
15- console . log ( language , category , snippet_title ) ;
1616
1717 useEffect ( ( ) => {
1818 const fetchSnippets = async ( ) => {
@@ -37,15 +37,36 @@ const SnippetModal = () => {
3737 } ;
3838
3939 fetchSnippets ( ) ;
40- } , [ ] ) ;
40+ } , [ snippet_title ] ) ;
4141
4242 if ( ! snippet ) return null ;
4343
4444 return ReactDOM . createPortal (
4545 < div className = "modal-overlay" >
46- < div className = "modal-content" >
47- { snippet . title }
48- < button onClick = { ( ) => navigate ( - 1 ) } > Close</ button >
46+ < div className = "modal | flow" data-flow-space = "lg" >
47+ < div className = "modal__header" >
48+ < h2 className = "section-title" > { snippet . title } </ h2 >
49+ < Button isIcon = { true } onClick = { ( ) => navigate ( - 1 ) } >
50+ < CloseIcon />
51+ </ Button >
52+ </ div >
53+ < div className = "code-preview" >
54+ < pre > { snippet . code } </ pre >
55+ </ div >
56+ < p >
57+ < b > Description: </ b >
58+ { snippet . description }
59+ </ p >
60+ < p >
61+ Contributed by < b > { snippet . author } </ b >
62+ </ p >
63+ < ul role = "list" className = "modal__tags" >
64+ { snippet . tags . map ( ( tag ) => (
65+ < li key = { tag } className = "modal__tag" >
66+ { tag }
67+ </ li >
68+ ) ) }
69+ </ ul >
4970 </ div >
5071 </ div > ,
5172 modalRoot
0 commit comments