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 | /* eslint-disable jsx-a11y/click-events-have-key-events */ import React from 'react'; import { css } from '@emotion/react'; import { coreDirectApi } from '@lib/apis/core'; import { getProjectsDataResponse } from '@lib/apis/core/getProjectsData'; import { useAsync } from 'react-use'; import LocationIcon from '@lib/components/icons/Location'; import { useRouter } from 'next/router'; import { useIsForWebviewContext } from '@lib/providers/IsForWebview'; export default function ProjectList({ color }: { color?: string }) { const { isWebview } = useIsForWebviewContext(); const { value: projectsData } = useAsync(async () => { const { data } = await coreDirectApi.get<getProjectsDataResponse>('/api/mainpage/header'); return data; }); const PROJECT_GAME_TABLE = { CLASSIC: 'classic', CLASSIC_PLUS: 'classicplus', MOBILE: 'mobile', INTERACTION: 'interaction', ETC: 'etc' } as const; const filterGameType = (project: { projectGameType: string; playArea: string; etcTypeDescription?: string; interactionTypeDescription?: string; }) => { let type = ''; const gameType = project.projectGameType.toLowerCase(); if (gameType === PROJECT_GAME_TABLE.CLASSIC || gameType === PROJECT_GAME_TABLE.CLASSIC_PLUS) type = project.playArea ?? '야외형'; if (gameType === PROJECT_GAME_TABLE.MOBILE) type = '모바일'; if (gameType === PROJECT_GAME_TABLE.INTERACTION) type = project.interactionTypeDescription ?? '키트형'; if (gameType === PROJECT_GAME_TABLE.ETC) type = project.etcTypeDescription ?? '교육용'; return type; }; const textColorStyle = React.useMemo(() => { const cssText = ` color: ${color}; `; return css(cssText); }, [color]); const router = useRouter(); const moveToProject = async (projectId: string, projectName: string) => { const projectLink = `https://realworld.app.link?deeplink_path=realworld://project?projectId=${projectId}&utm_source=webplay&utm_campaign=${projectName}&flow=0&utm_medium=webplay_ending_screen&$desktop_url=https://realworld.to/projects/${projectId}&utm_content=web&$ios_deep_view=realworld_deep_view&$ios_passive_deep_view=realworld_deep_view&$android_passive_deepview=realworld_deep_view&$android_deepview=realworld_deep_view&mt=8&$ios_uri_redirect_mode=0 `; await router.push(projectLink); }; const moveToProjectForWebview = (projectId: string) => { window.flutter_inappwebview.callHandler('moveProject', projectId); }; const onProjectClick = React.useMemo( () => (isWebview ? moveToProjectForWebview : moveToProject), [isWebview, moveToProject] ); return ( <div css={mainContainer}> <div css={[projectTitle, textColorStyle]}> 이 게임이 재밌었다면? <br /> 리얼월드에서 더 다양한 경험을 즐겨보세요! </div> <div css={projectContainer}> {projectsData?.map((project) => ( <div css={itemContainer}> <img css={itemImageStyle} src={project.verticalImageUrl} alt={project.name} onClick={() => onProjectClick(project.id, project.name)} /> <div css={itemTagTitleContainer}> <div css={itemTagWrapper}> {project.playArea && <LocationIcon css={playAreaIcon} />} <div css={itemTag}>{filterGameType(project)}</div> </div> <div key={project.id} css={[itemTitle, textColorStyle]}> {project.name} </div> </div> </div> ))} </div> </div> ); } const mainContainer = css` display: flex; flex-direction: column; gap: 16px; padding: 0 16px 24px; `; const projectTitle = css` color: #000000; font-feature-settings: 'clig' off, 'liga' off; font-family: LINE Seed Sans KR, sans-serif; font-size: 16px; font-style: normal; font-weight: 700; line-height: 130%; `; const projectContainer = css` display: grid; gap: 16px; grid-template-columns: repeat(2, 1fr); `; const itemContainer = css` display: flex; flex-direction: column; gap: 8px; `; const itemImageStyle = css` width: 100%; border-radius: 8px; cursor: pointer; `; const itemTagTitleContainer = css` display: flex; flex-direction: column; align-items: flex-start; gap: 6px; `; const itemTagWrapper = css` display: flex; padding: 2px 6px; justify-content: center; align-items: center; gap: 2px; border-radius: 4px; background: #f9f0ff; max-width: 100%; `; const itemTag = css` color: #aa59d9; font-family: LINE Seed Sans KR Medium, sans-serif; font-size: 10px; font-style: normal; font-weight: 700; line-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; `; const itemTitle = css` color: #000000; font-family: LINE Seed Sans KR Medium, sans-serif; font-size: 12px; font-style: normal; font-weight: 700; line-height: 16px; word-break: keep-all; `; const playAreaIcon = css` width: 12px; height: 12px; flex-shrink: 0; `; |