feat: 오른쪽 아래 문의·맨 위로 버튼과 문의 창 — 맨 위에서는 문의(전화·이메일 안내 창), 내리면 맨 위로 버튼으로 바뀜. 쇼츠 화면은 제외 (GA top_button·contact_click, sheet_open contact)

This commit is contained in:
skkim committed 2026-11-11 10:55:20 +09:00
1 parent f5bf98fb34
commit 4a2da04f98
9 files changed
+88 -3

No files matched your search

+33
View File
@@ -2,6 +2,7 @@ import { useCallback, useEffect, useMemo, useState, type ReactNode } from 'react
import { NavLink, Outlet, useLocation, useNavigationType } from 'react-router'
import { useIsFetching, useQuery, useQueryClient } from '@tanstack/react-query'
import { authConfigOptions, getSeasonWeekOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
import { track } from '../lib/analytics'
import { cx } from '../lib/utils'
import { kindOfHour, kst, seasonOf, type TimeKind } from '@nalssigak/shared/lib'
import './b.css'
@@ -89,6 +90,37 @@ function TopBar() {
)
}
// 이만큼 내려가면 문의 버튼이 맨 위로 버튼으로 바뀐다
const TOP_AFTER = 400
/** 오른쪽 아래 둥근 버튼: 맨 위에서는 문의(문의 창 열기), 내려가면 맨 위로 */
function FloatButton() {
const { pathname } = useLocation()
const { open } = useSheet()
const [down, setDown] = useState(() => window.scrollY > TOP_AFTER)
useEffect(() => {
const check = () => setDown(window.scrollY > TOP_AFTER)
window.addEventListener('scroll', check, { passive: true })
return () => window.removeEventListener('scroll', check)
}, [])
// 쇼츠는 화면 전체가 영상이라 가리지 않게 뺀다
if (pathname.startsWith('/shorts')) return null
const toTop = () => {
track('top_button', { page: TABS.find((t) => t.to !== '/' && pathname.startsWith(t.to))?.key ?? pathname.split('/')[1] ?? 'today' })
window.scrollTo({ top: 0, behavior: 'smooth' })
}
return (
<button
type="button"
onClick={down ? toTop : () => open({ type: 'contact' })}
aria-label={down ? '맨 위로' : '문의하기'}
className="fixed right-[max(12px,calc((100%-440px)/2+12px))] bottom-[calc(80px+env(safe-area-inset-bottom,0px))] z-20 size-14 cursor-pointer rounded-full drop-shadow-[0_6px_10px_rgb(40_48_74/0.22)]"
>
<Ic name={down ? 'top' : 'contact'} className="size-full" />
</button>
)
}
const STARS = Array.from({ length: 46 }, (_, i) => ({
left: `${(i * 41 + 7) % 100}%`,
top: `${(i * 67 + 3) % 96}%`,
@@ -279,6 +311,7 @@ function Shell() {
<main className="relative z-[1]">
<Outlet />
</main>
<FloatButton />
<nav aria-label="주요 메뉴" className="b-tabbar fixed inset-x-0 bottom-0 z-30 grid grid-cols-5 border-t px-[max(4px,calc((100%-432px)/2))] pt-[7px] pb-[calc(8px+env(safe-area-inset-bottom,0px))] backdrop-blur-[10px]">
{TABS.map((t) =>
t.key === 'today' ? (