feat: 10/21 회의 반영 — 공유 링크·로그인 없이 댓글·구글 로그인만, 히어로·오늘의 각 좋아요·댓글, 히어로 오늘/내일 스위치, 단풍 지도 65곳·3단계
- 공유: 이미지와 함께 고정 URL을 넘기고 링크도 클립보드에 복사 - 로그인 창은 구글만, 댓글은 로그인 없이 '동네 익명'(링크·전화번호 막기, IP당 하루 20개, 같은 IP만 지우기) - 히어로·오늘의 각 카드에 좋아요·댓글 (PostType HERO·TODAY_GAK) - 히어로 오늘/내일 스위치: 내일 구간별 날씨 점수·기온·최저최고·습도·1위 각, /v1/weather/today?day=tomorrow - 단풍 지도: 단풍 그림 지도, 단풍 전·첫 단풍·절정, 단풍잎·은행잎, 명소 65곳(산림청 예측 + 가까운 지점 날짜) - 하단 탭 바 불투명 (홈 바 자리로 글이 비치지 않게) - 사람 글 동네 우선 정렬·내 글 목록, 내 각 '있는 각에서 불러오기' - 댓글 표 user_id NULL 허용·ip_hash·region_name (운영 DB ALTER 필요)
This commit is contained in:
1 parent
14f24d1ab0
commit
93e041bb91
46 files changed
+1820
-337
No files matched your search
+37
-3
@@ -1,12 +1,13 @@
|
||||
import { useEffect, useRef, useState, type CSSProperties, type MouseEvent, type ReactNode, type RefObject } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { PostType, SlotTone, type GakSlide, type HoursSlide, type PlanSlide, type PostData, type ResFeed, type RowsSlide, type SunsetSlide, type WeekSlide } from '../api/client/types.gen'
|
||||
import { PostType, SlotTone, type GakSlide, type HoursSlide, type PlanSlide, type PostData, type PostReaction, type ResFeed, type RowsSlide, type SunsetSlide, type WeekSlide } from '../api/client/types.gen'
|
||||
import { cx } from '../lib/utils'
|
||||
import { cardBg, clockShort, fall } from './lib'
|
||||
import type { SlideBg } from './types'
|
||||
import { deg } from './weatherText'
|
||||
import { useMutation, useQueryClient, type QueryClient } from '@tanstack/react-query'
|
||||
import { likePostMutation, unlikePostMutation } from '../api/client/@tanstack/react-query.gen'
|
||||
import { usePinnedLike, type PinnedKey } from './pinnedLike'
|
||||
import { useSheet } from './sheetContext'
|
||||
import { CommentIcon, HeartIcon, SendIcon } from './svg'
|
||||
import { useCarousel } from './carousel'
|
||||
@@ -28,6 +29,8 @@ const ACCOUNTS: Record<PostType, readonly [string, string]> = {
|
||||
[PostType.DAY_TRIP]: ['당일치기', 'picnic'],
|
||||
[PostType.MOON]: ['오늘 밤 달', 'moon'],
|
||||
[PostType.UV]: ['자외선', 'glasses'],
|
||||
[PostType.HERO]: ['오늘 날씨', 'sun'],
|
||||
[PostType.TODAY_GAK]: ['오늘의 각', 'rabbit'],
|
||||
}
|
||||
|
||||
type Slide = HoursSlide | RowsSlide | GakSlide | SunsetSlide | WeekSlide | PlanSlide
|
||||
@@ -478,12 +481,23 @@ function FullCard({ post }: PostProps) {
|
||||
)
|
||||
}
|
||||
|
||||
type FrameProps = { title: string; account: string; avatar: string; caption?: ReactNode; more?: ReactNode; shot?: RefObject<HTMLDivElement | null>; children: ReactNode }
|
||||
type FrameProps = {
|
||||
title: string
|
||||
account: string
|
||||
avatar: string
|
||||
caption?: ReactNode
|
||||
more?: ReactNode
|
||||
shot?: RefObject<HTMLDivElement | null>
|
||||
pinned?: { key: PinnedKey; post?: PostReaction | null }
|
||||
children: ReactNode
|
||||
}
|
||||
|
||||
/** 피드 글과 같은 틀(계정 줄·본문·보내기 줄)에 날씨·각 같은 화면 조각을 담는다. 보내기는 shot(공유용 틀)이 있으면 그것을, 없으면 본문을 이미지로 */
|
||||
export function PostFrame({ title, account, avatar, caption, more, shot, children }: FrameProps) {
|
||||
export function PostFrame({ title, account, avatar, caption, more, shot, pinned, children }: FrameProps) {
|
||||
const { open } = useSheet()
|
||||
const bodyRef = useRef<HTMLDivElement>(null)
|
||||
const like = usePinnedLike(pinned?.key ?? 'gak_post', pinned?.post)
|
||||
const postId = pinned?.post?.post_id
|
||||
const share = () => {
|
||||
const el = shot?.current ?? bodyRef.current
|
||||
if (el) open({ type: 'share', share: { title, slides: [el] } })
|
||||
@@ -503,17 +517,37 @@ export function PostFrame({ title, account, avatar, caption, more, shot, childre
|
||||
</div>
|
||||
<div ref={bodyRef}>{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 && (
|
||||
<>
|
||||
<button type="button" onClick={like.toggle} aria-pressed={like.liked} aria-label="좋아요" className={cx('relative grid size-7 cursor-pointer place-items-center', TAP44)}>
|
||||
<HeartIcon className={like.liked ? 'fill-(--heart) stroke-(--heart)' : 'fill-none stroke-(--ink)'} />
|
||||
</button>
|
||||
<button type="button" onClick={() => open({ type: 'comments', postId })} aria-label="댓글 보기" className={cx('relative grid size-7 cursor-pointer place-items-center', TAP44)}>
|
||||
<CommentIcon className="fill-none stroke-(--ink) [stroke-linejoin:round]" />
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
<button type="button" onClick={share} aria-label="보내기" className={cx('relative grid size-7 cursor-pointer place-items-center', TAP44)}>
|
||||
<SendIcon className="fill-none stroke-(--ink) [stroke-linecap:round] [stroke-linejoin:round]" />
|
||||
</button>
|
||||
{more && <span className="ml-auto text-[13px] font-bold text-(--ink2)">{more}</span>}
|
||||
</div>
|
||||
{postId != null && (
|
||||
<p className="px-3 py-0.5 text-sm font-extrabold">
|
||||
{like.failed ? <span className="text-(--heart)" role="alert">좋아요를 반영하지 못했어요. 다시 해 주세요.</span> : `좋아요 ${like.count.toLocaleString()}개`}
|
||||
</p>
|
||||
)}
|
||||
{caption && (
|
||||
<p className="px-3 pt-0.5 pb-3 text-sm">
|
||||
<b className="mr-[5px] font-extrabold">날씨각</b>
|
||||
{caption}
|
||||
</p>
|
||||
)}
|
||||
{postId != null && (
|
||||
<button type="button" onClick={() => open({ type: 'comments', postId })} className="block cursor-pointer px-3 pb-3 text-sm font-semibold text-(--ink3)">
|
||||
{pinned?.post?.comment_count ? `댓글 ${pinned.post.comment_count}개 모두 보기` : '첫 댓글 남기기'}
|
||||
</button>
|
||||
)}
|
||||
</article>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user