feat: 사주 오늘의 점수 카드를 대시보드형으로 — 점수 링, 사주·날씨 영향 막대, 올린·내린 이유를 접지 않고 칩으로

This commit is contained in:
minaChoi committed 2026-10-29 13:23:56 +09:00
1 parent 549e227f90
commit b9dd0f203d
1 file changed
+66 -20
+66 -20
View File
@@ -225,30 +225,40 @@ function Reading({ birth, onEdit }: { birth: Birth; onEdit: () => void }) {
return (
<div className="flex flex-col gap-3">
<div ref={shot} className="mx-4 mt-3 rounded-[26px] bg-white px-5 pt-4 pb-5 shadow-[inset_0_-5px_0_var(--shade)]">
<p className="m-0 text-center text-[12.5px] font-extrabold text-(--ink3)">
<div ref={shot} className="mx-4 mt-3 rounded-[26px] bg-white px-4 pt-4 pb-4 shadow-[inset_0_-5px_0_var(--shade)]">
<p className="m-0 text-[12.5px] font-extrabold text-(--ink3)">
{Number(t.day.slice(5, 7))}월 {Number(t.day.slice(8, 10))}일 {t.pillar}일 · 오늘의 점수
</p>
<p className="m-0 text-center font-bagel text-[60px] leading-none">{t.score}</p>
<h3 className="m-0 mt-1.5 text-center font-jua text-[23px] leading-tight font-normal">{t.title}</h3>
<div className="mt-2.5 flex flex-wrap justify-center gap-1.5 text-[11.5px] font-extrabold">
<span className="rounded-full bg-[#f3f6fb] px-2.5 py-1">사주 {t.saju_score}점</span>
{t.weather_points != null && (
<span className={cx('rounded-full px-2.5 py-1', t.weather_points >= 0 ? 'bg-[#e3f6ea] text-[#1f7a4f]' : 'bg-[#ffe8dc] text-[#c2471b]')}>
날씨 영향 {t.weather_points >= 0 ? '+' : '−'}
{Math.abs(t.weather_points)}점
</span>
)}
<div className="mt-2 flex items-center gap-4">
<ScoreRing score={t.score} />
<div className="min-w-0 flex-1">
<h3 className="m-0 font-jua text-[21px] leading-tight font-normal">{t.title}</h3>
<ScoreBar label="사주" value={t.saju_score} width={t.saju_score} color="var(--ink)" />
{t.weather_points != null && (
<ScoreBar
label="날씨 영향"
value={t.weather_points}
width={Math.min(100, Math.abs(t.weather_points) * 3)}
color={t.weather_points >= 0 ? '#1f7a4f' : '#e8663a'}
signed
/>
)}
</div>
</div>
{(t.why?.length ?? 0) > 0 && (
<details className="mt-2 text-center">
<summary className="cursor-pointer text-xs font-bold text-(--ink3)">왜 이 점수인가요? (↑ 올린 것 · ↓ 내린 것)</summary>
<ul className="m-0 mt-1.5 list-none p-0 text-xs font-semibold text-(--ink2)">
{t.why!.map((w) => (
<li key={w}>{w}</li>
))}
</ul>
</details>
<ul className="m-0 mt-3 flex list-none flex-col gap-1.5 p-0">
{t.why!.map((w) => (
<li
key={w}
className={cx(
'rounded-xl px-3 py-2 text-[13px] leading-snug font-bold',
w.startsWith('↓') ? 'bg-[#fff1ea] text-[#b5421a]' : 'bg-[#eef3fb] text-(--ink)',
)}
>
{w}
</li>
))}
</ul>
)}
</div>
@@ -304,6 +314,42 @@ function DecisionCard({ c }: { c: SajuCard }) {
)
}
function ScoreRing({ score }: { score: number }) {
const r = 46
const len = 2 * Math.PI * r
return (
<div className="relative size-[116px] shrink-0">
<svg viewBox="0 0 116 116" className="size-full -rotate-90" aria-hidden>
<circle cx="58" cy="58" r={r} fill="none" stroke="#eef1f6" strokeWidth="11" />
<circle cx="58" cy="58" r={r} fill="none" stroke="var(--orange)" strokeWidth="11" strokeLinecap="round" strokeDasharray={`${(len * score) / 100} ${len}`} />
</svg>
<span className="absolute inset-0 grid place-items-center">
<span className="text-center">
<b className="block font-bagel text-[40px] leading-none">{score}</b>
<small className="text-[11px] font-extrabold text-(--ink3)">오늘의 점수</small>
</span>
</span>
</div>
)
}
function ScoreBar({ label, value, width, color, signed }: { label: string; value: number; width: number; color: string; signed?: boolean }) {
return (
<div className="mt-2">
<p className="m-0 flex justify-between text-[12.5px] font-extrabold" style={{ color }}>
<span>{label}</span>
<span>
{signed ? (value >= 0 ? '+' : '−') : ''}
{Math.abs(value)}점
</span>
</p>
<span className="mt-1 block h-2 overflow-hidden rounded-full bg-[#eef1f6]">
<span className="block h-full rounded-full" style={{ width: `${width}%`, background: color }} />
</span>
</div>
)
}
function MeCard({ r, onEdit }: { r: ResSaju; onEdit: () => void }) {
const me = r.me!
const cols = [...me.pillars].reverse()