diff --git a/TODO.md b/TODO.md index 16335ad..ecfc8ba 100644 --- a/TODO.md +++ b/TODO.md @@ -116,11 +116,11 @@ | [x] | 공유 이미지: 카드 아래 긴 제목이 한 줄 폭에 눌려 찌그러짐 — 두 줄 나눔 또는 말줄임 | 공유 이미지 점검 (10/7) | `frontend/src/b/storyImage.ts` (`fillText`) | | [x] | 공유 이미지: 카드 아래 제목을 빼고 주소 알약으로 바꿈 (시안 A, 사용자 결정). 카드 안 제목과 카드 아래 제목이 같아 두 번 보임. 아래 줄을 뺄지, 다른 말(지역·날짜)로 바꿀지 정하기 | 공유 이미지 점검 (10/7) | `frontend/src/b/storyImage.ts` | | [x] | 노치(아이폰 상단 카메라 영역) 대응 — 화면 위·아래가 노치·홈 막대에 가리지 않게 safe-area 여백 점검 | 사용자 요청 | `frontend/index.html`, `frontend/src/b/BLayout.tsx` | -| [ ] | 안드로이드 뒤로 가기: 시트가 열려 있을 때 시트만 닫히지 않고 페이지가 뒤로 감 (방문 기록 미사용) | QA 작성 중 발견 (10/8) | `frontend/src/b/Sheets.tsx:53` | -| [ ] | 로그아웃 상태에서 댓글 "게시" → 로그인 시트 → 로그인 후 시트가 닫혀 쓰던 댓글이 사라지고 댓글 화면으로 안 돌아옴 | QA 작성 중 발견 (10/8) | `frontend/src/b/Sheets.tsx:662`, `:753` | -| [ ] | 터치 영역 44px 미만 — 포스트 하트·댓글·보내기 28px, 댓글 하트 약 16px, 시트 × 30px | QA 작성 중 발견 (10/8) | `frontend/src/b/Post.tsx:426`, `frontend/src/b/Sheets.tsx:637`, `:96` | -| [ ] | 주말 순위 로드 실패 시 토/일 칩이 눌리는 것처럼 보이지만 동작 없음 | QA 작성 중 발견 (10/8) | `frontend/src/b/WeekPage.tsx:278` | -| [ ] | **[결정 필요]** "지금 위치로 찾기" 성공 후 지역 시트가 안 닫힘 (목록에서 고르면 닫힘) — 닫을지 정하기 | QA 작성 중 발견 (10/8) | `frontend/src/b/region.tsx:44`, `frontend/src/b/Sheets.tsx:938` | +| [x] | 안드로이드 뒤로 가기: 시트가 열려 있을 때 시트만 닫히지 않고 페이지가 뒤로 감 (방문 기록 미사용) | QA 작성 중 발견 (10/8) | `frontend/src/b/Sheets.tsx:53` | +| [x] | 로그아웃 상태에서 댓글 "게시" → 로그인 시트 → 로그인 후 시트가 닫혀 쓰던 댓글이 사라지고 댓글 화면으로 안 돌아옴 | QA 작성 중 발견 (10/8) | `frontend/src/b/Sheets.tsx:662`, `:753` | +| [x] | 터치 영역 44px 미만 — 포스트 하트·댓글·보내기 28px, 댓글 하트 약 16px, 시트 × 30px | QA 작성 중 발견 (10/8) | `frontend/src/b/Post.tsx:426`, `frontend/src/b/Sheets.tsx:637`, `:96` | +| [x] | 주말 순위 로드 실패 시 토/일 칩이 눌리는 것처럼 보이지만 동작 없음 | QA 작성 중 발견 (10/8) | `frontend/src/b/WeekPage.tsx:278` | +| [x] | "지금 위치로 찾기" 성공 후 지역 시트가 안 닫힘 (목록에서 고르면 닫힘) — 닫을지 정하기 | QA 작성 중 발견 (10/8) | `frontend/src/b/region.tsx:44`, `frontend/src/b/Sheets.tsx:938` | | [ ] | **[결정 필요]** 홈 화면 상태바 색(`theme-color`)이 낮 하늘색 고정 — 밤 테마 등 시간대 따라 바꿀지 | 노치 대응 중 발견 (10/8) | `frontend/index.html` | | [ ] | **[결정 필요]** 데이트 명소: 서울 기존 10곳(직접 고른 곳)을 거리순과 상관없이 앞에 고정할지 | 데이트 명소 전국 확대 (10/8) | `backend/services/week_service.py` (`pick_places`) | | [ ] | 데이트 명소: 14개 구는 30km 안 실내 명소가 없어 비 오는 날에도 야외만 나옴 | 데이트 명소 전국 확대 (10/8) | `backend/seed/place_tourapi.csv` | diff --git a/frontend/src/b/Post.tsx b/frontend/src/b/Post.tsx index 52926cf..a30a5ef 100644 --- a/frontend/src/b/Post.tsx +++ b/frontend/src/b/Post.tsx @@ -11,7 +11,7 @@ import { useAuth } from './authContext' import { useSheet } from './sheetContext' import { CommentIcon, HeartIcon, SendIcon } from './svg' import { useCarousel } from './carousel' -import { Arrows, Credit, Ic, Rows, Skel, Thumb } from './ui' +import { Arrows, Credit, Ic, Rows, Skel, TAP44, Thumb } from './ui' const ACCOUNTS: Record = { [PostType.WEATHER]: ['오늘 날씨', 'sun'], @@ -423,13 +423,13 @@ function FullCard({ post }: PostProps) { )}
- - -
diff --git a/frontend/src/b/Sheets.tsx b/frontend/src/b/Sheets.tsx index aa19c99..040b702 100644 --- a/frontend/src/b/Sheets.tsx +++ b/frontend/src/b/Sheets.tsx @@ -28,16 +28,39 @@ import { useSky } from './skyContext' import { SHARE_SIZES, shareImage, type ShareSize } from './storyImage' import { SheetContext, useSheet, type SharePayload, type SheetState } from './sheetContext' import { HeartIcon } from './svg' -import { Avatar, Ic, Skel, StateBox, Thumb } from './ui' +import { Avatar, Ic, Skel, StateBox, TAP44, Thumb } from './ui' export function SheetProvider({ children }: { children: ReactNode }) { const [state, setState] = useState(null) - const open = useCallback((s: Exclude) => setState(s), []) - const close = useCallback(() => setState(null), []) + // 창이 열려 있는 동안 방문 기록을 하나 쌓아 두어 뒤로 가기가 창만 닫게 한다 + const pushed = useRef(false) + const open = useCallback((s: Exclude) => { + if (!pushed.current) { + window.history.pushState({ ...window.history.state, sheet: true }, '') + pushed.current = true + } + setState(s) + }, []) + const close = useCallback(() => { + setState(null) + if (!pushed.current) return + pushed.current = false + window.history.back() + }, []) const api = useMemo(() => ({ open, close }), [open, close]) + useEffect(() => { + const onPop = () => { + if (!pushed.current) return + pushed.current = false + setState(null) + } + window.addEventListener('popstate', onPop) + return () => window.removeEventListener('popstate', onPop) + }, []) + // 로그인이 필요한 요청이 401을 받으면 로그인 창을 띄운다 - useEffect(() => subscribeAuth((reason) => reason === 'required' && setState({ type: 'login' })), []) + useEffect(() => subscribeAuth((reason) => reason === 'required' && open({ type: 'login' })), [open]) return ( @@ -53,6 +76,7 @@ const TITLES = { article: '읽을거리', seasonWeek: '이번 주 특집', share function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void }) { const ref = useRef(null) const { kind } = useSky() + const { open } = useSheet() const [gakTitle, setGakTitle] = useState('') const [articleTitle, setArticleTitle] = useState('') @@ -75,6 +99,7 @@ function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void } }, [isOpen]) + const then = state?.type === 'login' ? state.then : undefined const title = !state ? '' : state.type === 'gak' ? gakTitle : state.type === 'article' ? articleTitle || TITLES.article : TITLES[state.type] return ( @@ -93,7 +118,7 @@ function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void
@@ -101,8 +126,8 @@ function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void {state.type === 'article' && } {state.type === 'seasonWeek' && } {state.type === 'share' && } - {state.type === 'comments' && } - {state.type === 'login' && } + {state.type === 'comments' && } + {state.type === 'login' && open(then) : onClose} />} {state.type === 'me' && } {state.type === 'region' && }
@@ -632,14 +657,14 @@ function CommentRow({ c, postId }: { c: CommentData; postId: number }) { )} - ) } -function CommentsSheet({ postId }: { postId: number }) { +function CommentsSheet({ postId, draft }: { postId: number; draft?: string }) { const { region } = useRegion() const { open } = useSheet() const { loggedIn, me } = useAuth() @@ -651,13 +676,13 @@ function CommentsSheet({ postId }: { postId: number }) { }) const add = useMutation(addCommentMutation()) const [addFailed, setAddFailed] = useState(false) - const [text, setText] = useState('') + const [text, setText] = useState(draft ?? '') const inputRef = useRef(null) const comments = list.data?.pages.flatMap((p) => p.comments ?? []) ?? [] const submit = (e: FormEvent) => { e.preventDefault() - if (!loggedIn) return open({ type: 'login' }) + if (!loggedIn) return open({ type: 'login', then: { type: 'comments', postId, draft: text } }) const body = text.trim() if (!body || add.isPending) return setAddFailed(false) @@ -731,7 +756,7 @@ const AUTH_ERRORS: Record = { INVALID_INPUT: '아이디는 영어 소문자·숫자·_ 4~20자, 비밀번호는 8~64자, 닉네임은 2~12자로 써 주세요.', } -function LoginSheet({ onDone }: { onDone: () => void }) { +function LoginSheet({ onDone, onLoggedIn }: { onDone: () => void; onLoggedIn: () => void }) { const { me } = useAuth() const [mode, setMode] = useState<'login' | 'signup'>('login') const [loginId, setLoginId] = useState('') @@ -748,7 +773,7 @@ function LoginSheet({ onDone }: { onDone: () => void }) { return } setTokens(res.access_token, res.refresh_token ?? null) - onDone() + onLoggedIn() } const fail = () => setError('서버에 닿지 못했어요. 잠시 뒤에 다시 해 주세요.') @@ -925,6 +950,13 @@ function RegionSheet({ onDone }: { onDone: () => void }) { const { region, setRegion, locate, locateStatus } = useRegion() const { me, logout } = useAuth() const { open } = useSheet() + const alive = useRef(true) + useEffect(() => { + alive.current = true + return () => { + alive.current = false + } + }, []) const [q, setQ] = useState('') const deferred = useDeferredValue(q.trim()) const list = useQuery(listRegionsOptions(deferred ? { query: { q: deferred } } : undefined)) @@ -933,7 +965,7 @@ function RegionSheet({ onDone }: { onDone: () => void }) { return ( -

diff --git a/frontend/src/b/WeekPage.tsx b/frontend/src/b/WeekPage.tsx index e48bbbc..9dfca58 100644 --- a/frontend/src/b/WeekPage.tsx +++ b/frontend/src/b/WeekPage.tsx @@ -273,7 +273,7 @@ export function WeekPage() { {rankDays.length ? ( [d.day, `${d.weekday}요일 ${shortDay(d.day)}`] as const)} value={rankDay?.day ?? ''} onChange={setRankPick} /> ) : ( - {}} /> + {}} disabled /> )} {rankItems.length ? (

    diff --git a/frontend/src/b/region.tsx b/frontend/src/b/region.tsx index dc907ba..0946f26 100644 --- a/frontend/src/b/region.tsx +++ b/frontend/src/b/region.tsx @@ -35,7 +35,7 @@ export function RegionProvider({ children }: { children: ReactNode }) { writeStored(r) }, []) - const findNearest = useCallback(() => { + const findNearest = useCallback((onFound?: () => void) => { navigator.geolocation.getCurrentPosition( (pos) => { nearestRegion({ query: { lat: pos.coords.latitude, lon: pos.coords.longitude } }) @@ -43,6 +43,7 @@ export function RegionProvider({ children }: { children: ReactNode }) { if (!res.region) throw new Error('가까운 구를 찾지 못함') setRegion(res.region) setLocateStatus('idle') + onFound?.() }) .catch(() => setLocateStatus('error')) }, @@ -51,13 +52,13 @@ export function RegionProvider({ children }: { children: ReactNode }) { ) }, [setRegion]) - const locate = useCallback(() => { + const locate = useCallback((onFound?: () => void) => { if (!canLocate) { setLocateStatus('error') return } setLocateStatus('locating') - findNearest() + findNearest(onFound) }, [canLocate, findNearest]) // 처음 온 사람만 위치 권한을 물어 가장 가까운 구로 맞춘다 diff --git a/frontend/src/b/regionContext.ts b/frontend/src/b/regionContext.ts index 120ca46..52c840b 100644 --- a/frontend/src/b/regionContext.ts +++ b/frontend/src/b/regionContext.ts @@ -3,7 +3,7 @@ import type { RegionData } from '../api/client/types.gen' export type LocateStatus = 'idle' | 'locating' | 'denied' | 'error' -export type RegionApi = { region: RegionData; setRegion: (r: RegionData) => void; locate: () => void; locateStatus: LocateStatus } +export type RegionApi = { region: RegionData; setRegion: (r: RegionData) => void; locate: (onFound?: () => void) => void; locateStatus: LocateStatus } export const DEFAULT_REGION: RegionData = { code: '1144000000', name: '서울 마포구', short_name: '마포구', lat: 37.56071, lon: 126.91053 } diff --git a/frontend/src/b/sheetContext.ts b/frontend/src/b/sheetContext.ts index 9b0f817..25b5977 100644 --- a/frontend/src/b/sheetContext.ts +++ b/frontend/src/b/sheetContext.ts @@ -1,13 +1,15 @@ import { createContext, use } from 'react' export type SharePayload = { title: string; slides: HTMLElement[] } +type CommentsState = { type: 'comments'; postId: number; draft?: string } + export type SheetState = | { type: 'gak'; indexId: number } | { type: 'article'; articleId: number } | { type: 'share'; share: SharePayload } - | { type: 'comments'; postId: number } + | CommentsState | { type: 'seasonWeek' } - | { type: 'login' } + | { type: 'login'; then?: CommentsState } | { type: 'me' } | { type: 'region' } | null diff --git a/frontend/src/b/ui.tsx b/frontend/src/b/ui.tsx index 40e9474..671ffff 100644 --- a/frontend/src/b/ui.tsx +++ b/frontend/src/b/ui.tsx @@ -109,9 +109,12 @@ export function Rail({ children, className, label }: { children: ReactNode; clas ) } -type ChipsProps = { items: readonly (readonly [K, string])[]; value: K; onChange: (k: K) => void; label: string } +// 보이는 크기는 두고 누르는 영역만 가운데 44×44로 넓힌다 (위치 지정된 요소에 붙인다) +export const TAP44 = 'after:absolute after:top-1/2 after:left-1/2 after:size-11 after:-translate-1/2' -export function Chips({ items, value, onChange, label }: ChipsProps) { +type ChipsProps = { items: readonly (readonly [K, string])[]; value: K; onChange: (k: K) => void; label: string; disabled?: boolean } + +export function Chips({ items, value, onChange, label, disabled }: ChipsProps) { return ( {items.map(([k, l]) => ( @@ -119,8 +122,9 @@ export function Chips({ items, value, onChange, label }: Chips key={k} type="button" aria-pressed={value === k} + disabled={disabled} onClick={() => onChange(k)} - className={cx('shrink-0 cursor-pointer rounded-full px-3.5 py-[7px] text-[13.5px] font-bold', value === k ? 'bg-(--ink) text-white' : 'bg-white text-(--ink2) shadow-[inset_0_-3px_0_var(--shade)]')} + className={cx('shrink-0 cursor-pointer rounded-full disabled:cursor-default px-3.5 py-[7px] text-[13.5px] font-bold', value === k ? 'bg-(--ink) text-white' : 'bg-white text-(--ink2) shadow-[inset_0_-3px_0_var(--shade)]')} > {l}