1
1
import IconButton from "@mui/material/Button" ;
2
- import { makeStyles } from "@mui/styles" ;
3
2
import Tooltip from "@mui/material/Tooltip" ;
4
3
import Check from "@mui/icons-material/Check" ;
5
4
import { useClipboard } from "hooks/useClipboard" ;
6
- import { combineClasses } from "utils/combineClasses " ;
5
+ import { css } from "@emotion/react " ;
7
6
import { FileCopyIcon } from "../Icons/FileCopyIcon" ;
8
7
9
8
interface CopyButtonProps {
@@ -29,51 +28,53 @@ export const CopyButton: React.FC<React.PropsWithChildren<CopyButtonProps>> = ({
29
28
buttonClassName = "" ,
30
29
tooltipTitle = Language . tooltipTitle ,
31
30
} ) => {
32
- const styles = useStyles ( ) ;
33
31
const { isCopied, copy : copyToClipboard } = useClipboard ( text ) ;
34
32
33
+ const fileCopyIconStyles = css `
34
+ width : 20px ;
35
+ height : 20px ;
36
+ ` ;
37
+
35
38
return (
36
39
< Tooltip title = { tooltipTitle } placement = "top" >
37
40
< div
38
- className = { combineClasses ( [ styles . copyButtonWrapper , wrapperClassName ] ) }
41
+ className = { wrapperClassName }
42
+ css = { {
43
+ display : "flex" ,
44
+ } }
39
45
>
40
46
< IconButton
41
- className = { combineClasses ( [ styles . copyButton , buttonClassName ] ) }
47
+ className = { buttonClassName }
48
+ css = { ( theme ) => css `
49
+ border-radius : ${ theme . shape . borderRadius } px;
50
+ padding : ${ theme . spacing ( 0.85 ) } ;
51
+ min-width : 32px ;
52
+
53
+ & : hover {
54
+ background : ${ theme . palette . background . paper } ;
55
+ }
56
+ ` }
42
57
onClick = { copyToClipboard }
43
58
size = "small"
44
59
aria-label = { Language . ariaLabel }
45
60
variant = "text"
46
61
>
47
62
{ isCopied ? (
48
- < Check className = { styles . fileCopyIcon } />
63
+ < Check css = { fileCopyIconStyles } />
49
64
) : (
50
- < FileCopyIcon className = { styles . fileCopyIcon } />
65
+ < FileCopyIcon css = { fileCopyIconStyles } />
66
+ ) }
67
+ { ctaCopy && (
68
+ < div
69
+ css = { ( theme ) => ( {
70
+ marginLeft : theme . spacing ( 1 ) ,
71
+ } ) }
72
+ >
73
+ { ctaCopy }
74
+ </ div >
51
75
) }
52
- { ctaCopy && < div className = { styles . buttonCopy } > { ctaCopy } </ div > }
53
76
</ IconButton >
54
77
</ div >
55
78
</ Tooltip >
56
79
) ;
57
80
} ;
58
-
59
- const useStyles = makeStyles ( ( theme ) => ( {
60
- copyButtonWrapper : {
61
- display : "flex" ,
62
- } ,
63
- copyButton : {
64
- borderRadius : theme . shape . borderRadius ,
65
- padding : theme . spacing ( 0.85 ) ,
66
- minWidth : 32 ,
67
-
68
- "&:hover" : {
69
- background : theme . palette . background . paper ,
70
- } ,
71
- } ,
72
- fileCopyIcon : {
73
- width : 20 ,
74
- height : 20 ,
75
- } ,
76
- buttonCopy : {
77
- marginLeft : theme . spacing ( 1 ) ,
78
- } ,
79
- } ) ) ;
0 commit comments