-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[공통] v1.1.0 배포
- Loading branch information
Showing
18 changed files
with
247 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
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
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
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 |
---|---|---|
|
@@ -3,3 +3,6 @@ SNOWPACK_PUBLIC_API_URL=https://api.jujeol-jujeol.com | |
SNOWPACK_PUBLIC_KAKAO_CLIENT_ID=838bcd43c3b007b4ef38c3da555c4806 | ||
SNOWPACK_PUBLIC_ENV=PROD | ||
SNOWPACK_PUBLIC_SENTRY_DSN=https://[email protected]/5903219 | ||
SNOWPACK_PUBLIC_HOST_URL=https://jujeol-jujeol.com | ||
SNOWPACK_PUBLIC_KAKAO_JS_KEY=67ab5f05c77a95d99a10ebba0f22abfb | ||
SNOWPACK_PUBLIC_KAKAO_SHARE_TEMPLATE_ID=59769 |
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
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,28 @@ | ||
import { COLOR } from 'src/constants'; | ||
|
||
const LinkIcon = ({ width = '32px', height = '32px', color = COLOR.WHITE }: IconProps) => { | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
viewBox="0 0 27.65 27.82" | ||
width={width} | ||
height={height} | ||
fill={color} | ||
> | ||
<path | ||
className="cls-1" | ||
d="M9.2,19.82a1.51,1.51,0,0,1-1.06-.44,1.49,1.49,0,0,1,0-2.12l8.78-8.78A1.5,1.5,0,1,1,19,10.6l-8.78,8.78A1.51,1.51,0,0,1,9.2,19.82Z" | ||
/> | ||
<path | ||
className="cls-1" | ||
d="M7.84,27.82A7.84,7.84,0,0,1,2.29,14.44L6,10.77a1.49,1.49,0,0,1,2.12,0,1.51,1.51,0,0,1,0,2.12L4.41,16.56a4.84,4.84,0,0,0,6.85,6.85l4-4a1.51,1.51,0,0,1,2.12,0,1.49,1.49,0,0,1,0,2.12l-4,4A7.82,7.82,0,0,1,7.84,27.82Z" | ||
/> | ||
<path | ||
className="cls-1" | ||
d="M20.62,17.5a1.5,1.5,0,0,1-1.06-2.56l3.67-3.68a4.84,4.84,0,0,0-6.85-6.84l-4,4A1.5,1.5,0,0,1,10.26,6.3l4-4a7.85,7.85,0,0,1,11.09,11.1l-3.67,3.67A1.51,1.51,0,0,1,20.62,17.5Z" | ||
/> | ||
</svg> | ||
); | ||
}; | ||
|
||
export default LinkIcon; |
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
25 changes: 25 additions & 0 deletions
25
frontend/src/components/ShareLinks/CopyLinkButton.styles.ts
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,25 @@ | ||
import styled from '@emotion/styled'; | ||
import { SerializedStyles } from '@emotion/utils'; | ||
|
||
import { COLOR } from 'src/constants'; | ||
import Flex from 'src/styles/Flex'; | ||
|
||
export const Container = styled.div<{ css: SerializedStyles }>` | ||
${Flex({ flexDirection: 'column', justifyContent: 'center', alignItems: 'center' })} | ||
font-size: 0.8rem; | ||
color: ${COLOR.BLACK}; | ||
> button { | ||
cursor: copy; | ||
} | ||
> input { | ||
// input이 화면에 보이지 않으면 select할 범위를 찾지 못하는 이슈로 인해, 화면 바깥으로 숨김 | ||
position: fixed; | ||
top: -20rem; | ||
right: -20rem; | ||
} | ||
${({ css }) => css}; | ||
`; |
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,66 @@ | ||
import { useContext, useRef } from 'react'; | ||
import { useLocation } from 'react-router'; | ||
import { css as emotionCss } from '@emotion/react'; | ||
import { SerializedStyles } from '@emotion/utils'; | ||
|
||
import { COLOR, MESSAGE } from 'src/constants'; | ||
import { LinkIcon } from '../@Icons'; | ||
import IconButton from '../@shared/Button/IconButton'; | ||
import { SnackbarContext } from '../@shared/Snackbar/SnackbarProvider'; | ||
import { Container } from './CopyLinkButton.styles'; | ||
|
||
const HOST_URL = process.env.SNOWPACK_PUBLIC_HOST_URL; | ||
|
||
const CopyLinkButton = ({ css }: { css: SerializedStyles }) => { | ||
const inputRef = useRef<HTMLInputElement>(null); | ||
|
||
const location = useLocation(); | ||
|
||
const targetLink = HOST_URL + location.pathname; | ||
|
||
const { setSnackbarMessage } = useContext(SnackbarContext) ?? {}; | ||
|
||
const copyLink = async () => { | ||
const clipboard = navigator.clipboard; | ||
|
||
try { | ||
await clipboard.writeText(targetLink); | ||
|
||
setSnackbarMessage?.({ type: 'CONFIRM', message: MESSAGE.COPY_LINK_SUCCESS }); | ||
} catch (error) { | ||
try { | ||
// 카카오톡 인앱 브라우저에서 clipboard 미적용으로 인한 지원 하지 않음 에러 발생 | ||
inputRef.current?.select(); | ||
inputRef.current?.setSelectionRange(0, targetLink.length); | ||
|
||
document.execCommand('Copy'); | ||
setSnackbarMessage?.({ type: 'CONFIRM', message: MESSAGE.COPY_LINK_SUCCESS }); | ||
} catch (error) { | ||
setSnackbarMessage?.({ type: 'ERROR', message: MESSAGE.COPY_LINK_FAILED }); | ||
} | ||
} | ||
}; | ||
|
||
return ( | ||
<Container css={css}> | ||
<IconButton | ||
id="copy-url-button" | ||
size="SMALL" | ||
margin="0 0 0.2rem" | ||
css={emotionCss` | ||
padding: 0.6rem; | ||
background-color: ${COLOR.PURPLE_400}; | ||
border-radius: 50%; | ||
`} | ||
onClick={copyLink} | ||
> | ||
<LinkIcon /> | ||
</IconButton> | ||
<label htmlFor="copy-url-button">URL 복사</label> | ||
<input ref={inputRef} type="text" value={targetLink} readOnly /> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default CopyLinkButton; |
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,78 @@ | ||
import { useContext, useEffect } from 'react'; | ||
import { useLocation } from 'react-router'; | ||
import { css as emotionCss } from '@emotion/react'; | ||
import { SerializedStyles } from '@emotion/utils'; | ||
|
||
import { COLOR, MESSAGE } from 'src/constants'; | ||
import { KakaoIcon } from '../@Icons'; | ||
import IconButton from '../@shared/Button/IconButton'; | ||
import { SnackbarContext } from '../@shared/Snackbar/SnackbarProvider'; | ||
import { Container } from './CopyLinkButton.styles'; | ||
|
||
const JS_KEY = process.env.SNOWPACK_PUBLIC_KAKAO_JS_KEY; | ||
const TEMPLATE_ID = Number(process.env.SNOWPACK_PUBLIC_KAKAO_SHARE_TEMPLATE_ID); | ||
|
||
const KakaoShareButton = ({ | ||
content, | ||
css, | ||
}: { | ||
content: { title: string; description: string; imageUrl: string }; | ||
css: SerializedStyles; | ||
}) => { | ||
const location = useLocation(); | ||
const kakao = window.Kakao; | ||
|
||
const { setSnackbarMessage } = useContext(SnackbarContext) ?? {}; | ||
|
||
const shareWithKakao = async () => { | ||
if (!kakao) { | ||
setSnackbarMessage?.({ | ||
type: 'ERROR', | ||
message: MESSAGE.KAKAO_SHARE_FAILED, | ||
}); | ||
return; | ||
} | ||
|
||
kakao.Link.sendCustom({ | ||
templateId: TEMPLATE_ID, | ||
templateArgs: { | ||
TITLE: content.title, | ||
DESCRIPTION: content.description, | ||
IMAGE_URL: content.imageUrl, | ||
PATH: location.pathname.substring(1), | ||
}, | ||
}); | ||
}; | ||
|
||
useEffect(() => { | ||
if (!kakao?.isInitialized()) { | ||
kakao?.init(JS_KEY); | ||
} | ||
}, [kakao]); | ||
|
||
return ( | ||
<Container css={css}> | ||
<IconButton | ||
id="kakao-share-button" | ||
size="SMALL" | ||
margin="0 0 0.3rem" | ||
css={emotionCss` | ||
padding: 0.6rem; | ||
background-color: ${COLOR.YELLOW_300}; | ||
border-radius: 50%; | ||
`} | ||
onClick={shareWithKakao} | ||
> | ||
<KakaoIcon /> | ||
</IconButton> | ||
<label htmlFor="kakao-share-button"> | ||
카카오톡 | ||
<br /> | ||
공유하기 | ||
</label> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default KakaoShareButton; |
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
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