feat: 히어로 시안 A(점수 해가 주인공), 탭 순서 각을 가운데로, 자외선 축 '자외선 약함'·자전거각에 자외선
- 히어로: 시간대 탭, 날짜·시각 한 줄, 230px 해(저녁·밤은 달 모양)에 큰 점수, 기온·챙길 것 칩 한 줄, 캐릭터 말풍선 안 1위 각 - 탭: 오늘 · 노을 · 각 · 주말·행사 · 계절·상식 - 자외선 축 이름을 바깥이 좋은 쪽으로 '자외선 약함', 자전거각 자외선 5%(바람 30→25) - 각 계산기준 문서 생성기: 돌풍·지면온도 조건과 자외선·햇빛·가시거리 축 - TODO: 노치 대응
This commit is contained in:
1 parent
35b3e0df43
commit
bb77eb2fdc
9 files changed
+113
-120
No files matched your search
@@ -15,7 +15,7 @@ import { deg, skyText, slotAt } from './weatherText'
|
||||
type Mode = 'now' | TimeKind
|
||||
|
||||
const MODES: [Mode, string][] = [
|
||||
['now', '지금 시간'],
|
||||
['now', '지금'],
|
||||
['morning', '아침'],
|
||||
['day', '낮'],
|
||||
['sunset', '저녁'],
|
||||
@@ -37,7 +37,6 @@ const SHOOTS = [
|
||||
{ top: '20%', left: '52%', '--len': '70px', '--dur': '9s', '--dl': '4s' },
|
||||
{ top: '34%', left: '94%', '--len': '80px', '--dur': '11s', '--dl': '6.5s' },
|
||||
]
|
||||
const ORB_POS = { left: '66%', top: '6px', d: '.5s', f: '4.4s' }
|
||||
|
||||
function useNow(ms = 20000) {
|
||||
const [now, setNow] = useState(() => new Date())
|
||||
@@ -85,18 +84,17 @@ function Hero({ hero, today, feedLoad, todayLoad }: HeroProps) {
|
||||
const slot = slots.length ? slotAt(slots, mode === 'now' ? t.h : PREVIEW[mode].hour) : undefined
|
||||
// 지금은 /v1/feed hero 값을, 미리보기는 그 시각의 예보 칸을 쓴다
|
||||
const temp = mode === 'now' && hero ? hero.temp_c : slot?.temp_c
|
||||
const feels = mode === 'now' && hero ? hero.feels_c : slot?.feels_c
|
||||
const top1 = hero?.top1
|
||||
const who = kind === 'night' ? 'bear' : 'rabbit'
|
||||
// 저녁(노을)부터는 가운데 동그라미가 오늘 밤 달 모양이 된다
|
||||
const moon = (kind === 'sunset' || kind === 'night') && hero?.moon_name && hero.moon_pct != null ? { name: hero.moon_name, pct: hero.moon_pct, waning: WANING.includes(hero.moon_name) } : null
|
||||
const tempLoad = mode === 'now' ? feedLoad : todayLoad
|
||||
const feelsLine = temp != null ? `체감 ${deg(feels)}${slot ? ` · ${skyText(slot)}` : ''}` : failed(tempLoad) ? '날씨를 못 불러왔어요' : tempLoad === 'ready' ? '체감 ?°' : null
|
||||
const tempChip = temp != null ? `${deg(temp)}${slot ? ` ${skyText(slot)}` : ''}` : null
|
||||
const bubble = hero ? (hero.bubble ?? '오늘은 쉬어 가요') : failed(feedLoad) ? '앗, 날씨를 못 불러왔어요' : null
|
||||
|
||||
// 아래 값은 모두 로딩·완료·실패 사이 높이가 같다: 글자 자리 스켈레톤, 비 칸은 두 줄 높이로 고정
|
||||
// 시안 A: 점수 해가 주인공. 위에 시간대 탭과 날짜, 가운데 큰 해, 아래 칩 한 줄과 캐릭터 말풍선(1위 각)
|
||||
return (
|
||||
<div className="b-hero relative mx-3 mt-1 overflow-hidden rounded-[32px] px-[18px] pt-4 pb-[18px]" data-t={kind}>
|
||||
<div className="b-hero relative mx-3 mt-1 overflow-hidden rounded-[32px] px-[18px] pt-4 pb-4" data-t={kind}>
|
||||
<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} />
|
||||
@@ -105,42 +103,19 @@ function Hero({ hero, today, feedLoad, todayLoad }: HeroProps) {
|
||||
<span key={i} className="b-shoot" style={s} />
|
||||
))}
|
||||
</div>
|
||||
<div className="relative z-[3] flex flex-wrap gap-1.5" role="group" aria-label="시간대 배경 미리보기">
|
||||
<div className="relative z-[3] grid grid-cols-5 rounded-full bg-white/45 p-1" role="tablist" aria-label="시간대 배경 미리보기">
|
||||
{MODES.map(([m, l]) => (
|
||||
<button key={m} type="button" aria-pressed={mode === m} onClick={() => setMode(m)} className={cx('cursor-pointer rounded-full px-2.5 py-[5px] text-xs font-bold', mode === m ? 'bg-(--ink) text-white' : 'bg-white/55 text-(--ink)')}>
|
||||
<button key={m} type="button" role="tab" aria-selected={mode === m} onClick={() => setMode(m)} className={cx('cursor-pointer rounded-full py-[6px] text-[13px] font-bold', mode === m ? 'bg-white text-(--ink) shadow-[0_2px_6px_rgb(40_48_74/0.12)]' : 'text-(--ink) opacity-70')}>
|
||||
{l}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<div className="relative z-[3] mt-3 flex items-end justify-between">
|
||||
<div>
|
||||
<p className="mb-1 text-[13.5px] font-bold opacity-85">
|
||||
{t.mo}월 {t.d}일 {WEEKDAYS[t.wd]}요일 · {mode === 'now' ? '지금' : `${PREVIEW[mode].label} 미리보기`}
|
||||
</p>
|
||||
<div className="font-bagel text-[60px] leading-none">{mode === 'now' ? `${String(t.h).padStart(2, '0')}:${String(t.mi).padStart(2, '0')}` : PREVIEW[mode].clock}</div>
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<b className="block font-bagel text-[42px] leading-none font-normal">{heroVal(tempLoad, temp != null ? deg(temp) : null, 'w-[72px]')}</b>
|
||||
<span className="block text-[12.5px] font-bold opacity-85">{feelsLine ?? <Skel className="w-[118px]" />}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className={cx('relative z-[3] mt-3 grid gap-2.5', hero?.stats?.length === 1 ? 'grid-cols-1' : 'grid-cols-2')}>
|
||||
{/* 두 칸은 서버가 지금 챙길 것(비·미세먼지·자외선·일교차 등) 순서로 골라 준다 */}
|
||||
{hero?.stats?.length
|
||||
? hero.stats.map((s) => (
|
||||
<HeroStat key={s.label} icon={s.icon} label={s.label} tone={s.tone}>
|
||||
{s.value}
|
||||
</HeroStat>
|
||||
))
|
||||
: STAT_HOLD.map((k) => (
|
||||
<HeroStat key={k} icon="none" label="">
|
||||
{heroVal(feedLoad, null, 'w-16')}
|
||||
</HeroStat>
|
||||
))}
|
||||
</div>
|
||||
<div className="relative mt-5 h-[286px]">
|
||||
<span className="b-cloud b-fall top-6 left-[6%] h-[30px] w-[84px]" style={fall('.1s', '6s')} aria-hidden="true" />
|
||||
<div className="b-sun b-fall absolute top-10 left-1/2 -ml-[82px] grid aspect-square w-[164px] place-items-center rounded-full text-center" style={fall('0s', '5.6s', '8px')}>
|
||||
<p className="relative z-[3] mt-3 mb-0 text-[15px] font-bold opacity-90">
|
||||
{t.mo}월 {t.d}일 {WEEKDAYS[t.wd]} · <b className="font-bagel text-[22px] font-normal">{mode === 'now' ? `${String(t.h).padStart(2, '0')}:${String(t.mi).padStart(2, '0')}` : PREVIEW[mode].clock}</b>
|
||||
</p>
|
||||
<div className="relative h-[262px]">
|
||||
<span className="b-cloud b-fall top-6 left-[2%] h-9 w-[100px]" style={fall('.1s', '6s')} aria-hidden="true" />
|
||||
<div className="b-sun b-fall absolute top-4 left-1/2 -ml-[115px] grid aspect-square w-[230px] place-items-center rounded-full text-center" style={fall('0s', '5.6s', '8px')}>
|
||||
{/* 안 보이는 쪽을 덮어 오늘 밤 달 모양으로 */}
|
||||
{moon && (
|
||||
<svg viewBox="-1 -1 2 2" className="pointer-events-none absolute inset-0 size-full" aria-hidden="true">
|
||||
@@ -148,46 +123,48 @@ function Hero({ hero, today, feedLoad, todayLoad }: HeroProps) {
|
||||
</svg>
|
||||
)}
|
||||
<span className={cx('relative', moon && '[text-shadow:0_0_6px_#fff,0_0_12px_#fff]')}>
|
||||
<b className="block font-bagel text-[56px] leading-[0.9] font-normal">{heroVal(feedLoad, hero?.weather_score, 'w-[84px]')}</b>
|
||||
<small className="mt-0.5 block font-jua text-[14.5px]">{failed(feedLoad) ? '점수를 못 불러왔어요' : '오늘 날씨 점수'}</small>
|
||||
<small className="block font-jua text-[15px]">{failed(feedLoad) ? '점수를 못 불러왔어요' : '오늘 날씨 점수'}</small>
|
||||
<b className="block font-bagel text-[96px] leading-[0.95] font-normal">{heroVal(feedLoad, hero?.weather_score, 'w-[120px]')}</b>
|
||||
</span>
|
||||
</div>
|
||||
<span className="b-cloud b-fall top-[188px] left-[54%] h-10 w-[118px]" style={fall('.25s', '6.4s')} aria-hidden="true" />
|
||||
<span className="b-cloud b-fall top-[188px] left-[58%] h-11 w-[118px]" style={fall('.25s', '6.4s')} aria-hidden="true" />
|
||||
</div>
|
||||
{/* 기온 + 서버가 고른 챙길 것(비·미세먼지·자외선·일교차 등)을 한 줄 칩으로 */}
|
||||
<div className="relative z-[3] mt-2 flex flex-wrap justify-center gap-2">
|
||||
<Chip>{heroVal(tempLoad, tempChip, 'w-16')}</Chip>
|
||||
{hero?.stats?.length
|
||||
? hero.stats.map((s) => (
|
||||
<Chip key={s.label} tone={s.tone}>
|
||||
{s.label} {s.value}
|
||||
</Chip>
|
||||
))
|
||||
: feedLoad === 'loading' && <Chip>{heroVal(feedLoad, null, 'w-20')}</Chip>}
|
||||
</div>
|
||||
<div className="relative z-[3] mt-3 flex items-center gap-2">
|
||||
<Ic name={who} alt={who === 'rabbit' ? '토끼' : '곰'} className="w-[52px] shrink-0 drop-shadow-[0_8px_10px_rgb(40_48_74/0.15)]" />
|
||||
{top1 ? (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => open({ type: 'gak', indexId: top1.index_id })}
|
||||
aria-label={`1위 ${top1.name} ${top1.score}점, 계산 근거 보기`}
|
||||
className="b-fall absolute z-[2] flex w-24 cursor-pointer flex-col items-center"
|
||||
style={{ left: ORB_POS.left, top: ORB_POS.top, ...fall(ORB_POS.d, ORB_POS.f) }}
|
||||
>
|
||||
<span className="relative w-[78px]">
|
||||
<Ic name={top1.icon} className="w-full drop-shadow-[0_10px_12px_rgb(40_48_74/0.16)]" />
|
||||
<Ic name={MEDALS[0]} className="absolute -top-2 -left-3.5 w-[30px]" />
|
||||
</span>
|
||||
<span className="b-orb-label font-jua text-sm whitespace-nowrap">
|
||||
1위 {top1.name} <em className="font-bagel text-(--orange) not-italic">{top1.score}</em>
|
||||
</span>
|
||||
<button type="button" onClick={() => open({ type: 'gak', indexId: top1.index_id })} aria-label={`${bubble ?? ''} 1위 ${top1.name} ${top1.score}점, 계산 근거 보기`} className="b-bubble flex min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-[20px] px-3.5 py-2.5 text-left">
|
||||
<span className="min-w-0 flex-1 truncate font-jua text-[17px]">{bubble}</span>
|
||||
<Ic name={top1.icon} className="w-8 shrink-0" />
|
||||
<em className="font-bagel text-[17px] text-(--orange) not-italic">{top1.score}</em>
|
||||
</button>
|
||||
) : (
|
||||
feedLoad === 'loading' && (
|
||||
<span className="absolute z-[2] flex w-24 flex-col items-center gap-1" style={{ left: ORB_POS.left, top: ORB_POS.top }} aria-hidden="true">
|
||||
<Skel shape className="size-[78px] rounded-full" />
|
||||
<span className="font-jua text-sm">
|
||||
<Skel className="w-[72px]" />
|
||||
</span>
|
||||
</span>
|
||||
)
|
||||
<span className="b-bubble min-w-0 flex-1 rounded-[20px] px-3.5 py-2.5 font-jua text-[17px]">{bubble ?? <Skel className="w-[120px]" />}</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="relative z-[3] flex items-end gap-2">
|
||||
<Ic name={who} alt={who === 'rabbit' ? '토끼' : '곰'} className="w-[50px] drop-shadow-[0_8px_10px_rgb(40_48_74/0.15)]" />
|
||||
<span className="mb-3 rounded-[20px_20px_20px_6px] bg-white px-3.5 py-[9px] font-jua text-base text-(--ink) shadow-[0_8px_16px_rgb(40_48_74/0.1)]">{bubble ?? <Skel className="w-[120px]" />}</span>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** 히어로 아래 한 줄 칩. tone 은 서버가 정한 상태(비·경고)로 색을 바꾼다 */
|
||||
function Chip({ tone = 'normal', children }: { tone?: HeroStatData['tone']; children: ReactNode }) {
|
||||
return (
|
||||
<span className="b-stat rounded-full px-4 py-2 font-jua text-[16px] break-keep" data-tone={tone}>
|
||||
{children}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
const WANING = ['기우는 달', '하현달', '그믐달']
|
||||
|
||||
/**
|
||||
@@ -200,21 +177,6 @@ function moonPath(pct: number, r: number, lit: boolean) {
|
||||
return `M0,${-r} A${r},${r} 0 0 ${lit ? 1 : 0} 0,${r} ${edge}`
|
||||
}
|
||||
|
||||
const STAT_HOLD = ['a', 'b']
|
||||
|
||||
function HeroStat({ icon, label, tone = 'normal', children }: { icon: string; label: string; tone?: HeroStatData['tone']; children: ReactNode }) {
|
||||
return (
|
||||
<div className="b-stat flex min-h-[90px] items-center gap-2.5 rounded-[20px] px-3 py-[9px]" data-tone={tone}>
|
||||
<Ic name={icon} className="w-9 shrink-0" />
|
||||
<div className="min-w-0">
|
||||
<small className="block text-xs font-bold opacity-80">{label}</small>
|
||||
{/* 한국어가 글자 단위로 끊기지 않게 단어 단위로 줄바꿈 */}
|
||||
<b className="block font-jua text-lg font-normal break-keep">{children}</b>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function Stories({ items }: { items: TopIndex[] }) {
|
||||
const { open } = useSheet()
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user