fix: 해돋이·첫눈 지도 다듬기 — 그림 귀퉁이의 단풍잎 장식이 잘려 보이던 것(오른쪽은 위·아래 귀퉁이만 잘라 독도는 남김), 해돋이 지도 색을 살구빛 바탕·주황빛 땅으로, 처음 화면에서 한 단계 더 축소(울릉도·독도까지 전체 보기)
This commit is contained in:
1 parent
d7dfc1ba82
commit
0578c127d5
7 files changed
+31
-24
No files matched your search
@@ -14,6 +14,8 @@ const DOT_R = 4
|
||||
// 눈 예보도 없고 대표 지점도 아닌 곳의 이름이 나오기 시작하는 배율(처음 화면 대비): 처음엔 차분하게
|
||||
const LABEL_FROM = 2.2
|
||||
const TAP_R = 24
|
||||
// 처음 화면에서 − 를 한 번 더 누를 수 있다: 울릉도·독도까지 전체가 보인다
|
||||
const MIN_ZOOM = 1 / 1.6
|
||||
const SHARE_ICON = 'relative grid size-9 shrink-0 cursor-pointer place-items-center rounded-full [&_svg]:size-[19px] [&_svg]:fill-none [&_svg]:stroke-(--ink2) [&_svg]:stroke-[1.9]'
|
||||
const SHARE_BTN = `${SHARE_ICON} bg-white/80`
|
||||
const GROUPS: [SnowStage, string][] = [
|
||||
@@ -72,7 +74,7 @@ export function FirstSnowPage() {
|
||||
}
|
||||
setSel((cur) => (best && best !== cur ? best : null))
|
||||
}, [])
|
||||
const { box, view, fit, zoomAt, focus } = useMapView(vpRef, spots, params.get('spot'), pickAt)
|
||||
const { box, view, fit, zoomAt, focus } = useMapView(vpRef, spots, params.get('spot'), pickAt, MIN_ZOOM)
|
||||
|
||||
const pts = useMemo(
|
||||
() => spread(spots.map((m) => ({ m, x: view.tx + m.x * box.W * view.s, y: view.ty + m.y * box.W * view.s, r: m.stage === 'soon' ? ICON_R : DOT_R }))),
|
||||
|
||||
@@ -5,7 +5,7 @@ import { ICON_R, LABEL, MAP_SRC, PROVINCE, PROVINCES, labelBoxes, md, placeLabel
|
||||
import { useMapView } from './mapView'
|
||||
import { useSheet } from './sheetContext'
|
||||
import { SunriseMapShare, SunriseSpotShare } from './shareCards'
|
||||
import { clock, COAST, direction, dokdoRise, SUN_DOT, SUN_LABEL_INK, SUN_MAP_IMG, SUN_SHADOW, sunriseHeadline, useSunrise, type Coast, type SunSpot } from './sunrise'
|
||||
import { clock, COAST, direction, dokdoRise, SUN_DOT, SUN_LABEL_INK, SUN_MAP_IMG, SUN_PAPER, SUN_SHADOW, sunriseHeadline, useSunrise, type Coast, type SunSpot } from './sunrise'
|
||||
import { SendIcon } from './svg'
|
||||
import { Chips, Ic, TAP44 } from './ui'
|
||||
import { track } from '../lib/analytics'
|
||||
@@ -16,6 +16,8 @@ const DOT_R = 4
|
||||
// 대표 명소가 아닌 곳의 이름이 나오기 시작하는 배율(처음 화면 대비): 처음엔 대표 명소 이름만 보여 차분하게
|
||||
const LABEL_FROM = 2.2
|
||||
const TAP_R = 24
|
||||
// 처음 화면에서 − 를 한 번 더 누를 수 있다: 울릉도·독도까지 전체가 보인다
|
||||
const MIN_ZOOM = 1 / 1.6
|
||||
const SHARE_ICON = 'relative grid size-9 shrink-0 cursor-pointer place-items-center rounded-full [&_svg]:size-[19px] [&_svg]:fill-none [&_svg]:stroke-(--ink2) [&_svg]:stroke-[1.9]'
|
||||
const SHARE_BTN = `${SHARE_ICON} bg-white/80`
|
||||
const FILTERS: [Filter, string][] = [['all', '전체'], ...(Object.entries(COAST) as [Coast, string][])]
|
||||
@@ -66,7 +68,7 @@ export function SunrisePage() {
|
||||
}
|
||||
setSel((cur) => (best && best !== cur ? best : null))
|
||||
}, [])
|
||||
const { box, view, fit, zoomAt, focus } = useMapView(vpRef, spots, params.get('spot'), pickAt)
|
||||
const { box, view, fit, zoomAt, focus } = useMapView(vpRef, spots, params.get('spot'), pickAt, MIN_ZOOM)
|
||||
|
||||
const pts = useMemo(
|
||||
() => spread(shown.map((m) => ({ m, x: view.tx + m.x * box.W * view.s, y: view.ty + m.y * box.W * view.s, r: m.top ? ICON_R : DOT_R }))),
|
||||
@@ -135,7 +137,7 @@ export function SunrisePage() {
|
||||
|
||||
{days.length > 1 && <Chips label="날짜" items={days.map((d) => [d.key, `${d.label} ${md(d.date)}`] as const)} value={day.key} onChange={pickDay} />}
|
||||
|
||||
<div ref={vpRef} className="b-keep-bg relative mt-2 h-[min(122vw,calc(100dvh-330px),560px)] min-h-[300px] touch-pan-y overflow-hidden bg-[#fff6ea] select-none">
|
||||
<div ref={vpRef} className={cx('b-keep-bg relative mt-2 h-[min(122vw,calc(100dvh-330px),560px)] min-h-[300px] touch-pan-y overflow-hidden select-none', SUN_PAPER)}>
|
||||
<img src={MAP_SRC} alt="해돋이 지도" draggable={false} className={cx(SUN_MAP_IMG, 'max-w-none')} style={{ left: view.tx, top: view.ty, width: box.W * view.s, height: box.W * view.s }} />
|
||||
{provs.map((v) => (
|
||||
<span key={v.name} aria-hidden="true" className={PROVINCE} style={{ left: v.x, top: v.y }}>
|
||||
|
||||
@@ -20,8 +20,8 @@ export function useFirstSnow(enabled = true) {
|
||||
return { today, spots, forecast: !!q.data?.forecast, load: loadOf(q), refetch: q.refetch, inSeason: firstSnowInSeason(today) }
|
||||
}
|
||||
|
||||
// 지도 그림은 단풍 지도와 같은 것. 색을 다 빼고 옅게 해서 눈 내린 땅처럼 보이게, 양옆 귀퉁이의 단풍잎 장식은 잘라 낸다
|
||||
export const SNOW_MAP_IMG = 'pointer-events-none absolute max-w-none select-none mix-blend-multiply brightness-[1.25] saturate-0 opacity-70 [clip-path:inset(0_8%_0_14%)]'
|
||||
// 지도 그림은 단풍 지도와 같은 것. 색을 다 빼고 옅게 해서 눈 내린 땅처럼 보이게, 네 귀퉁이의 단풍잎 장식은 잘라 낸다(해돋이 지도 SUN_MAP_IMG 와 같은 범위)
|
||||
export const SNOW_MAP_IMG = 'pointer-events-none absolute max-w-none select-none mix-blend-multiply brightness-[1.25] saturate-0 opacity-70 [clip-path:polygon(14%_0,88%_0,88%_24%,100%_24%,100%_75%,88%_75%,88%_100%,14%_100%)]'
|
||||
// 지도 바탕: 차가운 흰색
|
||||
export const SNOW_PAPER = 'bg-[#f3f6fb]'
|
||||
// 눈 예보가 있는 곳의 이름표
|
||||
|
||||
@@ -11,9 +11,10 @@ const FIT_BOTTOM = 14
|
||||
/**
|
||||
* 전국 지도 그림의 확대·이동 (단풍 지도·해돋이 지도 페이지가 같이 쓴다).
|
||||
* 두 손가락은 확대·이동, 한 손가락은 확대했을 때만 지도 이동(아니면 페이지 스크롤), 두 번 누르면 확대, 한 번 누르면 pickAt(누른 자리).
|
||||
* places 는 처음 화면에 다 들어와야 하는 명소, linked 는 처음에 가운데로 데려갈 명소 이름(링크로 들어왔을 때)
|
||||
* places 는 처음 화면에 다 들어와야 하는 명소, linked 는 처음에 가운데로 데려갈 명소 이름(링크로 들어왔을 때).
|
||||
* minZoom 은 처음 화면보다 얼마나 더 축소할 수 있는지(처음 화면 대비 배율, 1 이면 처음 화면이 가장 작다)
|
||||
*/
|
||||
export function useMapView(vpRef: RefObject<HTMLDivElement | null>, places: Place[], linked: string | null, pickAt: (x: number, y: number) => void) {
|
||||
export function useMapView(vpRef: RefObject<HTMLDivElement | null>, places: Place[], linked: string | null, pickAt: (x: number, y: number) => void, minZoom = 1) {
|
||||
const [box, setBox] = useState({ W: 0, H: 0 })
|
||||
const [view, setView] = useState<View>({ s: 1, tx: 0, ty: 0 })
|
||||
const viewRef = useRef(view)
|
||||
@@ -40,14 +41,14 @@ export function useMapView(vpRef: RefObject<HTMLDivElement | null>, places: Plac
|
||||
const clamp = useCallback(
|
||||
(v: View): View => {
|
||||
const { W, H } = box
|
||||
const s = Math.min(fit.s * MAX_ZOOM, Math.max(fit.s, v.s))
|
||||
const s = Math.min(fit.s * MAX_ZOOM, Math.max(fit.s * minZoom, v.s))
|
||||
const w = W * s
|
||||
// 지도 그림 가장자리가 화면 안쪽으로 너무 들어오지 않게
|
||||
const tx = Math.min(W * 0.25, Math.max(W * 0.75 - w, v.tx))
|
||||
const ty = Math.min(H * 0.25, Math.max(H * 0.75 - w, v.ty))
|
||||
return { s, tx, ty }
|
||||
},
|
||||
[box, fit],
|
||||
[box, fit, minZoom],
|
||||
)
|
||||
|
||||
const anim = useRef(0)
|
||||
@@ -74,13 +75,13 @@ export function useMapView(vpRef: RefObject<HTMLDivElement | null>, places: Plac
|
||||
const zoomAt = useCallback(
|
||||
(f: number, cx: number, cy: number, smooth = false) => {
|
||||
const v = viewRef.current
|
||||
const s = Math.min(fit.s * MAX_ZOOM, Math.max(fit.s, v.s * f))
|
||||
const s = Math.min(fit.s * MAX_ZOOM, Math.max(fit.s * minZoom, v.s * f))
|
||||
const k = s / v.s
|
||||
const next = clamp({ s, tx: cx - (cx - v.tx) * k, ty: cy - (cy - v.ty) * k })
|
||||
if (smooth) animateTo(next)
|
||||
else set(next)
|
||||
},
|
||||
[fit, clamp, animateTo, set],
|
||||
[fit, minZoom, clamp, animateTo, set],
|
||||
)
|
||||
/** 그 명소를 화면 가운데쯤으로 확대해 데려간다 */
|
||||
const focus = useCallback(
|
||||
@@ -148,7 +149,7 @@ export function useMapView(vpRef: RefObject<HTMLDivElement | null>, places: Plac
|
||||
const x = (a.x + b.x) / 2
|
||||
const y = (a.y + b.y) / 2
|
||||
const v = viewRef.current
|
||||
const s = Math.min(fit.s * MAX_ZOOM, Math.max(fit.s, (v.s * d) / pinch.d))
|
||||
const s = Math.min(fit.s * MAX_ZOOM, Math.max(fit.s * minZoom, (v.s * d) / pinch.d))
|
||||
const k = s / v.s
|
||||
set(clamp({ s, tx: x - (pinch.x - v.tx) * k, ty: y - (pinch.y - v.ty) * k }))
|
||||
pinch = { d, x, y }
|
||||
@@ -236,7 +237,7 @@ export function useMapView(vpRef: RefObject<HTMLDivElement | null>, places: Plac
|
||||
el.removeEventListener('dblclick', onDbl)
|
||||
el.removeEventListener('wheel', onWheel)
|
||||
}
|
||||
}, [vpRef, fit, clamp, set, zoomAt, pickAt])
|
||||
}, [vpRef, fit, minZoom, clamp, set, zoomAt, pickAt])
|
||||
|
||||
return { box, view, fit, zoomAt, focus }
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import type { TopIndex } from '@nalssigak/shared/api/client/types.gen'
|
||||
import { SNOW_DOT, SNOW_MAP_IMG, SNOW_PAPER, SNOW_SHADOW, SNOW_STAGE, type SnowSpot } from './firstSnow'
|
||||
import { LEAF_SHADOW, MAP_IMG, MAP_SRC, md, PROVINCE, PROVINCES, STAGE, type Spot } from './foliage'
|
||||
import { MEDALS, type TimeKind } from '@nalssigak/shared/lib'
|
||||
import { clock, COAST, CROP_IMG, cropXY, direction, SUN_MAP_IMG, SUN_SHADOW, type SunSpot } from './sunrise'
|
||||
import { clock, COAST, CROP_IMG, cropXY, direction, SUN_MAP_IMG, SUN_PAPER, SUN_SHADOW, type SunSpot } from './sunrise'
|
||||
import { Ic } from './ui'
|
||||
|
||||
/** 공유 이미지 전용 틀. 화면 밖에 그려 두고 보내기 때 이것만 찍는다 (화면의 버튼은 이미지에서 빠지므로 글자만으로 만든다) */
|
||||
@@ -194,10 +194,10 @@ export function SunriseSpotShare({ spot, when, tops, ref }: { spot: SunSpot | nu
|
||||
const near = tops.filter((m) => m.name !== spot.name)
|
||||
return (
|
||||
<Offscreen>
|
||||
<div ref={ref} className="flex aspect-[4/5] flex-col bg-[#fff6ea] text-[#28304a]">
|
||||
<div ref={ref} className={cx('flex aspect-[4/5] flex-col text-[#28304a]', SUN_PAPER)}>
|
||||
<div className="relative flex-1 overflow-hidden">
|
||||
{/* 명소가 가운데 오게 지도 그림을 키워 옮긴다 */}
|
||||
<div className="absolute top-1/2 left-1/2 aspect-square w-[220%] bg-[#fff6ea]" style={{ transform: `translate(-${spot.x * 100}%, -${spot.y * 100}%)` }}>
|
||||
<div className={cx('absolute top-1/2 left-1/2 aspect-square w-[220%]', SUN_PAPER)} style={{ transform: `translate(-${spot.x * 100}%, -${spot.y * 100}%)` }}>
|
||||
<img src={MAP_SRC} alt="" className={cx(SUN_MAP_IMG, 'inset-0 size-full')} />
|
||||
{PROVINCES.map((v) => (
|
||||
<span key={v.name} className={cx(PROVINCE, 'text-[15px]')} style={{ left: `${v.x * 100}%`, top: `${v.y * 100}%` }}>
|
||||
@@ -233,10 +233,10 @@ export function SunriseSpotShare({ spot, when, tops, ref }: { spot: SunSpot | nu
|
||||
export function SunriseMapShare({ title, when, tops, ranked, ref }: { title: string; when: string; tops: SunSpot[]; ranked: SunSpot[]; ref: Ref<HTMLDivElement> }) {
|
||||
return (
|
||||
<Offscreen>
|
||||
<div ref={ref} className="flex aspect-[4/5] flex-col bg-[#fff6ea] px-4 pt-4 pb-3 text-[#28304a]">
|
||||
<div ref={ref} className={cx('flex aspect-[4/5] flex-col px-4 pt-4 pb-3 text-[#28304a]', SUN_PAPER)}>
|
||||
<p className="m-0 text-[13px] font-extrabold opacity-75">해돋이 지도 · {when}</p>
|
||||
<p className="m-0 font-jua text-[24px] leading-tight">{title}</p>
|
||||
<div className="relative mx-auto mt-1 aspect-square w-[72%] overflow-hidden bg-[#fff6ea]">
|
||||
<div className={cx('relative mx-auto mt-1 aspect-square w-[72%] overflow-hidden', SUN_PAPER)}>
|
||||
<img src={MAP_SRC} alt="" className={SUN_MAP_IMG} style={CROP_IMG} />
|
||||
{PROVINCES.map((v) => {
|
||||
const at = cropXY(v.x, v.y)
|
||||
|
||||
@@ -15,8 +15,10 @@ export function useSunrise() {
|
||||
return { days, day, setDay, spots, inSeason: sunriseInSeason(now) }
|
||||
}
|
||||
|
||||
// 지도 그림은 단풍 지도와 같은 것. 가을 색을 거의 다 빼고 옅게 해서 겨울 새벽 땅처럼 보이게, 양옆 귀퉁이의 단풍잎 장식은 잘라 낸다
|
||||
export const SUN_MAP_IMG = 'pointer-events-none absolute max-w-none select-none mix-blend-multiply brightness-[1.22] saturate-[.2] opacity-80 [clip-path:inset(0_8%_0_14%)]'
|
||||
// 지도 그림은 단풍 지도와 같은 것. 살구색 바탕(SUN_PAPER)에 주황 기운이 도는 땅으로 보이게 색을 바꾼다, 네 귀퉁이의 단풍잎 장식은 잘라 낸다(왼쪽 14%, 오른쪽은 위·아래 귀퉁이만 12%: 그 사이의 독도는 남긴다)
|
||||
export const SUN_MAP_IMG = 'pointer-events-none absolute max-w-none select-none mix-blend-multiply [filter:sepia(.9)_saturate(1.5)_hue-rotate(-12deg)_brightness(1.18)] opacity-70 [clip-path:polygon(14%_0,88%_0,88%_24%,100%_24%,100%_75%,88%_75%,88%_100%,14%_100%)]'
|
||||
// 지도 바탕: 따뜻한 살구빛 아침. 지도 그림은 바로 뒤 바탕과 곱해져 보이므로(mix-blend-multiply) 그림을 담는 칸에는 꼭 이 바탕을 같이 준다: 빼면 그림 둘레에 네모난 경계가 보인다
|
||||
export const SUN_PAPER = 'bg-[#ffecd4]'
|
||||
export const SUN_LABEL_INK = 'bg-[#ffffffeb] text-[#b4501a]'
|
||||
export const SUN_SHADOW = 'drop-shadow-[0_0_1.5px_#fff] drop-shadow-[0_1px_1px_rgb(40_48_74/0.45)]'
|
||||
// 대표 명소가 아닌 곳은 주황 점
|
||||
|
||||
@@ -7,7 +7,7 @@ import { ICON_R, LABEL, MAP_SRC, md, placeLabels, PROVINCE, PROVINCES, labelBoxe
|
||||
import { PostFrame } from './Post'
|
||||
import { useSheet } from './sheetContext'
|
||||
import { SunriseSpotShare } from './shareCards'
|
||||
import { clock, COAST, CROP_IMG, cropXY, SUN_LABEL_INK, SUN_MAP_IMG, SUN_SHADOW, sunriseHeadline, useSunrise } from './sunrise'
|
||||
import { clock, COAST, CROP_IMG, cropXY, SUN_LABEL_INK, SUN_MAP_IMG, SUN_PAPER, SUN_SHADOW, sunriseHeadline, useSunrise } from './sunrise'
|
||||
import { SendIcon } from './svg'
|
||||
import { Ic } from './ui'
|
||||
import { track } from '../lib/analytics'
|
||||
@@ -84,7 +84,7 @@ export function SunriseCard({ post }: { post?: PostReaction | null }) {
|
||||
const ranked = spots.slice(0, RANK_N)
|
||||
return (
|
||||
<PostFrame title="해돋이 지도" account="해돋이 지도" avatar="sun" pinned={{ key: 'foliage_post', post }} caption={`가장 이른 곳: ${spots.slice(0, 3).map((m) => `${m.name} ${clock(m.rise)}`).join(' · ')}`}>
|
||||
<div className="b-keep-bg relative bg-[#fff6ea] px-4 pt-4 pb-3 text-[#28304a]">
|
||||
<div className={cx('b-keep-bg relative px-4 pt-4 pb-3 text-[#28304a]', SUN_PAPER)}>
|
||||
<p className="m-0 text-[13px] font-extrabold opacity-75">해돋이 지도 · {when}</p>
|
||||
<p className="m-0 mt-1 font-jua text-[24px] leading-tight">{sunriseHeadline(day, spots)}</p>
|
||||
<div className="relative mt-1">
|
||||
@@ -95,7 +95,7 @@ export function SunriseCard({ post }: { post?: PostReaction | null }) {
|
||||
<div className="flex">
|
||||
<div className="min-w-0 shrink-0 grow-0 basis-full">
|
||||
{/* 그림의 빈 가장자리는 잘라 쓴다(CROP_IMG) */}
|
||||
<div ref={mapRef} onClick={tapMap} className="b-keep-bg relative mx-auto aspect-square w-full overflow-hidden bg-[#fff6ea]">
|
||||
<div ref={mapRef} onClick={tapMap} className={cx('b-keep-bg relative mx-auto aspect-square w-full overflow-hidden', SUN_PAPER)}>
|
||||
<img src={MAP_SRC} alt="" className={SUN_MAP_IMG} style={CROP_IMG} />
|
||||
{provs.map((v) => (
|
||||
<span key={v.name} aria-hidden="true" className={PROVINCE} style={{ left: v.x, top: v.y }}>
|
||||
|
||||
Reference in new issue
Block a user