[fix] site: 모달 닫기 스크롤 버그 수정 — 이용안내 체크인·체크아웃 병합, UI 다듬기
모달 onClose 가 inline 함수라 부모 리렌더마다 useEffect 가 다시 걸려 scrollY 를 0으로 덮어써 X 버튼으로 닫으면 페이지가 맨 위로 튀었다. - lib/ui/Modal.tsx: onClose 를 ref 로 들고 [open] 에만 의존하도록 수정 (BlogSection·ReviewSection 등 Modal 쓰는 7곳 전부 적용) - sections/EssentialInfoSection.tsx: 체크인·체크아웃 행을 한 줄로 병합 - sections/GallerySection.tsx, UnitsSection.tsx, MobileTabBar.tsx, SiteFooter.tsx, items/*: 표시 폭·간격·라벨 정리 - lib/ui/Carousel.tsx: loop 이음매 간격 재점검 - scripts/prerender.ts: countUniqueContent 가 socialPosts(자체 출력)를 세지 않도록 — 콘텐츠 0건 사이트가 게이트를 우회하던 경로 tsc 통과, vitest 100/102 passed (use-live-weather 실패 2건은 기존·무관) Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
13cc8cc830
commit
4260e20a70
22 files changed
+416
-391
No files matched your search
@@ -13,7 +13,7 @@
|
||||
* `data-slider="on"` 이 걸리며 드래그로 바뀐다. 이 사이트의 존재 이유가 인용이라
|
||||
* **모든 슬라이드는 항상 HTML 에 있다** — 지금 보이는 한 장만 그리지 않는다.
|
||||
*/
|
||||
import {useCallback, useEffect, useId, useRef, useState, type ReactNode} from 'react';
|
||||
import {createContext, useCallback, useContext, useEffect, useId, useRef, useState, type ReactNode} from 'react';
|
||||
import useEmblaCarousel from 'embla-carousel-react';
|
||||
import {AUTOPLAY_MS, useRailAutoplay} from './use-rail-autoplay';
|
||||
import {ChevronLeft, ChevronRight} from 'lucide-react';
|
||||
@@ -52,6 +52,14 @@ interface CarouselProps {
|
||||
* 그렇게 옮겨진 슬라이드에는 트랙의 flex `gap` 이 적용되지 않는다 — 이음매에서만
|
||||
* 카드 둘이 딱 붙는다. 간격을 아무리 맞춰도 그 자리는 안 고쳐진다.
|
||||
* 되감기를 없애면 슬라이드는 늘 flex 흐름 안에 있고, 간격은 한 값으로 유지된다.
|
||||
* ★ `loop` 을 다시 쓰는 자리(미니 블로그, 2026-09-18)에서 위 증상을 실측으로 재현했다 —
|
||||
* Playwright 로 좌표를 재 보니 이음매(마지막→첫 장)에서만 간격이 정확히 0px 였다.
|
||||
* flex `gap` 은 **컨테이너** 속성이라 DOM 순서로만 계산되는데, embla 의 loop 보정
|
||||
* transform 은 슬라이드를 시각적으로만 반대편에 옮겨 놓아 그 이웃 관계를 못 본다.
|
||||
* 그래서 `loop` 일 때는 트랙의 `gap` 을 0 으로 끄고, 대신 **슬라이드 자신의
|
||||
* `margin-inline-end`** 로 간격을 준다(`CarouselSlide` 의 `SlideGapContext`) — margin 은
|
||||
* 슬라이드 자기 박스에 붙어 있어 embla 가 loop 거리를 잴 때 그 크기에 포함된다.
|
||||
* `loop=false`(기본값)인 다른 모든 레일은 이 경로를 안 타서 예전 그대로다.
|
||||
*/
|
||||
autoplay?: number | false;
|
||||
/**
|
||||
@@ -66,6 +74,8 @@ interface CarouselProps {
|
||||
className?: string;
|
||||
}
|
||||
|
||||
/** `loop` 일 때만 값이 선다(간격을 rem 값으로) — `CarouselSlide` 가 자기 margin 으로 대신 낸다. */
|
||||
const SlideGapContext = createContext<number | null>(null);
|
||||
|
||||
export function Carousel({
|
||||
label,
|
||||
@@ -212,8 +222,8 @@ export function Carousel({
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className="slider-track" style={{gap: `${gap}rem`}} id={id}>
|
||||
{children}
|
||||
<div className="slider-track" style={{gap: loop ? 0 : `${gap}rem`}} id={id}>
|
||||
<SlideGapContext.Provider value={loop ? gap : null}>{children}</SlideGapContext.Provider>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -264,8 +274,13 @@ export function Carousel({
|
||||
* "옆으로 더 있다"는 유일한 시각 신호다** — 딱 맞게 자르면 아무도 밀지 않는다.
|
||||
*/
|
||||
export function CarouselSlide({basis, children}: {basis: string; children: ReactNode}) {
|
||||
const loopGap = useContext(SlideGapContext);
|
||||
return (
|
||||
<div className={`min-w-0 shrink-0 grow-0 ${basis}`} aria-roledescription="슬라이드">
|
||||
<div
|
||||
className={`min-w-0 shrink-0 grow-0 ${basis}`}
|
||||
style={loopGap != null ? {marginInlineEnd: `${loopGap}rem`} : undefined}
|
||||
aria-roledescription="슬라이드"
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {useEffect} from 'react';
|
||||
import {useEffect, useRef} from 'react';
|
||||
import type {ReactNode} from 'react';
|
||||
import {X} from 'lucide-react';
|
||||
|
||||
@@ -13,29 +13,47 @@ export function Modal({
|
||||
open,
|
||||
onClose,
|
||||
label,
|
||||
title,
|
||||
children,
|
||||
wide,
|
||||
}: {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
label: string;
|
||||
/** 닫기 버튼과 한 줄에 놓일 제목. 없으면 닫기 버튼만 뜬다. */
|
||||
title?: ReactNode;
|
||||
children: ReactNode;
|
||||
/** 안이 2열(정보+예약)로 갈리는 경우처럼 lg 폭이 필요할 때. */
|
||||
wide?: boolean;
|
||||
}) {
|
||||
const onCloseRef = useRef(onClose);
|
||||
onCloseRef.current = onClose;
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
const onKey = (event: KeyboardEvent) => {
|
||||
if (event.key === 'Escape') onClose();
|
||||
if (event.key === 'Escape') onCloseRef.current();
|
||||
};
|
||||
const previous = document.body.style.overflow;
|
||||
document.body.style.overflow = 'hidden';
|
||||
const scrollY = window.scrollY;
|
||||
const body = document.body;
|
||||
const prevPosition = body.style.position;
|
||||
const prevTop = body.style.top;
|
||||
const prevWidth = body.style.width;
|
||||
const prevOverflow = body.style.overflow;
|
||||
body.style.position = 'fixed';
|
||||
body.style.top = `-${scrollY}px`;
|
||||
body.style.width = '100%';
|
||||
body.style.overflow = 'hidden';
|
||||
window.addEventListener('keydown', onKey);
|
||||
return () => {
|
||||
document.body.style.overflow = previous;
|
||||
body.style.position = prevPosition;
|
||||
body.style.top = prevTop;
|
||||
body.style.width = prevWidth;
|
||||
body.style.overflow = prevOverflow;
|
||||
window.scrollTo(0, scrollY);
|
||||
window.removeEventListener('keydown', onKey);
|
||||
};
|
||||
}, [open, onClose]);
|
||||
}, [open]);
|
||||
|
||||
if (!open) return null;
|
||||
|
||||
@@ -51,24 +69,27 @@ export function Modal({
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-label={label}
|
||||
className={`absolute inset-x-0 bottom-0 max-h-[88svh] overflow-auto rounded-t-2xl px-5 pb-8 pt-14 sm:bottom-auto sm:left-1/2 sm:top-1/2 sm:max-h-[85vh] sm:w-full sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-2xl ${
|
||||
className={`absolute inset-x-0 bottom-0 flex max-h-[88svh] flex-col overflow-hidden rounded-t-2xl sm:bottom-auto sm:left-1/2 sm:top-1/2 sm:max-h-[85vh] sm:w-full sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-2xl ${
|
||||
wide ? 'sm:max-w-3xl' : 'sm:max-w-lg'
|
||||
}`}
|
||||
style={{backgroundColor: 'var(--color-surface)'}}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
aria-label="닫기"
|
||||
className="tap absolute right-3 top-3 z-10 flex size-10 items-center justify-center rounded-full shadow-md"
|
||||
style={{
|
||||
backgroundColor: 'var(--color-surface)',
|
||||
boxShadow: '0 1px 2px rgba(0,0,0,.18), 0 0 0 1px color-mix(in oklab, currentColor 12%, transparent)',
|
||||
}}
|
||||
>
|
||||
<X className="size-5" />
|
||||
</button>
|
||||
{children}
|
||||
<div className="border-line flex shrink-0 items-center justify-between gap-3 border-b p-5 pb-4">
|
||||
{title && <h3 className="h3 min-w-0 truncate">{title}</h3>}
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
aria-label="닫기"
|
||||
className="tap ml-auto flex size-10 shrink-0 items-center justify-center rounded-full shadow-md"
|
||||
style={{
|
||||
backgroundColor: 'var(--color-surface)',
|
||||
boxShadow: '0 1px 2px rgba(0,0,0,.18), 0 0 0 1px color-mix(in oklab, currentColor 12%, transparent)',
|
||||
}}
|
||||
>
|
||||
<X className="size-5" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="overflow-y-auto p-5 pb-8">{children}</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user