Merge remote-tracking branch 'origin/main' into feat/apps-in-toss
This commit is contained in:
commit
239a22ee06
139 files changed
+7645
-59
No files matched your search
@@ -37,15 +37,47 @@ import { useInstall, useInstallable } from './install'
|
||||
import { InstallSheet } from './installBanner'
|
||||
import { ARTICLE_CAT, SHEET_CLOSE_MS, SHEET_OPEN_MS } from './lib'
|
||||
import { MixSheet, MyGakSheet } from './myGak'
|
||||
import { TarotSheet } from './fortune'
|
||||
import { LevelCard, LevelSheet, LevelUpSheet, useCloseAndGo, useShareReward } from './level'
|
||||
import { BIRTH_PLACES, useAccountBirth, useBirth, useSaveBirth } from './sajuBirth'
|
||||
import { ownPage, useRegion } from './regionContext'
|
||||
import { WeatherWhySheet } from './weatherWhy'
|
||||
import { useSky } from './skyContext'
|
||||
import { LEVELS } from './cloudMerge'
|
||||
import { SHARE_SIZES, shareImage, type ShareSize } from './storyImage'
|
||||
import { SheetContext, useSheet, type SharePayload, type SheetState } from './sheetContext'
|
||||
import { HeartIcon } from './svg'
|
||||
import { MyTalks, TalkSheet } from './talk'
|
||||
import { Avatar, Ic, Skel, StateBox, TAP44, Thumb } from './ui'
|
||||
|
||||
/** 내 정보: 계정에 저장한 생년월일 (날씨 사주) */
|
||||
function MyBirth() {
|
||||
useAccountBirth()
|
||||
const birth = useBirth()
|
||||
const save = useSaveBirth()
|
||||
const go = useCloseAndGo()
|
||||
const place = BIRTH_PLACES.find(([k]) => k === birth?.place)?.[1]
|
||||
return (
|
||||
<section aria-label="내 생년월일" className="flex items-center gap-2.5 rounded-2xl bg-[#f6f8fc] px-3.5 py-3">
|
||||
<Ic name="yin_yang" className="size-7 shrink-0" />
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="m-0 text-[13px] font-extrabold">내 생년월일</p>
|
||||
<p className="m-0 truncate text-xs font-semibold text-(--ink2)">
|
||||
{birth ? `${birth.y}.${birth.m}.${birth.d}${birth.hour != null ? ` ${birth.hour}시 ${birth.minute ?? 0}분` : ''}${place ? ` · ${place}` : ''}` : '넣어 두면 날씨 사주를 바로 볼 수 있어요'}
|
||||
</p>
|
||||
</div>
|
||||
<button type="button" onClick={() => go('/saju')} className="shrink-0 cursor-pointer text-xs font-extrabold text-(--orange)">
|
||||
{birth ? '사주 보기' : '넣기'}
|
||||
</button>
|
||||
{birth && (
|
||||
<button type="button" onClick={() => save(null)} className="shrink-0 cursor-pointer text-xs font-extrabold text-(--ink3)">
|
||||
지우기
|
||||
</button>
|
||||
)}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export function SheetProvider({ children }: { children: ReactNode }) {
|
||||
const [state, setState] = useState<SheetState>(null)
|
||||
// 창이 열려 있는 동안 방문 기록을 하나 쌓아 두어 뒤로 가기가 창만 닫게 한다
|
||||
@@ -55,6 +87,7 @@ export function SheetProvider({ children }: { children: ReactNode }) {
|
||||
window.history.pushState({ ...window.history.state, sheet: true }, '')
|
||||
pushed.current = true
|
||||
}
|
||||
track('sheet_open', { sheet: s.type })
|
||||
setState(s)
|
||||
}, [])
|
||||
const close = useCallback(() => {
|
||||
@@ -86,7 +119,7 @@ export function SheetProvider({ children }: { children: ReactNode }) {
|
||||
)
|
||||
}
|
||||
|
||||
const TITLES = { article: '읽을거리', seasonWeek: '이번 주 특집', share: '보내기', comments: '댓글', login: '로그인', me: '내 정보', region: '지역 바꾸기', install: '홈 화면에 추가', weatherWhy: '날씨 점수는 이렇게 나와요', talk: '이야기' } as const
|
||||
const TITLES = { article: '읽을거리', seasonWeek: '이번 주 특집', share: '보내기', comments: '댓글', login: '로그인', me: '내 정보', region: '지역 바꾸기', install: '홈 화면에 추가', weatherWhy: '날씨 점수는 이렇게 나와요', talk: '이야기', tarot: '오늘 타로', level: '내 레벨', levelUp: '레벨이 올랐어요', gameHelp: '구름 합치기 하는 법' } as const
|
||||
|
||||
/** 아래에서 올라오는 창: 네이티브 <dialog>라 ESC·포커스 가두기·포커스 되돌리기가 기본으로 된다 */
|
||||
function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void }) {
|
||||
@@ -166,14 +199,18 @@ function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void
|
||||
{shown.type === 'seasonWeek' && <SeasonWeekSheet />}
|
||||
{shown.type === 'share' && <ShareSheet share={shown.share} />}
|
||||
{shown.type === 'comments' && <CommentsSheet postId={shown.postId} draft={shown.draft} />}
|
||||
{shown.type === 'login' && <LoginSheet onDone={onClose} onLoggedIn={then ? () => open(then) : onClose} />}
|
||||
{shown.type === 'login' && <LoginSheet onDone={onClose} onLoggedIn={then ? () => open(then) : onClose} why={shown.why} />}
|
||||
{shown.type === 'me' && <MeSheet onDone={onClose} />}
|
||||
{shown.type === 'region' && <RegionSheet onDone={onClose} />}
|
||||
{shown.type === 'mix' && <MixSheet shared={shown.shared} onDone={onClose} />}
|
||||
{shown.type === 'myGak' && <MyGakSheet gak={shown.gak} shot={shown.shot} onDone={onClose} />}
|
||||
{shown.type === 'install' && <InstallSheet />}
|
||||
{shown.type === 'weatherWhy' && <WeatherWhySheet d={shown.why} />}
|
||||
{shown.type === 'tarot' && <TarotSheet />}
|
||||
{shown.type === 'level' && <LevelSheet />}
|
||||
{shown.type === 'levelUp' && <LevelUpSheet level={shown.level} />}
|
||||
{shown.type === 'talk' && <TalkSheet talk={shown.talk} />}
|
||||
{shown.type === 'gameHelp' && <GameHelpSheet />}
|
||||
</div>
|
||||
)}
|
||||
{!shown && <RegionLinks />}
|
||||
@@ -515,6 +552,37 @@ function ArticleSheet({ articleId, onTitle }: { articleId: number; onTitle: (t:
|
||||
}
|
||||
|
||||
/* ---------- 이번 주 특집 ---------- */
|
||||
const GAME_STEPS = [
|
||||
'목표 점수를 채우면 다음 라운드로 넘어가요. 라운드가 오를수록 목표가 높아져요.',
|
||||
'손가락을 좌우로 움직여 떨어뜨릴 자리를 고르고, 손을 떼면 떨어져요.',
|
||||
'떨어지는 동안 오늘 우리 동네 바람만큼 옆으로 밀려요. 바람 방향을 보고 조금 비켜 떨어뜨리세요.',
|
||||
'같은 그림끼리 닿으면 한 단계 큰 그림으로 합쳐지고 점수가 올라요.',
|
||||
'해 둘이 만나면 사라지면서 보너스 점수!',
|
||||
'쌓인 그림이 위쪽 점선을 넘은 채로 잠깐 있으면 끝나요. 판은 다음 라운드로 그대로 이어져요.',
|
||||
'로그인하면 라운드를 깰 때마다 2각을 받아요. 하루 20각까지예요.',
|
||||
]
|
||||
|
||||
function GameHelpSheet() {
|
||||
return (
|
||||
<Body>
|
||||
<ol className="m-0 flex list-decimal flex-col gap-2 pl-5 text-[15px] leading-[1.6]">
|
||||
{GAME_STEPS.map((t) => (
|
||||
<li key={t}>{t}</li>
|
||||
))}
|
||||
</ol>
|
||||
<p className="mt-4 mb-2 text-[13px] font-extrabold text-(--ink2)">합쳐지는 순서</p>
|
||||
<div className="grid grid-cols-4 gap-2 rounded-[16px] bg-[#f3f6fb] p-3">
|
||||
{LEVELS.map((l, i) => (
|
||||
<span key={l.icon} className="flex flex-col items-center gap-0.5 text-[12px] font-bold">
|
||||
<Ic name={l.icon} className="size-8" />
|
||||
{i + 1}. {l.name}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</Body>
|
||||
)
|
||||
}
|
||||
|
||||
function SeasonWeekSheet() {
|
||||
const { open } = useSheet()
|
||||
const q = useQuery(getSeasonWeekOptions())
|
||||
@@ -554,6 +622,7 @@ const SIZE_KEYS = Object.keys(SHARE_SIZES) as ShareSize[]
|
||||
|
||||
function ShareSheet({ share }: { share: SharePayload }) {
|
||||
const { region } = useRegion()
|
||||
const reward = useShareReward()
|
||||
const { kind } = useSky()
|
||||
const [size, setSize] = useState<ShareSize>('story')
|
||||
const [images, setImages] = useState<Partial<Record<ShareSize, { blob: Blob; src: string }>>>({})
|
||||
@@ -600,6 +669,7 @@ function ShareSheet({ share }: { share: SharePayload }) {
|
||||
(r) => {
|
||||
setToast(r === 'saved' ? '이미지를 저장하고 링크를 보냈어요' : '링크를 보냈어요')
|
||||
track('share', { content_type: 'image', item_id: share.title, method: 'share_sheet', ratio: SHARE_SIZES[size].ratio })
|
||||
reward()
|
||||
},
|
||||
(e: unknown) => {
|
||||
console.error('[share] toss', e)
|
||||
@@ -620,6 +690,7 @@ function ShareSheet({ share }: { share: SharePayload }) {
|
||||
async () => {
|
||||
setToast((await copied) ? '보냈어요. 링크도 복사해 뒀어요' : '보냈어요')
|
||||
track('share', { content_type: 'image', item_id: share.title, method: 'share_sheet', ratio: SHARE_SIZES[size].ratio })
|
||||
reward()
|
||||
},
|
||||
(e: unknown) => {
|
||||
if (e instanceof DOMException && e.name === 'AbortError') return
|
||||
@@ -693,9 +764,10 @@ function CommentMenu({ c, postId, onNotice }: { c: CommentData; postId: number;
|
||||
const block = useMutation(blockAuthorMutation())
|
||||
const pending = report.isPending || block.isPending
|
||||
|
||||
const finish = (notice: string) => ({
|
||||
const finish = (notice: string, done: () => void) => ({
|
||||
onSuccess: (res: { result?: { success?: boolean } }) => {
|
||||
if (!res.result?.success) return setFailed(true)
|
||||
done()
|
||||
setStep('closed')
|
||||
onNotice(notice)
|
||||
queryClient.invalidateQueries({ predicate: isCommentList })
|
||||
@@ -729,14 +801,14 @@ function CommentMenu({ c, postId, onNotice }: { c: CommentData; postId: number;
|
||||
)}
|
||||
{step === 'report' &&
|
||||
REPORT_REASONS.map(([reason, label]) => (
|
||||
<button key={reason} type="button" disabled={pending} className={btn} onClick={() => report.mutate({ path: { comment_id: c.comment_id }, body: { reason } }, finish('신고했어요. 확인하고 조치할게요.'))}>
|
||||
<button key={reason} type="button" disabled={pending} className={btn} onClick={() => report.mutate({ path: { comment_id: c.comment_id }, body: { reason } }, finish('신고했어요. 확인하고 조치할게요.', () => track('report', { content_type: 'comment', reason })))}>
|
||||
{label}
|
||||
</button>
|
||||
))}
|
||||
{step === 'block' && (
|
||||
<>
|
||||
<span className="w-full text-[13px] font-bold text-(--ink)">{c.nickname}님 댓글을 더는 안 볼까요?</span>
|
||||
<button type="button" disabled={pending} className={cx(btn, 'bg-(--heart) text-white')} onClick={() => block.mutate({ path: { comment_id: c.comment_id } }, finish('차단했어요. 내 정보에서 풀 수 있어요.'))}>
|
||||
<button type="button" disabled={pending} className={cx(btn, 'bg-(--heart) text-white')} onClick={() => block.mutate({ path: { comment_id: c.comment_id } }, finish('차단했어요. 내 정보에서 풀 수 있어요.', () => track('block', { content_type: 'comment' })))}>
|
||||
차단하기
|
||||
</button>
|
||||
<button type="button" disabled={pending} className={btn} onClick={() => go('closed')}>
|
||||
@@ -783,6 +855,7 @@ function CommentRow({ c, postId, onNotice }: { c: CommentData; postId: number; o
|
||||
if (res.result?.success) {
|
||||
setLiked(!!res.liked)
|
||||
if (res.like_count != null) setCount(res.like_count)
|
||||
if (next) track('like', { content_type: 'comment', item_id: c.comment_id })
|
||||
return
|
||||
}
|
||||
revert()
|
||||
@@ -884,6 +957,7 @@ function CommentsSheet({ postId, draft }: { postId: number; draft?: string }) {
|
||||
if (res.result?.desc === 'TERMS_REQUIRED') return setAskTerms(true)
|
||||
setAddFailed(!res.result?.success)
|
||||
if (!res.result?.success) return
|
||||
track('comment', { post_id: postId })
|
||||
setText('')
|
||||
queryClient.invalidateQueries({ queryKey: listCommentsInfiniteQueryKey({ path: { post_id: postId } }) })
|
||||
queryClient.invalidateQueries({ queryKey: getFeedQueryKey({ query: { region: region.code } }) })
|
||||
@@ -906,6 +980,7 @@ function CommentsSheet({ postId, draft }: { postId: number; draft?: string }) {
|
||||
{
|
||||
onSuccess: (res) => {
|
||||
if (!res.result?.success) return setAddFailed(true)
|
||||
track('terms_agree', {})
|
||||
queryClient.setQueryData(meQueryKey(), res)
|
||||
setAskTerms(false)
|
||||
send()
|
||||
@@ -978,7 +1053,7 @@ function CommentsSheet({ postId, draft }: { postId: number; draft?: string }) {
|
||||
}
|
||||
|
||||
/* ---------- 로그인 ---------- */
|
||||
function LoginSheet({ onDone, onLoggedIn }: { onDone: () => void; onLoggedIn: () => void }) {
|
||||
function LoginSheet({ onDone, onLoggedIn, why }: { onDone: () => void; onLoggedIn: () => void; why?: 'level' }) {
|
||||
const { me } = useAuth()
|
||||
const [error, setError] = useState('')
|
||||
|
||||
@@ -999,7 +1074,7 @@ function LoginSheet({ onDone, onLoggedIn }: { onDone: () => void; onLoggedIn: ()
|
||||
return (
|
||||
<Body>
|
||||
<div className="flex flex-col gap-2.5">
|
||||
<p className="text-center text-sm font-semibold text-(--ink2)">글쓰기는 로그인한 뒤에 할 수 있어요.</p>
|
||||
<p className="text-center text-sm font-semibold text-(--ink2)">{why === 'level' ? '로그인하면 출석·사주·좋아요로 각이 쌓여 레벨이 올라요.' : '글쓰기는 로그인한 뒤에 할 수 있어요.'}</p>
|
||||
<GoogleButton
|
||||
onResult={(res) => {
|
||||
setError('')
|
||||
@@ -1194,6 +1269,8 @@ function MeSheet({ onDone }: { onDone: () => void }) {
|
||||
<Avatar character={me.character} color={me.color} mood={me.mood} size={64} />
|
||||
<p className="m-0 text-center text-sm font-semibold text-(--ink2)">{me.provider === AuthProvider.TOSS ? '토스로 로그인했어요' : me.provider === AuthProvider.GOOGLE ? '구글 계정으로 로그인했어요' : `${me.login_id}(으)로 로그인했어요`}</p>
|
||||
</div>
|
||||
<LevelCard />
|
||||
<MyBirth />
|
||||
{installable && (
|
||||
<button type="button" onClick={() => install('menu')} className="cursor-pointer rounded-2xl bg-[#fff4ec] py-2.5 font-jua text-[15.5px] text-(--orange)">
|
||||
📲 홈 화면에 추가
|
||||
|
||||
Reference in new issue
Block a user