Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | /* eslint-disable jsx-a11y/click-events-have-key-events */ import React from 'react'; import { css } from '@emotion/react'; import CloseIcon from '@lib/components/icons/Close'; import FacebookIcon from '@lib/components/icons/Facebook'; import TwitterIcon from '@lib/components/icons/Twitter'; import CopyIcon from '@lib/components/icons/Copy'; import { getProjectDetail } from '@lib/apis/core/getProjectDetail'; import { useAsyncFn } from 'react-use'; import { useToastContext } from '@lib/providers/Toast'; export function useShareModal() { const [isOpen, setIsOpen] = React.useState(false); const onClose = () => setIsOpen(false); const openShareModal = () => setIsOpen(true); const shareModalProps = React.useMemo( () => ({ isOpen, onClose }), [isOpen, setIsOpen] ); return { props: shareModalProps, openShareModal }; } interface ShareModalProps { isOpen: boolean; onClose: () => void; gameId: string; } export function ShareModal({ isOpen, onClose, gameId }: ShareModalProps) { const { openToast } = useToastContext(); const [fetchProjectState, doFetchProjectState] = useAsyncFn(async () => { const project = await getProjectDetail(gameId); return project; }, [gameId]); const sendUrl = `https://realworld.to/projects/${gameId}`; function shareOnFacebook() { const url = `https://www.facebook.com/sharer/sharer.php?u=${sendUrl}`; window.open(url, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width=600,height=400'); onClose(); } const shareOnTwitter = React.useCallback(async () => { const projectDetail = fetchProjectState.value ?? (await doFetchProjectState()); const { name } = projectDetail; const url = `https://twitter.com/intent/tweet?&text=${`${name} - 지금 바로 리얼월드에서 플레이해보세요!`} ${sendUrl}`; window.open(url, 'TwitterWindow', 'width=600,height=450'); onClose(); }, [fetchProjectState.value]); function copyUrl() { navigator.clipboard.writeText(sendUrl); openToast({ text: '복사가 완료되었습니다.' }); onClose(); } return isOpen ? ( <div css={modalWrapper}> <div css={backDrop}> <div css={modalBody}> <div css={modalHeader}> <div css={modalTitle}>게임 공유하기</div> <button type="button" css={closeButton} onClick={onClose}> <CloseIcon css={closeButtonIcon} /> </button> </div> <div css={dividerWrapper}> <div css={divider} /> </div> <div css={modalContentContainer}> <div css={shareItemContainer}> <div css={shareItem}> <FacebookIcon css={shareIcon} onClick={shareOnFacebook} /> <div css={shareText}>페이스북</div> </div> <div css={shareItem}> <TwitterIcon css={shareIcon} onClick={shareOnTwitter} /> <div css={shareText}>X(트위터)</div> </div> <div css={shareItem}> <CopyIcon css={shareIcon} onClick={copyUrl} /> <div css={shareText}>링크복사</div> </div> </div> </div> </div> </div> </div> ) : null; } const modalWrapper = css` position: absolute; display: flex; justify-content: center; align-items: center; padding: 0 8px; `; const backDrop = css` position: fixed; display: flex; justify-content: center; align-items: center; top: 0; right: 0; bottom: 0; left: 0; background: rgba(0, 0, 0, 0.4); padding: 0 16px; z-index: 10000; `; const modalBody = css` max-width: 343px; width: 100%; margin: 0 16px; padding: 8px; border-radius: 8px; background: #ffffff; `; const modalHeader = css` position: relative; padding: 8px; `; const modalTitle = css` color: #000000; text-align: center; font-family: Noto Sans KR sans-serif; font-size: 18px; font-style: normal; font-weight: 500; line-height: 24px; `; const closeButton = css` position: absolute; top: 0; right: 0; display: flex; justify-content: flex-end; border: none; background: none; padding: 8px; `; const closeButtonIcon = css` color: #505050; width: 18px; height: 18px; cursor: pointer; `; const dividerWrapper = css` padding: 8px; `; const divider = css` width: 100%; height: 1px; background: #ededed; `; const modalContentContainer = css` padding: 16px; @media (max-width: 375px) { padding: 8px; } `; const shareItemContainer = css` display: flex; justify-content: center; gap: 30px; @media (max-width: 375px) { gap: 20px; } `; const shareItem = css` display: flex; flex-direction: column; gap: 4px; `; const shareIcon = css` cursor: pointer; @media (max-width: 375px) { width: 40px; height: 40px; } `; const shareText = css` color: #000000; text-align: center; font-feature-settings: 'clig' off, 'liga' off; font-family: Noto Sans KR sans-serif; font-size: 10px; font-style: normal; font-weight: 500; line-height: 16px; `; |