diff --git a/backend/router/v1/feed/protocol.py b/backend/router/v1/feed/protocol.py index f943e34..92e3b7d 100644 --- a/backend/router/v1/feed/protocol.py +++ b/backend/router/v1/feed/protocol.py @@ -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): diff --git a/backend/services/feed_service.py b/backend/services/feed_service.py index 085c653..3de6aca 100644 --- a/backend/services/feed_service.py +++ b/backend/services/feed_service.py @@ -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: diff --git a/backend/tests/test_moon.py b/backend/tests/test_moon.py index 7f3a4c7..30dcb6d 100644 --- a/backend/tests/test_moon.py +++ b/backend/tests/test_moon.py @@ -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) diff --git a/frontend/src/b/Post.tsx b/frontend/src/b/Post.tsx index a182f3e..8741505 100644 --- a/frontend/src/b/Post.tsx +++ b/frontend/src/b/Post.tsx @@ -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 = { @@ -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 ( + <> + + + + + + ) +} + 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 ) return ( -
+
{slide.eyebrow} - + {slide.moon_pct != null ? : }
) diff --git a/frontend/src/b/TodayPage.tsx b/frontend/src/b/TodayPage.tsx index 83a3276..ee61ca2 100644 --- a/frontend/src/b/TodayPage.tsx +++ b/frontend/src/b/TodayPage.tsx @@ -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 ))}
-
- {/* 안 보이는 쪽을 덮어 오늘 밤 달 모양으로 */} - {moon && ( - - )} +
+ {/* 오늘 밤 실제 모양의 달 (빛 번짐까지 그려서 공보다 크게) */} + {moon && } {/* 점수 근거가 있으면 해를 눌러도 근거 창: 구석 버튼은 구름에 가려져서 상태 줄 끝으로 옮김 */} {(() => { const body = ( @@ -389,7 +386,8 @@ function Hero({ hero, post, today, ranked, all, feedLoad, todayLoad }: HeroProps {heroVal(feedLoad, score, 'w-[84px]')} ) - 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 {body} return (