feat: 달 포스트·히어로 달을 오늘 밤 실제 모양으로 — 표면 무늬·빛 번짐, 보름엔 가장 밝게, 저녁엔 노을빛, 달 포스트는 밤하늘·별 배경

This commit is contained in:
minaChoi committed 2026-10-27 13:14:30 +09:00
1 parent fcc4163e15
commit d32e24a5ab
8 files changed
+143 -24

No files matched your search

+2
View File
@@ -38,6 +38,8 @@ class RowsSlide(WebPacketProtocol):
rows: list[Row] = []
image: Optional[str] = None # 있으면 아이콘 대신 카드 전체에 사진
image_credit: Optional[str] = None # 사진 출처 표기 ("ⓒ한국관광공사")
moon_pct: Optional[int] = Field(default=None, description="달 포스트만: 빛나는 면의 비율 0~100 (아이콘 대신 이 모양으로 달을 그린다)")
moon_waxing: Optional[bool] = Field(default=None, description="달 포스트만: 차오르는 달이면 true (오른쪽이 밝음)")
class GakSlide(WebPacketProtocol):
+3 -3
View File
@@ -600,7 +600,7 @@ class FeedService:
else "구름 사이로 잠깐씩 보일 수도 있어요." if view.startswith("흐려서")
else "하루하루 차오르는 중이에요. 보름까지 같이 세어 봐요 🌙" if waxing else "조금씩 기우는 중이에요. 그만큼 별은 더 잘 보여요 ✨")
return PostData(**base, title=f"오늘 밤 {name}", icon="moon", caption=caption,
slides=[RowsSlide(kind="rows", eyebrow=eyebrow, line=f"오늘 밤은 {name},\n{view}", icon="moon",
slides=[RowsSlide(kind="rows", eyebrow=eyebrow, line=f"오늘 밤은 {name},\n{view}", icon="moon", moon_pct=round(m.lit * 100), moon_waxing=m.waxing,
rows=[*rows, Row(label="다음 보름", value=f"{nxt.month}.{nxt.day:02d} ({_WEEKDAY_KO[nxt.weekday()]})")])],
share_messages=[f"오늘 밤은 {name}이래 🌙"])
when = f"{'내일 ' if at.date() > tonight.date() else ''}{at:%H:%M}"
@@ -608,14 +608,14 @@ class FeedService:
line = f"오늘 밤 보름달,\n{when}에 가장 둥글어요"
caption = "구름 사이로 잠깐씩 보일 수 있어요." if view.startswith("흐려서") else "소원 빌기 딱 좋은 밤이에요 🌕"
return PostData(**base, title="오늘 밤 보름달", icon="moon", caption=caption,
slides=[RowsSlide(kind="rows", eyebrow=eyebrow, line=line, icon="moon", rows=[Row(label="보이는지", value=view), *rows])],
slides=[RowsSlide(kind="rows", eyebrow=eyebrow, line=line, icon="moon", moon_pct=100, moon_waxing=False, rows=[Row(label="보이는지", value=view), *rows])],
share_messages=["오늘 밤 보름달이래 🌕 같이 볼래?"])
stars = next((i for i in (c.board.items if c.board else []) if i.definition.code == "stars"), None)
if stars is not None:
rows.append(Row(label="별보기각", value=f"{stars.score.score}점"))
caption = "구름이 많아 별은 아쉬워요." if sky is Sky.CLOUDY else "불빛 적은 곳으로 조금만 나가 봐요 ✨"
return PostData(**base, title="오늘 밤 달 없는 밤", icon="moon", caption=caption,
slides=[RowsSlide(kind="rows", eyebrow=eyebrow, line="달이 숨는 밤,\n별이 제일 잘 보여요", icon="moon", rows=rows)],
slides=[RowsSlide(kind="rows", eyebrow=eyebrow, line="달이 숨는 밤,\n별이 제일 잘 보여요", icon="moon", moon_pct=0, moon_waxing=True, rows=rows)],
share_messages=["오늘 밤 달이 없어서 별 보기 좋대 ✨"])
def _day_trip(self, base: dict, pick: TripPick, events: list[EventItem]) -> PostData:
+11
View File
@@ -41,6 +41,17 @@ def test_moon_post_every_night_with_full_and_new_moon_stories():
assert plain.title == "오늘 밤 차오르는 달" and plain.slides[0].rows[-1].label == "다음 보름" and plain.slides[0].rows[-1].value.startswith("10.07")
def test_moon_post_slide_carries_shape_for_drawing():
full = _moon_post(datetime(2025, 10, 7, 20, 0, tzinfo=KST)).slides[0]
assert full.moon_pct == 100
new = _moon_post(datetime(2024, 4, 9, 1, 0, tzinfo=KST)).slides[0]
assert new.moon_pct == 0
waxing = _moon_post(datetime(2025, 10, 4, 20, 0, tzinfo=KST)).slides[0]
assert 70 < waxing.moon_pct < 97 and waxing.moon_waxing is True
waning = _moon_post(datetime(2025, 10, 10, 20, 0, tzinfo=KST)).slides[0]
assert 70 < waning.moon_pct < 97 and waning.moon_waxing is False
SEOUL = (37.57, 126.98)
+25 -3
View File
@@ -13,6 +13,7 @@ import { usePinnedLike, type PinnedKey } from './pinnedLike'
import { useSheet } from './sheetContext'
import { CommentIcon, HeartIcon, SendIcon } from './svg'
import { useCarousel } from './carousel'
import { MoonArt } from './moon'
import { Arrows, Credit, Ic, Rows, Skel, TAP44, Thumb } from './ui'
const ACCOUNTS: Record<PostType, readonly [string, string]> = {
@@ -52,7 +53,7 @@ function slideBg(post: PostData, slide: Slide): SlideBg {
if (slide.kind === 'plan') return slide.eyebrow.startsWith('일') ? 'peach' : 'butter'
if (slide.kind === 'gak') return GAK_BG[post.post_id % GAK_BG.length]
if (slide.kind === 'image') return 'sky'
if (post.post_type === PostType.EVENT) return 'night'
if (post.post_type === PostType.EVENT || post.post_type === PostType.MOON) return 'night'
if (post.post_type === PostType.TIP) return 'sky'
if (post.post_type === PostType.AIR) return slide.icon === 'vent' ? 'mint' : 'lilac'
if (post.post_type === PostType.DAY_TRIP) return slide.image ? 'night' : 'mint'
@@ -104,6 +105,27 @@ function Pic({ name, className }: { name: string; className?: string }) {
const slideBase = 'relative flex h-full w-full shrink-0 flex-col px-5 py-[22px]'
// 달 포스트 밤하늘 별: [left %, top %, 크기 px]
const STARS: [number, number, number][] = [
[8, 34, 2], [18, 52, 1.5], [30, 40, 2.5], [44, 30, 1.5], [52, 58, 2], [62, 22, 1.5], [90, 18, 2], [94, 44, 1.5], [12, 70, 1.5], [38, 66, 2], [76, 74, 1.5], [86, 64, 2], [24, 12, 1.5], [70, 10, 2.5],
]
/** 달 포스트 그림: 아이콘 대신 오늘 밤 실제 모양의 달과 별 */
function MoonPic({ pct, waxing }: { pct: number; waxing: boolean }) {
return (
<>
<span className="pointer-events-none absolute inset-0 -z-10" aria-hidden="true">
{STARS.map(([x, y, s]) => (
<i key={`${x},${y}`} className="absolute rounded-full bg-white opacity-80 shadow-[0_0_6px_rgb(255_255_255/0.8)]" style={{ left: `${x}%`, top: `${y}%`, width: s, height: s }} />
))}
</span>
<span className="b-fall pointer-events-none absolute top-[22%] right-0 w-[60%]" style={fall('.1s', '5s')}>
<MoonArt pct={pct} waxing={waxing} className="b-bob w-full" />
</span>
</>
)
}
function SlideView({ slide, bg, img }: { slide: Slide; bg: SlideBg; img?: CSSProperties }) {
const { open } = useSheet()
if (slide.kind === 'hours') {
@@ -258,12 +280,12 @@ function SlideView({ slide, bg, img }: { slide: Slide; bg: SlideBg; img?: CSSPro
</div>
)
return (
<div className={cx(slideBase, `b-bg-${bg}`)} style={img}>
<div className={cx(slideBase, `b-bg-${bg}`, slide.moon_pct != null && 'isolate')} style={img}>
<Eyebrow className={DARK.has(bg) ? 'opacity-85' : undefined}>{slide.eyebrow}</Eyebrow>
<Big className="relative z-[1]">
<Lines text={slide.line} />
</Big>
<Pic name={slide.icon} className="w-[36%]" />
{slide.moon_pct != null ? <MoonPic pct={slide.moon_pct} waxing={!!slide.moon_waxing} /> : <Pic name={slide.icon} className="w-[36%]" />}
<Rows rows={slide.rows ?? []} dark={DARK.has(bg)} />
</div>
)
+6 -18
View File
@@ -21,6 +21,7 @@ import { cardBg, kindOfHour, kst, type Load, loadOf, MEDALS, type TimeKind, WEEK
import { fall } from './lib'
import { FoliageCard } from './foliageMap'
import { InstallBanner } from './installBanner'
import { MoonArt } from './moon'
import { MyGakRow } from './myGak'
import { fromShare } from './myGakState'
import { PostCard, PostCardSkel, PostFrame } from './Post'
@@ -372,13 +373,9 @@ function Hero({ hero, post, today, ranked, all, feedLoad, todayLoad }: HeroProps
</span>
))}
<div className={'b-fall absolute top-2 left-1/2 -ml-16 aspect-square w-32'} style={fall('0s', '5.6s')}>
<div className="b-sun b-bob relative grid size-full place-items-center rounded-full text-center">
{/* 안 보이는 쪽을 덮어 오늘 밤 달 모양으로 */}
{moon && (
<svg viewBox="-1 -1 2 2" className="pointer-events-none absolute inset-0 size-full" aria-hidden="true">
<path d={moonPath(moon.pct, 1, false)} fill={kind === 'sunset' ? 'rgb(96 40 86 / .55)' : 'rgb(34 30 86 / .62)'} transform={moon.waning ? 'scale(-1,1)' : undefined} />
</svg>
)}
<div className={cx('b-sun b-bob relative grid size-full place-items-center rounded-full text-center', moon && 'b-moon')}>
{/* 오늘 밤 실제 모양의 달 (빛 번짐까지 그려서 공보다 크게) */}
{moon && <MoonArt pct={moon.pct} waxing={!moon.waning} tone={kind === 'sunset' ? 'dusk' : 'night'} className="pointer-events-none absolute -top-1/4 -left-1/4 size-[150%] max-w-none" />}
{/* 점수 근거가 있으면 해를 눌러도 근거 창: 구석 버튼은 구름에 가려져서 상태 줄 끝으로 옮김 */}
{(() => {
const body = (
@@ -389,7 +386,8 @@ function Hero({ hero, post, today, ranked, all, feedLoad, todayLoad }: HeroProps
<b className="block font-bagel text-[52px] leading-[0.95] font-normal">{heroVal(feedLoad, score, 'w-[84px]')}</b>
</>
)
const cls = cx('relative', moon && '[text-shadow:0_0_6px_#fff,0_0_12px_#fff]')
// 가운데가 밝은 달이면 진한 글씨에 흰 번짐, 가운데가 어두운 달(초승·그믐)이면 흰 글씨
const cls = cx('relative', moon && (moon.pct >= 50 ? '[text-shadow:0_0_6px_#fff,0_0_12px_#fff]' : 'text-white [text-shadow:0_1px_8px_rgb(10_14_40/0.6)]'))
if (!why || score == null) return <span className={cls}>{body}</span>
return (
<button
@@ -470,16 +468,6 @@ function Hero({ hero, post, today, ranked, all, feedLoad, todayLoad }: HeroProps
const WANING = ['기우는 달', '하현달', '그믐달']
/**
* 반지름 r 인 달에서 밝은 쪽(lit) 또는 어두운 쪽 경로. 차오르는 달 기준(오른쪽이 밝음), 기우는 달은 좌우를 뒤집어 쓴다.
* 바깥 반원과 명암 경계(가로 반지름 r·|1-2k| 인 타원 호)로 이루어진다.
*/
function moonPath(pct: number, r: number, lit: boolean) {
const k = pct / 100
const edge = `A${r * Math.abs(1 - 2 * k)},${r} 0 0 ${k < 0.5 ? 0 : 1} 0,${-r}`
return `M0,${-r} A${r},${r} 0 0 ${lit ? 1 : 0} 0,${r} ${edge}`
}
function GakCard({ items, post, place, at }: { items: TopIndex[]; post?: PostReaction | null; place: string; at: string }) {
const { open } = useSheet()
const tplRef = useRef<HTMLDivElement>(null)
+5
View File
@@ -287,6 +287,11 @@
inset 16px 18px 28px rgb(255 255 255 / 0.6),
0 0 60px rgb(190 180 255 / 0.45);
}
/* 달 그림(MoonArt)이 빛까지 그리므로 공 바탕·그림자는 뺀다 */
.b-hero .b-sun.b-moon {
background: none;
box-shadow: none;
}
.b-cloud {
position: absolute;
+79
View File
@@ -0,0 +1,79 @@
import { useId } from 'react'
import { moonPath } from '@nalssigak/shared/lib/today'
// 앞면 바다(어두운 무늬) 자리: [x, y, 가로 반지름, 세로 반지름]. 실제 달 앞면 배치를 대강 따른다
const MARIA: [number, number, number, number][] = [
[-0.32, -0.36, 0.3, 0.26],
[0.12, -0.36, 0.17, 0.15],
[0.3, -0.06, 0.2, 0.17],
[-0.56, 0.06, 0.26, 0.42],
[0.66, -0.26, 0.1, 0.12],
[0.52, 0.22, 0.13, 0.15],
[-0.14, 0.44, 0.18, 0.13],
[-0.46, 0.5, 0.1, 0.09],
]
// 작은 크레이터: [x, y, 반지름]
const CRATERS: [number, number, number][] = [
[0.1, 0.72, 0.07],
[0.42, 0.52, 0.05],
[-0.66, -0.5, 0.05],
[0.62, 0.52, 0.04],
[-0.2, 0.08, 0.04],
]
// 저녁(노을)엔 노을빛이 도는 달, 밤엔 하얀 달
const TONES = {
night: { body: ['#fffcf2', '#f6ebcb', '#e0cc98'], shade: '#1a2050' },
dusk: { body: ['#fff8ee', '#ffe2cc', '#f2b9a2'], shade: '#4a2a63' },
}
/** 오늘 밤 실제 모양대로 그린 달. pct 는 빛나는 면의 비율 0~100, 기우는 달은 왼쪽이 밝다 */
export function MoonArt({ pct, waxing, tone = 'night', className }: { pct: number; waxing: boolean; tone?: keyof typeof TONES; className?: string }) {
const id = useId()
const t = TONES[tone]
const k = pct / 100
const full = pct >= 99
const hidden = pct <= 1
return (
<svg viewBox="-1.5 -1.5 3 3" className={className} aria-hidden="true">
<defs>
<radialGradient id={`${id}glow`}>
<stop offset="0.6" stopColor="#fff4cf" stopOpacity="0.55" />
<stop offset="0.8" stopColor="#ffe9a8" stopOpacity="0.16" />
<stop offset="1" stopColor="#ffe9a8" stopOpacity="0" />
</radialGradient>
<radialGradient id={`${id}body`} cx="0.4" cy="0.36" r="0.72">
<stop offset="0" stopColor={t.body[0]} />
<stop offset="0.6" stopColor={t.body[1]} />
<stop offset="1" stopColor={t.body[2]} />
</radialGradient>
<radialGradient id={`${id}limb`}>
<stop offset="0.72" stopColor="#8a6f3c" stopOpacity="0" />
<stop offset="1" stopColor="#8a6f3c" stopOpacity="0.28" />
</radialGradient>
<clipPath id={`${id}disc`}>
<circle r="1" />
</clipPath>
<filter id={`${id}soft`} x="-0.2" y="-0.2" width="1.4" height="1.4">
<feGaussianBlur stdDeviation="0.035" />
</filter>
</defs>
{!hidden && <circle r="1.5" fill={`url(#${id}glow)`} opacity={full ? 1 : 0.12 + 0.8 * k} />}
<g clipPath={`url(#${id}disc)`}>
<circle r="1" fill={`url(#${id}body)`} />
<g filter={`url(#${id}soft)`} fill="#c4b287" opacity="0.55">
{MARIA.map(([x, y, rx, ry]) => (
<ellipse key={`${x},${y}`} cx={x} cy={y} rx={rx} ry={ry} />
))}
</g>
{CRATERS.map(([x, y, r]) => (
<circle key={`${x},${y}`} cx={x} cy={y} r={r} fill="#efe2bd" stroke="#cdbb8c" strokeWidth="0.018" opacity="0.8" />
))}
<circle r="1" fill={`url(#${id}limb)`} />
{/* 안 보이는 쪽: 흐릿한 경계로 덮고, 땅빛(지구조) 정도만 비치게 */}
{!full && <path d={moonPath(pct, 1.04, false)} fill={t.shade} opacity="0.94" filter={`url(#${id}soft)`} transform={waxing ? undefined : 'scale(-1,1)'} />}
</g>
{hidden && <circle r="1" fill="none" stroke="#fff" strokeOpacity="0.18" strokeWidth="0.025" />}
</svg>
)
}
+12
View File
@@ -2896,6 +2896,18 @@ export type RowsSlide = {
* Image Credit
*/
image_credit?: string | null;
/**
* Moon Pct
*
* 달 포스트만: 빛나는 면의 비율 0~100 (아이콘 대신 이 모양으로 달을 그린다)
*/
moon_pct?: number | null;
/**
* Moon Waxing
*
* 달 포스트만: 차오르는 달이면 true (오른쪽이 밝음)
*/
moon_waxing?: boolean | null;
};
/**