@@ -2,27 +2,28 @@ import { motion, useReducedMotion } from "motion/react";
22import React from "react" ;
33import ReactDOM from "react-dom" ;
44
5+ import { useAppContext } from "@contexts/AppContext" ;
56import { useEscapeKey } from "@hooks/useEscapeKey" ;
67import { SnippetType } from "@types" ;
7- import { slugify } from "@utils/slugify" ;
88
99import Button from "./Button" ;
1010import CodePreview from "./CodePreview" ;
1111import { CloseIcon } from "./Icons" ;
1212
1313type Props = {
1414 snippet : SnippetType ;
15- language : string ;
15+ extension : string ;
1616 handleCloseModal : ( ) => void ;
1717} ;
1818
1919const SnippetModal : React . FC < Props > = ( {
2020 snippet,
21- language ,
21+ extension ,
2222 handleCloseModal,
2323} ) => {
2424 const modalRoot = document . getElementById ( "modal-root" ) ;
2525
26+ const { language, subLanguage } = useAppContext ( ) ;
2627 const shouldReduceMotion = useReducedMotion ( ) ;
2728
2829 useEscapeKey ( handleCloseModal ) ;
@@ -49,7 +50,7 @@ const SnippetModal: React.FC<Props> = ({
4950 key = "modal-content"
5051 className = "modal | flow"
5152 data-flow-space = "lg"
52- layoutId = { `${ language } -${ snippet . title } ` }
53+ layoutId = { `${ extension } -${ snippet . title } ` }
5354 transition = { {
5455 ease : [ 0 , 0.75 , 0.25 , 1 ] ,
5556 duration : shouldReduceMotion ? 0 : 0.3 ,
@@ -62,7 +63,14 @@ const SnippetModal: React.FC<Props> = ({
6263 </ Button >
6364 </ div >
6465 < div className = "modal__body | flow" >
65- < CodePreview language = { slugify ( language ) } code = { snippet . code } />
66+ { /* TODO: update the language name and remove all-sub-languages */ }
67+ < CodePreview
68+ languageName = {
69+ subLanguage === "all-sub-languages" ? language . name : subLanguage
70+ }
71+ extension = { extension }
72+ code = { snippet . code }
73+ />
6674 < p >
6775 < b > Description: </ b >
6876 { snippet . description }
0 commit comments