-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add share button to preview page (#26)
* preview 페이지에 share 기능 추가 * 복사 성공시 뜨는 alert 문구 변경
- Loading branch information
Showing
3 changed files
with
39 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react'; | ||
|
||
type Props = { | ||
title: string; | ||
url: string; | ||
}; | ||
|
||
function ShareButton({ title, url }: Props) { | ||
const handleClick = async () => { | ||
if (navigator.share) { | ||
await navigator.share({ | ||
title, | ||
url, | ||
}); | ||
} else { | ||
// share api 지원하지 않을시 clipboard 복사로 대체 | ||
await navigator.clipboard.writeText(url); | ||
alert('Copied link to clipboard.\nShare the link!'); | ||
} | ||
}; | ||
|
||
return ( | ||
<button className="btn btn-wide" onClick={handleClick}> | ||
Share | ||
</button> | ||
); | ||
} | ||
|
||
export default ShareButton; |
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
c9038d2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
moon-svg – ./
moon-svg-git-main-hmu332233.vercel.app
moon-phase.vercel.app
moon-svg-hmu332233.vercel.app
moon-svg.minung.dev