|
1 | 1 | import Page from "components/common/Page"
|
2 | 2 | import React from "react"
|
3 | 3 | import styled from "styled-components"
|
| 4 | + |
4 | 5 | import useTranslation from "utils/hooks/useTranslation"
|
5 | 6 |
|
| 7 | +const KAKAO_MAP_URL = "https://place.map.kakao.com/700052629" |
| 8 | +const NAVER_MAP_URL = "https://naver.me/FfMdLRIM" |
| 9 | +const GOOGLE_MAP_URL = "https://maps.app.goo.gl/H8QiqNRrHHwa6giv7" |
| 10 | +const GOOGLE_MAP_IFRAME_SRC = |
| 11 | + "https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d4548.557545780045!2d126.92092772543593!3d37.55771056652137!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x357c98d855555555%3A0x843e97bd5279ea6b!2z7ZWc67mb66-465SU7Ja0KOyjvCk!5e0!3m2!1sko!2skr!4v1730765243757!5m2!1sko!2skr" |
| 12 | + |
| 13 | +type MapInfoStateType = { |
| 14 | + mapType: "kakao" | "google" |
| 15 | +} |
| 16 | + |
6 | 17 | const Tutorial = () => {
|
| 18 | + const kakaoMapRef = React.useRef<HTMLDivElement>(null) |
| 19 | + const [state, setState] = React.useState<MapInfoStateType>({ mapType: "kakao" }) |
7 | 20 | const t = useTranslation()
|
8 | 21 |
|
| 22 | + const selectMap = (mapType: MapInfoStateType["mapType"]) => |
| 23 | + setState((prevState) => ({ ...prevState, mapType })) |
| 24 | + |
| 25 | + React.useEffect(() => { |
| 26 | + if (!(window.kakao && window.kakao.maps && kakaoMapRef.current)) return |
| 27 | + |
| 28 | + const content = `<a href="${KAKAO_MAP_URL}"><div style="width:150px;text-align:center;color:#000">${t("한빛미디어")}</div></a>` |
| 29 | + const position = new window.kakao.maps.LatLng(37.55917491634307, 126.9278766893293) |
| 30 | + const map = new window.kakao.maps.Map(kakaoMapRef.current, { center: position, level: 3 }) |
| 31 | + new kakao.maps.InfoWindow({ content }).open(map, new kakao.maps.Marker({ map, position })) |
| 32 | + }) |
| 33 | + |
| 34 | + const flexBoxStyle: React.CSSProperties = { |
| 35 | + display: "flex", |
| 36 | + justifyContent: "center", |
| 37 | + alignItems: "center", |
| 38 | + } |
| 39 | + const columnFlexBoxStyle: React.CSSProperties = { ...flexBoxStyle, flexDirection: "column" } |
| 40 | + const mapStyle: React.CSSProperties = { border: 0, width: "100%", height: "450px" } |
| 41 | + |
9 | 42 | return (
|
10 | 43 | <Page title={t("튜토리얼")}>
|
11 | 44 | <h1>
|
@@ -263,8 +296,26 @@ const Tutorial = () => {
|
263 | 296 | <h3>시간 & 장소</h3>
|
264 | 297 | <ul>
|
265 | 298 | <li>시간 : 10:00 ~ 18:00</li>
|
266 |
| - <li>장소 : 서울 서대문구 연희로 2길 62</li> |
| 299 | + <li> |
| 300 | + 장소 : 서울 서대문구 연희로 2길 62 |
| 301 | + </li> |
267 | 302 | </ul>
|
| 303 | + <div> |
| 304 | + <div style={{ ...flexBoxStyle }}> |
| 305 | + <MapSelectTabBtn className={state.mapType === "kakao" ? "active" : ""} onClick={() => selectMap("kakao")}>{t("카카오맵")}</MapSelectTabBtn> |
| 306 | + <MapSelectTabBtn className={state.mapType === "google" ? "active" : ""} onClick={() => selectMap("google")}>{t("구글 지도")}</MapSelectTabBtn> |
| 307 | + </div> |
| 308 | + |
| 309 | + <div style={{ ...columnFlexBoxStyle, display: state.mapType === "kakao" ? "flex" : "none" }}> |
| 310 | + <div ref={kakaoMapRef} style={mapStyle}></div> |
| 311 | + <FullWidthAnchorBtn href={KAKAO_MAP_URL} target="_blank" rel="noreferrer"><button className="kakao">{t("카카오맵에서 열기")}</button></FullWidthAnchorBtn> |
| 312 | + <FullWidthAnchorBtn href={NAVER_MAP_URL} target="_blank" rel="noreferrer"><button className="naver">{t("네이버 지도에서 열기")}</button></FullWidthAnchorBtn> |
| 313 | + </div> |
| 314 | + <div style={{ ...columnFlexBoxStyle, display: state.mapType === "google" ? "flex" : "none" }}> |
| 315 | + <iframe title="map" src={GOOGLE_MAP_IFRAME_SRC} style={mapStyle} allowFullScreen loading="lazy" referrerPolicy="no-referrer-when-downgrade"></iframe> |
| 316 | + <FullWidthAnchorBtn href={GOOGLE_MAP_URL} target="_blank" rel="noreferrer"><button className="google">{t("구글 지도에서 열기")}</button></FullWidthAnchorBtn> |
| 317 | + </div> |
| 318 | + </div> |
268 | 319 | </p>
|
269 | 320 | <br />
|
270 | 321 | <p>
|
@@ -359,3 +410,58 @@ const TutorialProgramDetails = styled.details`
|
359 | 410 | }
|
360 | 411 | }
|
361 | 412 | `
|
| 413 | + |
| 414 | +const MapSelectTabBtn = styled.button` |
| 415 | + flex-grow: 1; |
| 416 | + padding: 0.25rem; |
| 417 | +
|
| 418 | + border: none; |
| 419 | + background-color: rgba(255, 255, 255, 0.05); |
| 420 | + font-weight: lighter; |
| 421 | +
|
| 422 | + border-radius: 0; |
| 423 | +
|
| 424 | + &:hover { |
| 425 | + background-color: rgba(255, 255, 255, 0.1); |
| 426 | + } |
| 427 | +
|
| 428 | + &.active { |
| 429 | + background-color: rgba(255, 255, 255, 0.3); |
| 430 | + font-weight: bold; |
| 431 | + } |
| 432 | +` |
| 433 | + |
| 434 | +const FullWidthAnchorBtn = styled.a` |
| 435 | + width: 100%; |
| 436 | + height: 1.5rem; |
| 437 | + display: flex; |
| 438 | + justify-content: flex-start; |
| 439 | + align-items: center; |
| 440 | +
|
| 441 | + button { |
| 442 | + width: 100%; |
| 443 | + height: 100%; |
| 444 | + margin: 0; |
| 445 | + padding: 0 0.5rem; |
| 446 | +
|
| 447 | + font-size: 0.75rem; |
| 448 | + font-weight: bold; |
| 449 | + border: none; |
| 450 | + border-radius: unset; |
| 451 | +
|
| 452 | + &.kakao { |
| 453 | + background-color: #fee500; |
| 454 | + color: #191919; |
| 455 | + } |
| 456 | +
|
| 457 | + &.naver { |
| 458 | + background-color: #04c75b; |
| 459 | + color: #fff; |
| 460 | + } |
| 461 | +
|
| 462 | + &.google { |
| 463 | + background-color: #4285f4; |
| 464 | + color: #fff; |
| 465 | + } |
| 466 | + } |
| 467 | +` |
0 commit comments