File tree Expand file tree Collapse file tree 16 files changed +246
-30
lines changed
Expand file tree Collapse file tree 16 files changed +246
-30
lines changed Original file line number Diff line number Diff line change 77 </ head >
88 < body >
99 < div id ="root "> </ div >
10+ < script src ="https://developers.kakao.com/sdk/js/kakao.js "> </ script >
1011 < script type ="module " src ="/src/main.tsx "> </ script >
1112 </ body >
1213</ html >
Original file line number Diff line number Diff line change 1+ import { useEffect } from "react" ;
2+
3+ interface KakoShareButtonProps {
4+ title : string ;
5+ description : string ;
6+ imageUrl : string ;
7+ }
8+
9+ const KakaoShareButton = ( {
10+ title,
11+ description,
12+ imageUrl
13+ } : KakoShareButtonProps ) => {
14+ const kakaoJavascriptKey = import . meta. env . VITE_KAKAO_JAVASCRIPT_KEY ;
15+
16+ useEffect ( ( ) => {
17+ // 카카오톡 SDK 초기화
18+ if ( window . Kakao && ! window . Kakao . isInitialized ( ) ) {
19+ window . Kakao . init ( kakaoJavascriptKey ) ;
20+ }
21+ } , [ ] ) ;
22+
23+ const handleShare = ( ) => {
24+ if ( window . Kakao ) {
25+ // 카카오톡 공유 기능 호출
26+ window . Kakao . Share . sendDefault ( {
27+ objectType : "feed" ,
28+ content : {
29+ title : title ,
30+ description : description ,
31+ imageUrl : imageUrl ,
32+ link : {
33+ mobileWebUrl : window . location . href ,
34+ webUrl : window . location . href
35+ }
36+ }
37+ } ) ;
38+ }
39+ } ;
40+ return (
41+ < div >
42+ < button onClick = { handleShare } >
43+ < img
44+ src = "/icon/kakaotalk.svg"
45+ alt = "카카오톡 공유하기 버튼"
46+ width = { 72 }
47+ height = { 72 }
48+ />
49+ </ button >
50+ </ div >
51+ ) ;
52+ } ;
53+
54+ export default KakaoShareButton ;
Original file line number Diff line number Diff line change 1+ import { useState } from "react" ;
2+ import ShareModal from "@/components/modal/ShareModal" ;
3+
14const ShareButton = ( ) => {
2- return (
3- < button className = "flex justify-center items-center bg-primary-pale border border-primary-light rounded-lg w-full h-[60px] font-bold text-primary-normal" >
4- 공유하기
5+ const [ shareModalIsOpen , setShareModalIsOpen ] = useState ( false ) ;
6+
7+ return (
8+ < >
9+ < button onClick = { ( ) => setShareModalIsOpen ( true ) } className = "flex h-[60px] w-full items-center justify-center rounded-lg border border-primary-light bg-primary-pale font-bold text-primary-normal" >
10+ 공유하기
511 </ button >
6- )
7- }
12+ { shareModalIsOpen && (
13+ < ShareModal closeModal = { ( ) => setShareModalIsOpen ( false ) } />
14+ ) }
15+ </ >
16+ ) ;
17+ } ;
818
9- export default ShareButton ;
19+ export default ShareButton ;
Original file line number Diff line number Diff line change 1+ const TwitterShareButton = ( { title } : { title : string } ) => {
2+ const currentUrl = window . location . href ;
3+
4+ return (
5+ < a
6+ href = { `https://twitter.com/intent/tweet?text=${ title } &url=${ currentUrl } ` }
7+ className = "flex flex-col items-center gap-1"
8+ >
9+ < img src = "/icon/twitter.svg" alt = "트위터 아이콘" width = { 76 } height = { 76 } />
10+ < p className = "text-md text-gray-800" > 트위터</ p >
11+ </ a >
12+ ) ;
13+ } ;
14+
15+ export default TwitterShareButton ;
Original file line number Diff line number Diff line change 1+ import UrlCopyButton from "@/components/button/UrlCopyButton" ;
2+
3+ const UrlCopyBar = ( ) => {
4+ const currentUrl = window . location . href ;
5+
6+ return (
7+ < div className = "flex h-[54px] w-full max-w-[420px] items-center justify-between rounded-lg border border-gray-100 px-4 py-[15px]" >
8+ < span className = "text-lg " > { currentUrl } </ span >
9+ < UrlCopyButton currentUrl = { currentUrl } />
10+ </ div >
11+ ) ;
12+ } ;
13+
14+ export default UrlCopyBar ;
Original file line number Diff line number Diff line change 1+ const UrlCopyButton = ( { currentUrl} : { currentUrl : string } ) => {
2+ const handleCopy = ( ) => {
3+ navigator . clipboard
4+ . writeText ( currentUrl )
5+ . then ( ( ) => {
6+ alert ( "URL이 복사되었습니다!" ) ; // toast로 바꾸어야 함 -> 4.10 정준영
7+ } )
8+ . catch ( ( err ) => {
9+ console . error ( "URL 복사 실패:" , err ) ;
10+ } ) ;
11+ } ;
12+
13+ return (
14+ < button
15+ onClick = { handleCopy }
16+ className = "bg-primary-normal h-8 text-white flex items-center justify-center rounded-[20px] px-4 py-2"
17+ >
18+ 복사
19+ </ button >
20+ ) ;
21+ } ;
22+
23+ export default UrlCopyButton ;
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ type HeaderProps = {
1414const Header = ( {
1515 title = "" ,
1616 showPreviousIcon = true ,
17- showShareIcon = false ,
17+ showShareIcon = true ,
1818 children
1919} : HeaderProps ) => {
2020 const { pathname } = useLocation ( ) ;
You can’t perform that action at this time.
0 commit comments