feat: 단풍 지도·이번 주 행사 띠·계절 이야기 띠에 좋아요·댓글(서버 포스트 자리 18·19·20), 히어로 아래 글자 칸 높이를 미리 잡아 오늘의 각부터 피드가 밀려 내려가던 문제 수정
This commit is contained in:
1 parent
eb84a72c2f
commit
03e54ad552
9 files changed
+60
-25
No files matched your search
@@ -147,6 +147,9 @@ class PostType(CodeEnum):
|
|||||||
UV = 15 # 오늘 낮 자외선 (아침·낮, '보통' 이상인 날만)
|
UV = 15 # 오늘 낮 자외선 (아침·낮, '보통' 이상인 날만)
|
||||||
HERO = 16 # 히어로(오늘 날씨)의 좋아요·댓글 자리. 피드 목록엔 안 나온다
|
HERO = 16 # 히어로(오늘 날씨)의 좋아요·댓글 자리. 피드 목록엔 안 나온다
|
||||||
TODAY_GAK = 17 # 오늘의 각 카드의 좋아요·댓글 자리. 피드 목록엔 안 나온다
|
TODAY_GAK = 17 # 오늘의 각 카드의 좋아요·댓글 자리. 피드 목록엔 안 나온다
|
||||||
|
FOLIAGE = 18 # 단풍 지도 카드의 좋아요·댓글 자리. 피드 목록엔 안 나온다
|
||||||
|
EVENTS_BAND = 19 # 이번 주 가까운 행사 띠의 좋아요·댓글 자리
|
||||||
|
SEASON_BAND = 20 # 이번 주 계절 이야기 띠의 좋아요·댓글 자리
|
||||||
|
|
||||||
|
|
||||||
class EventKind(CodeEnum):
|
class EventKind(CodeEnum):
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ async def get_feed(
|
|||||||
err, feed = await service.feed(region)
|
err, feed = await service.feed(region)
|
||||||
if err is not ErrorType.SUCCESS:
|
if err is not ErrorType.SUCCESS:
|
||||||
return Res_Feed(result=error_info(err))
|
return Res_Feed(result=error_info(err))
|
||||||
pinned = [x for x in (feed.hero_post, feed.gak_post) if x is not None]
|
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]
|
ids = [p.post_id for p in feed.posts] + [x.post_id for x in pinned]
|
||||||
counts = await reactions.counts(ids)
|
counts = await reactions.counts(ids)
|
||||||
liked, saved = await reactions.marks(user, ids)
|
liked, saved = await reactions.marks(user, ids)
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ class PostData(WebPacketProtocol):
|
|||||||
|
|
||||||
|
|
||||||
class PostReaction(WebPacketProtocol):
|
class PostReaction(WebPacketProtocol):
|
||||||
"""포스트 틀이 아닌 카드(히어로·오늘의 각)에 붙는 좋아요·댓글."""
|
"""포스트 틀이 아닌 카드(히어로·오늘의 각·단풍 지도·띠)에 붙는 좋아요·댓글."""
|
||||||
post_id: int
|
post_id: int
|
||||||
like_count: int
|
like_count: int
|
||||||
comment_count: int
|
comment_count: int
|
||||||
@@ -235,6 +235,9 @@ class Res_Feed(Res_WebPacketProtocol):
|
|||||||
posts: list[PostData] = []
|
posts: list[PostData] = []
|
||||||
hero_post: Optional[PostReaction] = None
|
hero_post: Optional[PostReaction] = None
|
||||||
gak_post: Optional[PostReaction] = None
|
gak_post: Optional[PostReaction] = None
|
||||||
|
foliage_post: Optional[PostReaction] = None
|
||||||
|
events_post: Optional[PostReaction] = None
|
||||||
|
season_post: Optional[PostReaction] = None
|
||||||
bands: Optional[Bands] = None
|
bands: Optional[Bands] = None
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -65,12 +65,18 @@ LINEUP = [
|
|||||||
(20, PostType.UV, RefType.NONE, None),
|
(20, PostType.UV, RefType.NONE, None),
|
||||||
(21, PostType.HERO, RefType.NONE, None),
|
(21, PostType.HERO, RefType.NONE, None),
|
||||||
(22, PostType.TODAY_GAK, RefType.NONE, None),
|
(22, PostType.TODAY_GAK, RefType.NONE, None),
|
||||||
|
(23, PostType.FOLIAGE, RefType.NONE, None),
|
||||||
|
(24, PostType.EVENTS_BAND, RefType.NONE, None),
|
||||||
|
(25, PostType.SEASON_BAND, RefType.NONE, None),
|
||||||
]
|
]
|
||||||
# 피드 목록 대신 히어로·오늘의 각 카드에 좋아요·댓글만 붙는 자리
|
# 피드 목록 대신 히어로·오늘의 각·단풍 지도·띠에 좋아요·댓글만 붙는 자리
|
||||||
_PINNED = {PostType.HERO: "hero_post", PostType.TODAY_GAK: "gak_post"}
|
_PINNED = {
|
||||||
|
PostType.HERO: "hero_post", PostType.TODAY_GAK: "gak_post", PostType.FOLIAGE: "foliage_post",
|
||||||
|
PostType.EVENTS_BAND: "events_post", PostType.SEASON_BAND: "season_post",
|
||||||
|
}
|
||||||
# 좋아요·댓글 단위. 이 종류들은 전국이 같은 카드 하나, 나머지는 그 구 데이터로 채우는 카드라 시도마다 따로 만든다.
|
# 좋아요·댓글 단위. 이 종류들은 전국이 같은 카드 하나, 나머지는 그 구 데이터로 채우는 카드라 시도마다 따로 만든다.
|
||||||
NATIONAL_SCOPE = "00"
|
NATIONAL_SCOPE = "00"
|
||||||
NATIONAL_TYPES = frozenset({PostType.SEASON, PostType.TIP, PostType.QUOTE, PostType.MOON})
|
NATIONAL_TYPES = frozenset({PostType.SEASON, PostType.TIP, PostType.QUOTE, PostType.MOON, PostType.FOLIAGE, PostType.SEASON_BAND})
|
||||||
|
|
||||||
|
|
||||||
def sido_of(region_code: str) -> str:
|
def sido_of(region_code: str) -> str:
|
||||||
|
|||||||
@@ -1192,7 +1192,7 @@ export type PostData = {
|
|||||||
/**
|
/**
|
||||||
* PostReaction
|
* PostReaction
|
||||||
*
|
*
|
||||||
* 포스트 틀이 아닌 카드(히어로·오늘의 각)에 붙는 좋아요·댓글.
|
* 포스트 틀이 아닌 카드(히어로·오늘의 각·단풍 지도·띠)에 붙는 좋아요·댓글.
|
||||||
*/
|
*/
|
||||||
export type PostReaction = {
|
export type PostReaction = {
|
||||||
/**
|
/**
|
||||||
@@ -1284,7 +1284,19 @@ export const PostType = {
|
|||||||
/**
|
/**
|
||||||
* TODAY_GAK
|
* TODAY_GAK
|
||||||
*/
|
*/
|
||||||
TODAY_GAK: 17
|
TODAY_GAK: 17,
|
||||||
|
/**
|
||||||
|
* FOLIAGE
|
||||||
|
*/
|
||||||
|
FOLIAGE: 18,
|
||||||
|
/**
|
||||||
|
* EVENTS_BAND
|
||||||
|
*/
|
||||||
|
EVENTS_BAND: 19,
|
||||||
|
/**
|
||||||
|
* SEASON_BAND
|
||||||
|
*/
|
||||||
|
SEASON_BAND: 20
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1726,6 +1738,9 @@ export type ResFeed = {
|
|||||||
posts?: Array<PostData>;
|
posts?: Array<PostData>;
|
||||||
hero_post?: PostReaction | null;
|
hero_post?: PostReaction | null;
|
||||||
gak_post?: PostReaction | null;
|
gak_post?: PostReaction | null;
|
||||||
|
foliage_post?: PostReaction | null;
|
||||||
|
events_post?: PostReaction | null;
|
||||||
|
season_post?: PostReaction | null;
|
||||||
bands?: Bands | null;
|
bands?: Bands | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ const ACCOUNTS: Record<PostType, readonly [string, string]> = {
|
|||||||
[PostType.UV]: ['자외선', 'glasses'],
|
[PostType.UV]: ['자외선', 'glasses'],
|
||||||
[PostType.HERO]: ['오늘 날씨', 'sun'],
|
[PostType.HERO]: ['오늘 날씨', 'sun'],
|
||||||
[PostType.TODAY_GAK]: ['오늘의 각', 'rabbit'],
|
[PostType.TODAY_GAK]: ['오늘의 각', 'rabbit'],
|
||||||
|
[PostType.FOLIAGE]: ['단풍 지도', 'maple'],
|
||||||
|
[PostType.EVENTS_BAND]: ['이번 주 가까운 행사', 'fireworks'],
|
||||||
|
[PostType.SEASON_BAND]: ['이번 주 계절 이야기', 'fallen_leaf'],
|
||||||
}
|
}
|
||||||
|
|
||||||
type Slide = HoursSlide | RowsSlide | GakSlide | SunsetSlide | WeekSlide | PlanSlide
|
type Slide = HoursSlide | RowsSlide | GakSlide | SunsetSlide | WeekSlide | PlanSlide
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import { InstallBanner } from './installBanner'
|
|||||||
import { MyGakRow } from './myGak'
|
import { MyGakRow } from './myGak'
|
||||||
import { fromShare } from './myGakState'
|
import { fromShare } from './myGakState'
|
||||||
import { PostCard, PostCardSkel, PostFrame } from './Post'
|
import { PostCard, PostCardSkel, PostFrame } from './Post'
|
||||||
import { usePinnedLike } from './pinnedLike'
|
import { usePinnedLike, type PinnedKey } from './pinnedLike'
|
||||||
import { FeedComposer, TalkCard } from './talk'
|
import { FeedComposer, TalkCard } from './talk'
|
||||||
import { useFeedTalks } from './talkState'
|
import { useFeedTalks } from './talkState'
|
||||||
import { useRegion } from './regionContext'
|
import { useRegion } from './regionContext'
|
||||||
@@ -399,7 +399,8 @@ function Hero({ hero, post, today, ranked, all, feedLoad, todayLoad }: HeroProps
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="relative z-[3] text-center">
|
{/* 다 불러온 높이(한 줄 말·날씨 한 줄·상태 두 줄)를 미리 잡아 둔다: 늦게 채워지며 아래 피드가 밀려 내려가지 않게 */}
|
||||||
|
<div className="relative z-[3] min-h-[103px] text-center">
|
||||||
{top1 ? (
|
{top1 ? (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
@@ -521,18 +522,21 @@ function PostsSkel() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function Band({ tone, title, sub, to, children }: { tone: 1 | 2 | 3; title: string; sub: string; to: string; children: ReactNode }) {
|
/** 띠도 포스트 틀에 담아 좋아요·댓글·보내기를 단다 (post 는 서버의 띠 자리) */
|
||||||
|
function Band({ tone, title, sub, to, avatar, post, pinKey, children }: { tone: 1 | 2 | 3; title: string; sub: string; to: string; avatar: string; post?: PostReaction | null; pinKey: PinnedKey; children: ReactNode }) {
|
||||||
return (
|
return (
|
||||||
<section className={cx('mt-3.5 pt-4 pb-3.5', `b-band-${tone}`)} aria-label={title}>
|
<PostFrame title={title} account={title} avatar={avatar} pinned={{ key: pinKey, post }}>
|
||||||
<Sec title={title} sub={sub} more={{ to }} className="pt-0" />
|
<section className={cx('pt-4 pb-3.5', `b-band-${tone}`)} aria-label={title}>
|
||||||
{children}
|
<Sec title={title} sub={sub} more={{ to }} className="pt-0" />
|
||||||
</section>
|
{children}
|
||||||
|
</section>
|
||||||
|
</PostFrame>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function EventsBand({ events }: { events: BandEvent[] }) {
|
function EventsBand({ events, post }: { events: BandEvent[]; post?: PostReaction | null }) {
|
||||||
return (
|
return (
|
||||||
<Band tone={1} title="이번 주 가까운 행사" sub="30km 안 · 날씨까지 같이 보고 골라요" to="/week">
|
<Band tone={1} title="이번 주 가까운 행사" sub="30km 안 · 날씨까지 같이 보고 골라요" to="/week" avatar="fireworks" post={post} pinKey="events_post">
|
||||||
<Rail>
|
<Rail>
|
||||||
{events.map((e, i) => (
|
{events.map((e, i) => (
|
||||||
<Link key={e.event_id} to="/week" className="w-[200px] overflow-hidden rounded-[22px] bg-white shadow-[inset_0_-5px_0_var(--shade),0_8px_16px_rgb(40_48_74/0.06)]">
|
<Link key={e.event_id} to="/week" className="w-[200px] overflow-hidden rounded-[22px] bg-white shadow-[inset_0_-5px_0_var(--shade),0_8px_16px_rgb(40_48_74/0.06)]">
|
||||||
@@ -549,10 +553,10 @@ function EventsBand({ events }: { events: BandEvent[] }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function SeasonBand({ news }: { news: BandArticle[] }) {
|
function SeasonBand({ news, post }: { news: BandArticle[]; post?: PostReaction | null }) {
|
||||||
const { open } = useSheet()
|
const { open } = useSheet()
|
||||||
return (
|
return (
|
||||||
<Band tone={3} title="이번 주 계절 이야기" sub="예년 이맘때의 소식" to="/season">
|
<Band tone={3} title="이번 주 계절 이야기" sub="예년 이맘때의 소식" to="/season" avatar="fallen_leaf" post={post} pinKey="season_post">
|
||||||
<Rail>
|
<Rail>
|
||||||
{news.map((a) => (
|
{news.map((a) => (
|
||||||
<button key={a.article_id} type="button" onClick={() => open({ type: 'article', articleId: a.article_id })} className="w-[200px] cursor-pointer overflow-hidden rounded-[22px] bg-white text-left shadow-[inset_0_-5px_0_var(--shade),0_8px_16px_rgb(40_48_74/0.06)]">
|
<button key={a.article_id} type="button" onClick={() => open({ type: 'article', articleId: a.article_id })} className="w-[200px] cursor-pointer overflow-hidden rounded-[22px] bg-white text-left shadow-[inset_0_-5px_0_var(--shade),0_8px_16px_rgb(40_48_74/0.06)]">
|
||||||
@@ -615,8 +619,8 @@ export function TodayPage() {
|
|||||||
|
|
||||||
// 디자인대로 3·6·9번째 글 뒤에 띠를 넣고, 글이 모자라면 남은 띠는 맨 뒤에 붙인다
|
// 디자인대로 3·6·9번째 글 뒤에 띠를 넣고, 글이 모자라면 남은 띠는 맨 뒤에 붙인다
|
||||||
const bandAt: [number, ReactNode][] = [
|
const bandAt: [number, ReactNode][] = [
|
||||||
[3, bands?.events?.length ? <EventsBand key="events" events={bands.events} /> : null],
|
[3, bands?.events?.length ? <EventsBand key="events" events={bands.events} post={f?.events_post} /> : null],
|
||||||
[9, bands?.season?.length ? <SeasonBand key="season" news={bands.season} /> : null],
|
[9, bands?.season?.length ? <SeasonBand key="season" news={bands.season} post={f?.season_post} /> : null],
|
||||||
]
|
]
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -646,7 +650,7 @@ export function TodayPage() {
|
|||||||
{posts.map((p, i) => (
|
{posts.map((p, i) => (
|
||||||
<Fragment key={p.post_id}>
|
<Fragment key={p.post_id}>
|
||||||
<PostCard post={p} />
|
<PostCard post={p} />
|
||||||
{i === 1 && <FoliageCard />}
|
{i === 1 && <FoliageCard post={f?.foliage_post} />}
|
||||||
{i > 0 && i % TALK_EVERY === 0 && talks[i / TALK_EVERY - 1] && <TalkCard t={talks[i / TALK_EVERY - 1]} />}
|
{i > 0 && i % TALK_EVERY === 0 && talks[i / TALK_EVERY - 1] && <TalkCard t={talks[i / TALK_EVERY - 1]} />}
|
||||||
{bandAt.find(([at]) => at === i + 1)?.[1]}
|
{bandAt.find(([at]) => at === i + 1)?.[1]}
|
||||||
</Fragment>
|
</Fragment>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useLayoutEffect, useMemo, useRef, useState, type MouseEvent } from 'react'
|
import { useLayoutEffect, useMemo, useRef, useState, type MouseEvent } from 'react'
|
||||||
import { useNavigate } from 'react-router'
|
import { useNavigate } from 'react-router'
|
||||||
import { cx } from '../lib/utils'
|
import { cx } from '../lib/utils'
|
||||||
|
import type { PostReaction } from '../api/client/types.gen'
|
||||||
import { useCarousel } from './carousel'
|
import { useCarousel } from './carousel'
|
||||||
import { headline, ICON_R, LABEL, LABEL_INK, LEAF_SHADOW, MAP_IMG, MAP_SRC, md, placeLabels, PROVINCE, PROVINCES, labelBoxes, placeProvinces, rankNow, spread, useFoliage, useLabelSize } from './foliage'
|
import { headline, ICON_R, LABEL, LABEL_INK, LEAF_SHADOW, MAP_IMG, MAP_SRC, md, placeLabels, PROVINCE, PROVINCES, labelBoxes, placeProvinces, rankNow, spread, useFoliage, useLabelSize } from './foliage'
|
||||||
import { PostFrame } from './Post'
|
import { PostFrame } from './Post'
|
||||||
@@ -13,7 +14,7 @@ const TAP_R = 24
|
|||||||
const RANK_N = 7
|
const RANK_N = 7
|
||||||
|
|
||||||
/** 피드의 단풍 지도 카드: 1장은 지금 절정인 곳만 잎 아이콘으로(누르면 카드 안에 정보), 2장은 지금 가기 좋은 순위. '지도 크게 보기'로 단풍 지도 페이지 */
|
/** 피드의 단풍 지도 카드: 1장은 지금 절정인 곳만 잎 아이콘으로(누르면 카드 안에 정보), 2장은 지금 가기 좋은 순위. '지도 크게 보기'로 단풍 지도 페이지 */
|
||||||
export function FoliageCard() {
|
export function FoliageCard({ post }: { post?: PostReaction | null }) {
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const { today, spots, inSeason } = useFoliage()
|
const { today, spots, inSeason } = useFoliage()
|
||||||
const peak = useMemo(() => spots.filter((m) => m.stage === 'peak').sort((a, b) => Number(a.kind === 'ginkgo') - Number(b.kind === 'ginkgo') || a.y - b.y), [spots])
|
const peak = useMemo(() => spots.filter((m) => m.stage === 'peak').sort((a, b) => Number(a.kind === 'ginkgo') - Number(b.kind === 'ginkgo') || a.y - b.y), [spots])
|
||||||
@@ -55,7 +56,7 @@ export function FoliageCard() {
|
|||||||
// 2번째 장: 지금 절정인 곳을 절정 예상일이 오늘과 가까운 순서로
|
// 2번째 장: 지금 절정인 곳을 절정 예상일이 오늘과 가까운 순서로
|
||||||
const ranked = rankNow(spots).slice(0, RANK_N)
|
const ranked = rankNow(spots).slice(0, RANK_N)
|
||||||
return (
|
return (
|
||||||
<PostFrame title="단풍 지도" account="단풍 지도" avatar="maple" caption={peak.length ? `지금 절정 ${peak.length}곳: ${peak.slice(0, 5).map((m) => m.name).join(' · ')}${peak.length > 5 ? ' 외' : ''}` : undefined}>
|
<PostFrame title="단풍 지도" account="단풍 지도" avatar="maple" pinned={{ key: 'foliage_post', post }} caption={peak.length ? `지금 절정 ${peak.length}곳: ${peak.slice(0, 5).map((m) => m.name).join(' · ')}${peak.length > 5 ? ' 외' : ''}` : undefined}>
|
||||||
<div className="b-keep-bg relative bg-[#fff6ea] px-4 pt-4 pb-3 text-[#28304a]">
|
<div className="b-keep-bg relative bg-[#fff6ea] px-4 pt-4 pb-3 text-[#28304a]">
|
||||||
<p className="m-0 text-[13px] font-extrabold opacity-75">단풍 지도 · {md(today)}</p>
|
<p className="m-0 text-[13px] font-extrabold opacity-75">단풍 지도 · {md(today)}</p>
|
||||||
<p className="m-0 mt-1 font-jua text-[24px] leading-tight">{headline(spots)}</p>
|
<p className="m-0 mt-1 font-jua text-[24px] leading-tight">{headline(spots)}</p>
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ import { useMutation, useQueryClient } from '@tanstack/react-query'
|
|||||||
import { likePostMutation, unlikePostMutation } from '../api/client/@tanstack/react-query.gen'
|
import { likePostMutation, unlikePostMutation } from '../api/client/@tanstack/react-query.gen'
|
||||||
import type { PostReaction, ResFeed } from '../api/client/types.gen'
|
import type { PostReaction, ResFeed } from '../api/client/types.gen'
|
||||||
|
|
||||||
export type PinnedKey = 'hero_post' | 'gak_post'
|
export type PinnedKey = 'hero_post' | 'gak_post' | 'foliage_post' | 'events_post' | 'season_post'
|
||||||
|
|
||||||
/** 히어로·오늘의 각처럼 포스트 틀이 아닌 카드의 좋아요. 화면을 먼저 바꾸고 실패하면 되돌린다 */
|
/** 히어로·오늘의 각·단풍 지도·띠처럼 포스트 틀이 아닌 카드의 좋아요. 화면을 먼저 바꾸고 실패하면 되돌린다 */
|
||||||
export function usePinnedLike(key: PinnedKey, r?: PostReaction | null) {
|
export function usePinnedLike(key: PinnedKey, r?: PostReaction | null) {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const like = useMutation(likePostMutation())
|
const like = useMutation(likePostMutation())
|
||||||
|
|||||||
Reference in new issue
Block a user