feat: 히어로 공유 이미지를 하루 띠로 — 아침·낮·저녁·밤 네 줄(그 시간대 하늘·날씨·기온·날씨 점수·1등 각, 지금 표시), 1:1은 2×2 칸

This commit is contained in:
minaChoi committed 2026-10-21 13:33:54 +09:00
1 parent 8b487b7030
commit b5c280ca3c
4 files changed
+91 -62

No files matched your search

+24 -21
View File
@@ -15,7 +15,7 @@ import { useFeedTalks } from './talkState'
import { useRegion } from './regionContext'
import { useSheet } from './sheetContext'
import { useSky } from './skyContext'
import { GakShareCard, HeroShareCard, type HeroShare } from './shareCards'
import { DayShareCard, DayShareGrid, GakShareCard, type DayShare } from './shareCards'
import { SendIcon } from './svg'
import { Ic, Rail, Sec, Skel, StateBox, TAP44, Thumb } from './ui'
import { deg, slotAt } from './weatherText'
@@ -86,7 +86,7 @@ function atSlot(items: TopIndex[], kind: TimeKind | null): TopIndex[] {
]
}
type HeroProps = { hero?: HeroData | null; today?: ResWeatherToday; ranked: TopIndex[]; feedLoad: Load; todayLoad: Load }
type HeroProps = { hero?: HeroData | null; today?: ResWeatherToday; ranked: TopIndex[]; all: TopIndex[]; feedLoad: Load; todayLoad: Load }
type Weather = 'clear' | 'partly' | 'cloudy' | 'rain' | 'snow' | 'sleet'
@@ -108,11 +108,13 @@ const CLOUDS = [
]
const CLOUD_N: Record<Weather, number> = { clear: 0, partly: 2, cloudy: 3, rain: 3, snow: 3, sleet: 3 }
function Hero({ hero, today, ranked, feedLoad, todayLoad }: HeroProps) {
function Hero({ hero, today, ranked, all, feedLoad, todayLoad }: HeroProps) {
const { open } = useSheet()
const { region } = useRegion()
const tplRef = useRef<HTMLDivElement>(null)
const share = () => tplRef.current && open({ type: 'share', share: { title: `${region.name} 오늘 날씨`, slides: [tplRef.current] } })
const gridRef = useRef<HTMLDivElement>(null)
const share = () =>
tplRef.current && open({ type: 'share', share: { title: `${region.name} 오늘 날씨`, slides: [tplRef.current], square: gridRef.current ? [gridRef.current] : undefined } })
const { preview, setServerKind, setPreview } = useSky()
const mode: Mode = preview ?? 'now'
const clock = useNow()
@@ -148,26 +150,27 @@ function Hero({ hero, today, ranked, feedLoad, todayLoad }: HeroProps) {
const rain = weather === 'rain' || weather === 'sleet'
const snow = weather === 'snow' || weather === 'sleet'
const shareData: HeroShare = {
kind,
sky: weather,
date: `${t.mo}월 ${t.d}일 ${WEEKDAYS[t.wd]}요일`,
place: region.name,
label: `${slotScore != null && mode !== 'now' ? PREVIEW[mode].label : '지금'} 날씨 점수`,
score,
bubble,
summary: top1?.summary,
status: status.map((x) => ({ label: x.label, value: x.value, warn: x.tone === 'warn' })),
slots: KINDS.map((k) => {
const s = slotOf(k === nowKind ? 'now' : k)
return { label: k === nowKind ? '지금' : PREVIEW[k].label, icon: k === 'night' && weatherOf(s) === 'clear' ? 'moon' : WEATHER_ICON[weatherOf(s)], temp: s?.temp_c != null ? deg(s.temp_c) : '–', on: k === kind }
}),
}
// 공유 이미지: 아침~밤 네 시간대 모두. 점수는 시간대 점수, 각은 그 시간대 1등
const days: DayShare[] = KINDS.map((k) => {
const isNow = k === nowKind
const s = slotOf(isNow ? 'now' : k)
const top = atSlot(all, k).find((g) => g.active)
return {
kind: k,
label: PREVIEW[k].label,
now: isNow,
icon: k === 'night' && weatherOf(s) === 'clear' ? 'moon' : WEATHER_ICON[weatherOf(s)],
temp: s?.temp_c != null ? deg(s.temp_c) : '–',
score: hero?.weather_slots?.[SLOT_KEY[k]] ?? (isNow ? hero?.weather_score : null),
gak: top ? { name: top.name, icon: top.icon } : null,
}
})
// 시안 D4-2: 가운데 해(점수)와 하늘 날씨, 결론 두 줄, 상태 한 줄, 아래 하루 흐름 칸(누르면 그 시간대 하늘로)
return (
<div className="b-hero relative mx-3 mt-1 overflow-hidden rounded-[28px] px-4 pt-3 pb-3" data-t={kind} data-sky={weather}>
<HeroShareCard d={shareData} ref={tplRef} />
<DayShareCard days={days} ref={tplRef} />
<DayShareGrid days={days} ref={gridRef} />
<div className="b-stars pointer-events-none absolute inset-0" aria-hidden="true">
{STARS.map((s, i) => (
<i key={i} className="absolute size-[3px] rounded-full shadow-[0_0_6px_#fff]" style={s} />
@@ -388,7 +391,7 @@ export function TodayPage() {
return (
// 피드 칸은 전국 공통이라 지역이 바뀌어도 글 번호가 같다. 지역마다 새로 그려 넘긴 슬라이드·펼친 상태가 남지 않게 한다
<section key={region.code} aria-label="오늘" aria-busy={load === 'loading'} className={cx('transition-opacity', feed.isPlaceholderData && 'opacity-60')}>
<Hero hero={f?.hero} today={today.data} ranked={stories} feedLoad={load} todayLoad={loadOf(today)} />
<Hero hero={f?.hero} today={today.data} ranked={stories} all={f?.stories ?? []} feedLoad={load} todayLoad={loadOf(today)} />
<FeedComposer onPosted={(t) => setMine((m) => [t, ...m])} />
{mine.map((t) => (
<TalkCard key={t.talk_id} t={t} />