Compare commits
20
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a249c509d | ||
|
|
55edc037fb | ||
|
|
a17cef201d | ||
|
|
0414160520 | ||
|
|
0bc8ca02a4 | ||
|
|
1557ba42c4 | ||
|
|
9af3407546 | ||
|
|
117de90c3e | ||
|
|
be60551f49 | ||
|
|
dcf2fe5a53 | ||
|
|
132301dc28 | ||
|
|
dd133c9d52 | ||
|
|
5459b97ba0 | ||
|
|
1908433e46 | ||
|
|
7dcd6c6a4c | ||
|
|
7d84226105 | ||
|
|
c45940c358 | ||
|
|
09e8b4734a | ||
|
|
a87f245547 | ||
|
|
197fafdc02 |
No files matched your search
@@ -62,6 +62,7 @@
|
||||
| [ ] | 오늘 화면 쇼츠 줄 — YouTube Data API 키(`YOUTUBE_API_KEY`) 발급해 운영 .env 에 넣기. 없으면 `youtube_shorts`(영상 ID 3개 고정)만 나와 새 쇼츠가 자동으로 안 붙음 (https://console.cloud.google.com/apis/library/youtube.googleapis.com) | 채널 RSS가 404라 키 없이 채널 목록을 못 받음 | `backend/config/settings.py`, `backend/services/shorts_service.py` |
|
||||
| [ ] | **[결정 필요]** 쇼츠 문구 검토: '소리 켜기'/'소리 끄기' (줄 제목은 없앰) | 화면 문구 규칙 | `frontend/src/b/Shorts.tsx` |
|
||||
| [ ] | 쇼츠를 올린 직후 목록 갱신(`ShortsService.refresh`) 부르기 — 지금은 워커가 07·12·18시 10분에만 받아 18시 넘어 올리면 다음 날 아침에 뜸. 자동 업로드면 끝난 뒤 호출, 손으로 올리면 관리자 갱신 API | 올리는 방식 확인 필요 | `backend/services/shorts_service.py`, `backend/worker_main.py` |
|
||||
| [ ] | 쇼츠 API 실패·빈 목록일 때 공유 링크로 들어오면 남색 빈 화면만 보임 — 그 영상 ID 하나라도 띄우거나 × 버튼·안내 문구 보이기 | 10/27 QA 실패 (`items` 가 비면 빈 div 만 그림) | `frontend/src/b/Shorts.tsx` |
|
||||
| [ ] | 쇼츠 자동재생 아이폰 사파리 실기기 확인 — 소리 꺼도 자동재생을 막는다는 보고 있음 | 헤드리스 크롬에서만 확인 | `frontend/src/b/Shorts.tsx` |
|
||||
| [x] | 단풍 명소 `남이섬`이 두 번 들어감(절정 10-25·10-27) — 10-27(화목원) 쪽 지움, 67곳 | 10/27 전체 점검 | `frontend/seo/foliage_2026.json` |
|
||||
| [x] | 날짜 따라 깨지던 테스트 2개 — 노을 칸은 그날 해 지는 시각으로, 방위각은 한 해 범위(240~300°)로 확인 | 10/27 전체 점검 | `backend/tests/test_weather_today.py`, `backend/tests/test_sky_api.py` |
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import APIRouter, Depends, Path, Query, Request
|
||||
from fastapi import APIRouter, Depends, Path, Query
|
||||
|
||||
from common.auth import optional_user
|
||||
from common.database.model.models import User
|
||||
from common.enums import ErrorType, PostType
|
||||
from common.enums import ErrorType
|
||||
from common.liker import Liker, liker
|
||||
from common.models.errors import error_info
|
||||
from router.v1.feed.protocol import Res_Feed, Res_Post
|
||||
@@ -13,26 +13,15 @@ from services.reaction_service import ReactionService
|
||||
|
||||
router = APIRouter(prefix="/v1/feed", tags=["feed"])
|
||||
|
||||
# 토스에 올라간 10/13 번들은 UV 까지만 알아서, 그 뒤에 생긴 글 종류(카드뉴스 등)가 오면 흰 화면이 된다
|
||||
TOSS_KNOWN_MAX = PostType.UV.value
|
||||
|
||||
|
||||
def _from_toss(request: Request) -> bool:
|
||||
ref = request.headers.get("origin") or request.headers.get("referer") or ""
|
||||
return "AppsInToss" in request.headers.get("user-agent", "") or ".tossmini.com" in ref
|
||||
|
||||
|
||||
@router.get("", response_model=Res_Feed, response_model_exclude_none=True, summary="메인 피드: 하늘 영역, 오늘의 각, 오늘 포스트 전부, 띠")
|
||||
async def get_feed(
|
||||
request: Request,
|
||||
region: str = Query(..., description="구 행정코드"), user: Optional[User] = Depends(optional_user), who: Liker = Depends(liker),
|
||||
service: FeedService = Depends(), reactions: ReactionService = Depends(),
|
||||
) -> Res_Feed:
|
||||
err, feed = await service.feed(region)
|
||||
if err is not ErrorType.SUCCESS:
|
||||
return Res_Feed(result=error_info(err))
|
||||
if _from_toss(request):
|
||||
feed = feed.model_copy(update={"posts": [p for p in feed.posts if p.post_type.value <= TOSS_KNOWN_MAX]})
|
||||
pinned = [x for x in (feed.hero_post, feed.gak_post, feed.foliage_post, feed.events_post, feed.season_post) if x is not None]
|
||||
ids = [p.post_id for p in feed.posts] + [x.post_id for x in pinned]
|
||||
counts = await reactions.counts(ids)
|
||||
|
||||
@@ -5,6 +5,7 @@ from pydantic import Field
|
||||
|
||||
from common.enums import PostType, SkySituation, SlotTone
|
||||
from common.models.gmodel import Res_WebPacketProtocol, WebPacketProtocol
|
||||
from router.v1.index.protocol import TrendPoint
|
||||
|
||||
|
||||
class Row(WebPacketProtocol):
|
||||
@@ -51,8 +52,8 @@ class GakSlide(WebPacketProtocol):
|
||||
score: int
|
||||
line: str
|
||||
summary: str
|
||||
rows: list[Row] = Field(default=[], description="점수 근거: 비중 큰 날씨 조건부터 네 개와 지금 값 (기온 · 체감 18°)")
|
||||
say: Optional[str] = Field(default=None, description="점수 구간 설명 문장 (seed sentences)")
|
||||
trend: list[TrendPoint] = Field(default=[], description="오늘 · 내일 · 이번 주말 점수 (각 상세 날짜 칸과 같은 값)")
|
||||
|
||||
|
||||
class Cut(WebPacketProtocol):
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import asyncio
|
||||
import random
|
||||
import re
|
||||
from dataclasses import dataclass, field
|
||||
from datetime import date, datetime, time, timedelta
|
||||
from typing import Optional
|
||||
@@ -25,6 +24,7 @@ from router.v1.feed.protocol import (
|
||||
BandArticle, BandEvent, Bands, Cut, GakSlide, Hero, HeroStat, HeroTomorrow, HourCell, HoursSlide, ImageSlide, PostData, PostReaction, Res_Feed, Row, RowsSlide, SunsetSlide,
|
||||
PlanSlide, PlanStep, TopIndex, WeatherWhy, WeekDay, WeekGak, WeekSlide,
|
||||
)
|
||||
from router.v1.index.protocol import TrendPoint
|
||||
from services.air_service import GRADE_LABEL as AIR_GRADE_LABEL
|
||||
from services.air_service import pm10_grade, pm25_grade
|
||||
from services.bot_comment import fill_bot_comments
|
||||
@@ -34,7 +34,7 @@ from services.calc.moon import MoonNight, nearest, night, view_line
|
||||
from services.calc.sky_score import GRADE_LABEL, sky_title
|
||||
from services.calc.sun import sun_times
|
||||
from services.hero_stats import UV_HIGH, HeroInput, discomfort_label, hero_stats, hero_status, uv_label, uv_level
|
||||
from services.index_service import IndexBoard, IndexItem, IndexService
|
||||
from services.index_service import IndexBoard, IndexItem, IndexService, slot_label
|
||||
from services.now_service import NowService, NowWeather
|
||||
from services.season_service import SeasonService
|
||||
from services.sky_service import SkyService, SkyView, day_verdict
|
||||
@@ -425,7 +425,7 @@ class FeedService:
|
||||
cards.append(data)
|
||||
gak_posts = sorted((p for p in posts or [] if PostType(p.post_type) is PostType.GAK), key=lambda p: p.index_rank or 0)
|
||||
for p, item in zip(gak_posts, gak):
|
||||
cards.append(self._gak(p, item))
|
||||
cards.append(self._gak(p, item, board.day))
|
||||
has_warning = bool(now_w and now_w.warnings)
|
||||
# 오늘 이야기 줄엔 제철인 각만 (철 지난 각은 각 탭 목록 끝에만)
|
||||
items = [i for i in board.items if i.in_season] if board else []
|
||||
@@ -504,10 +504,11 @@ class FeedService:
|
||||
return dict(post_id=p.post_id, post_type=PostType(p.post_type), like_count=p.like_count, comment_count=p.comment_count,
|
||||
published_at=p.published_at.astimezone(KST))
|
||||
|
||||
def _gak(self, p: Post, i: IndexItem) -> PostData:
|
||||
def _gak(self, p: Post, i: IndexItem, today: date) -> PostData:
|
||||
d = i.definition
|
||||
return PostData(**self._base(p), title=f"{d.name} {i.score.score}점", icon=d.icon, caption=_gak_caption(i),
|
||||
slides=[GakSlide(kind="gak", index_id=d.index_id, code=d.code, name=d.name, rank=i.rank, score=i.score.score, line=d.description, summary=i.score.summary, rows=gak_rows(i), say=_band_sentence(d.sentences, i.score.score))],
|
||||
slides=[GakSlide(kind="gak", index_id=d.index_id, code=d.code, name=d.name, rank=i.rank, score=i.score.score, line=d.description, summary=i.score.summary, say=_band_sentence(d.sentences, i.score.score),
|
||||
trend=[TrendPoint(day=t.score_date, label=slot_label(t.score_date, today), score=t.score, estimated=t.estimated) for t in i.trend])],
|
||||
share_messages=[f"오늘 {d.name} 어때? {d.name} {i.score.score}점이래"])
|
||||
|
||||
def _render(self, p: Post, c: "_Ctx") -> Optional[PostData]:
|
||||
@@ -779,30 +780,6 @@ def _band_sentence(sentences: Optional[dict], score: int) -> Optional[str]:
|
||||
return sentences[str(lo)] if lo is not None else None
|
||||
|
||||
|
||||
# 각 포스트에 보일 근거 줄 이름. 시간(요일·노을 점수)은 계산 방식 설명이라 뺀다
|
||||
_AXIS_NAME = {"temp": "기온", "rain": "비", "wind": "바람", "humidity": "습도", "air": "미세먼지", "uv": "자외선", "sun": "햇볕", "view": "시야"}
|
||||
_NOTE_HEAD = {"wind": "바람 ", "humidity": "습도 ", "air": "초미세먼지 "}
|
||||
|
||||
|
||||
def gak_rows(i: IndexItem, n: int = 4) -> list[Row]:
|
||||
"""비중이 큰 조건부터 n개와 지금 값. 점수에 안 쓰는 조건도 n개가 될 때까지 지금 날씨로 채운다. 값은 계산 근거 문구의 첫 마디 (체감 18°, 확률 20%, 초속 3m)."""
|
||||
d, notes = i.definition, i.score.notes or {}
|
||||
weighted = sorted((a for a in _AXIS_NAME if getattr(d, f"weight_{a}", 0) and notes.get(a)), key=lambda a: -getattr(d, f"weight_{a}"))
|
||||
axes = weighted + [a for a in ("temp", "rain", "wind", "air", "humidity") if a not in weighted and notes.get(a)]
|
||||
rows = []
|
||||
for a in axes[:n]:
|
||||
head, _, tail = notes[a].partition(", ")
|
||||
prob = re.search(r"확률 \d+%", notes[a]) if a == "rain" else None
|
||||
if prob:
|
||||
value = prob.group(0)
|
||||
elif a == "air" and tail:
|
||||
value = tail
|
||||
else:
|
||||
value = head.removeprefix(_NOTE_HEAD.get(a, ""))
|
||||
rows.append(Row(label=_AXIS_NAME[a], value=value))
|
||||
return rows
|
||||
|
||||
|
||||
def _gak_caption(i: IndexItem) -> str:
|
||||
"""슬라이드에 없는 내일 점수(없으면 하기 좋은 시간). 점수 구간 설명 문장은 슬라이드에 있다."""
|
||||
nxt = next((x for x in i.trend if x.score_date > i.score.score_date), None)
|
||||
|
||||
@@ -416,18 +416,3 @@ def test_uv_post_only_when_moderate_or_higher():
|
||||
assert FeedService._uv_post(None, base, ctx([(9, 1.0), (12, 2.5)])) is None
|
||||
assert FeedService._uv_post(None, base, ctx([])) is None
|
||||
|
||||
|
||||
def test_gak_rows_shows_heaviest_conditions_with_short_values():
|
||||
from types import SimpleNamespace
|
||||
|
||||
from services.feed_service import gak_rows
|
||||
|
||||
d = SimpleNamespace(weight_temp=30, weight_rain=25, weight_wind=10, weight_humidity=0, weight_air=15, weight_uv=0, weight_sun=0, weight_view=0, weight_time=20)
|
||||
notes = {"temp": "체감 18°, 편한 범위 15~25° 안", "rain": "비 확률 20%", "wind": "바람 초속 3.1m", "air": "초미세먼지 16㎍/㎥, 좋음", "time": "수요일"}
|
||||
item = SimpleNamespace(definition=d, score=SimpleNamespace(notes=notes))
|
||||
assert [(r.label, r.value) for r in gak_rows(item, 3)] == [("기온", "체감 18°"), ("비", "확률 20%"), ("미세먼지", "좋음")]
|
||||
# 점수에 안 쓰는 조건은 뒤에 지금 날씨로 채운다
|
||||
d.weight_wind = 0
|
||||
assert [r.label for r in gak_rows(item)] == ["기온", "비", "미세먼지", "바람"]
|
||||
item.score.notes = {**notes, "rain": "비 소식, 내일까지 비 확률 70%"}
|
||||
assert gak_rows(item)[1].value == "확률 70%"
|
||||
@@ -1,18 +0,0 @@
|
||||
from starlette.requests import Request
|
||||
|
||||
from common.enums import PostType
|
||||
from router.v1.feed.feed import TOSS_KNOWN_MAX, _from_toss
|
||||
|
||||
|
||||
def _req(headers: dict) -> Request:
|
||||
return Request({"type": "http", "headers": [(k.lower().encode(), v.encode()) for k, v in headers.items()]})
|
||||
|
||||
|
||||
def test_from_toss_by_referer_or_user_agent():
|
||||
assert _from_toss(_req({"referer": "https://nalssigak.apps.tossmini.com/"}))
|
||||
assert _from_toss(_req({"user-agent": "Mozilla/5.0 ... AppsInToss TossApp/5.282.1"}))
|
||||
assert not _from_toss(_req({"referer": "https://weather.o2o.kr/", "user-agent": "Mozilla/5.0 Safari"}))
|
||||
|
||||
|
||||
def test_card_is_hidden_from_old_toss_bundle():
|
||||
assert PostType.CARD.value > TOSS_KNOWN_MAX >= PostType.UV.value
|
||||
@@ -152,3 +152,29 @@
|
||||
- [ ] 작은 버튼이 잘 눌리는지: 포스트 하트·댓글·보내기, 댓글 하트, 시트 ×
|
||||
- [ ] 댓글 입력칸을 누르면 키보드 위로 입력칸·게시 버튼이 보인다 (확인)
|
||||
- [ ] 로그인 시트 비밀번호 칸·버튼, 지역 검색 목록이 키보드에 가려지지 않는다 (확인)
|
||||
|
||||
## 17. 오늘 탭: 쇼츠 줄·쇼츠 페이지
|
||||
|
||||
10/27 헤드리스 크롬(iPhone 13·SE·데스크톱 1280)으로 자동 점검한 결과. `[x]` 통과, `[ ]` 실패·미확인.
|
||||
|
||||
- [x] 히어로 바로 아래 세로 카드 줄(3개), 제목 줄 없음
|
||||
- [x] 줄이 화면에 보이면 첫 카드만 소리 없이 재생, 화면 밖으로 나가면 플레이어를 내림
|
||||
- [x] 카드 누름 → `/shorts/영상ID`, 영상이 헤더·버튼 줄과 하단 탭 사이에 9:16으로 맞고, 앞뒤 영상까지 3개만 띄움
|
||||
- [x] 쇼츠 페이지에선 뒤 페이지가 스크롤되지 않고, 닫으면 다시 스크롤됨
|
||||
- [x] '소리 켜기' 누름 → '소리 끄기'로 바뀜
|
||||
- [x] 위아래로 넘기면 주소가 그 영상으로 바뀜(뒤로 가기 기록은 안 쌓임 → 뒤로 가기 한 번에 오늘 화면)
|
||||
- [x] 영상 탭 → 일시정지, 다시 탭 → 재생 (모바일·마우스 둘 다)
|
||||
- [x] × · Esc · 하단 탭 누름 → 쇼츠 페이지를 닫고 이동
|
||||
- [x] 공유 링크로 바로 들어오면 그 영상부터, 닫으면 오늘 화면으로(뒤로 가기에 남지 않음)
|
||||
- [x] 목록에 없는 영상 ID 링크 → 그 영상을 맨 앞에 붙여 보임 / `/shorts`(ID 없음) → 첫 영상부터 / 새로고침해도 그대로
|
||||
- [x] 마우스로 20px 끌면 제자리, 30px 넘게 끌면 다음·이전, 첫 영상에서 아래로 끌면 그대로
|
||||
- [x] 마우스 휠·키보드 ↓로도 넘어감
|
||||
- [x] 쇼츠 API 실패·빈 목록 → 오늘 화면에서 줄이 통째로 숨음
|
||||
- [ ] **실패** 쇼츠 API 실패·빈 목록일 때 공유 링크(`/shorts/영상ID`)로 들어오면 남색 빈 화면만 계속 보임. 영상·× 버튼·안내 문구 없음(하단 탭으로만 나갈 수 있음)
|
||||
- [ ] 미확인: 밤 테마에서 쇼츠 카드 그림·영상이 남색 판에 가려지지 않는지 (자동 캡처가 다른 곳을 찍음, 눈으로 확인 필요)
|
||||
- [ ] 미확인: 아이폰 사파리 실기기 자동재생, 손가락으로 위아래 넘길 때 한 장씩 딱 멈추는지 (헤드리스는 터치 스크롤 재현 불가)
|
||||
|
||||
## 18. 각 포스트 카드
|
||||
|
||||
- [x] 아이폰 13·SE에서 점수·각 이름·'계산 근거 보기' 버튼이 카드 밖으로 잘리지 않는다 (10/27 근거 표·요약 줄 뺀 뒤, SE는 점수 글씨를 작게)
|
||||
- [x] 카드마다 같은 내용이 반복되지 않는다: 기온·비·바람·미세먼지 표와 '오전 10시 13°, 바람 조금' 줄 없음, 말풍선 문장은 각마다 다름
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useCallback, useEffect, useMemo, useState, type ReactNode } from 'react'
|
||||
import { NavLink, Outlet, useLocation, useNavigationType } from 'react-router'
|
||||
import { useIsFetching, useQuery } from '@tanstack/react-query'
|
||||
import { getSeasonWeekOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
|
||||
import { useIsFetching, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { authConfigOptions, getSeasonWeekOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
|
||||
import { IS_TOSS } from '../lib/platform'
|
||||
import { cx } from '../lib/utils'
|
||||
import { kindOfHour, kst, seasonOf, type TimeKind } from '@nalssigak/shared/lib'
|
||||
@@ -9,6 +9,7 @@ import './b.css'
|
||||
import { AuthProvider } from './auth'
|
||||
import { RegionProvider } from './region'
|
||||
import { useAuth } from './authContext'
|
||||
import { preloadGoogle } from './googleScript'
|
||||
import { useRegion } from './regionContext'
|
||||
import { useSheet } from './sheetContext'
|
||||
import { SheetProvider } from './Sheets'
|
||||
@@ -47,7 +48,16 @@ function TopBar() {
|
||||
const { region, locateStatus } = useRegion()
|
||||
const { open } = useSheet()
|
||||
const { me, mePending } = useAuth()
|
||||
const queryClient = useQueryClient()
|
||||
const tab = TABS.find((t) => t.to !== '/' && pathname.startsWith(t.to))
|
||||
const loggedOut = !IS_TOSS && !mePending && !me
|
||||
|
||||
// 로그인 창을 처음 열 때 버벅이지 않게 구글 로그인 준비물을 미리 받아 둔다
|
||||
useEffect(() => {
|
||||
if (!loggedOut) return
|
||||
void queryClient.prefetchQuery({ ...authConfigOptions(), staleTime: Infinity })
|
||||
return preloadGoogle()
|
||||
}, [loggedOut, queryClient])
|
||||
|
||||
return (
|
||||
<header className="sticky top-0 z-20 flex h-[calc(54px+env(safe-area-inset-top,0px))] items-center justify-between gap-2 px-4 pt-[env(safe-area-inset-top,0px)]">
|
||||
|
||||
+26
-16
@@ -53,7 +53,8 @@ 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 || post.post_type === PostType.MOON) return 'night'
|
||||
if (post.post_type === PostType.MOON) return 'night'
|
||||
if (post.post_type === PostType.EVENT) return slide.image ? 'night' : 'peach'
|
||||
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'
|
||||
@@ -63,18 +64,16 @@ function slideBg(post: PostData, slide: Slide): SlideBg {
|
||||
const DARK = new Set<SlideBg>(['dusk', 'night'])
|
||||
|
||||
// 그림 배경이 있는 각(code)과 장 수. 여러 장이면 글마다 돌려 쓴다
|
||||
const BG_IMAGES: Record<string, number> = { bike: 4, picnic: 1, hiking: 1, camping: 1, stars: 1, walk: 1, hangang: 1 }
|
||||
const EVENT_BG_N = 4
|
||||
const BG_IMAGES: Record<string, number> = { bike: 4, picnic: 1, hiking: 1, hangang: 1 }
|
||||
|
||||
function bgImage(name: string, n: number, seed: number): CSSProperties {
|
||||
const file = n > 1 ? `${name}-${'abcd'[seed % n]}` : name
|
||||
return { backgroundImage: `url(/post-bg/${file}.webp)`, backgroundSize: 'cover', backgroundPosition: 'center' }
|
||||
}
|
||||
|
||||
/** 그림 배경: 각은 각마다, 사진 없는 행사는 행사용. 없으면 색 배경만 */
|
||||
/** 그림 배경: 각은 각마다. 없으면 색 배경만 */
|
||||
function slideImage(post: PostData, slide: Slide): CSSProperties | undefined {
|
||||
if (slide.kind === 'gak') return BG_IMAGES[slide.code] ? bgImage(slide.code, BG_IMAGES[slide.code], post.post_id) : undefined
|
||||
if (post.post_type === PostType.EVENT && slide.kind === 'rows' && !slide.image) return bgImage('event', EVENT_BG_N, post.post_id)
|
||||
return undefined
|
||||
}
|
||||
|
||||
@@ -164,17 +163,28 @@ function SlideView({ slide, bg, img }: { slide: Slide; bg: SlideBg; img?: CSSPro
|
||||
<div className={cx(slideBase, `b-bg-${bg}`)} style={img}>
|
||||
<Eyebrow>오늘의 각 · {slide.rank}위</Eyebrow>
|
||||
<Big>{slide.line}</Big>
|
||||
<Pic name={slide.code} />
|
||||
<Pic name={slide.code} className="[@media(max-height:700px)]:top-[26%] [@media(max-height:700px)]:w-[34%]" />
|
||||
{slide.say && <p className="relative z-[1] m-0 mt-2.5 w-[56%] rounded-[16px] rounded-tl-[4px] bg-white/80 px-3 py-2 text-[14px] leading-snug font-bold">{slide.say}</p>}
|
||||
{/* 점수 근거: 비중 큰 조건과 지금 값. 오른쪽 아이콘과 겹치지 않게 왼쪽 반만 */}
|
||||
{!!slide.rows?.length && (
|
||||
<div className="relative z-[1] mt-2 w-[56%] rounded-[16px] bg-white/70 px-3 text-[14px] [&_b]:text-[15px] [&>div>div]:py-1.5 [&>div]:mt-0">
|
||||
<Rows rows={slide.rows} />
|
||||
{/* 오른쪽 아래 빈 곳에 오늘·내일·주말 점수 (각 상세 날짜 칸과 같은 값) */}
|
||||
<div className="relative z-[1] mt-auto flex items-end justify-between gap-3">
|
||||
<div>
|
||||
<b className="block font-bagel text-[82px] leading-[0.9] font-normal text-(--orange) [@media(max-height:700px)]:text-[64px]">{slide.score}</b>
|
||||
<p className="m-0 font-jua text-[29px] leading-tight">{slide.name}</p>
|
||||
</div>
|
||||
)}
|
||||
<b className="mt-auto font-bagel text-[82px] leading-[0.9] font-normal text-(--orange)">{slide.score}</b>
|
||||
<p className="m-0 font-jua text-[29px] leading-tight">{slide.name}</p>
|
||||
<Eyebrow className="mt-1">{slide.summary}</Eyebrow>
|
||||
{!!slide.trend?.length && (
|
||||
<div className="grid w-[46%] grid-cols-2 gap-1.5">
|
||||
{slide.trend.map((t) => (
|
||||
<div key={t.day} className="rounded-xl bg-white/80 px-1 py-1.5 text-center">
|
||||
<small className="block text-[11px] font-extrabold whitespace-nowrap text-(--ink2)">
|
||||
{t.label}
|
||||
{t.estimated && ' 예상'}
|
||||
</small>
|
||||
<b className="block font-bagel text-lg leading-tight font-normal text-(--orange)">{t.score}</b>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<button type="button" onClick={() => open({ type: 'gak', indexId: slide.index_id })} className="mt-3 cursor-pointer self-start rounded-full bg-(--orange) px-4 py-[9px] font-jua text-[15px] text-white shadow-[inset_0_-5px_0_var(--orange-deep)]">
|
||||
계산 근거 보기
|
||||
</button>
|
||||
@@ -438,7 +448,7 @@ function FullCard({ post }: PostProps) {
|
||||
<small className="text-xs font-semibold text-(--ink2)">{account}</small>
|
||||
</span>
|
||||
</div>
|
||||
<div className="relative aspect-[4/5] overflow-hidden" onClick={onTap}>
|
||||
<div className="b-day relative aspect-[4/5] overflow-hidden" onClick={onTap}>
|
||||
{n > 1 && (
|
||||
<span data-noshot className="absolute top-3 right-3 z-[2] rounded-full bg-[rgb(30_36_56/0.55)] px-[9px] py-[3px] text-xs font-extrabold text-white" aria-hidden="true">
|
||||
{index + 1}/{n}
|
||||
@@ -548,7 +558,7 @@ export function PostFrame({ title, account, avatar, caption, more, shot, pinned,
|
||||
<small className="text-xs font-semibold text-(--ink2)">{account}</small>
|
||||
</span>
|
||||
</div>
|
||||
<div ref={bodyRef}>{children}</div>
|
||||
<div ref={bodyRef} className="b-day">{children}</div>
|
||||
<div className="flex items-center gap-3.5 px-3 pt-2.5 pb-1 [&_svg]:size-[26px] [&_svg]:stroke-[1.9]">
|
||||
{postId != null && (
|
||||
<>
|
||||
|
||||
+42
-21
@@ -34,7 +34,7 @@ import { ago, articleMeta, AVATAR_COLORS, cardBg, CHARACTERS, dateRange, loadOf,
|
||||
import { GoogleButton } from './googleLogin'
|
||||
import { useInstall, useInstallable } from './install'
|
||||
import { InstallSheet } from './installBanner'
|
||||
import { ARTICLE_CAT } from './lib'
|
||||
import { ARTICLE_CAT, SHEET_CLOSE_MS, SHEET_OPEN_MS } from './lib'
|
||||
import { MixSheet } from './myGak'
|
||||
import { ownPage, useRegion } from './regionContext'
|
||||
import { WeatherWhySheet } from './weatherWhy'
|
||||
@@ -95,11 +95,25 @@ function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void
|
||||
const [gakTitle, setGakTitle] = useState('')
|
||||
const [articleTitle, setArticleTitle] = useState('')
|
||||
|
||||
// 닫히는 동안에도 내려가는 창에 내용이 남아 있게, 마지막으로 연 창을 들고 있는다
|
||||
const [shown, setShown] = useState<SheetState>(state)
|
||||
if (state && state !== shown) setShown(state)
|
||||
const closing = !state && shown != null
|
||||
|
||||
useEffect(() => {
|
||||
const el = ref.current
|
||||
if (!el) return
|
||||
if (state && !el.open) el.showModal()
|
||||
if (!state && el.open) el.close()
|
||||
if (state) {
|
||||
if (!el.open) el.showModal()
|
||||
return
|
||||
}
|
||||
if (!el.open) return
|
||||
// 내려가는 애니메이션이 끝난 뒤에 실제로 닫는다
|
||||
const t = setTimeout(() => {
|
||||
el.close()
|
||||
setShown(null)
|
||||
}, SHEET_CLOSE_MS)
|
||||
return () => clearTimeout(t)
|
||||
}, [state])
|
||||
|
||||
// 창이 열려 있는 동안 뒤 페이지는 스크롤되지 않게 잠근다
|
||||
@@ -109,15 +123,17 @@ function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void
|
||||
const root = document.documentElement
|
||||
const before = root.style.overflow
|
||||
root.style.overflow = 'hidden'
|
||||
root.classList.add('b-sheet-open')
|
||||
// 뒤 화면 움직임 멈추기는 페이지 전체 스타일을 다시 계산하게 해서, 창이 다 올라온 뒤에 한다
|
||||
const pause = setTimeout(() => root.classList.add('b-sheet-open'), SHEET_OPEN_MS)
|
||||
return () => {
|
||||
clearTimeout(pause)
|
||||
root.style.overflow = before
|
||||
root.classList.remove('b-sheet-open')
|
||||
}
|
||||
}, [isOpen])
|
||||
|
||||
const then = state?.type === 'login' ? state.then : undefined
|
||||
const title = !state ? '' : state.type === 'gak' ? gakTitle : state.type === 'article' ? articleTitle || TITLES.article : state.type === 'mix' ? (state.shared ? '받은 각' : '내 각 만들기') : TITLES[state.type]
|
||||
const then = shown?.type === 'login' ? shown.then : undefined
|
||||
const title = !shown ? '' : shown.type === 'gak' ? gakTitle : shown.type === 'article' ? articleTitle || TITLES.article : shown.type === 'mix' ? (shown.shared ? '받은 각' : '내 각 만들기') : TITLES[shown.type]
|
||||
|
||||
return (
|
||||
<dialog
|
||||
@@ -125,12 +141,17 @@ function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void
|
||||
aria-label={title}
|
||||
data-t={kind}
|
||||
onClose={onClose}
|
||||
// ESC 도 바로 닫지 않고 내려가며 닫히게
|
||||
onCancel={(e) => {
|
||||
e.preventDefault()
|
||||
onClose()
|
||||
}}
|
||||
onClick={(e) => {
|
||||
if (e.target === e.currentTarget) onClose()
|
||||
}}
|
||||
className="b-sheet-dialog b-app fixed inset-x-0 top-auto bottom-0 m-0 mx-auto max-h-[86dvh] w-full max-w-[440px] overflow-visible bg-transparent p-0 text-(--ink)"
|
||||
className={cx('b-sheet-dialog b-app fixed inset-x-0 top-auto bottom-0 m-0 mx-auto max-h-[86dvh] w-full max-w-[440px] overflow-visible bg-transparent p-0 text-(--ink)', closing && 'b-sheet-closing')}
|
||||
>
|
||||
{state && (
|
||||
{shown && (
|
||||
<div className="b-sheet flex max-h-[86dvh] flex-col rounded-t-[22px] bg-white pb-[env(safe-area-inset-bottom,0px)]">
|
||||
<div className="relative border-b border-(--line) px-4 pt-2 pb-2.5 text-center">
|
||||
<div className="mx-auto mb-2.5 h-1 w-10 rounded-full bg-(--line)" aria-hidden="true" />
|
||||
@@ -139,21 +160,21 @@ function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void
|
||||
×
|
||||
</button>
|
||||
</div>
|
||||
{state.type === 'gak' && <GakSheet indexId={state.indexId} onTitle={setGakTitle} />}
|
||||
{state.type === 'article' && <ArticleSheet articleId={state.articleId} onTitle={setArticleTitle} />}
|
||||
{state.type === 'seasonWeek' && <SeasonWeekSheet />}
|
||||
{state.type === 'share' && <ShareSheet share={state.share} />}
|
||||
{state.type === 'comments' && <CommentsSheet postId={state.postId} draft={state.draft} />}
|
||||
{state.type === 'login' && <LoginSheet onDone={onClose} onLoggedIn={then ? () => open(then) : onClose} />}
|
||||
{state.type === 'me' && <MeSheet onDone={onClose} />}
|
||||
{state.type === 'region' && <RegionSheet onDone={onClose} />}
|
||||
{state.type === 'mix' && <MixSheet shared={state.shared} onDone={onClose} />}
|
||||
{state.type === 'install' && <InstallSheet />}
|
||||
{state.type === 'weatherWhy' && <WeatherWhySheet d={state.why} />}
|
||||
{state.type === 'talk' && <TalkSheet talk={state.talk} />}
|
||||
{shown.type === 'gak' && <GakSheet indexId={shown.indexId} onTitle={setGakTitle} />}
|
||||
{shown.type === 'article' && <ArticleSheet articleId={shown.articleId} onTitle={setArticleTitle} />}
|
||||
{shown.type === 'seasonWeek' && <SeasonWeekSheet />}
|
||||
{shown.type === 'share' && <ShareSheet share={shown.share} />}
|
||||
{shown.type === 'comments' && <CommentsSheet postId={shown.postId} draft={shown.draft} />}
|
||||
{shown.type === 'login' && <LoginSheet onDone={onClose} onLoggedIn={then ? () => open(then) : onClose} />}
|
||||
{shown.type === 'me' && <MeSheet onDone={onClose} />}
|
||||
{shown.type === 'region' && <RegionSheet onDone={onClose} />}
|
||||
{shown.type === 'mix' && <MixSheet shared={shown.shared} onDone={onClose} />}
|
||||
{shown.type === 'install' && <InstallSheet />}
|
||||
{shown.type === 'weatherWhy' && <WeatherWhySheet d={shown.why} />}
|
||||
{shown.type === 'talk' && <TalkSheet talk={shown.talk} />}
|
||||
</div>
|
||||
)}
|
||||
{!state && <RegionLinks />}
|
||||
{!shown && <RegionLinks />}
|
||||
</dialog>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -159,8 +159,8 @@ const WEATHER_ICON: Record<Weather, string> = {
|
||||
sleet: 'snow',
|
||||
}
|
||||
// 구름 수: 구름 많음 둘, 흐림·비·눈 셋
|
||||
// 히어로 오른쪽 위 좋아요·댓글·보내기: 셋 다 같은 32px 칸에 아이콘 가운데, 수는 아이콘 옆
|
||||
const HERO_ACT = 'relative flex h-8 min-w-8 cursor-pointer items-center justify-center gap-1 text-[13px] font-extrabold'
|
||||
// 히어로 오른쪽 위 좋아요·댓글·보내기: 아이콘마다 좌우 여백을 같게, 숫자가 붙어도 아이콘 사이 간격이 그대로
|
||||
const HERO_ACT = 'relative flex h-8 cursor-pointer items-center justify-center gap-1 px-[5px] text-[13px] leading-none font-extrabold tabular-nums'
|
||||
const CLOUDS = [
|
||||
{ cls: 'top-9 left-[5%] h-8 w-[84px]', d: '.1s', f: '6s' },
|
||||
{ cls: 'top-[96px] left-[63%] h-9 w-[96px]', d: '.25s', f: '6.4s' },
|
||||
|
||||
+66
-26
@@ -120,13 +120,37 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* 아래 창은 불투명한 채로 화면 아래에서 끝까지 올라오고, 닫힐 땐 다시 내려간다 (반투명으로 올라오면 뒤 탭 바가 비쳐 깜빡여 보였다) */
|
||||
.b-sheet {
|
||||
animation: b-up 0.26s cubic-bezier(0.2, 0.9, 0.3, 1);
|
||||
animation: b-up 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
|
||||
}
|
||||
.b-sheet-dialog[open]::backdrop {
|
||||
animation: b-fade-in 0.2s ease-out;
|
||||
}
|
||||
.b-sheet-closing .b-sheet {
|
||||
animation: b-down 0.2s ease-in forwards;
|
||||
}
|
||||
.b-sheet-closing::backdrop {
|
||||
animation: b-fade-out 0.2s ease-in forwards;
|
||||
}
|
||||
@keyframes b-up {
|
||||
from {
|
||||
transform: translateY(40px);
|
||||
opacity: 0.4;
|
||||
transform: translateY(100%);
|
||||
}
|
||||
}
|
||||
@keyframes b-down {
|
||||
to {
|
||||
transform: translateY(100%);
|
||||
}
|
||||
}
|
||||
@keyframes b-fade-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
@keyframes b-fade-out {
|
||||
to {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,11 +174,13 @@
|
||||
.b-fall,
|
||||
.b-heart-pop,
|
||||
.b-like-bit,
|
||||
.b-sheet {
|
||||
.b-sheet,
|
||||
.b-sheet-dialog[open]::backdrop {
|
||||
animation: none !important;
|
||||
}
|
||||
.b-heart-pop,
|
||||
.b-like-bit {
|
||||
.b-like-bit,
|
||||
.b-sheet-closing .b-sheet {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
@@ -594,72 +620,86 @@ html.b-sheet-open .b-app :is(.b-fall, .b-bob, .b-blob, .b-skystars i, .b-shoot,
|
||||
.b-app[data-t='night'] .b-tabbar {
|
||||
--ink: #fff;
|
||||
}
|
||||
.b-app[data-t='night'] .bg-white {
|
||||
.b-app[data-t='night'] .bg-white:not(.b-day, .b-day *) {
|
||||
background-color: var(--card);
|
||||
}
|
||||
.b-app[data-t='night'] [class*='bg-white/'] {
|
||||
.b-app[data-t='night'] [class*='bg-white/']:not(.b-day, .b-day *) {
|
||||
background-color: rgb(34 42 92 / 0.85);
|
||||
}
|
||||
.b-app[data-t='night'] :is([class*='bg-[#f'], [class*='bg-[#e'], [class*='bg-[#d'], [class*='bg-[#c'], [class*='bg-[linear-gradient']):not(.b-keep-bg) {
|
||||
.b-app[data-t='night'] :is([class*='bg-[#f'], [class*='bg-[#e'], [class*='bg-[#d'], [class*='bg-[#c'], [class*='bg-[linear-gradient']):not(.b-keep-bg, .b-day, .b-day *) {
|
||||
background: var(--chip);
|
||||
}
|
||||
.b-app[data-t='night'] [class*='border-[#dfe5ee]'] {
|
||||
.b-app[data-t='night'] [class*='border-[#dfe5ee]']:not(.b-day, .b-day *) {
|
||||
border-color: rgb(255 255 255 / 0.12);
|
||||
}
|
||||
.b-app[data-t='night'] [class*='rgb(217_229_244'] {
|
||||
.b-app[data-t='night'] [class*='rgb(217_229_244']:not(.b-day, .b-day *) {
|
||||
box-shadow: inset 0 -5px 0 var(--shade);
|
||||
}
|
||||
.b-app[data-t='night'] .bg-\(--ink\) {
|
||||
.b-app[data-t='night'] .bg-\(--ink\):not(.b-day, .b-day *) {
|
||||
background-color: #4b56b5;
|
||||
color: #fff;
|
||||
}
|
||||
.b-app[data-t='night'] .bg-\(--ink\) .text-\[\#ffb3c4\] {
|
||||
.b-app[data-t='night'] .bg-\(--ink\) .text-\[\#ffb3c4\]:not(.b-day, .b-day *) {
|
||||
color: #ffd0dc;
|
||||
}
|
||||
/* b-keep-bg(밤에도 밝은 바탕 그대로) 안은 글자도 그대로 */
|
||||
.b-app[data-t='night'] .text-\[\#28304a\]:not(.b-keep-bg, .b-keep-bg *) {
|
||||
.b-app[data-t='night'] .text-\[\#28304a\]:not(.b-keep-bg, .b-keep-bg *, .b-day, .b-day *) {
|
||||
color: var(--ink);
|
||||
}
|
||||
.b-app[data-t='night'] :is(.text-\[\#1f9d62\], .text-\[\#1f7a4f\]) {
|
||||
.b-app[data-t='night'] :is(.text-\[\#1f9d62\], .text-\[\#1f7a4f\]):not(.b-day, .b-day *) {
|
||||
color: #4fd39a;
|
||||
}
|
||||
.b-app[data-t='night'] .text-\[\#d6457a\] {
|
||||
.b-app[data-t='night'] .text-\[\#d6457a\]:not(.b-day, .b-day *) {
|
||||
color: #ff8db5;
|
||||
}
|
||||
.b-app[data-t='night'] .text-\[\#c2471b\] {
|
||||
.b-app[data-t='night'] .text-\[\#c2471b\]:not(.b-day, .b-day *) {
|
||||
color: #ffab85;
|
||||
}
|
||||
.b-app[data-t='night'] .bg-\[\#dff5ea\] {
|
||||
.b-app[data-t='night'] .bg-\[\#dff5ea\]:not(.b-day, .b-day *) {
|
||||
background: rgb(79 211 154 / 0.16);
|
||||
}
|
||||
.b-app[data-t='night'] .bg-\[\#ffe8dc\] {
|
||||
.b-app[data-t='night'] .bg-\[\#ffe8dc\]:not(.b-day, .b-day *) {
|
||||
background: rgb(255 138 87 / 0.16);
|
||||
}
|
||||
.b-app[data-t='night'] .b-bg-sky {
|
||||
.b-app[data-t='night'] .b-bg-sky:not(.b-day, .b-day *) {
|
||||
background: linear-gradient(180deg, #2a4384, #1f2c62);
|
||||
}
|
||||
.b-app[data-t='night'] .b-bg-butter {
|
||||
.b-app[data-t='night'] .b-bg-butter:not(.b-day, .b-day *) {
|
||||
background: linear-gradient(180deg, #4d4128, #2c2a3e);
|
||||
}
|
||||
.b-app[data-t='night'] .b-bg-peach {
|
||||
.b-app[data-t='night'] .b-bg-peach:not(.b-day, .b-day *) {
|
||||
background: linear-gradient(180deg, #553632, #2e2840);
|
||||
}
|
||||
.b-app[data-t='night'] .b-bg-mint {
|
||||
.b-app[data-t='night'] .b-bg-mint:not(.b-day, .b-day *) {
|
||||
background: linear-gradient(180deg, #1f4a45, #1d2d4a);
|
||||
}
|
||||
.b-app[data-t='night'] .b-bg-lilac {
|
||||
.b-app[data-t='night'] .b-bg-lilac:not(.b-day, .b-day *) {
|
||||
background: linear-gradient(180deg, #3d3480, #262a5e);
|
||||
}
|
||||
.b-app[data-t='night'] .b-band-1 {
|
||||
.b-app[data-t='night'] .b-band-1:not(.b-day, .b-day *) {
|
||||
background: linear-gradient(180deg, rgb(255 160 110 / 0.12), rgb(255 255 255 / 0));
|
||||
}
|
||||
.b-app[data-t='night'] .b-band-2 {
|
||||
.b-app[data-t='night'] .b-band-2:not(.b-day, .b-day *) {
|
||||
background: linear-gradient(180deg, rgb(255 214 110 / 0.12), rgb(255 255 255 / 0));
|
||||
}
|
||||
.b-app[data-t='night'] .b-band-3 {
|
||||
.b-app[data-t='night'] .b-band-3:not(.b-day, .b-day *) {
|
||||
background: linear-gradient(180deg, rgb(110 230 180 / 0.12), rgb(255 255 255 / 0));
|
||||
}
|
||||
|
||||
/* 밤에도 포스트 카드 본문은 낮 색 그대로 (어두운 카드가 줄줄이 이어지지 않게). 위 밤 덮어쓰기는 이 안을 뺀다 */
|
||||
.b-app[data-t='night'] .b-day {
|
||||
--ink: #28304a;
|
||||
--ink2: #5a6380;
|
||||
--ink3: #8a92aa;
|
||||
--line: #e6ecf4;
|
||||
--shade: #d9e5f4;
|
||||
--orange: #ff7a45;
|
||||
--heart: #ff3b5c;
|
||||
--skel: color-mix(in oklab, currentColor 13%, transparent);
|
||||
color: var(--ink);
|
||||
color-scheme: light;
|
||||
}
|
||||
|
||||
.b-app[data-t='night'] img[data-dark] {
|
||||
filter: drop-shadow(0 0 1px rgb(255 255 255 / 0.9)) drop-shadow(0 0 6px rgb(255 255 255 / 0.3));
|
||||
}
|
||||
|
||||
@@ -66,7 +66,8 @@ export function FoliageCard({ post }: { post?: PostReaction | null }) {
|
||||
</span>
|
||||
<div ref={sliderRef} className="overflow-hidden" role="region" aria-label="슬라이드 2장, 옆으로 넘겨 보세요">
|
||||
<div className="flex">
|
||||
<div className="min-w-0 shrink-0 grow-0 basis-full">
|
||||
{/* 밀어 낸 지도가 옆 장(가기 좋은 곳)을 덮지 않게 이 장 밖은 자른다 */}
|
||||
<div className="min-w-0 shrink-0 grow-0 basis-full overflow-hidden">
|
||||
{/* 지도 그림은 땅이 왼쪽에 치우쳐 있어 오른쪽(빈 바다)으로 밀어 가운데에 맞춘다 */}
|
||||
<div ref={mapRef} onClick={tapMap} className="b-keep-bg relative mx-auto aspect-square w-full translate-x-[7%] bg-[#fff6ea]">
|
||||
<img src={MAP_SRC} alt="" className={MAP_IMG} />
|
||||
|
||||
@@ -2,43 +2,20 @@ import { useMutation, useQuery } from '@tanstack/react-query'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { authConfigOptions, googleLoginMutation } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
|
||||
import type { ResAuth } from '@nalssigak/shared/api/client/types.gen'
|
||||
|
||||
type GoogleId = {
|
||||
initialize: (o: { client_id: string; callback: (r: { credential?: string }) => void; ux_mode?: 'popup' }) => void
|
||||
renderButton: (el: HTMLElement, o: Record<string, string | number>) => void
|
||||
}
|
||||
declare global {
|
||||
interface Window {
|
||||
google?: { accounts: { id: GoogleId } }
|
||||
}
|
||||
}
|
||||
|
||||
const SCRIPT = 'https://accounts.google.com/gsi/client'
|
||||
let loading: Promise<GoogleId> | null = null
|
||||
|
||||
/** 구글 로그인 스크립트는 로그인 창을 처음 열 때 한 번만 받는다 */
|
||||
function loadGoogle(): Promise<GoogleId> {
|
||||
if (window.google?.accounts.id) return Promise.resolve(window.google.accounts.id)
|
||||
loading ??= new Promise((resolve, reject) => {
|
||||
const s = document.createElement('script')
|
||||
s.src = SCRIPT
|
||||
s.async = true
|
||||
s.onload = () => (window.google?.accounts.id ? resolve(window.google.accounts.id) : reject(new Error('gsi missing')))
|
||||
s.onerror = () => {
|
||||
loading = null
|
||||
reject(new Error('gsi load failed'))
|
||||
}
|
||||
document.head.appendChild(s)
|
||||
})
|
||||
return loading
|
||||
}
|
||||
import { cx } from '../lib/utils'
|
||||
import { loadGoogle } from './googleScript'
|
||||
import { SHEET_OPEN_MS } from './lib'
|
||||
import { Skel } from './ui'
|
||||
|
||||
/** 구글로 계속하기 버튼. 서버에 클라이언트 ID가 없으면 아무것도 그리지 않는다 */
|
||||
export function GoogleButton({ onResult, onFail }: { onResult: (res: ResAuth) => void; onFail: () => void }) {
|
||||
const clientId = useQuery({ ...authConfigOptions(), staleTime: Infinity }).data?.google_client_id
|
||||
const config = useQuery({ ...authConfigOptions(), staleTime: Infinity })
|
||||
const clientId = config.data?.google_client_id
|
||||
const login = useMutation(googleLoginMutation())
|
||||
const box = useRef<HTMLDivElement>(null)
|
||||
const [broken, setBroken] = useState(false)
|
||||
// 구글 버튼(iframe)이 다 그려지기 전엔 같은 크기의 스켈레톤을 보여 준다. 빈칸에 버튼이 툭 튀어나오면 버벅이는 것처럼 보여서
|
||||
const [ready, setReady] = useState(false)
|
||||
const { mutate } = login
|
||||
// 로그인 창이 다시 그려질 때마다 버튼을 새로 만들지 않게 콜백은 ref 로 들고 있는다
|
||||
const cb = useRef({ onResult, onFail })
|
||||
@@ -49,8 +26,10 @@ export function GoogleButton({ onResult, onFail }: { onResult: (res: ResAuth) =>
|
||||
useEffect(() => {
|
||||
if (!clientId || !box.current) return
|
||||
let alive = true
|
||||
loadGoogle().then(
|
||||
(g) => {
|
||||
// 버튼(iframe)을 만드는 일이 무거워, 로그인 창이 다 올라온 뒤에 만든다. 자리는 min-h 로 잡아 둬서 밀리지 않는다
|
||||
const wait = new Promise((r) => setTimeout(r, SHEET_OPEN_MS))
|
||||
Promise.all([loadGoogle(), wait]).then(
|
||||
([g]) => {
|
||||
if (!alive || !box.current) return
|
||||
g.initialize({
|
||||
client_id: clientId,
|
||||
@@ -61,6 +40,9 @@ export function GoogleButton({ onResult, onFail }: { onResult: (res: ResAuth) =>
|
||||
},
|
||||
})
|
||||
g.renderButton(box.current, { theme: 'outline', size: 'large', shape: 'pill', text: 'continue_with', locale: 'ko', width: box.current.offsetWidth })
|
||||
const frame = box.current.querySelector('iframe')
|
||||
if (frame) frame.addEventListener('load', () => alive && setReady(true), { once: true })
|
||||
else setReady(true)
|
||||
},
|
||||
(e: unknown) => {
|
||||
console.error('[google] script', e)
|
||||
@@ -72,10 +54,14 @@ export function GoogleButton({ onResult, onFail }: { onResult: (res: ResAuth) =>
|
||||
}
|
||||
}, [clientId, mutate])
|
||||
|
||||
if (config.isPending) return <Skel shape className="mx-auto h-[44px] w-full max-w-[400px] rounded-full" />
|
||||
if (!clientId) return null
|
||||
return (
|
||||
<div className="flex flex-col gap-2">
|
||||
<div ref={box} className="flex min-h-[44px] justify-center" aria-busy={login.isPending} />
|
||||
<div className="relative">
|
||||
{!ready && !broken && <Skel shape className="absolute inset-x-0 top-0 mx-auto h-[44px] w-full max-w-[400px] rounded-full" />}
|
||||
<div ref={box} className={cx('flex min-h-[44px] justify-center transition-opacity duration-200', ready ? 'opacity-100' : 'opacity-0')} aria-busy={login.isPending || !ready} />
|
||||
</div>
|
||||
{broken && <p className="m-0 text-center text-[13px] font-bold text-(--ink3)">구글 로그인을 불러오지 못했어요. 잠시 뒤에 다시 해 주세요.</p>}
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
export type GoogleId = {
|
||||
initialize: (o: { client_id: string; callback: (r: { credential?: string }) => void; ux_mode?: 'popup' }) => void
|
||||
renderButton: (el: HTMLElement, o: Record<string, string | number>) => void
|
||||
}
|
||||
declare global {
|
||||
interface Window {
|
||||
google?: { accounts: { id: GoogleId } }
|
||||
}
|
||||
}
|
||||
|
||||
const SCRIPT = 'https://accounts.google.com/gsi/client'
|
||||
let loading: Promise<GoogleId> | null = null
|
||||
|
||||
/** 구글 로그인 스크립트는 한 번만 받는다. 실패하면 다음에 다시 받는다 */
|
||||
export function loadGoogle(): Promise<GoogleId> {
|
||||
if (window.google?.accounts.id) return Promise.resolve(window.google.accounts.id)
|
||||
loading ??= new Promise((resolve, reject) => {
|
||||
const s = document.createElement('script')
|
||||
s.src = SCRIPT
|
||||
s.async = true
|
||||
s.onload = () => (window.google?.accounts.id ? resolve(window.google.accounts.id) : reject(new Error('gsi missing')))
|
||||
s.onerror = () => {
|
||||
loading = null
|
||||
reject(new Error('gsi load failed'))
|
||||
}
|
||||
document.head.appendChild(s)
|
||||
})
|
||||
return loading
|
||||
}
|
||||
|
||||
/** 로그인 안 한 사람은 화면이 한가할 때 스크립트를 미리 받아 둔다. 로그인 창이 올라오는 도중에 스크립트를 실행하느라 화면이 멈추지 않게. 돌려준 함수로 취소 */
|
||||
export function preloadGoogle(): () => void {
|
||||
const run = () => void loadGoogle().catch((e: unknown) => console.error('[google] preload', e))
|
||||
if ('requestIdleCallback' in window) {
|
||||
const id = requestIdleCallback(run, { timeout: 4000 })
|
||||
return () => cancelIdleCallback(id)
|
||||
}
|
||||
const id = setTimeout(run, 2500)
|
||||
return () => clearTimeout(id)
|
||||
}
|
||||
@@ -14,3 +14,8 @@ export function iconSrc(name: string) {
|
||||
export const fall = (d: string, f = '4.8s') => ({ '--d': d, '--f': f }) as CSSProperties
|
||||
|
||||
export const ARTICLE_CAT: Record<number, [string, string]> = { 1: [ARTICLE_LABEL[1], 'text-[#1f9d62]'], 2: [ARTICLE_LABEL[2], 'text-[#7a5cd6]'], 3: [ARTICLE_LABEL[3], 'text-(--orange)'] }
|
||||
|
||||
/** 아래 창이 다 올라오는 시간(.b-sheet 0.26s). 무거운 일은 이 뒤로 미뤄 올라오는 동안 버벅이지 않게 */
|
||||
export const SHEET_OPEN_MS = 280
|
||||
/** 아래 창이 내려가며 닫히는 시간(.b-sheet-closing 0.2s). 이 뒤에 실제로 닫는다 */
|
||||
export const SHEET_CLOSE_MS = 200
|
||||
@@ -5,7 +5,7 @@ const line = { fill: 'none', stroke: 'currentColor', strokeLinecap: 'round', str
|
||||
// 좋아요·댓글·보내기 세 아이콘이 나란히 놓일 때 크기가 같아 보이게: 하트는 원래 그림이 작아 10% 키우고(보이는 칸을 좁힘), 보내기는 커서 5% 줄인다
|
||||
export function HeartIcon({ className }: P) {
|
||||
return (
|
||||
<svg viewBox="1.1 2.75 21.8 21.8" className={className} aria-hidden="true">
|
||||
<svg viewBox="1.1 1.95 21.8 21.8" className={className} aria-hidden="true">
|
||||
<path d="M12 20.5s-8-4.9-8-11A4.6 4.6 0 0 1 12 6.8a4.6 4.6 0 0 1 8 2.7c0 6.1-8 11-8 11z" />
|
||||
</svg>
|
||||
)
|
||||
|
||||
+14
-7
@@ -32,8 +32,6 @@ const WRITE_ERRORS: Record<string, string> = {
|
||||
INVALID_INPUT: '100자 안으로 써 주세요.',
|
||||
}
|
||||
|
||||
// 글이 이보다 적으면 '동네 사람들' 묶음 대신 첫 글 쓰기 카드
|
||||
const GROUP_MIN = 3
|
||||
const COMPOSE_ID = 'talk-compose'
|
||||
|
||||
const REASONS = [
|
||||
@@ -130,13 +128,19 @@ function Composer({ onDone }: { onDone?: (t: TalkData) => void }) {
|
||||
id={COMPOSE_ID}
|
||||
value={text}
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
onFocus={(e) => {
|
||||
// 로그인 전엔 읽기 전용이라 눌러도 키보드가 안 올라온다 (키보드가 떴다 내려가며 로그인 창이 버벅이던 것). 누르거나 Enter 면 로그인 창
|
||||
onClick={(e) => {
|
||||
if (loggedIn) return
|
||||
// 로그인 창(<dialog>)은 닫힐 때 포커스를 이 칸으로 돌려놓아 다시 열리므로, 열기 전에 포커스를 뺀다
|
||||
// 창이 닫힐 때 포커스가 이 칸으로 돌아와 테두리가 번쩍이지 않게
|
||||
e.currentTarget.blur()
|
||||
open({ type: 'login' })
|
||||
}}
|
||||
readOnly={busy}
|
||||
onKeyDown={(e) => {
|
||||
if (loggedIn || (e.key !== 'Enter' && e.key !== ' ')) return
|
||||
e.preventDefault()
|
||||
open({ type: 'login' })
|
||||
}}
|
||||
readOnly={busy || !loggedIn}
|
||||
maxLength={BODY_MAX}
|
||||
rows={2}
|
||||
placeholder={`지금 ${region.name.split(' ').at(-1)} 날씨 어때요?`}
|
||||
@@ -360,7 +364,10 @@ export function TalkGroup({ title, topic, talks }: { title: string; topic?: numb
|
||||
export function FirstTalkCard() {
|
||||
const { region } = useRegion()
|
||||
const place = region.name.split(' ').at(-1)
|
||||
const { loggedIn } = useAuth()
|
||||
const { open } = useSheet()
|
||||
const go = () => {
|
||||
if (!loggedIn) return open({ type: 'login' })
|
||||
const el = document.getElementById(COMPOSE_ID)
|
||||
el?.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
||||
el?.focus({ preventScroll: true })
|
||||
@@ -376,10 +383,10 @@ export function FirstTalkCard() {
|
||||
)
|
||||
}
|
||||
|
||||
/** '동네 사람들' 자리: 글이 GROUP_MIN 개 이상이면 묶음, 아니면 첫 글 쓰기 */
|
||||
/** '동네 사람들' 자리: 글이 하나라도 있으면 묶음, 없으면 첫 글 쓰기 */
|
||||
export function NearTalks({ talks, loaded }: { talks: TalkData[]; loaded: boolean }) {
|
||||
if (!loaded) return null
|
||||
if (talks.length >= GROUP_MIN) return <TalkGroup title="동네 사람들" talks={talks} />
|
||||
if (talks.length) return <TalkGroup title="동네 사람들" talks={talks} />
|
||||
return IS_TOSS ? null : <FirstTalkCard />
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
import { moonPath } from '@nalssigak/shared/lib/today';
|
||||
import { useId } from 'react';
|
||||
import Svg, { Circle, ClipPath, Defs, Ellipse, FeGaussianBlur, Filter, G, Path, RadialGradient, Stop } from 'react-native-svg';
|
||||
|
||||
// 앞면 바다(어두운 무늬) 자리: [x, y, 가로 반지름, 세로 반지름]. 실제 달 앞면 배치를 대강 따른다 (웹 frontend/src/b/moon.tsx 와 같다)
|
||||
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, 기우는 달은 왼쪽이 밝다. 빛 번짐까지 그려서 달 지름은 size 의 2/3 */
|
||||
export function MoonArt({ pct, waxing, tone = 'night', size }: { pct: number; waxing: boolean; tone?: keyof typeof TONES; size: number }) {
|
||||
const id = useId().replace(/[^a-zA-Z0-9]/g, '');
|
||||
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" width={size} height={size} pointerEvents="none">
|
||||
<Defs>
|
||||
<RadialGradient id={`${id}glow`} cx="0" cy="0" r="1.5" gradientUnits="userSpaceOnUse">
|
||||
<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.2" cy="-0.28" r="1.44" gradientUnits="userSpaceOnUse">
|
||||
<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`} cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse">
|
||||
<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>
|
||||
);
|
||||
}
|
||||
@@ -5,11 +5,12 @@ import type { SlideBg } from '@nalssigak/shared/lib/types';
|
||||
import { deg } from '@nalssigak/shared/lib/weatherText';
|
||||
import { Image } from 'expo-image';
|
||||
import { LinearGradient } from 'expo-linear-gradient';
|
||||
import type { ReactNode } from 'react';
|
||||
import { useState, type ReactNode } from 'react';
|
||||
import { Pressable, StyleSheet, View } from 'react-native';
|
||||
import { Text } from '@/components/text';
|
||||
import Svg, { Polygon } from 'react-native-svg';
|
||||
|
||||
import { MoonArt } from '@/components/moon';
|
||||
import { Credit, Ic, Rows, Thumb } from '@/components/ui';
|
||||
import { CARD_BG } from '@/lib/colors';
|
||||
import { useSheet } from '@/lib/sheet';
|
||||
@@ -54,7 +55,7 @@ export function slideBg(post: PostData, slide: Slide): SlideBg {
|
||||
if (slide.kind === 'week') return 'mint';
|
||||
if (slide.kind === 'plan') return slide.eyebrow.startsWith('일') ? 'peach' : 'butter';
|
||||
if (slide.kind === 'gak') return GAK_BG[post.post_id % GAK_BG.length];
|
||||
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';
|
||||
@@ -86,6 +87,28 @@ function Pic({ name, widthPct = 42 }: { name: string; widthPct?: number }) {
|
||||
);
|
||||
}
|
||||
|
||||
// 달 포스트 밤하늘 별: [left %, top %, 크기]
|
||||
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 }) {
|
||||
const [w, setW] = useState(0);
|
||||
return (
|
||||
<View pointerEvents="none" style={StyleSheet.absoluteFill} onLayout={(e) => setW(e.nativeEvent.layout.width)}>
|
||||
{STARS.map(([x, y, s]) => (
|
||||
<View key={`${x},${y}`} className="absolute rounded-full bg-white opacity-80" style={{ left: `${x}%`, top: `${y}%`, width: s, height: s }} />
|
||||
))}
|
||||
{w > 0 && (
|
||||
<View className="absolute top-[22%] right-0">
|
||||
<MoonArt pct={pct} waxing={waxing} size={w * 0.6} />
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
export function SlideView({ slide, bg }: { slide: Slide; bg: SlideBg }) {
|
||||
const { open } = useSheet();
|
||||
const { kind } = useSky();
|
||||
@@ -246,13 +269,14 @@ export function SlideView({ slide, bg }: { slide: Slide; bg: SlideBg }) {
|
||||
);
|
||||
return (
|
||||
<Base colors={colors}>
|
||||
{slide.moon_pct != null && <MoonPic pct={slide.moon_pct} waxing={!!slide.moon_waxing} />}
|
||||
<Eyebrow light={light} className={light ? 'opacity-85' : undefined}>
|
||||
{slide.eyebrow}
|
||||
</Eyebrow>
|
||||
<Big light={light} className="z-[1]">
|
||||
{slide.line}
|
||||
</Big>
|
||||
<Pic name={slide.icon} widthPct={36} />
|
||||
{slide.moon_pct == null && <Pic name={slide.icon} widthPct={36} />}
|
||||
<Rows rows={slide.rows ?? []} dark={light} />
|
||||
</Base>
|
||||
);
|
||||
|
||||
@@ -200,6 +200,11 @@ function CommentRow({ c, postId, onNotice }: { c: CommentData; postId: number; o
|
||||
<View className="flex-1">
|
||||
<Text className="text-sm text-ink">
|
||||
<Text className="font-extrabold">{c.nickname} </Text>
|
||||
{c.official && (
|
||||
<>
|
||||
<Text className="bg-orange text-[10.5px] font-extrabold text-white">{' 날씨각 '}</Text>{' '}
|
||||
</>
|
||||
)}
|
||||
{c.body}
|
||||
</Text>
|
||||
<View className="mt-0.5 flex-row flex-wrap items-center">
|
||||
@@ -214,7 +219,8 @@ function CommentRow({ c, postId, onNotice }: { c: CommentData; postId: number; o
|
||||
</>
|
||||
)}
|
||||
</Text>
|
||||
{!c.mine && <CommentMenu c={c} postId={postId} onNotice={onNotice} />}
|
||||
{/* 날씨각 캐릭터 댓글은 운영 문구라 신고·차단 메뉴가 없다 */}
|
||||
{!c.mine && !c.official && <CommentMenu c={c} postId={postId} onNotice={onNotice} />}
|
||||
</View>
|
||||
</View>
|
||||
<Pressable onPress={toggle} hitSlop={12} accessibilityRole="button" accessibilityState={{ selected: liked }} accessibilityLabel="댓글 좋아요" className="pt-1">
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import type { Hero as HeroData, ResWeatherToday, TopIndex } from '@nalssigak/shared/api/client/types.gen';
|
||||
import { kindOfHour, kst, type Load, type TimeKind, WEEKDAYS } from '@nalssigak/shared/lib';
|
||||
import { KINDS, moonPath, PREVIEW, SLOT_KEY, WANING, type Weather, WEATHER_ICON, weatherOf } from '@nalssigak/shared/lib/today';
|
||||
import { KINDS, PREVIEW, SLOT_KEY, WANING, type Weather, WEATHER_ICON, weatherOf } from '@nalssigak/shared/lib/today';
|
||||
import { deg, slotAt } from '@nalssigak/shared/lib/weatherText';
|
||||
import { useEffect, useState, type ReactNode } from 'react';
|
||||
import { Pressable, View, type DimensionValue, type ViewStyle } from 'react-native';
|
||||
import { Text } from '@/components/text';
|
||||
import Animated, { cancelAnimation, Easing, useAnimatedStyle, useReducedMotion, useSharedValue, withDelay, withRepeat, withTiming } from 'react-native-reanimated';
|
||||
import { LinearGradient } from 'expo-linear-gradient';
|
||||
import Svg, { Defs, Path, RadialGradient, Rect, Stop } from 'react-native-svg';
|
||||
import Svg, { Defs, RadialGradient, Rect, Stop } from 'react-native-svg';
|
||||
|
||||
import { Fall } from '@/components/fall';
|
||||
import { MoonArt } from '@/components/moon';
|
||||
import { Shoot, type ShootSpec } from '@/components/sky-bg';
|
||||
import { Ic, Skel } from '@/components/ui';
|
||||
import { useSheet } from '@/lib/sheet';
|
||||
@@ -140,6 +141,12 @@ export function Hero({ hero, today, ranked, feedLoad, todayLoad }: Props) {
|
||||
const snow = weather === 'snow' || weather === 'sleet';
|
||||
const orb = ORB[kind === 'sunset' ? 'sunset' : kind === 'night' ? 'night' : 'sun'];
|
||||
const text = dark ? 'text-white' : 'text-[#28304a]';
|
||||
// 가운데가 밝은 달이면 진한 글씨에 흰 번짐, 가운데가 어두운 달(초승·그믐·삭)이면 흰 글씨
|
||||
const orbText: { color: string; textShadowColor?: string; textShadowRadius?: number } = !moon
|
||||
? { color: orb.text }
|
||||
: moon.pct >= 50
|
||||
? { color: orb.text, textShadowColor: '#fff', textShadowRadius: 8 }
|
||||
: { color: '#fff', textShadowColor: 'rgba(10,14,40,0.6)', textShadowRadius: 8 };
|
||||
|
||||
return (
|
||||
<View className="mx-3 mt-1 overflow-hidden rounded-[28px] px-4 pt-3 pb-3">
|
||||
@@ -157,7 +164,13 @@ export function Hero({ hero, today, ranked, feedLoad, todayLoad }: Props) {
|
||||
</Text>
|
||||
<View className="h-[146px] items-center">
|
||||
<Fall d={0} f={5600} amp={8}>
|
||||
<View className="mt-2 size-32 items-center justify-center" style={{ boxShadow: `0 20px 40px ${kind === 'night' ? 'rgb(190 180 255 / 0.35)' : kind === 'sunset' ? 'rgb(255 150 110 / 0.4)' : 'rgb(240 106 58 / 0.32)'}`, borderRadius: 64 }}>
|
||||
<View className="mt-2 size-32 items-center justify-center" style={moon ? undefined : { boxShadow: `0 20px 40px ${kind === 'night' ? 'rgb(190 180 255 / 0.35)' : kind === 'sunset' ? 'rgb(255 150 110 / 0.4)' : 'rgb(240 106 58 / 0.32)'}`, borderRadius: 64 }}>
|
||||
{/* 저녁·밤엔 오늘 밤 실제 모양의 달 (빛 번짐까지 그려서 공보다 크게) */}
|
||||
{moon ? (
|
||||
<View pointerEvents="none" style={{ position: 'absolute', top: -32, left: -32 }}>
|
||||
<MoonArt pct={moon.pct} waxing={!moon.waning} tone={kind === 'sunset' ? 'dusk' : 'night'} size={192} />
|
||||
</View>
|
||||
) : (
|
||||
<Svg viewBox="-1 -1 2 2" width={128} height={128} style={{ position: 'absolute' }}>
|
||||
<Defs>
|
||||
<RadialGradient id="orb" cx="-0.32" cy="-0.4" r="1.4" gradientUnits="userSpaceOnUse">
|
||||
@@ -168,13 +181,12 @@ export function Hero({ hero, today, ranked, feedLoad, todayLoad }: Props) {
|
||||
</RadialGradient>
|
||||
</Defs>
|
||||
<Rect x="-1" y="-1" width="2" height="2" rx="1" fill="url(#orb)" opacity={gray ? 0.85 : 1} />
|
||||
{/* 안 보이는 쪽을 덮어 오늘 밤 달 모양으로 */}
|
||||
{moon && <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>
|
||||
<Text className="font-jua text-[12px]" style={{ color: orb.text }}>
|
||||
)}
|
||||
<Text className="font-jua text-[12px]" style={orbText}>
|
||||
{failed(feedLoad) ? '점수를 못 불러왔어요' : `${slotScore != null && mode !== 'now' ? PREVIEW[mode].label : '지금'} 날씨 점수`}
|
||||
</Text>
|
||||
<Text className="font-bagel text-[52px] leading-[52px]" style={{ color: orb.text }}>
|
||||
<Text className="font-bagel text-[52px] leading-[52px]" style={orbText}>
|
||||
{heroVal(feedLoad, score, 'w-[84px] h-10')}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
@@ -646,18 +646,18 @@ export type GakSlide = {
|
||||
* Summary
|
||||
*/
|
||||
summary: string;
|
||||
/**
|
||||
* Rows
|
||||
*
|
||||
* 점수 근거: 비중 큰 날씨 조건부터 네 개와 지금 값 (기온 · 체감 18°)
|
||||
*/
|
||||
rows?: Array<Row>;
|
||||
/**
|
||||
* Say
|
||||
*
|
||||
* 점수 구간 설명 문장 (seed sentences)
|
||||
*/
|
||||
say?: string | null;
|
||||
/**
|
||||
* Trend
|
||||
*
|
||||
* 오늘 · 내일 · 이번 주말 점수 (각 상세 날짜 칸과 같은 값)
|
||||
*/
|
||||
trend?: Array<TrendPoint>;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user