feat: 히어로 공유 이미지를 하루 띠로 — 아침·낮·저녁·밤 네 줄(그 시간대 하늘·날씨·기온·날씨 점수·1등 각, 지금 표시), 1:1은 2×2 칸
This commit is contained in:
1 parent
8b487b7030
commit
b5c280ca3c
4 files changed
+91
-62
No files matched your search
@@ -1,8 +1,7 @@
|
||||
import type { Ref } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import type { TopIndex } from '../api/client/types.gen'
|
||||
import { cx } from '../lib/utils'
|
||||
import { MEDALS } from './lib'
|
||||
import { MEDALS, type TimeKind } from './lib'
|
||||
import { Ic } from './ui'
|
||||
|
||||
/** 공유 이미지 전용 틀. 화면 밖에 그려 두고 보내기 때 이것만 찍는다 (화면의 버튼은 이미지에서 빠지므로 글자만으로 만든다) */
|
||||
@@ -15,50 +14,76 @@ function Offscreen({ children }: { children: React.ReactNode }) {
|
||||
)
|
||||
}
|
||||
|
||||
export type HeroShare = {
|
||||
kind: string
|
||||
sky: string
|
||||
date: string
|
||||
place: string
|
||||
export type DayShare = {
|
||||
kind: TimeKind
|
||||
label: string
|
||||
now: boolean
|
||||
icon: string
|
||||
temp: string
|
||||
score?: number | null
|
||||
bubble?: string | null
|
||||
summary?: string | null
|
||||
status: { label: string; value: string; warn: boolean }[]
|
||||
slots: { label: string; icon: string; temp: string; on: boolean }[]
|
||||
gak?: { name: string; icon: string } | null
|
||||
}
|
||||
|
||||
export function HeroShareCard({ d, ref }: { d: HeroShare; ref: Ref<HTMLDivElement> }) {
|
||||
function DayLabel({ d }: { d: DayShare }) {
|
||||
return (
|
||||
<span className="flex items-center gap-1.5 font-jua text-[20px]">
|
||||
{d.label}
|
||||
{d.now && <small className="rounded-full bg-[#ff7a45] px-1.5 py-px font-sans text-[11px] font-extrabold text-white">지금</small>}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
/** 히어로 공유: 아침·낮·저녁·밤 네 줄. 줄마다 그 시간대 하늘에 날씨·기온, 날씨 점수, 그 시간 1등 각. 로고·지역·날짜는 공유 틀이 그린다 */
|
||||
export function DayShareCard({ days, ref }: { days: DayShare[]; ref: Ref<HTMLDivElement> }) {
|
||||
return (
|
||||
<Offscreen>
|
||||
<div ref={ref} className="b-hero relative flex aspect-[4/5] flex-col overflow-hidden px-5 pt-5 pb-4 text-center" data-t={d.kind} data-sky={d.sky}>
|
||||
<p className="m-0 text-left text-[14px] font-bold opacity-80">
|
||||
{d.date} · {d.place}
|
||||
</p>
|
||||
<div className="b-sun mx-auto mt-5 grid aspect-square w-36 place-items-center rounded-full">
|
||||
<span>
|
||||
<small className="block font-jua text-[13px]">{d.label}</small>
|
||||
<b className="block font-bagel text-[58px] leading-[0.95] font-normal">{d.score ?? '–'}</b>
|
||||
</span>
|
||||
</div>
|
||||
<p className="m-0 mt-4 font-jua text-[26px] leading-tight">{d.bubble}</p>
|
||||
{d.summary && <p className="m-0 mt-1 text-[15px] font-bold opacity-80">{d.summary}</p>}
|
||||
<p className="m-0 mt-2 flex flex-wrap justify-center gap-x-2 font-jua text-[14px]">
|
||||
{d.status.map((x) => (
|
||||
<span key={x.label} className={cx('whitespace-nowrap', x.warn && 'b-warn')}>
|
||||
<span className="opacity-75">{x.label}</span> {x.value}
|
||||
<div ref={ref} className="flex aspect-[4/5] flex-col">
|
||||
{days.map((d) => (
|
||||
<div key={d.kind} className="b-hero grid flex-1 grid-cols-[76px_64px_1fr_auto] items-center gap-2 px-5" data-t={d.kind}>
|
||||
<DayLabel d={d} />
|
||||
<span className="flex flex-col items-center">
|
||||
<Ic name={d.icon} className="h-8 w-8 object-contain" />
|
||||
<b className="font-jua text-[17px] font-normal">{d.temp}</b>
|
||||
</span>
|
||||
))}
|
||||
</p>
|
||||
<div className="b-strip mt-auto grid grid-cols-4 gap-1 rounded-[18px] p-[3px]">
|
||||
{d.slots.map((s) => (
|
||||
<span key={s.label} className={cx('flex flex-col items-center rounded-[14px] py-1.5', s.on && 'b-strip-on')}>
|
||||
<span className="text-[13px] font-bold opacity-80">{s.label}</span>
|
||||
<Ic name={s.icon} className="my-0.5 h-[22px] w-[22px] object-contain" />
|
||||
<b className="font-jua text-[15px] font-normal">{s.temp}</b>
|
||||
<span className="flex min-w-0 items-center gap-1.5">
|
||||
{d.gak && <Ic name={d.gak.icon} className="w-7 shrink-0" />}
|
||||
<b className="truncate font-jua text-[18px] font-normal">{d.gak?.name ?? '쉬어 가요'}</b>
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
<span className="text-right">
|
||||
<b className="block font-bagel text-[40px] leading-none font-normal">{d.score ?? '–'}</b>
|
||||
<small className="text-[11px] font-bold opacity-75">날씨 점수</small>
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</Offscreen>
|
||||
)
|
||||
}
|
||||
|
||||
/** 1:1 공유용: 같은 내용을 2×2 칸으로 */
|
||||
export function DayShareGrid({ days, ref }: { days: DayShare[]; ref: Ref<HTMLDivElement> }) {
|
||||
return (
|
||||
<Offscreen>
|
||||
<div ref={ref} className="grid aspect-square grid-cols-2 grid-rows-2">
|
||||
{days.map((d) => (
|
||||
<div key={d.kind} className="b-hero flex flex-col justify-between p-4" data-t={d.kind}>
|
||||
<span className="flex items-center justify-between">
|
||||
<DayLabel d={d} />
|
||||
<span className="flex items-center gap-1 font-jua text-[16px]">
|
||||
<Ic name={d.icon} className="h-6 w-6 object-contain" />
|
||||
{d.temp}
|
||||
</span>
|
||||
</span>
|
||||
<span className="flex items-end gap-1.5">
|
||||
<b className="font-bagel text-[48px] leading-none font-normal">{d.score ?? '–'}</b>
|
||||
<small className="pb-1 text-[11px] font-bold opacity-75">날씨 점수</small>
|
||||
</span>
|
||||
<span className="flex min-w-0 items-center gap-1.5">
|
||||
{d.gak && <Ic name={d.gak.icon} className="w-6 shrink-0" />}
|
||||
<b className="truncate font-jua text-[16px] font-normal">{d.gak?.name ?? '쉬어 가요'}</b>
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</Offscreen>
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user