fix: 히어로를 휴대폰 한 화면에 — 해 줄이고 칩을 한 줄 세 칸으로
This commit is contained in:
1 parent
498e4d677a
commit
e8382f450b
1 file changed
+31
-27
@@ -30,6 +30,9 @@ const PREVIEW: Record<TimeKind, { label: string; clock: string; hour: number }>
|
||||
night: { label: '밤', clock: '22:10', hour: 22 },
|
||||
}
|
||||
|
||||
// 히어로 칸을 받아 오는 동안 자리만 잡아 둔다
|
||||
const STAT_HOLD = ['a', 'b']
|
||||
|
||||
const STARS = Array.from({ length: 26 }, (_, i) => ({ left: `${(i * 37) % 100}%`, top: `${(i * 53) % 60}%`, opacity: 0.4 + ((i * 7) % 6) / 10 }))
|
||||
// 별똥별 셋: 위치·길이·주기를 엇갈려 하나씩 떨어지게
|
||||
const SHOOTS = [
|
||||
@@ -93,7 +96,7 @@ function Hero({ hero, today, feedLoad, todayLoad }: HeroProps) {
|
||||
|
||||
// 시안 A: 점수 해가 주인공. 위에 시간대 탭과 날짜, 가운데 큰 해, 아래 칩 한 줄과 캐릭터 말풍선(1위 각)
|
||||
return (
|
||||
<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-hero relative mx-3 mt-1 overflow-hidden rounded-[28px] px-4 pt-3 pb-3" 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} />
|
||||
@@ -104,17 +107,17 @@ function Hero({ hero, today, feedLoad, todayLoad }: HeroProps) {
|
||||
</div>
|
||||
<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" 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')}>
|
||||
<button key={m} type="button" role="tab" aria-selected={mode === m} onClick={() => setMode(m)} className={cx('cursor-pointer rounded-full py-[5px] 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>
|
||||
<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 className="relative z-[3] mt-2 mb-0 text-[14px] font-bold opacity-90">
|
||||
{t.mo}월 {t.d}일 {WEEKDAYS[t.wd]} · <b className="font-bagel text-[19px] 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')}>
|
||||
<div className="relative h-[196px]">
|
||||
<span className="b-cloud b-fall top-3 left-[4%] h-8 w-[84px]" style={fall('.1s', '6s')} aria-hidden="true" />
|
||||
<div className="b-sun b-fall absolute top-2 left-1/2 -ml-[90px] grid aspect-square w-[180px] 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">
|
||||
@@ -122,44 +125,45 @@ function Hero({ hero, today, feedLoad, todayLoad }: HeroProps) {
|
||||
</svg>
|
||||
)}
|
||||
<span className={cx('relative', moon && '[text-shadow:0_0_6px_#fff,0_0_12px_#fff]')}>
|
||||
<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>
|
||||
<small className="block font-jua text-[13px]">{failed(feedLoad) ? '점수를 못 불러왔어요' : '오늘 날씨 점수'}</small>
|
||||
<b className="block font-bagel text-[74px] leading-[0.95] font-normal">{heroVal(feedLoad, hero?.weather_score, 'w-[120px]')}</b>
|
||||
</span>
|
||||
</div>
|
||||
<span className="b-cloud b-fall top-[188px] left-[58%] h-11 w-[118px]" style={fall('.25s', '6.4s')} aria-hidden="true" />
|
||||
<span className="b-cloud b-fall top-[140px] left-[58%] h-9 w-[96px]" 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>
|
||||
{/* 기온 + 서버가 고른 챙길 것(비·미세먼지·자외선·일교차 등)을 한 줄 세 칸으로. 휴대폰에서 두 줄로 넘치지 않게 칸 안에서 위아래로 */}
|
||||
<div className="relative z-[3] mt-1 grid auto-cols-fr grid-flow-col gap-1.5">
|
||||
<Stat label={mode === 'now' ? '지금' : PREVIEW[mode].label}>{heroVal(tempLoad, tempChip, 'w-12')}</Stat>
|
||||
{hero?.stats?.length
|
||||
? hero.stats.map((s) => (
|
||||
<Chip key={s.label} tone={s.tone}>
|
||||
{s.label} {s.value}
|
||||
</Chip>
|
||||
<Stat key={s.label} label={s.label} tone={s.tone}>
|
||||
{s.value}
|
||||
</Stat>
|
||||
))
|
||||
: feedLoad === 'loading' && <Chip>{heroVal(feedLoad, null, 'w-20')}</Chip>}
|
||||
: feedLoad === 'loading' && STAT_HOLD.map((k) => <Stat key={k} label="">{heroVal(feedLoad, null, 'w-12')}</Stat>)}
|
||||
</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)]" />
|
||||
<div className="relative z-[3] mt-2 flex items-center gap-2">
|
||||
<Ic name={who} alt={who === 'rabbit' ? '토끼' : '곰'} className="w-[44px] 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={`${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" />
|
||||
<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-[18px] px-3 py-2 text-left">
|
||||
<span className="min-w-0 flex-1 truncate font-jua text-[16px]">{bubble}</span>
|
||||
<Ic name={top1.icon} className="w-7 shrink-0" />
|
||||
<em className="font-bagel text-[17px] text-(--orange) not-italic">{top1.score}</em>
|
||||
</button>
|
||||
) : (
|
||||
<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>
|
||||
<span className="b-bubble min-w-0 flex-1 rounded-[18px] px-3 py-2 font-jua text-[16px]">{bubble ?? <Skel className="w-[120px]" />}</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** 히어로 아래 한 줄 칩. tone 은 서버가 정한 상태(비·경고)로 색을 바꾼다 */
|
||||
function Chip({ tone = 'normal', children }: { tone?: HeroStatData['tone']; children: ReactNode }) {
|
||||
/** 히어로 아래 한 칸: 작은 이름 위, 값 아래. tone 은 서버가 정한 상태(비·경고)로 색을 바꾼다 */
|
||||
function Stat({ label, tone = 'normal', children }: { label: string; 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 className="b-stat flex min-w-0 flex-col items-center rounded-2xl px-1.5 pt-1.5 pb-2 text-center break-keep" data-tone={tone}>
|
||||
<small className="text-[11.5px] font-bold opacity-75">{label}</small>
|
||||
<b className="font-jua text-[14.5px] leading-tight font-normal">{children}</b>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user