diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index bc573d3..aad4c2a 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -3,6 +3,7 @@ import { BLayout } from './b/BLayout' import { FoliagePage } from './b/FoliagePage' import { GakPage } from './b/GakPage' import { SeasonPage } from './b/SeasonPage' +import { ShortsPage } from './b/Shorts' import { SkyPage } from './b/SkyPage' import { TalkPage } from './b/TalkPage' import { TodayPage } from './b/TodayPage' @@ -22,6 +23,7 @@ export default function App() { } /> } /> } /> + } /> } /> diff --git a/frontend/src/b/Shorts.tsx b/frontend/src/b/Shorts.tsx index 9e7e9f4..75a6d7a 100644 --- a/frontend/src/b/Shorts.tsx +++ b/frontend/src/b/Shorts.tsx @@ -1,5 +1,6 @@ import { useQuery } from '@tanstack/react-query' -import { useEffect, useRef, useState } from 'react' +import { type CSSProperties, useEffect, useEffectEvent, useLayoutEffect, useRef, useState } from 'react' +import { Link, useNavigate, useParams } from 'react-router' import { listShortsOptions } from '../api/client/@tanstack/react-query.gen' import type { ShortItem } from '../api/client' import { cx } from '../lib/utils' @@ -11,8 +12,21 @@ const CARD_W = 120 const PLAYER_W = 200 const SCALE = (CARD_W / PLAYER_W) * 1.4 -// 전체 화면 창의 영상 칸: 닫기 줄 아래 남은 높이와 화면 너비 안에 9:16으로 맞춘다 -const FIT = { width: 'min(100vw, calc((100dvh - env(safe-area-inset-top, 0px) - 52px) * 9 / 16))', aspectRatio: '9 / 16' } +// 쇼츠 페이지의 영상 칸: 위 헤더(54px)·버튼 줄(48px)과 아래 탭 바(--shorts-tab) 사이 높이와 화면 너비 안에 9:16으로 맞춘다 +const FIT = { width: 'min(100vw, calc((100dvh - env(safe-area-inset-top, 0px) - 54px - 48px - var(--shorts-tab, 0px)) * 9 / 16))', aspectRatio: '9 / 16' } + +/** 아래 탭 바 높이 (기기마다 안전 영역이 달라 실제로 잰다) */ +function useTabBarHeight() { + const [h, setH] = useState(0) + useLayoutEffect(() => { + const nav = document.querySelector('nav.b-tabbar') + if (!nav) return + const ro = new ResizeObserver(() => setH(nav.offsetHeight)) + ro.observe(nav) + return () => ro.disconnect() + }, []) + return h +} const YT_ORIGIN = 'https://www.youtube-nocookie.com' @@ -46,12 +60,11 @@ function useVisible(threshold = 0.5) { return [ref, visible] as const } -/** 오늘 화면 히어로 아래 쇼츠 줄: 첫 카드만 소리 없이 재생, 누르면 전체 화면에서 위아래로 넘겨 본다 */ +/** 오늘 화면 히어로 아래 쇼츠 줄: 첫 카드만 소리 없이 재생, 누르면 쇼츠 페이지(/shorts/영상ID)에서 위아래로 넘겨 본다 */ export function ShortsRail() { const q = useQuery(listShortsOptions()) const items = q.data?.items ?? [] const [ref, visible] = useVisible() - const [openAt, setOpenAt] = useState(null) if (q.isPending) { return ( @@ -72,17 +85,16 @@ export function ShortsRail() { {items.map((s, i) => ( - setOpenAt(i)} /> + ))} - {openAt != null && setOpenAt(null)} />} ) } -function ShortCard({ s, playing, onOpen }: { s: ShortItem; playing: boolean; onOpen: () => void }) { +function ShortCard({ s, playing }: { s: ShortItem; playing: boolean }) { return ( -