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' ? (
+46 -1
View File
@@ -92,7 +92,7 @@ export function SheetProvider({ children }: { children: ReactNode }) {
)
}
const TITLES = { article: '읽을거리', seasonWeek: '이번 주 특집', share: '보내기', comments: '댓글', login: '로그인', me: '내 정보', region: '지역 바꾸기', install: '홈 화면에 추가', weatherWhy: '날씨 점수는 이렇게 나와요', talk: '이야기', tarot: '오늘 타로', level: '내 레벨', levelUp: '레벨이 올랐어요', gameHelp: '구름 합치기 하는 법' } as const
const TITLES = { article: '읽을거리', seasonWeek: '이번 주 특집', share: '보내기', comments: '댓글', login: '로그인', me: '내 정보', region: '지역 바꾸기', install: '홈 화면에 추가', weatherWhy: '날씨 점수는 이렇게 나와요', talk: '이야기', tarot: '오늘 타로', level: '내 레벨', levelUp: '레벨이 올랐어요', gameHelp: '구름 합치기 하는 법', contact: '날씨각 문의' } as const
/** 아래에서 올라오는 창: 네이티브 <dialog>라 ESC·포커스 가두기·포커스 되돌리기가 기본으로 된다 */
function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void }) {
@@ -183,6 +183,7 @@ function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void
{shown.type === 'level' && <LevelSheet />}
{shown.type === 'levelUp' && <LevelUpSheet level={shown.level} />}
{shown.type === 'gameHelp' && <GameHelpSheet />}
{shown.type === 'contact' && <ContactSheet onDone={onClose} />}
</div>
)}
</dialog>
@@ -554,6 +555,50 @@ function GameHelpSheet() {
)
}
const CONTACTS = [
{ method: 'phone', label: '전화 문의', value: '010-2755-6463', href: 'tel:010-2755-6463', icon: 'M6.6 3h3l1.5 4.2-2 1.5a12 12 0 0 0 6.2 6.2l1.5-2L21 14.4v3A2.6 2.6 0 0 1 18.4 20 15.4 15.4 0 0 1 4 5.6 2.6 2.6 0 0 1 6.6 3Z' },
{ method: 'email', label: '이메일 문의', value: 'sales@o2o.kr', href: 'mailto:sales@o2o.kr', icon: 'M3.5 6.5h17v11h-17zM4 7l8 6.5L20 7' },
] as const
/** 오른쪽 아래 문의 버튼으로 여는 창: 운영사 소개와 전화·이메일 */
function ContactSheet({ onDone }: { onDone: () => void }) {
return (
<Body className="flex flex-col items-center text-center">
<img src="/b/aio2o.png" alt="AIO2O" width={162} height={27} className="mt-1 block h-[27px] w-auto" />
<h4 className="mt-3 mb-0 font-jua text-[22px] font-normal">무엇을 도와드릴까요?</h4>
<p className="mt-1.5 mb-0 text-[13.5px] leading-[1.6] font-semibold text-(--ink2)">
날씨각은 에이아이오투오가 만듭니다.
<br />
AI로 생활에 유용한 정보를 연결하고,
<br />
산업 현장의 문제를 해결합니다.
</p>
<div className="mt-4 flex w-full flex-col gap-2">
{CONTACTS.map((c) => (
<a key={c.method} href={c.href} onClick={() => track('contact_click', { method: c.method })} className="flex items-center gap-3 rounded-[16px] bg-[#f3f6fb] p-3 text-left text-(--ink)">
<span className="b-keep-bg grid size-11 shrink-0 place-items-center rounded-full bg-white text-(--orange)">
<svg viewBox="0 0 24 24" className="size-[22px]" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
<path d={c.icon} />
</svg>
</span>
<span className="flex min-w-0 flex-1 flex-col">
<span className="text-[12px] font-bold text-(--ink2)">{c.label}</span>
<span className="truncate text-[17px] font-extrabold">{c.value}</span>
</span>
<span className="text-xl text-(--orange)" aria-hidden="true">
›
</span>
</a>
))}
</div>
<p className="mt-3.5 mb-0 text-[12px] font-semibold text-(--ink3)">주식회사 에이아이오투오 · AIO2O</p>
<button type="button" onClick={onDone} className="mt-3 w-full cursor-pointer rounded-[14px] bg-(--orange) p-3 text-[15px] font-extrabold text-white">
확인
</button>
</Body>
)
}
function SeasonWeekSheet() {
const { open } = useSheet()
const q = useQuery(getSeasonWeekOptions())
+1 -1
View File
@@ -1,7 +1,7 @@
import type { CSSProperties } from 'react'
import { ARTICLE_LABEL } from '@nalssigak/shared/lib'
const SHARED = new Set(['bear', 'bike', 'bronze', 'camping', 'carwash', 'chimaek', 'cloud', 'coldwind', 'delivery', 'dog', 'garden', 'glasses', 'gold', 'hiking', 'iced_hot', 'jjamppong', 'laundry', 'letter', 'makeup', 'makgeolli', 'maple', 'moon', 'muggy', 'naengmyeon', 'photo', 'picnic', 'rabbit', 'rain', 'running', 'silver', 'snow', 'stars', 'sun_cloud', 'sun', 'sunset', 'taxi', 'umbrella', 'vent', 'walk', 'yajang', 'baseball', 'study', 'netflix', 'chestnut', 'peanut', 'tangerine', 'sweet_potato', 'fallen_leaf', 'kimchi', 'apple', 'mask', 'golf', 'jipkok', 'fishing', 'drive', 'kite', 'waterplay', 'riverwind', 'trot', 'pajeon', 'bingsu', 'blanket', 'indoordry', 'flower', 'bungeoppang', 'singing_rain', 'hangang', 'themepark', 'date', 'frizz', 'boiler', 'sunscreen', 'mosquito', 'tennis', 'hyodo', 'thanks', 'gift', 'party', 'game', 'selfie', 'sentimental', 'ginkgo'])
const SHARED = new Set(['bear', 'bike', 'bronze', 'camping', 'carwash', 'chimaek', 'cloud', 'coldwind', 'delivery', 'dog', 'garden', 'glasses', 'gold', 'hiking', 'iced_hot', 'jjamppong', 'laundry', 'letter', 'makeup', 'makgeolli', 'maple', 'moon', 'muggy', 'naengmyeon', 'photo', 'picnic', 'rabbit', 'rain', 'running', 'silver', 'snow', 'stars', 'sun_cloud', 'sun', 'sunset', 'taxi', 'umbrella', 'vent', 'walk', 'yajang', 'baseball', 'study', 'netflix', 'chestnut', 'peanut', 'tangerine', 'sweet_potato', 'fallen_leaf', 'kimchi', 'apple', 'mask', 'golf', 'jipkok', 'fishing', 'drive', 'kite', 'waterplay', 'riverwind', 'trot', 'pajeon', 'bingsu', 'blanket', 'indoordry', 'flower', 'bungeoppang', 'singing_rain', 'hangang', 'themepark', 'date', 'frizz', 'boiler', 'sunscreen', 'mosquito', 'tennis', 'hyodo', 'thanks', 'gift', 'party', 'game', 'selfie', 'sentimental', 'ginkgo', 'top', 'contact'])
const OWN = new Set(['fireworks', 'bulb', 'calendar', 'thermo', 'sheaf', 'popup', 'exhibition', 'concert', 'crystal_ball', 'yin_yang', 'tshirt', 'clapper', 'speech', 'droplet', 'leaf', 'rainbow', 'milky_way', 'shooting_star', 'alarm_clock', 'check_mark_button', 'sparkles', 'warning', 'locked', 'money_bag', 'red_heart', 'briefcase', 'spiral_calendar', 'two_hearts', 'sunrise', 'candy', 'lollipop', 'spider', 'spider_web', 'bat', 'ghost', 'skull', 'jack_o_lantern', 'pepero_choco', 'pepero_almond', 'pepero_strawberry', 'pepero_nude', 'pepero_pair', 'pepero_bundle', 'pepero_box', 'pepero_basket', 'xmas_candy_cane', 'xmas_ornament', 'xmas_gingerbread', 'xmas_santa_hat', 'xmas_stocking', 'xmas_wreath', 'xmas_santa', 'christmas_tree', 'pear', 'dango', 'moon_viewing', 'full_moon'])
/** 아이콘 이름 → 파일 경로 (공용 public/icons, B 전용 public/b/icons). 'none'(데이터 없는 칸)은 그림 없음 */
+1
View File
@@ -25,6 +25,7 @@ export type SheetState =
| { type: 'level' }
| { type: 'levelUp'; level: number }
| { type: 'gameHelp' }
| { type: 'contact' }
| null
export type SheetApi = { open: (s: Exclude<SheetState, null>) => void; close: () => void }