From 46087e64da4e8d50bf1ba196a2f78d35d81b03f4 Mon Sep 17 00:00:00 2001 From: Mina Choi Date: Thu, 8 Oct 2026 08:54:13 +0900 Subject: [PATCH 01/30] =?UTF-8?q?fix:=20=EB=85=B8=EC=B9=98=C2=B7=ED=99=88?= =?UTF-8?q?=20=EB=A7=89=EB=8C=80=EC=97=90=20=EC=83=81=EB=8B=A8=20=EB=B0=94?= =?UTF-8?q?=EC=99=80=20=ED=95=98=EB=8B=A8=20=EC=8B=9C=ED=8A=B8=EA=B0=80=20?= =?UTF-8?q?=EA=B0=80=EB=A6=AC=EC=A7=80=20=EC=95=8A=EA=B2=8C=20safe-area=20?= =?UTF-8?q?=EC=97=AC=EB=B0=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TODO.md | 2 +- frontend/index.html | 1 + frontend/src/b/BLayout.tsx | 4 ++-- frontend/src/b/Sheets.tsx | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/TODO.md b/TODO.md index b90f8b6..154c301 100644 --- a/TODO.md +++ b/TODO.md @@ -103,4 +103,4 @@ | [x] | 공유 이미지: 2장 카드는 한 이미지에 엇갈려 묶음 (사용자 결정). 여러 장 카드는 보고 있는 1장만 나감(주말 예보는 2번째 장 내용이 빠짐). 1장만 / 장마다 이미지 여러 장 / 2장을 한 이미지에 중 정하기 | 공유 이미지 점검 (10/7) | `frontend/src/b/storyImage.ts`, `frontend/src/b/Post.tsx` (`share`) | | [x] | 공유 이미지: 카드 아래 긴 제목이 한 줄 폭에 눌려 찌그러짐 — 두 줄 나눔 또는 말줄임 | 공유 이미지 점검 (10/7) | `frontend/src/b/storyImage.ts` (`fillText`) | | [x] | 공유 이미지: 카드 아래 제목을 빼고 주소 알약으로 바꿈 (시안 A, 사용자 결정). 카드 안 제목과 카드 아래 제목이 같아 두 번 보임. 아래 줄을 뺄지, 다른 말(지역·날짜)로 바꿀지 정하기 | 공유 이미지 점검 (10/7) | `frontend/src/b/storyImage.ts` | -| [ ] | 노치(아이폰 상단 카메라 영역) 대응 — 화면 위·아래가 노치·홈 막대에 가리지 않게 safe-area 여백 점검 | 사용자 요청 | `frontend/index.html`, `frontend/src/b/BLayout.tsx` | +| [x] | 노치(아이폰 상단 카메라 영역) 대응 — 화면 위·아래가 노치·홈 막대에 가리지 않게 safe-area 여백 점검 | 사용자 요청 | `frontend/index.html`, `frontend/src/b/BLayout.tsx` | diff --git a/frontend/index.html b/frontend/index.html index fe31fb9..1ea539e 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -5,6 +5,7 @@ + 날씨각 diff --git a/frontend/src/b/BLayout.tsx b/frontend/src/b/BLayout.tsx index 63ef3a2..ef334dc 100644 --- a/frontend/src/b/BLayout.tsx +++ b/frontend/src/b/BLayout.tsx @@ -30,7 +30,7 @@ function TopBar() { const tab = TABS.find((t) => t.to !== '/' && pathname.startsWith(t.to)) return ( -
+
{tab?.title ?

{tab.title}

:

날씨각

} ))} diff --git a/frontend/src/b/Sheets.tsx b/frontend/src/b/Sheets.tsx index 0623302..ff02d78 100644 --- a/frontend/src/b/Sheets.tsx +++ b/frontend/src/b/Sheets.tsx @@ -28,7 +28,7 @@ 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 } from './ui' +import { Avatar, Ic, Skel, StateBox, Thumb } from './ui' export function SheetProvider({ children }: { children: ReactNode }) { const [state, setState] = useState(null) @@ -397,9 +397,7 @@ function ArticleSheet({ articleId, onTitle }: { articleId: number; onTitle: (t: if (!a) return {load === 'loading' ? : q.refetch()} empty="글을 찾지 못했어요." hold={} className="inset-0" />} return ( -
- -
+

{articleMeta(a)}

{a.title}

{(q.data?.body ?? []).map((t) => ( diff --git a/frontend/src/b/TodayPage.tsx b/frontend/src/b/TodayPage.tsx index f89a3de..5bb3de9 100644 --- a/frontend/src/b/TodayPage.tsx +++ b/frontend/src/b/TodayPage.tsx @@ -284,9 +284,7 @@ function SeasonBand({ news }: { news: BandArticle[] }) { {news.map((a) => (
- - 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 ? (