chore: main 병합 — 로그인 없이 댓글·좋아요, 구글 로그인만, 동네 이야기·카드뉴스 등 (차단 표 user_block 하나로 합침, 익명 댓글도 신고 가능)
This commit is contained in:
commit
dba34675c8
408 files changed
+36377
-725
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { useCallback, useEffect, useMemo, useState, type ReactNode } from 'react'
|
||||
import { NavLink, Outlet, useLocation } from 'react-router'
|
||||
import { NavLink, Outlet, useLocation, useNavigationType } from 'react-router'
|
||||
import { useIsFetching, useQuery } from '@tanstack/react-query'
|
||||
import { getSeasonWeekOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
|
||||
import { cx } from '../lib/utils'
|
||||
@@ -202,12 +202,41 @@ function FirstLoad() {
|
||||
)
|
||||
}
|
||||
|
||||
// 페이지마다 마지막 스크롤 위치: 뒤로 가기로 돌아오면 그 자리로
|
||||
const scrolled = new Map<string, number>()
|
||||
|
||||
function Shell() {
|
||||
const { pathname } = useLocation()
|
||||
const { pathname, key } = useLocation()
|
||||
const navType = useNavigationType()
|
||||
const { kind } = useSky()
|
||||
useEffect(() => {
|
||||
window.scrollTo({ top: 0 })
|
||||
}, [pathname])
|
||||
const save = () => scrolled.set(key, window.scrollY)
|
||||
window.addEventListener('scroll', save, { passive: true })
|
||||
return () => window.removeEventListener('scroll', save)
|
||||
}, [key])
|
||||
useEffect(() => {
|
||||
const top = navType === 'POP' ? scrolled.get(key) : undefined
|
||||
if (top == null) {
|
||||
window.scrollTo({ top: 0 })
|
||||
return
|
||||
}
|
||||
// 피드가 다시 그려져 그 높이가 될 때까지 최대 3초 맞추고, 그 사이 사람이 화면을 만지면 멈춘다
|
||||
let tries = 0
|
||||
let raf = 0
|
||||
const stop = () => cancelAnimationFrame(raf)
|
||||
const go = () => {
|
||||
window.scrollTo({ top })
|
||||
if (Math.abs(window.scrollY - top) > 2 && ++tries < 180) raf = requestAnimationFrame(go)
|
||||
}
|
||||
go()
|
||||
window.addEventListener('touchstart', stop, { once: true, passive: true })
|
||||
window.addEventListener('wheel', stop, { once: true, passive: true })
|
||||
return () => {
|
||||
stop()
|
||||
window.removeEventListener('touchstart', stop)
|
||||
window.removeEventListener('wheel', stop)
|
||||
}
|
||||
}, [pathname, key, navType])
|
||||
// 지금 보고 있는 탭을 다시 누르면 맨 위로
|
||||
const toTopIfHere = (to: string) => () => {
|
||||
if (pathname === to) window.scrollTo({ top: 0, behavior: 'smooth' })
|
||||
@@ -232,7 +261,7 @@ function Shell() {
|
||||
{TABS.map((t) =>
|
||||
t.key === 'today' ? (
|
||||
// 메인 탭: 막대 위로 솟은 큰 주황 동그라미
|
||||
<NavLink key={t.key} to={t.to} end onClick={toTopIfHere(t.to)} className={({ isActive }) => cx('b-tab-main relative -mt-6 flex flex-col items-center gap-1 text-[12px] font-extrabold', isActive || pathname.startsWith('/today/') ? 'text-(--orange)' : 'text-(--ink3)')}>
|
||||
<NavLink key={t.key} to={t.to} end onClick={toTopIfHere(t.to)} className={({ isActive }) => cx('b-tab-main relative -mt-6 flex flex-col items-center gap-1 text-[12px] font-extrabold', isActive || pathname.startsWith('/today/') || pathname.startsWith('/tomorrow/') ? 'text-(--orange)' : 'text-(--ink3)')}>
|
||||
<span className="b-keep-bg grid size-[60px] place-items-center rounded-full bg-[linear-gradient(160deg,#ffb067,var(--orange)_55%,var(--orange-deep))] text-white shadow-[0_8px_18px_rgb(255_122_69/0.45),inset_0_-4px_0_rgb(0_0_0/0.12)] ring-4 ring-white/85 [&_svg]:stroke-[2.6]">
|
||||
<TabIcon name={t.key} className="size-[30px]" />
|
||||
</span>
|
||||
|
||||
Reference in new issue
Block a user