-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a simple menu item as a backup for copying the link in case the…
… browser does not support web share api
- Loading branch information
1 parent
30288a0
commit 2981fa3
Showing
2 changed files
with
66 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import * as React from 'react'; | ||
import Menu from '@mui/material/Menu'; | ||
import MenuItem from '@mui/material/MenuItem'; | ||
|
||
interface Props { | ||
anchorEl: HTMLElement | null; | ||
open: boolean; | ||
onClose: (open: boolean) => void; | ||
url: string; | ||
} | ||
|
||
const ShareMenu = (props: Props) => { | ||
const { anchorEl, open, onClose, url } = props; | ||
|
||
const copy = () => { | ||
navigator.clipboard.writeText(url).then((value) => { | ||
onClose(!open); | ||
}); | ||
}; | ||
|
||
return ( | ||
<Menu | ||
open={open} | ||
onClose={onClose} | ||
anchorEl={anchorEl} | ||
MenuListProps={{ | ||
'aria-labelledby': 'basic-button' | ||
}} | ||
> | ||
<MenuItem onClick={copy}>Copy Link</MenuItem> | ||
</Menu> | ||
); | ||
}; | ||
|
||
export default ShareMenu; |