1
- import { makeStyles } from "@mui/styles " ;
2
- import { FC } from "react" ;
1
+ import { type FC } from "react " ;
2
+ import { useTheme } from "@emotion/ react" ;
3
3
import { MONOSPACE_FONT_FAMILY } from "theme/constants" ;
4
- import { combineClasses } from "utils/combineClasses" ;
5
4
import { CopyButton } from "../CopyButton/CopyButton" ;
6
- import { Theme } from "@mui/material/styles" ;
7
5
8
6
export interface CodeExampleProps {
9
7
code : string ;
@@ -14,46 +12,40 @@ export interface CodeExampleProps {
14
12
/**
15
13
* Component to show single-line code examples, with a copy button
16
14
*/
17
- export const CodeExample : FC < CodeExampleProps > = ( {
18
- code,
19
- password,
20
- className,
21
- } ) => {
22
- const styles = useStyles ( { password } ) ;
15
+ export const CodeExample : FC < CodeExampleProps > = ( props ) => {
16
+ const { code, password, className } = props ;
17
+ const theme = useTheme ( ) ;
23
18
24
19
return (
25
- < div className = { combineClasses ( [ styles . root , className ] ) } >
26
- < code className = { styles . code } > { code } </ code >
20
+ < div
21
+ css = { {
22
+ display : "flex" ,
23
+ flexDirection : "row" ,
24
+ alignItems : "center" ,
25
+ background : "rgb(0 0 0 / 30%)" ,
26
+ color : theme . palette . primary . contrastText ,
27
+ fontFamily : MONOSPACE_FONT_FAMILY ,
28
+ fontSize : 14 ,
29
+ borderRadius : theme . shape . borderRadius ,
30
+ padding : theme . spacing ( 1 ) ,
31
+ lineHeight : "150%" ,
32
+ border : `1px solid ${ theme . palette . divider } ` ,
33
+ } }
34
+ className = { className }
35
+ >
36
+ < code
37
+ css = { {
38
+ padding : theme . spacing ( 0 , 1 ) ,
39
+ width : "100%" ,
40
+ display : "flex" ,
41
+ alignItems : "center" ,
42
+ wordBreak : "break-all" ,
43
+ "-webkit-text-security" : password ? "disc" : undefined ,
44
+ } }
45
+ >
46
+ { code }
47
+ </ code >
27
48
< CopyButton text = { code } />
28
49
</ div >
29
50
) ;
30
51
} ;
31
-
32
- interface styleProps {
33
- inline ?: boolean ;
34
- password ?: boolean ;
35
- }
36
-
37
- const useStyles = makeStyles < Theme , styleProps > ( ( theme ) => ( {
38
- root : ( props ) => ( {
39
- display : props . inline ? "inline-flex" : "flex" ,
40
- flexDirection : "row" ,
41
- alignItems : "center" ,
42
- background : "rgb(0 0 0 / 30%)" ,
43
- color : theme . palette . primary . contrastText ,
44
- fontFamily : MONOSPACE_FONT_FAMILY ,
45
- fontSize : 14 ,
46
- borderRadius : theme . shape . borderRadius ,
47
- padding : theme . spacing ( 1 ) ,
48
- lineHeight : "150%" ,
49
- border : `1px solid ${ theme . palette . divider } ` ,
50
- } ) ,
51
- code : {
52
- padding : theme . spacing ( 0 , 1 ) ,
53
- width : "100%" ,
54
- display : "flex" ,
55
- alignItems : "center" ,
56
- wordBreak : "break-all" ,
57
- "-webkit-text-security" : ( props ) => ( props . password ? "disc" : undefined ) ,
58
- } ,
59
- } ) ) ;
0 commit comments