feat: 히어로 두 칸을 상황별로 고르고 아이콘·색을 상태에 맞춤
- 비 예보 → 미세먼지 나쁨 → 자외선 높음(낮) → 일교차 10° → 체감 쌀쌀 → 불쾌지수 75 순서, 모자라면 비 없음·미세먼지·자외선·달 - 조심(노랑)·비(파랑) 강조, 미세먼지 나쁨은 마스크 아이콘(Fluent Emoji) - Hero.stats 추가, 자외선은 openmeteo_hourly 지금 시각 값
This commit is contained in:
1 parent
5e2846ff72
commit
4096ce0441
13 files changed
+288
-21
No files matched your search
@@ -2,7 +2,7 @@ import { Fragment, useEffect, useState, type ReactNode } from 'react'
|
||||
import { Link } from 'react-router'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { getFeedOptions, getWeatherTodayOptions } from '../api/client/@tanstack/react-query.gen'
|
||||
import type { BandArticle, BandEvent, Hero as HeroData, ResWeatherToday, TopIndex } from '../api/client/types.gen'
|
||||
import type { BandArticle, BandEvent, Hero as HeroData, HeroStat as HeroStatData, ResWeatherToday, TopIndex } from '../api/client/types.gen'
|
||||
import { cx } from '../lib/utils'
|
||||
import { cardBg, fall, kindOfHour, kst, type Load, loadOf, MEDALS, type TimeKind, WEEKDAYS } from './lib'
|
||||
import { PostCard, PostCardSkel } from './Post'
|
||||
@@ -125,12 +125,18 @@ function Hero({ hero, today, feedLoad, todayLoad }: HeroProps) {
|
||||
</div>
|
||||
</div>
|
||||
<div className="relative z-[3] mt-3 grid grid-cols-2 gap-2.5">
|
||||
<HeroStat icon="thermo" label="불쾌지수">
|
||||
{heroVal(feedLoad, hero?.discomfort != null ? `${hero.discomfort} · ${hero.discomfort_label ?? ''}` : null, 'w-16')}
|
||||
</HeroStat>
|
||||
<HeroStat icon="umbrella" label="지금 비">
|
||||
{heroVal(feedLoad, hero?.will_rain_2h == null ? null : hero.will_rain_2h ? '2시간 안에 와요' : '2시간 동안 안 와요', 'w-16')}
|
||||
</HeroStat>
|
||||
{/* 두 칸은 서버가 지금 챙길 것(비·미세먼지·자외선·일교차 등) 순서로 골라 준다 */}
|
||||
{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" />
|
||||
@@ -194,9 +200,11 @@ function moonPath(pct: number, r: number, lit: boolean) {
|
||||
return `M0,${-r} A${r},${r} 0 0 ${lit ? 1 : 0} 0,${r} ${edge}`
|
||||
}
|
||||
|
||||
function HeroStat({ icon, label, children }: { icon: string; label: string; children: ReactNode }) {
|
||||
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]">
|
||||
<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>
|
||||
|
||||
@@ -184,6 +184,17 @@
|
||||
.b-hero[data-t='sunset'] .b-stat {
|
||||
background: rgb(30 16 80 / 0.2);
|
||||
}
|
||||
/* 히어로 칸 강조: 조심(노랑)·비(파랑). 시간대 배경과 상관없이 같은 색 */
|
||||
.b-hero .b-stat[data-tone='warn'] {
|
||||
background: #fff3d6;
|
||||
color: var(--ink);
|
||||
box-shadow: inset 0 -5px 0 #ffd98a;
|
||||
}
|
||||
.b-hero .b-stat[data-tone='rain'] {
|
||||
background: #dcecff;
|
||||
color: var(--ink);
|
||||
box-shadow: inset 0 -5px 0 #a9cdf5;
|
||||
}
|
||||
.b-orb-label {
|
||||
text-shadow: 0 2px 0 rgb(255 255 255 / 0.7);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { CSSProperties } from 'react'
|
||||
|
||||
const SHARED = new Set(['bear', 'bike', 'bronze', 'camping', 'carwash', 'chimaek', 'cloud', 'coldwind', 'delivery', 'dog', 'garden', 'glasses', 'gold', 'hiking', 'iced_hot', 'jjamppong', 'laundry', 'letter', 'makeup', 'makgeolli', 'maple', 'moon', 'muggy', 'naengmyeon', 'photo', 'picnic', 'rabbit', 'rain', 'running', 'silver', 'snow', 'stars', 'sun_cloud', 'sun', 'sunset', 'taxi', 'umbrella', 'vent', 'walk', 'yajang', 'baseball', 'study', 'netflix', 'chestnut', 'peanut', 'tangerine', 'sweet_potato', 'fallen_leaf', 'kimchi', 'apple'])
|
||||
const SHARED = new Set(['bear', 'bike', 'bronze', 'camping', 'carwash', 'chimaek', 'cloud', 'coldwind', 'delivery', 'dog', 'garden', 'glasses', 'gold', 'hiking', 'iced_hot', 'jjamppong', 'laundry', 'letter', 'makeup', 'makgeolli', 'maple', 'moon', 'muggy', 'naengmyeon', 'photo', 'picnic', 'rabbit', 'rain', 'running', 'silver', 'snow', 'stars', 'sun_cloud', 'sun', 'sunset', 'taxi', 'umbrella', 'vent', 'walk', 'yajang', 'baseball', 'study', 'netflix', 'chestnut', 'peanut', 'tangerine', 'sweet_potato', 'fallen_leaf', 'kimchi', 'apple', 'mask'])
|
||||
const OWN = new Set(['fireworks', 'bulb', 'calendar', 'thermo', 'sheaf', 'popup', 'exhibition', 'concert'])
|
||||
|
||||
/** 아이콘 이름 → 파일 경로 (공용 public/icons, B 전용 public/b/icons). 'none'(데이터 없는 칸)은 그림 없음 */
|
||||
|
||||
Reference in new issue
Block a user