-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstallCommand.tsx
More file actions
46 lines (41 loc) · 1.09 KB
/
InstallCommand.tsx
File metadata and controls
46 lines (41 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { useState } from 'react';
import ContentCopyIcon from '@mui/icons-material/ContentCopy';
import CheckIcon from '@mui/icons-material/Check';
import { IconButton, Stack, Typography } from '@mui/material';
export const InstallCommand = () => {
const [copied, setCopied] = useState(false);
const command = 'npm install @dfsync/client';
const handleCopy = async () => {
await navigator.clipboard.writeText(command);
setCopied(true);
setTimeout(() => setCopied(false), 2000);
};
return (
<Stack
direction="row"
alignItems="center"
justifyContent="space-between"
sx={{
bgcolor: 'background.paper',
border: '1px solid',
borderColor: 'divider',
borderRadius: 1,
px: 3,
py: 2,
maxWidth: 500,
}}
>
<Typography
sx={{
fontFamily: 'monospace',
fontSize: 14,
}}
>
{command}
</Typography>
<IconButton size="small" onClick={handleCopy}>
{copied ? <CheckIcon /> : <ContentCopyIcon />}
</IconButton>
</Stack>
);
};