feat: 내 각 아이콘·상세, 이야기 내 글·무한 스크롤, 공유 이미지 얇은 띠, 행사 주소 수집
- 내 각: 아이콘 고르기(my_gak.icon), 카드는 아이콘·점수·아쉬운 조건만, 눌러서 상세(시간대·조건별 점수), 공유는 공통 공유 창 - 이야기: 오늘 쓴 내 글 묶음, '내 글' 칩·탭, 무한 스크롤, 사진 카메라 버튼, 지우기 확인, ⋯ 메뉴 하트 옆, 글 시간 서버 계산(1일 전) - 공유 이미지: 1:1·4:5 는 아래 얇은 띠 한 줄로 카드를 크게 - 행사: 수집 때 주소 저장(event.address), 행사 포스트에 장소·주소·기간 - 히어로 말풍선 '오늘 낮은 / 내일 낮은', 내일을 볼 때 배경도 따라감, 달 보름 순간이 낮이면 뜨는 시각으로 - 단풍 지도 피드 맨 위, 행사·계절 띠 포스트 틀 되돌림, 쇼츠 홈 버튼 가림·닫기 버튼, 하단 여백, 회색 글자 대비 - 토스 앱에선 쇼츠 플레이어를 하나만 띄움
This commit is contained in:
1 parent
3a249c509d
commit
ffe6153148
35 files changed
+566
-185
No files matched your search
@@ -264,7 +264,7 @@ function Shell() {
|
||||
{/* 위·아래 바: 띠는 화면 끝까지, 내용은 가운데 440px 안 */}
|
||||
<div className="b-topbg fixed inset-x-0 top-0 z-[19] h-[calc(54px+env(safe-area-inset-top,0px))] backdrop-blur-md" aria-hidden="true" />
|
||||
<div className="fixed inset-x-0 top-0 z-[19] h-[env(safe-area-inset-top,0px)] transition-colors duration-1400" style={{ backgroundColor: NOTCH_BG[kind] }} aria-hidden="true" />
|
||||
<div className="relative mx-auto min-h-dvh max-w-[440px] overflow-x-clip pb-[calc(70px+env(safe-area-inset-bottom,0px))]">
|
||||
<div className="relative mx-auto min-h-dvh max-w-[440px] overflow-x-clip pb-[calc(104px+env(safe-area-inset-bottom,0px))]">
|
||||
<TopBar />
|
||||
<main className="relative z-[1]">
|
||||
<Outlet />
|
||||
|
||||
@@ -35,7 +35,7 @@ import { GoogleButton } from './googleLogin'
|
||||
import { useInstall, useInstallable } from './install'
|
||||
import { InstallSheet } from './installBanner'
|
||||
import { ARTICLE_CAT, SHEET_CLOSE_MS, SHEET_OPEN_MS } from './lib'
|
||||
import { MixSheet } from './myGak'
|
||||
import { MixSheet, MyGakSheet } from './myGak'
|
||||
import { ownPage, useRegion } from './regionContext'
|
||||
import { WeatherWhySheet } from './weatherWhy'
|
||||
import { useSky } from './skyContext'
|
||||
@@ -133,7 +133,7 @@ function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void
|
||||
}, [isOpen])
|
||||
|
||||
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]
|
||||
const title = !shown ? '' : shown.type === 'gak' ? gakTitle : shown.type === 'article' ? articleTitle || TITLES.article : shown.type === 'mix' ? (shown.shared ? '받은 각' : '내 각 만들기') : shown.type === 'myGak' ? '내 각' : TITLES[shown.type]
|
||||
|
||||
return (
|
||||
<dialog
|
||||
@@ -169,6 +169,7 @@ function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void
|
||||
{shown.type === 'me' && <MeSheet onDone={onClose} />}
|
||||
{shown.type === 'region' && <RegionSheet onDone={onClose} />}
|
||||
{shown.type === 'mix' && <MixSheet shared={shown.shared} onDone={onClose} />}
|
||||
{shown.type === 'myGak' && <MyGakSheet gak={shown.gak} shot={shown.shot} onDone={onClose} />}
|
||||
{shown.type === 'install' && <InstallSheet />}
|
||||
{shown.type === 'weatherWhy' && <WeatherWhySheet d={shown.why} />}
|
||||
{shown.type === 'talk' && <TalkSheet talk={shown.talk} />}
|
||||
@@ -560,6 +561,7 @@ function ShareSheet({ share }: { share: SharePayload }) {
|
||||
const [toast, setToast] = useState('')
|
||||
const image = images[size]
|
||||
const text = `${share.title} · 날씨각`
|
||||
const url = share.url ?? SITE_URL
|
||||
|
||||
// 고른 크기의 이미지를 미리 만들어 둔다. 누를 때 만들면 아이폰이 공유창을 막는다
|
||||
useEffect(() => {
|
||||
@@ -605,15 +607,15 @@ function ShareSheet({ share }: { share: SharePayload }) {
|
||||
)
|
||||
return
|
||||
}
|
||||
if (navigator.canShare?.({ files: [file], text, url: SITE_URL })) {
|
||||
const copied = navigator.clipboard?.writeText(SITE_URL).then(
|
||||
if (navigator.canShare?.({ files: [file], text, url })) {
|
||||
const copied = navigator.clipboard?.writeText(url).then(
|
||||
() => true,
|
||||
(e: unknown) => {
|
||||
console.error('[share] copy link', e)
|
||||
return false
|
||||
},
|
||||
)
|
||||
navigator.share({ files: [file], title: share.title, text, url: SITE_URL }).then(
|
||||
navigator.share({ files: [file], title: share.title, text, url }).then(
|
||||
async () => {
|
||||
setToast((await copied) ? '보냈어요. 링크도 복사해 뒀어요' : '보냈어요')
|
||||
track('share', { content_type: 'image', item_id: share.title, method: 'share_sheet', ratio: SHARE_SIZES[size].ratio })
|
||||
@@ -635,7 +637,7 @@ function ShareSheet({ share }: { share: SharePayload }) {
|
||||
setToast('이미지를 내려받았어요')
|
||||
return
|
||||
}
|
||||
navigator.clipboard.writeText(`${text} ${SITE_URL}`).then(
|
||||
navigator.clipboard.writeText(`${text} ${url}`).then(
|
||||
() => setToast('이미지를 내려받고 링크를 복사했어요'),
|
||||
() => setToast('이미지를 내려받았어요. 링크 복사는 막혀 있어요'),
|
||||
)
|
||||
|
||||
@@ -3,7 +3,9 @@ import { type CSSProperties, type PointerEvent as ReactPointerEvent, useEffect,
|
||||
import { Link, useNavigate, useParams } from 'react-router'
|
||||
import { listShortsOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
|
||||
import type { ShortItem } from '@nalssigak/shared/api/client'
|
||||
import { IS_TOSS } from '../lib/platform'
|
||||
import { cx } from '../lib/utils'
|
||||
import { CloseIcon } from './svg'
|
||||
import { Rail, Skel, SkelRail, TAP44 } from './ui'
|
||||
|
||||
// 유튜브는 플레이어가 200×200 이상이어야 해서, 카드 안 미리보기는 200px 너비로 띄우고 줄여 보인다.
|
||||
@@ -15,13 +17,18 @@ const SCALE = (CARD_W / PLAYER_W) * 1.4
|
||||
// 쇼츠 페이지의 영상 칸: 위 헤더(54px)·버튼 줄(48px)과 아래 탭 바(--shorts-tab) 사이 높이와 화면 너비 안에 9:16으로 맞춘다
|
||||
const FIT = { width: 'min(100vw, calc((100dvh - env(safe-area-inset-top, 0px) - 54px - 48px - var(--shorts-tab, 0px)) * 9 / 16))', aspectRatio: '9 / 16' }
|
||||
|
||||
/** 아래 탭 바 높이 (기기마다 안전 영역이 달라 실제로 잰다) */
|
||||
/** 아래 탭 바가 가리는 높이: 탭 바 위로 솟은 가운데 홈 동그라미까지 (기기마다 안전 영역이 달라 실제로 잰다) */
|
||||
function useTabBarHeight() {
|
||||
const [h, setH] = useState(0)
|
||||
useLayoutEffect(() => {
|
||||
const nav = document.querySelector<HTMLElement>('nav.b-tabbar')
|
||||
if (!nav) return
|
||||
const ro = new ResizeObserver(() => setH(nav.offsetHeight))
|
||||
const measure = () => {
|
||||
const bar = nav.getBoundingClientRect()
|
||||
const bump = nav.querySelector('.b-tab-main > *')?.getBoundingClientRect().top ?? bar.top
|
||||
setH(Math.round(bar.bottom - Math.min(bar.top, bump)))
|
||||
}
|
||||
const ro = new ResizeObserver(measure)
|
||||
ro.observe(nav)
|
||||
return () => ro.disconnect()
|
||||
}, [])
|
||||
@@ -85,7 +92,8 @@ export function ShortsRail() {
|
||||
<section ref={ref} aria-label="날씨각 쇼츠">
|
||||
<Rail label="쇼츠 목록">
|
||||
{items.map((s, i) => (
|
||||
<ShortCard key={s.id} s={s} playing={i === 0 && visible} />
|
||||
// 토스 앱 웹뷰는 유튜브 플레이어가 무거워, 줄에선 표지만 보이고 누르면 재생
|
||||
<ShortCard key={s.id} s={s} playing={!IS_TOSS && i === 0 && visible} />
|
||||
))}
|
||||
</Rail>
|
||||
</section>
|
||||
@@ -282,8 +290,9 @@ function ShortsViewer({ items, start, onClose, onAt }: { items: ShortItem[]; sta
|
||||
/>
|
||||
<div className="absolute inset-0 bg-black/35" aria-hidden="true" />
|
||||
<div className="relative mx-auto flex h-12 w-full max-w-[440px] shrink-0 items-center justify-between px-3">
|
||||
<button type="button" onClick={onClose} aria-label="닫기" className={cx('relative grid size-9 cursor-pointer place-items-center rounded-full bg-white/15 text-xl text-white', TAP44)}>
|
||||
×
|
||||
{/* 글자 '×'는 글꼴마다 아래로 처져 그림으로 */}
|
||||
<button type="button" onClick={onClose} aria-label="닫기" className={cx('relative grid size-9 cursor-pointer place-items-center rounded-full bg-white/15 text-white', TAP44)}>
|
||||
<CloseIcon className="size-[18px]" />
|
||||
</button>
|
||||
<button type="button" onClick={toggleSound} aria-pressed={sound} className="h-9 cursor-pointer rounded-full bg-white/15 px-3.5 text-[13px] font-bold text-white">
|
||||
{sound ? '소리 끄기' : '소리 켜기'}
|
||||
@@ -294,7 +303,8 @@ function ShortsViewer({ items, start, onClose, onAt }: { items: ShortItem[]; sta
|
||||
<div key={s.id} data-i={i} className="relative grid h-full snap-start place-items-center">
|
||||
<div className="relative" style={FIT}>
|
||||
<img src={`https://i.ytimg.com/vi/${s.id}/hqdefault.jpg`} alt="" className="absolute inset-0 size-full object-cover" />
|
||||
{Math.abs(i - at) <= 1 && (
|
||||
{/* 웹은 앞뒤 영상까지 미리 띄워 넘길 때 깜빡이지 않게, 토스 앱은 무거워 지금 영상 하나만 */}
|
||||
{(IS_TOSS ? i === at : Math.abs(i - at) <= 1) && (
|
||||
<iframe
|
||||
ref={(f) => {
|
||||
if (f) frames.current.set(i, f)
|
||||
@@ -314,7 +324,7 @@ function ShortsViewer({ items, start, onClose, onAt }: { items: ShortItem[]; sta
|
||||
return next
|
||||
})
|
||||
}}
|
||||
className={cx('absolute inset-0 size-full border-0 transition-opacity duration-200', !ready.has(i) && 'opacity-0')}
|
||||
className={cx('absolute inset-0 size-full border-0 transition-opacity duration-200', !IS_TOSS && !ready.has(i) && 'opacity-0')}
|
||||
/>
|
||||
)}
|
||||
<div
|
||||
|
||||
+58
-26
@@ -1,44 +1,76 @@
|
||||
import { useEffect, useEffectEvent, useRef } from 'react'
|
||||
import { useSearchParams } from 'react-router'
|
||||
import type { TalkTopic } from '@nalssigak/shared/api/client/types.gen'
|
||||
import { cx } from '../lib/utils'
|
||||
import { TalkCard } from './talk'
|
||||
import { TOPICS, useTopicTalks } from './talkState'
|
||||
import { Sec } from './ui'
|
||||
import { useAuth } from './authContext'
|
||||
import { useSheet } from './sheetContext'
|
||||
import { FeedComposer, TalkCard } from './talk'
|
||||
import { TOPICS, useMyTalks, useTopicTalks } from './talkState'
|
||||
import { Rail, Sec } from './ui'
|
||||
|
||||
/** 주제별 사람 글: 위 주제 탭, 아래 글 목록. 피드 묶음의 '전체 보기'가 ?topic= 으로 연다 */
|
||||
type Tab = TalkTopic | 'all' | 'mine'
|
||||
|
||||
/** 목록 끝이 화면 아래 600px 안에 들어오면 다음 쪽을 받는다 (글이 많아도 버튼 없이 이어서) */
|
||||
function MoreOnScroll({ onMore }: { onMore: () => void }) {
|
||||
const ref = useRef<HTMLDivElement>(null)
|
||||
const more = useEffectEvent(onMore)
|
||||
useEffect(() => {
|
||||
const el = ref.current
|
||||
if (!el) return
|
||||
const io = new IntersectionObserver(([e]) => e.isIntersecting && more(), { rootMargin: '0px 0px 600px 0px' })
|
||||
io.observe(el)
|
||||
return () => io.disconnect()
|
||||
}, [])
|
||||
return <div ref={ref} className="h-px" aria-hidden="true" />
|
||||
}
|
||||
|
||||
/** 주제별 사람 글: 위 주제 탭(한 줄 가로로 밀기, 끝에 '내 글'), 아래 글 목록. 피드 묶음의 '전체 보기'가 ?topic= · ?mine=1 로 연다 */
|
||||
export function TalkPage() {
|
||||
const [params, setParams] = useSearchParams()
|
||||
const { loggedIn } = useAuth()
|
||||
const { open } = useSheet()
|
||||
const raw = Number(params.get('topic'))
|
||||
const topic = TOPICS.some(([k]) => k === raw) ? (raw as TalkTopic) : undefined
|
||||
const { talks, loaded, more, loadMore } = useTopicTalks(topic)
|
||||
const tabs: (readonly [TalkTopic | undefined, string])[] = [[undefined, '전체'], ...TOPICS]
|
||||
const tab: Tab = params.get('mine') ? 'mine' : TOPICS.some(([k]) => k === raw) ? (raw as TalkTopic) : 'all'
|
||||
const topicList = useTopicTalks(tab === 'all' || tab === 'mine' ? undefined : tab)
|
||||
const mineList = useMyTalks(tab === 'mine' && loggedIn)
|
||||
const { talks, loaded, more, loadMore } = tab === 'mine' ? mineList : topicList
|
||||
const tabs: (readonly [Tab, string])[] = [['all', '전체'], ...TOPICS, ['mine', '내 글']]
|
||||
const go = (k: Tab) => setParams(k === 'mine' ? { mine: '1' } : k === 'all' ? {} : { topic: String(k) }, { replace: true })
|
||||
|
||||
return (
|
||||
<section aria-label="동네 사람들 글">
|
||||
<Sec title="동네 사람들 글" sub="가까운 동네 글부터 보여요" />
|
||||
<div className="flex flex-wrap gap-1.5 px-4 pb-1" role="tablist" aria-label="글 주제">
|
||||
{tabs.map(([k, label]) => (
|
||||
<button
|
||||
key={label}
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={topic === k}
|
||||
onClick={() => setParams(k ? { topic: String(k) } : {}, { replace: true })}
|
||||
className={cx('cursor-pointer rounded-full px-3 py-1.5 text-[13px] font-extrabold', topic === k ? 'bg-(--ink) text-white' : 'bg-white text-(--ink2)')}
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
))}
|
||||
<div role="tablist" aria-label="글 주제">
|
||||
<Rail className="gap-1.5 pt-0">
|
||||
{tabs.map(([k, label]) => (
|
||||
<button
|
||||
key={label}
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={tab === k}
|
||||
onClick={() => go(k)}
|
||||
className={cx('cursor-pointer rounded-full px-3 py-1.5 text-[13px] font-extrabold whitespace-nowrap', tab === k ? 'bg-(--ink) text-white' : 'bg-white text-(--ink2)')}
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
))}
|
||||
</Rail>
|
||||
</div>
|
||||
{loaded && !talks.length && <p className="mx-4 mt-6 text-center text-[14px] font-semibold text-(--ink3)">아직 이 주제 글이 없어요. 오늘 탭에서 첫 글을 써 주세요.</p>}
|
||||
<FeedComposer />
|
||||
{tab === 'mine' && !loggedIn ? (
|
||||
<p className="mx-4 mt-6 text-center text-[14px] font-semibold text-(--ink3)">
|
||||
로그인하면 내가 쓴 글을 모아 볼 수 있어요.{' '}
|
||||
<button type="button" onClick={() => open({ type: 'login' })} className="cursor-pointer font-extrabold text-(--orange)">
|
||||
로그인
|
||||
</button>
|
||||
</p>
|
||||
) : (
|
||||
loaded && !talks.length && <p className="mx-4 mt-6 text-center text-[14px] font-semibold text-(--ink3)">{tab === 'mine' ? '아직 쓴 글이 없어요. 위 칸에서 첫 글을 써 주세요.' : '아직 이 주제 글이 없어요. 위 칸에서 첫 글을 써 주세요.'}</p>
|
||||
)}
|
||||
{talks.map((t) => (
|
||||
<TalkCard key={`${t.talk_id}:${t.liked}:${t.like_count}`} t={t} />
|
||||
))}
|
||||
{more && (
|
||||
<button type="button" onClick={() => loadMore()} className="mx-3 mt-3 w-[calc(100%-1.5rem)] cursor-pointer rounded-[14px] bg-white py-2.5 text-[13.5px] font-extrabold text-(--ink2)">
|
||||
더 보기
|
||||
</button>
|
||||
)}
|
||||
{more && <MoreOnScroll onMore={() => loadMore()} />}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
@@ -12,23 +12,23 @@ import {
|
||||
type Hero as HeroData,
|
||||
type PostReaction,
|
||||
type ResWeatherToday,
|
||||
type TalkData,
|
||||
type TopIndex,
|
||||
type WeatherSlot,
|
||||
} from '@nalssigak/shared/api/client/types.gen'
|
||||
import { cx } from '../lib/utils'
|
||||
import { cardBg, kindOfHour, kst, type Load, loadOf, MEDALS, type TimeKind, WEEKDAYS } from '@nalssigak/shared/lib'
|
||||
import { fall } from './lib'
|
||||
import { useAuth } from './authContext'
|
||||
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'
|
||||
import { usePinnedLike, type PinnedKey } from './pinnedLike'
|
||||
import { usePinnedLike } from './pinnedLike'
|
||||
import { ShortsRail } from './Shorts'
|
||||
import { FeedComposer, NearTalks, TalkCard, TalkGroup } from './talk'
|
||||
import { topicName, useTalkGroups } from './talkState'
|
||||
import { FeedComposer, NearTalks, TalkGroup } from './talk'
|
||||
import { topicName, useTalkGroups, useTodayMyTalks } from './talkState'
|
||||
import { useRegion } from './regionContext'
|
||||
import { useSheet } from './sheetContext'
|
||||
import { useSky } from './skyContext'
|
||||
@@ -211,6 +211,10 @@ function Hero({ hero, post, today, ranked, all, feedLoad, todayLoad }: HeroProps
|
||||
const kind = mode === 'now' ? nowKind : mode
|
||||
// 화면 전체 하늘 배경도 같은 시간대로 맞춘다
|
||||
useEffect(() => setServerKind(hero?.sky_mode ?? null), [hero?.sky_mode, setServerKind])
|
||||
// 내일을 볼 땐 배경·글자색도 내일 고른 칸을 따른다 (오늘 밤을 고른 채 내일 낮을 보면 낮 하늘에 흰 글자가 되던 것)
|
||||
useEffect(() => {
|
||||
if (tmr) setPreview(tmrKind)
|
||||
}, [tmr, tmrKind, setPreview])
|
||||
const slots = (tmr ? tomorrowQ.data?.slots : today?.slots) ?? []
|
||||
const slotsLoad = tmr ? loadOf(tomorrowQ) : todayLoad
|
||||
// 그 시각 칸, 비어 있으면(지난 새벽 칸 등) 그 뒤 첫 예보 칸
|
||||
@@ -243,13 +247,14 @@ function Hero({ hero, post, today, ranked, all, feedLoad, todayLoad }: HeroProps
|
||||
waning: WANING.includes(hero.moon_name),
|
||||
}
|
||||
: null
|
||||
// 말풍선 머리말은 칸 이름 그대로: 지금은 / 아침은 / 낮은 / 저녁은 / 밤은
|
||||
const when = mode === 'now' || mode === nowKind ? '지금' : PREVIEW[mode].label
|
||||
// 말풍선 머리말: 지금은 / 오늘 낮은 / 내일은 / 내일 낮은 (어느 날 어느 칸인지 같이)
|
||||
const when = mode === 'now' || mode === nowKind ? '지금' : `오늘 ${PREVIEW[mode].label}`
|
||||
const tmrWhen = mode === 'now' ? '내일' : `내일 ${PREVIEW[mode].label}`
|
||||
const bubble = tmr
|
||||
? top1
|
||||
? top1.score >= 70
|
||||
? `내일은 ${top1.name}!`
|
||||
: '내일은 쉬어 가요'
|
||||
? `${tmrWhen}은 ${top1.name}!`
|
||||
: `${tmrWhen}은 쉬어 가요`
|
||||
: null
|
||||
: slotTop
|
||||
? slotTop.score >= 70
|
||||
@@ -326,7 +331,11 @@ function Hero({ hero, post, today, ranked, all, feedLoad, todayLoad }: HeroProps
|
||||
type="button"
|
||||
role="radio"
|
||||
aria-checked={tmr === v}
|
||||
onClick={() => setTmr(v)}
|
||||
onClick={() => {
|
||||
// 내일로 넘어갈 땐 지금 보던 시간대 그대로 시작해 배경이 튀지 않게
|
||||
if (v && !tmr) setTmrKind(kind)
|
||||
setTmr(v)
|
||||
}}
|
||||
className={cx('cursor-pointer rounded-full px-2.5 py-0.5 font-jua text-[13px]', tmr === v ? 'b-strip-on text-(--orange-deep)' : 'opacity-75')}
|
||||
>
|
||||
{l}
|
||||
@@ -516,21 +525,18 @@ function PostsSkel() {
|
||||
)
|
||||
}
|
||||
|
||||
/** 띠도 포스트 틀에 담아 좋아요·댓글·보내기를 단다 (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 }) {
|
||||
function Band({ tone, title, sub, to, children }: { tone: 1 | 2 | 3; title: string; sub: string; to: string; children: ReactNode }) {
|
||||
return (
|
||||
<PostFrame title={title} account={title} avatar={avatar} pinned={{ key: pinKey, post }}>
|
||||
<section className={cx('pt-4 pb-3.5', `b-band-${tone}`)} aria-label={title}>
|
||||
<Sec title={title} sub={sub} more={{ to }} className="pt-0" />
|
||||
{children}
|
||||
</section>
|
||||
</PostFrame>
|
||||
<section className={cx('mt-3.5 pt-4 pb-3.5', `b-band-${tone}`)} aria-label={title}>
|
||||
<Sec title={title} sub={sub} more={{ to }} className="pt-0" />
|
||||
{children}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
function EventsBand({ events, post }: { events: BandEvent[]; post?: PostReaction | null }) {
|
||||
function EventsBand({ events }: { events: BandEvent[] }) {
|
||||
return (
|
||||
<Band tone={1} title="이번 주 가까운 행사" sub="30km 안 · 날씨까지 같이 보고 골라요" to="/week" avatar="fireworks" post={post} pinKey="events_post">
|
||||
<Band tone={1} title="이번 주 가까운 행사" sub="30km 안 · 날씨까지 같이 보고 골라요" to="/week">
|
||||
<Rail>
|
||||
{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)]">
|
||||
@@ -547,10 +553,10 @@ function EventsBand({ events, post }: { events: BandEvent[]; post?: PostReaction
|
||||
)
|
||||
}
|
||||
|
||||
function SeasonBand({ news, post }: { news: BandArticle[]; post?: PostReaction | null }) {
|
||||
function SeasonBand({ news }: { news: BandArticle[] }) {
|
||||
const { open } = useSheet()
|
||||
return (
|
||||
<Band tone={3} title="이번 주 계절 이야기" sub="예년 이맘때의 소식" to="/season" avatar="fallen_leaf" post={post} pinKey="season_post">
|
||||
<Band tone={3} title="이번 주 계절 이야기" sub="예년 이맘때의 소식" to="/season">
|
||||
<Rail>
|
||||
{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)]">
|
||||
@@ -579,8 +585,9 @@ export function TodayPage() {
|
||||
const bands = f?.bands
|
||||
const nowAt = f?.hero?.now_at
|
||||
const load = loadOf(feed)
|
||||
const [mine, setMine] = useState<TalkData[]>([])
|
||||
// 사람 글은 묶음으로: '동네 사람들'은 오늘의 각 아래, 주제 묶음은 같은 주제 포스트 아래. 방금 올린 내 글은 글쓰기 칸 아래에 따로 있으니 빼고
|
||||
// 사람 글은 묶음으로: '동네 사람들'은 오늘의 각 아래, 주제 묶음은 같은 주제 포스트 아래. 오늘 쓴 내 글은 글쓰기 칸 아래 '오늘 내 글'에 따로 있으니 빼고
|
||||
const { loggedIn } = useAuth()
|
||||
const mine = useTodayMyTalks(loggedIn)
|
||||
const talkGroups = useTalkGroups()
|
||||
const groupOf = (topic: number) => (talkGroups.groups.get(topic) ?? []).filter((t) => !mine.some((m) => m.talk_id === t.talk_id))
|
||||
const group = (topic: number) => {
|
||||
@@ -610,12 +617,12 @@ export function TodayPage() {
|
||||
|
||||
// 디자인대로 3·6·9번째 글 뒤에 띠를 넣고, 글이 모자라면 남은 띠는 맨 뒤에 붙인다
|
||||
const bandAt: [number, ReactNode][] = [
|
||||
[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} post={f?.season_post} /> : null],
|
||||
[3, bands?.events?.length ? <EventsBand key="events" events={bands.events} /> : null],
|
||||
[9, bands?.season?.length ? <SeasonBand key="season" news={bands.season} /> : null],
|
||||
]
|
||||
|
||||
// 사람 글 묶음은 포스트 사이사이에 하나씩: 묶음·띠·단풍 카드가 이미 붙는 자리와 바로 앞 자리는 건너뛰어 가로 목록이 연달아 나오지 않게
|
||||
const spreadTopics = [TalkTopic.OUTFIT, ...(raining ? [] : [TalkTopic.RAIN]), ...(sunsetAt < 0 ? [TalkTopic.SKY] : []), ...(posts.length < 2 ? [TalkTopic.FOLIAGE] : [])].filter((tp) => groupOf(tp).length)
|
||||
const spreadTopics = [TalkTopic.OUTFIT, ...(raining ? [] : [TalkTopic.RAIN]), ...(sunsetAt < 0 ? [TalkTopic.SKY] : [])].filter((tp) => groupOf(tp).length)
|
||||
const taken = new Set([1, sunsetAt, ...bandAt.map(([at]) => at - 1)])
|
||||
const spreadAt = new Map<number, ReactNode>()
|
||||
let spreadN = 0
|
||||
@@ -629,11 +636,12 @@ export function TodayPage() {
|
||||
// 피드 칸은 전국 공통이라 지역이 바뀌어도 글 번호가 같다. 지역마다 새로 그려 넘긴 슬라이드·펼친 상태가 남지 않게 한다
|
||||
<section key={region.code} aria-label="오늘" aria-busy={load === 'loading'} className={cx('transition-opacity', feed.isPlaceholderData && 'opacity-60')}>
|
||||
<Hero hero={f?.hero} post={f?.hero_post} today={today.data} ranked={stories} all={f?.stories ?? []} feedLoad={load} todayLoad={loadOf(today)} />
|
||||
{/* 단풍철엔 단풍 지도를 피드 맨 위에, 단풍 이야기 묶음은 바로 아래 */}
|
||||
<FoliageCard />
|
||||
{group(TalkTopic.FOLIAGE)}
|
||||
<ShortsRail />
|
||||
<FeedComposer onPosted={(t) => setMine((m) => [t, ...m])} />
|
||||
{mine.map((t) => (
|
||||
<TalkCard key={t.talk_id} t={t} onGone={() => setMine((m) => m.filter((x) => x.talk_id !== t.talk_id))} />
|
||||
))}
|
||||
<FeedComposer />
|
||||
{mine.length > 0 && <TalkGroup title="오늘 내 글" talks={mine} href="/talk?mine=1" />}
|
||||
{raining && group(TalkTopic.RAIN)}
|
||||
<MyGakRow />
|
||||
{/* 실패 안내는 여기 한 번만, 각 카드 스켈레톤과 같은 크기로 */}
|
||||
@@ -656,8 +664,6 @@ export function TodayPage() {
|
||||
<Fragment key={p.post_id}>
|
||||
<PostCard post={p} />
|
||||
{i === sunsetAt && group(TalkTopic.SKY)}
|
||||
{i === 1 && <FoliageCard post={f?.foliage_post} />}
|
||||
{i === 1 && group(TalkTopic.FOLIAGE)}
|
||||
{bandAt.find(([at]) => at === i + 1)?.[1]}
|
||||
{spreadAt.get(i)}
|
||||
</Fragment>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
.b-app {
|
||||
--ink: #28304a;
|
||||
--ink2: #5a6380;
|
||||
--ink3: #8a92aa;
|
||||
--ink3: #6b738c;
|
||||
--line: #e6ecf4;
|
||||
--page: #f7fbff;
|
||||
--outer: #dfeaf6;
|
||||
@@ -690,7 +690,7 @@ html.b-sheet-open .b-app :is(.b-fall, .b-bob, .b-blob, .b-skystars i, .b-shoot,
|
||||
.b-app[data-t='night'] .b-day {
|
||||
--ink: #28304a;
|
||||
--ink2: #5a6380;
|
||||
--ink3: #8a92aa;
|
||||
--ink3: #6b738c;
|
||||
--line: #e6ecf4;
|
||||
--shade: #d9e5f4;
|
||||
--orange: #ff7a45;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useLayoutEffect, useMemo, useRef, useState, type MouseEvent } from 'react'
|
||||
import { useNavigate } from 'react-router'
|
||||
import { cx } from '../lib/utils'
|
||||
import type { PostReaction } from '@nalssigak/shared/api/client/types.gen'
|
||||
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 { PostFrame } from './Post'
|
||||
@@ -14,7 +13,7 @@ const TAP_R = 24
|
||||
const RANK_N = 7
|
||||
|
||||
/** 피드의 단풍 지도 카드: 1장은 지금 절정인 곳만 잎 아이콘으로(누르면 카드 안에 정보), 2장은 지금 가기 좋은 순위. '지도 크게 보기'로 단풍 지도 페이지 */
|
||||
export function FoliageCard({ post }: { post?: PostReaction | null }) {
|
||||
export function FoliageCard() {
|
||||
const navigate = useNavigate()
|
||||
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])
|
||||
@@ -56,7 +55,7 @@ export function FoliageCard({ post }: { post?: PostReaction | null }) {
|
||||
// 2번째 장: 지금 절정인 곳을 절정 예상일이 오늘과 가까운 순서로
|
||||
const ranked = rankNow(spots).slice(0, RANK_N)
|
||||
return (
|
||||
<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}>
|
||||
<PostFrame title="단풍 지도" account="단풍 지도" avatar="maple" 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]">
|
||||
<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>
|
||||
|
||||
+173
-37
@@ -1,7 +1,8 @@
|
||||
import { useState, type ReactNode } from 'react'
|
||||
import { useRef, useState, type ReactNode } from 'react'
|
||||
import type { MyGakPreset, MyGakRule, MyGakScore } from '@nalssigak/shared/api/client/types.gen'
|
||||
import { cx } from '../lib/utils'
|
||||
import { gakName, shareUrl, SLOTS, type MyGak, type Slot, useMyGak, useMyGakScores, usePresets } from './myGakState'
|
||||
import { gakName, MY_GAK_ICON, shareUrl, SLOTS, type MyGak, type Slot, useMyGak, useMyGakScores, usePresets } from './myGakState'
|
||||
import { MyGakShareCard } from './shareCards'
|
||||
import { useRegion } from './regionContext'
|
||||
import { useSheet } from './sheetContext'
|
||||
import { Ic, Rail, Sec } from './ui'
|
||||
@@ -27,55 +28,160 @@ function Reasons({ s }: { s?: MyGakScore }) {
|
||||
)
|
||||
}
|
||||
|
||||
/** 오늘 탭의 내 각 줄: 내가 정한 조건으로 매긴 오늘 점수 */
|
||||
// 조건 이름. 점수 응답의 factors 와 reasons 는 같은 순서다
|
||||
const AXIS_NAME: Record<string, string> = { temp: '기온', rain: '비', wind: '바람', air: '미세먼지', humidity: '습도' }
|
||||
// 조건 점수가 이보다 낮으면 '아쉬운 조건'으로 카드에 칩을 단다
|
||||
const SHORT = 70
|
||||
|
||||
/** 조건마다 이름·점수·실제 값 (실제 값은 근거 문구의 첫 마디: 체감 15°) */
|
||||
function conditions(s?: MyGakScore) {
|
||||
const notes = s?.reasons ?? []
|
||||
return Object.entries(s?.factors ?? {}).map(([axis, value], i) => ({ axis, label: AXIS_NAME[axis] ?? axis, value, note: notes[i] ?? '', short: (notes[i] ?? '').split(', ')[0] }))
|
||||
}
|
||||
|
||||
/** 오늘 탭의 내 각 줄: 카드엔 아이콘·이름·점수·아쉬운 조건만, 누르면 상세 창 */
|
||||
export function MyGakRow() {
|
||||
const { open } = useSheet()
|
||||
const { items, remove } = useMyGak()
|
||||
const { items } = useMyGak()
|
||||
const scores = useMyGakScores(items.map((g) => g.rule)).data?.scores ?? []
|
||||
const [copied, setCopied] = useState<number | null>(null)
|
||||
const send = (g: MyGak, i: number) => {
|
||||
const url = shareUrl(g)
|
||||
if (navigator.share) {
|
||||
navigator.share({ title: `${g.name} · 날씨각`, url }).catch((e: unknown) => {
|
||||
if (!(e instanceof DOMException && e.name === 'AbortError')) console.error('[myGak] share', e)
|
||||
})
|
||||
return
|
||||
}
|
||||
navigator.clipboard.writeText(url).then(
|
||||
() => setCopied(i),
|
||||
(e: unknown) => console.error('[myGak] copy', e),
|
||||
)
|
||||
}
|
||||
const shots = useRef<(HTMLDivElement | null)[]>([])
|
||||
return (
|
||||
<>
|
||||
<Sec title="내 각" sub="내가 정한 날씨 조건으로 오늘 점수를 매겨요" />
|
||||
<Rail label="내 각">
|
||||
{items.map((g, i) => (
|
||||
<div key={g.id ?? 'local'} className="flex w-[220px] flex-col gap-1.5 rounded-[22px] bg-white p-3 shadow-[inset_0_-5px_0_var(--shade)]">
|
||||
<div className="flex items-center gap-1">
|
||||
<b className="font-jua text-[17px] leading-tight font-normal">{g.name}</b>
|
||||
<Score s={scores[i]} />
|
||||
</div>
|
||||
<Reasons s={scores[i]} />
|
||||
<div className="mt-auto flex gap-1.5 pt-0.5">
|
||||
<button type="button" onClick={() => send(g, i)} className="cursor-pointer rounded-full bg-(--ink) px-3 py-1.5 text-[12.5px] font-extrabold text-white">
|
||||
{copied === i ? '링크 복사함' : '친구에게 보내기'}
|
||||
</button>
|
||||
<button type="button" onClick={() => remove(g)} className="cursor-pointer rounded-full bg-[#eef4fc] px-3 py-1.5 text-[12.5px] font-extrabold text-(--ink2)">
|
||||
지우기
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
{items.map((g, i) => {
|
||||
const s = scores[i]
|
||||
const miss = conditions(s).filter((c) => c.value < SHORT).slice(0, 2)
|
||||
return (
|
||||
<button
|
||||
key={g.id ?? 'local'}
|
||||
type="button"
|
||||
onClick={() => open({ type: 'myGak', gak: g, shot: shots.current[i] })}
|
||||
aria-label={`${g.name} ${s?.score ?? ''}점 자세히`}
|
||||
className="flex w-[200px] cursor-pointer flex-col gap-2 rounded-[22px] bg-white p-3 text-left shadow-[inset_0_-5px_0_var(--shade)]"
|
||||
>
|
||||
<span className="flex w-full items-start justify-between">
|
||||
<Ic name={g.icon ?? MY_GAK_ICON} className="size-10" />
|
||||
<Score s={s} big />
|
||||
</span>
|
||||
<span>
|
||||
<b className="block font-jua text-[17px] leading-tight font-normal">{g.name}</b>
|
||||
<small className="text-xs font-bold text-(--ink3)">{s?.slot ? `${SLOT_WORD[s.slot as Slot]} 기준` : '예보를 불러오는 중이에요'}</small>
|
||||
</span>
|
||||
{s?.slot && (
|
||||
<span className="flex flex-wrap gap-1 text-[11.5px] font-extrabold">
|
||||
{miss.length ? (
|
||||
miss.map((c) => (
|
||||
<span key={c.axis} className="rounded-full bg-[#ffe8dc] px-2 py-0.5 text-[#c2471b]">
|
||||
{c.short}
|
||||
</span>
|
||||
))
|
||||
) : (
|
||||
<span className="rounded-full bg-[#dff5ea] px-2 py-0.5 text-[#1f7a4f]">조건 다 맞아요</span>
|
||||
)}
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
<button type="button" onClick={() => open({ type: 'mix' })} className="flex w-[120px] cursor-pointer flex-col items-center justify-center gap-1 rounded-[22px] border-2 border-dashed border-(--line) p-3 font-jua text-[15px] text-(--ink2)">
|
||||
<span className="text-[26px] leading-none">+</span>
|
||||
내 각 만들기
|
||||
</button>
|
||||
</Rail>
|
||||
{items.map((g, i) => (
|
||||
<MyGakShareCard
|
||||
key={g.id ?? 'local'}
|
||||
name={g.name}
|
||||
icon={g.icon ?? MY_GAK_ICON}
|
||||
score={scores[i]?.score}
|
||||
slot={scores[i]?.slot ? SLOT_WORD[scores[i].slot as Slot] : undefined}
|
||||
rows={conditions(scores[i])}
|
||||
ref={(el) => {
|
||||
shots.current[i] = el
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
/** 내 각 상세: 시간대별 점수, 조건별 점수와 실제 값, 공유하기(다른 포스트와 같은 공유 창)·지우기 */
|
||||
export function MyGakSheet({ gak, shot, onDone }: { gak: MyGak; shot?: HTMLElement | null; onDone: () => void }) {
|
||||
const { open } = useSheet()
|
||||
const { remove } = useMyGak()
|
||||
const s = useMyGakScores([gak.rule]).data?.scores?.[0]
|
||||
const [confirm, setConfirm] = useState(false)
|
||||
const rows = conditions(s)
|
||||
return (
|
||||
<div className="flex-1 overflow-auto overscroll-contain px-4 pt-3.5 pb-[18px]">
|
||||
<div className="flex items-center gap-3">
|
||||
<Ic name={gak.icon ?? MY_GAK_ICON} className="size-14" />
|
||||
<span className="min-w-0 flex-1">
|
||||
<b className="block font-jua text-[22px] leading-tight font-normal">{gak.name}</b>
|
||||
<small className="text-[12.5px] font-bold text-(--ink3)">{s?.slot ? `${SLOT_WORD[s.slot as Slot]} 기준 점수` : '예보를 불러오는 중이에요'}</small>
|
||||
</span>
|
||||
<Score s={s} big />
|
||||
</div>
|
||||
<div className="mt-3 grid grid-cols-4 gap-1.5" aria-label="시간대별 점수">
|
||||
{SLOTS.map(([k, word]) => {
|
||||
const v = s?.slots?.[k]
|
||||
return (
|
||||
<div key={k} className={cx('rounded-2xl px-1 py-2 text-center', s?.slot === k ? 'bg-[#fff4ec]' : 'bg-[#f3f6fb]')}>
|
||||
<small className="block text-xs font-extrabold text-(--ink2)">{word}</small>
|
||||
<b className={cx('block font-bagel text-xl font-normal', v != null ? 'text-(--orange)' : 'text-(--ink3)')}>{v ?? '–'}</b>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
<div className="mt-3.5 flex flex-col gap-2.5">
|
||||
{rows.map((c) => (
|
||||
<div key={c.axis} className="grid grid-cols-[64px_1fr_32px] items-center gap-x-2.5 text-[13.5px] font-bold">
|
||||
<span>{c.label}</span>
|
||||
<i className="block h-[9px] overflow-hidden rounded-full bg-[#e3eaf4]">
|
||||
<s className="b-keep-bg block h-full bg-[linear-gradient(90deg,#ffc86e,var(--orange))]" style={{ width: `${c.value}%` }} />
|
||||
</i>
|
||||
<em className="text-right text-xs text-(--ink2) not-italic tabular-nums">{c.value}</em>
|
||||
<p className="col-start-2 col-end-4 m-0 -mt-0.5 text-[12.5px] font-semibold text-(--ink2)">{c.note}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<div className="mt-4 flex gap-2">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => open({ type: 'share', share: { title: gak.name, slides: shot ? [shot] : [], url: shareUrl(gak) } })}
|
||||
disabled={!shot}
|
||||
className="flex-1 cursor-pointer rounded-2xl bg-(--orange) py-3 font-jua text-[16px] text-white disabled:opacity-45"
|
||||
>
|
||||
공유하기
|
||||
</button>
|
||||
{confirm ? (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
remove(gak)
|
||||
onDone()
|
||||
}}
|
||||
className="cursor-pointer rounded-2xl bg-[#fdecec] px-4 py-3 font-jua text-[16px] text-(--heart)"
|
||||
>
|
||||
지우기
|
||||
</button>
|
||||
<button type="button" onClick={() => setConfirm(false)} className="cursor-pointer rounded-2xl bg-[#eef4fc] px-4 py-3 font-jua text-[16px] text-(--ink2)">
|
||||
취소
|
||||
</button>
|
||||
</>
|
||||
) : (
|
||||
<button type="button" onClick={() => setConfirm(true)} className="cursor-pointer rounded-2xl bg-[#eef4fc] px-4 py-3 font-jua text-[16px] text-(--ink2)">
|
||||
지우기
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
{confirm && <p className="mt-1.5 mb-0 text-right text-[12.5px] font-bold text-(--ink2)">지울까요?</p>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function Row({ label, on, onToggle, children }: { label: string; on: boolean; onToggle: () => void; children: ReactNode }) {
|
||||
return (
|
||||
<div className={cx('flex min-h-[44px] flex-wrap items-center gap-2 border-b border-(--line) py-2', !on && 'opacity-60')}>
|
||||
@@ -124,6 +230,32 @@ type Cond = 'temp' | 'rain' | 'wind_max' | 'air' | 'humidity'
|
||||
|
||||
const condsOf = (r: MyGakRule): Record<Cond, boolean> => ({ temp: !!r.temp, rain: !!r.rain, wind_max: r.wind_max != null, air: !!r.air, humidity: !!r.humidity })
|
||||
|
||||
/** 내 각 아이콘 고르기: 있는 각 아이콘 그대로 */
|
||||
function IconPicker({ value, onPick }: { value: string; onPick: (icon: string) => void }) {
|
||||
const icons = [...new Set([MY_GAK_ICON, ...(usePresets().data ?? []).map((p) => p.icon)])]
|
||||
return (
|
||||
<div className="mt-3">
|
||||
<span className="font-jua text-[19px]">아이콘</span>
|
||||
<div className="-mx-4">
|
||||
<Rail label="아이콘" className="gap-1.5">
|
||||
{icons.map((icon) => (
|
||||
<button
|
||||
key={icon}
|
||||
type="button"
|
||||
aria-pressed={value === icon}
|
||||
aria-label={`아이콘 ${icon}`}
|
||||
onClick={() => onPick(icon)}
|
||||
className={cx('grid size-12 cursor-pointer place-items-center rounded-2xl', value === icon ? 'bg-(--orange) ring-2 ring-(--orange)' : 'bg-[#f3f6fb]')}
|
||||
>
|
||||
<Ic name={icon} className="size-8" />
|
||||
</button>
|
||||
))}
|
||||
</Rail>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** 있는 각을 골라 그 각 조건으로 채운다 */
|
||||
function PresetPicker({ picked, onPick }: { picked: string | null; onPick: (p: MyGakPreset) => void }) {
|
||||
const items = usePresets().data ?? []
|
||||
@@ -159,9 +291,11 @@ export function MixSheet({ shared, onDone }: { shared?: MyGak; onDone: () => voi
|
||||
const [vals, setVals] = useState({ ...DEFAULT_RULE, ...(shared?.rule ?? {}) } as typeof DEFAULT_RULE)
|
||||
const [on, setOn] = useState<Record<Cond, boolean>>(shared ? condsOf(shared.rule) : { temp: true, rain: true, wind_max: false, air: false, humidity: false })
|
||||
const [picked, setPicked] = useState<string | null>(null)
|
||||
const [icon, setIcon] = useState(shared?.icon ?? MY_GAK_ICON)
|
||||
const pick = (p: MyGakPreset) => {
|
||||
setPicked(p.code)
|
||||
setName(p.name)
|
||||
setIcon(p.icon)
|
||||
setVals({ ...DEFAULT_RULE, ...p.rule } as typeof DEFAULT_RULE)
|
||||
setOn(condsOf(p.rule))
|
||||
}
|
||||
@@ -184,6 +318,7 @@ export function MixSheet({ shared, onDone }: { shared?: MyGak; onDone: () => voi
|
||||
<span className="font-jua text-[19px]">이름</span>
|
||||
<input value={name} onChange={(e) => setName(e.target.value)} maxLength={11} placeholder="소맥, 야독, 새우깡" className="mt-1.5 w-full rounded-2xl bg-[#f3f6fb] px-3.5 py-2.5 text-[15px]" />
|
||||
</label>
|
||||
<IconPicker value={icon} onPick={setIcon} />
|
||||
</>
|
||||
)}
|
||||
<fieldset disabled={!!shared} className="m-0 mt-3 border-0 p-0">
|
||||
@@ -215,7 +350,8 @@ export function MixSheet({ shared, onDone }: { shared?: MyGak; onDone: () => voi
|
||||
</div>
|
||||
</fieldset>
|
||||
<div className="mt-2 flex flex-col gap-1.5 rounded-[20px] bg-[#f3f6fb] p-3.5">
|
||||
<div className="flex items-center">
|
||||
<div className="flex items-center gap-2">
|
||||
<Ic name={icon} className="size-8" />
|
||||
<b className="font-jua text-[20px] font-normal">{title}</b>
|
||||
<Score s={valid ? score : undefined} big />
|
||||
</div>
|
||||
@@ -225,7 +361,7 @@ export function MixSheet({ shared, onDone }: { shared?: MyGak; onDone: () => voi
|
||||
<button
|
||||
type="button"
|
||||
disabled={!valid || !gakName(name) || pending}
|
||||
onClick={() => create({ name, rule }, onDone)}
|
||||
onClick={() => create({ name, icon, rule }, onDone)}
|
||||
className="mt-3.5 w-full cursor-pointer rounded-2xl bg-(--orange) py-3 font-jua text-[17px] text-white disabled:cursor-default disabled:opacity-45"
|
||||
>
|
||||
{shared ? '내 각으로 가져오기' : '내 각으로 저장'}
|
||||
|
||||
@@ -19,7 +19,10 @@ export const SLOTS: [Slot, string][] = [
|
||||
]
|
||||
|
||||
/** 내 각 하나. 로그인하지 않으면 이 기기에 하나만(id 없음) */
|
||||
export type MyGak = { id?: number; name: string; rule: MyGakRule }
|
||||
export type MyGak = { id?: number; name: string; icon?: string | null; rule: MyGakRule }
|
||||
|
||||
/** 아이콘을 안 골랐을 때 */
|
||||
export const MY_GAK_ICON = 'rabbit'
|
||||
|
||||
function readLocal(): MyGak | null {
|
||||
try {
|
||||
@@ -58,7 +61,7 @@ export const gakName = (name: string) => {
|
||||
|
||||
/** 받은 링크(/?my=...)에 이름과 조건을 그대로 담는다 */
|
||||
export function shareUrl(g: MyGak) {
|
||||
const json = JSON.stringify({ n: g.name, r: g.rule })
|
||||
const json = JSON.stringify({ n: g.name, i: g.icon ?? undefined, r: g.rule })
|
||||
const b64 = btoa(String.fromCharCode(...new TextEncoder().encode(json)))
|
||||
return `${SITE_URL}/?my=${b64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '')}`
|
||||
}
|
||||
@@ -66,8 +69,9 @@ export function shareUrl(g: MyGak) {
|
||||
export function fromShare(code: string): MyGak | null {
|
||||
try {
|
||||
const bin = atob(code.replace(/-/g, '+').replace(/_/g, '/'))
|
||||
const v = JSON.parse(new TextDecoder().decode(Uint8Array.from(bin, (c) => c.charCodeAt(0)))) as { n?: unknown; r?: unknown }
|
||||
return typeof v.n === 'string' && v.r && typeof v.r === 'object' ? { name: v.n, rule: v.r as MyGakRule } : null
|
||||
const v = JSON.parse(new TextDecoder().decode(Uint8Array.from(bin, (c) => c.charCodeAt(0)))) as { n?: unknown; i?: unknown; r?: unknown }
|
||||
const icon = typeof v.i === 'string' && /^[a-z_]{1,32}$/.test(v.i) ? v.i : null
|
||||
return typeof v.n === 'string' && v.r && typeof v.r === 'object' ? { name: v.n, icon, rule: v.r as MyGakRule } : null
|
||||
} catch (e) {
|
||||
console.warn('[myGak] 받은 링크를 읽지 못함', e)
|
||||
return null
|
||||
@@ -108,14 +112,14 @@ export function useMyGak() {
|
||||
const { mutate } = add
|
||||
useEffect(() => {
|
||||
if (!loggedIn || !saved) return
|
||||
mutate({ body: { name: saved.name, rule: saved.rule } }, { onSuccess: () => setLocal(null) })
|
||||
mutate({ body: { name: saved.name, icon: saved.icon, rule: saved.rule } }, { onSuccess: () => setLocal(null) })
|
||||
}, [loggedIn, saved, mutate])
|
||||
|
||||
const items: MyGak[] = loggedIn ? (q.data?.items ?? []).map((g) => ({ id: g.my_gak_id, name: g.name, rule: g.rule })) : saved ? [saved] : []
|
||||
const items: MyGak[] = loggedIn ? (q.data?.items ?? []).map((g) => ({ id: g.my_gak_id, name: g.name, icon: g.icon, rule: g.rule })) : saved ? [saved] : []
|
||||
|
||||
/** 로그인 없이 두 번째를 만들려 하면 로그인 창을 띄운다 */
|
||||
const create = (g: MyGak, onDone?: () => void) => {
|
||||
const item = { name: gakName(g.name), rule: g.rule }
|
||||
const item = { name: gakName(g.name), icon: g.icon, rule: g.rule }
|
||||
if (loggedIn) {
|
||||
add.mutate({ body: item }, { onSuccess: (res) => res.result?.success && onDone?.() })
|
||||
return
|
||||
|
||||
@@ -185,3 +185,32 @@ export function FoliageMapShare({ title, peak, ranked, ref }: { title: string; p
|
||||
</Offscreen>
|
||||
)
|
||||
}
|
||||
|
||||
/** 내 각 공유: 아이콘·이름·점수, 조건마다 막대와 실제 값. 로고·지역·날짜는 공유 틀이 그린다 */
|
||||
export function MyGakShareCard({ name, icon, score, slot, rows, ref }: { name: string; icon: string; score?: number | null; slot?: string; rows: { axis: string; label: string; value: number; note: string }[]; ref: Ref<HTMLDivElement> }) {
|
||||
return (
|
||||
<Offscreen>
|
||||
<div ref={ref} className="b-band-1 flex aspect-[4/5] flex-col bg-white px-5 pt-5 pb-4 text-[#28304a]">
|
||||
<p className="m-0 text-[13px] font-extrabold opacity-75">내 각{slot ? ` · ${slot} 기준` : ''}</p>
|
||||
<div className="mt-2 flex items-center gap-3">
|
||||
<Ic name={icon} className="w-[64px] shrink-0" />
|
||||
<b className="min-w-0 flex-1 font-jua text-[28px] leading-tight font-normal">{name}</b>
|
||||
<em className="font-bagel text-[52px] leading-none text-[#ff7a45] not-italic">{score ?? '–'}</em>
|
||||
</div>
|
||||
<ul className="m-0 mt-4 grid list-none gap-2.5 p-0">
|
||||
{rows.map((r) => (
|
||||
<li key={r.axis} className="rounded-[18px] bg-white px-3 py-2.5 shadow-[inset_0_-4px_0_#d9e5f4]">
|
||||
<span className="flex items-center gap-2 text-[14px] font-extrabold">
|
||||
{r.label}
|
||||
<i className="block h-[8px] flex-1 overflow-hidden rounded-full bg-[#e3eaf4]">
|
||||
<s className="block h-full bg-[linear-gradient(90deg,#ffc86e,#ff7a45)]" style={{ width: `${r.value}%` }} />
|
||||
</i>
|
||||
</span>
|
||||
<small className="mt-0.5 block text-[12.5px] font-semibold text-[#5a6380]">{r.note}</small>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
</Offscreen>
|
||||
)
|
||||
}
|
||||
@@ -2,8 +2,8 @@ import type { MyGak } from './myGakState'
|
||||
import type { TalkData } from '@nalssigak/shared/api/client/types.gen'
|
||||
import type { WeatherWhyPayload } from './weatherWhy'
|
||||
import { createContext, use } from 'react'
|
||||
/** square: 1:1 비율일 때 slides 대신 찍을 틀 (없으면 slides) */
|
||||
export type SharePayload = { title: string; slides: HTMLElement[]; square?: HTMLElement[] }
|
||||
/** square: 1:1 비율일 때 slides 대신 찍을 틀 (없으면 slides). url: 같이 보낼 링크 (없으면 사이트 주소) */
|
||||
export type SharePayload = { title: string; slides: HTMLElement[]; square?: HTMLElement[]; url?: string }
|
||||
|
||||
type CommentsState = { type: 'comments'; postId: number; draft?: string }
|
||||
|
||||
@@ -17,6 +17,7 @@ export type SheetState =
|
||||
| { type: 'me' }
|
||||
| { type: 'region' }
|
||||
| { type: 'mix'; shared?: MyGak }
|
||||
| { type: 'myGak'; gak: MyGak; shot?: HTMLElement | null }
|
||||
| { type: 'install' }
|
||||
| { type: 'weatherWhy'; why: WeatherWhyPayload }
|
||||
| { type: 'talk'; talk: TalkData }
|
||||
|
||||
@@ -2,7 +2,9 @@ import { domToCanvas } from 'modern-screenshot'
|
||||
import { API_BASE_URL } from '../api/setup'
|
||||
|
||||
const W = 1080
|
||||
const SIDE = 60
|
||||
const SIDE = 24
|
||||
// 1:1·4:5 아래 띠 높이: 날씨각 · 동네·날짜 · 주소 한 줄
|
||||
const FOOT = 84
|
||||
|
||||
// 시간대별 배경 (화면 하늘 배경과 같은 색)
|
||||
const SKY: Record<string, [string, string, string]> = {
|
||||
@@ -12,11 +14,14 @@ const SKY: Record<string, [string, string, string]> = {
|
||||
night: ['#0e1433', '#1b2356', '#2a2e6e'],
|
||||
}
|
||||
|
||||
/** 공유 이미지 크기. 위: 로고·지역 날짜, 가운데: 카드, 아래: 주소 */
|
||||
/**
|
||||
* 공유 이미지 크기. 9:16 은 위 로고·지역 날짜, 가운데 카드, 아래 주소 알약.
|
||||
* 1:1·4:5(strip)는 카드를 크게 두고 아래 얇은 띠 한 줄(날씨각 · 지역 날짜 · 주소)만
|
||||
*/
|
||||
export const SHARE_SIZES = {
|
||||
story: { ratio: '9:16', w: 9, hr: 16, h: 1920, logoY: 250, logoPx: 96, subY: 325, subPx: 40, pillY: 1760, pillH: 100, labelPx: 34, hostPx: 46 },
|
||||
feed: { ratio: '4:5', w: 4, hr: 5, h: 1350, logoY: 140, logoPx: 76, subY: 200, subPx: 34, pillY: 1250, pillH: 84, labelPx: 30, hostPx: 40 },
|
||||
square: { ratio: '1:1', w: 1, hr: 1, h: 1080, logoY: 115, logoPx: 64, subY: 168, subPx: 30, pillY: 990, pillH: 80, labelPx: 28, hostPx: 38 },
|
||||
story: { ratio: '9:16', w: 9, hr: 16, h: 1920, strip: false, logoY: 250, logoPx: 96, subY: 325, subPx: 40, pillY: 1760, pillH: 100, labelPx: 34, hostPx: 46 },
|
||||
feed: { ratio: '4:5', w: 4, hr: 5, h: 1350, strip: true, logoY: 0, logoPx: 40, subY: 0, subPx: 26, pillY: 0, pillH: 0, labelPx: 0, hostPx: 32 },
|
||||
square: { ratio: '1:1', w: 1, hr: 1, h: 1080, strip: true, logoY: 0, logoPx: 40, subY: 0, subPx: 26, pillY: 0, pillH: 0, labelPx: 0, hostPx: 32 },
|
||||
} as const
|
||||
export type ShareSize = keyof typeof SHARE_SIZES
|
||||
|
||||
@@ -113,7 +118,7 @@ type Box = { x: number; y: number; w: number; h: number }
|
||||
function place(n: number, aspect: number, top: number, bottom: number): Box[] {
|
||||
const room = bottom - top
|
||||
if (n === 1) {
|
||||
const w = Math.min(W - SIDE * 3, room / aspect)
|
||||
const w = Math.min(W - SIDE * 2, room / aspect)
|
||||
const h = w * aspect
|
||||
return [{ x: (W - w) / 2, y: top + (room - h) / 2, w, h }]
|
||||
}
|
||||
@@ -152,11 +157,11 @@ export async function shareImage(slides: HTMLElement[], opts: { size: ShareSize;
|
||||
document.fonts.load(LOGO(z.hostPx), opts.host),
|
||||
document.fonts.load(LOGO(36), '12'),
|
||||
document.fonts.load(SANS(z.subPx), opts.sub),
|
||||
document.fonts.load(SANS(z.labelPx), PILL_LABEL),
|
||||
...(z.strip ? [] : [document.fonts.load(SANS(z.labelPx), PILL_LABEL)]),
|
||||
])
|
||||
const css = await fontCss(cards.map((c) => c.textContent ?? '').join(''))
|
||||
const aspect = cards[0].offsetHeight / cards[0].offsetWidth
|
||||
const boxes = place(cards.length, aspect, z.subY + 60, z.pillY - z.pillH / 2 - 50)
|
||||
const boxes = z.strip ? place(cards.length, aspect, SIDE, z.h - FOOT) : place(cards.length, aspect, z.subY + 60, z.pillY - z.pillH / 2 - 50)
|
||||
const shots = await Promise.all(cards.map((c, i) => domToCanvas(c, { scale: boxes[i].w / c.offsetWidth, filter: keep, font: css ? { cssText: css } : false, fetchFn: viaProxy })))
|
||||
|
||||
const canvas = document.createElement('canvas')
|
||||
@@ -173,13 +178,15 @@ export async function shareImage(slides: HTMLElement[], opts: { size: ShareSize;
|
||||
ctx.fillStyle = bg
|
||||
ctx.fillRect(0, 0, W, z.h)
|
||||
|
||||
ctx.textAlign = 'center'
|
||||
ctx.fillStyle = '#ff7a45'
|
||||
ctx.font = LOGO(z.logoPx)
|
||||
ctx.fillText('날씨각', W / 2, z.logoY)
|
||||
ctx.fillStyle = dark ? '#bcc3ea' : '#5a6380'
|
||||
ctx.font = SANS(z.subPx)
|
||||
ctx.fillText(opts.sub, W / 2, z.subY, W - SIDE * 2)
|
||||
if (!z.strip) {
|
||||
ctx.textAlign = 'center'
|
||||
ctx.fillStyle = '#ff7a45'
|
||||
ctx.font = LOGO(z.logoPx)
|
||||
ctx.fillText('날씨각', W / 2, z.logoY)
|
||||
ctx.fillStyle = dark ? '#bcc3ea' : '#5a6380'
|
||||
ctx.font = SANS(z.subPx)
|
||||
ctx.fillText(opts.sub, W / 2, z.subY, W - SIDE * 2)
|
||||
}
|
||||
|
||||
const r = 40 * (boxes[0].w / 900)
|
||||
shots.forEach((shot, i) => {
|
||||
@@ -200,6 +207,28 @@ export async function shareImage(slides: HTMLElement[], opts: { size: ShareSize;
|
||||
})
|
||||
if (shots.length > 1) boxes.forEach((b, i) => badge(ctx, b.x + 6, b.y + 6, i + 1))
|
||||
|
||||
if (z.strip) {
|
||||
// 아래 띠: 왼쪽 [날씨각 지역 · 날짜], 오른쪽 주소. 카드 양 끝에 맞춘다
|
||||
const left = Math.min(...boxes.map((b) => b.x))
|
||||
const right = Math.max(...boxes.map((b) => b.x + b.w))
|
||||
const y = z.h - FOOT / 2 + 2
|
||||
ctx.textBaseline = 'middle'
|
||||
ctx.textAlign = 'left'
|
||||
ctx.fillStyle = '#ff7a45'
|
||||
ctx.font = LOGO(z.logoPx)
|
||||
ctx.fillText('날씨각', left, y)
|
||||
const logoW = ctx.measureText('날씨각').width
|
||||
ctx.font = LOGO(z.hostPx)
|
||||
const hostW = ctx.measureText(opts.host).width
|
||||
ctx.textAlign = 'right'
|
||||
ctx.fillText(opts.host, right, y)
|
||||
ctx.textAlign = 'left'
|
||||
ctx.fillStyle = dark ? '#bcc3ea' : '#5a6380'
|
||||
ctx.font = SANS(z.subPx)
|
||||
ctx.fillText(opts.sub, left + logoW + 16, y, Math.max(0, right - hostW - 24 - (left + logoW + 16)))
|
||||
return new Promise((resolve, reject) => canvas.toBlob((b) => (b ? resolve(b) : reject(new Error('toBlob failed'))), 'image/png'))
|
||||
}
|
||||
|
||||
// 주소 알약: [오늘 내 동네 각 보기 host]
|
||||
ctx.font = SANS(z.labelPx)
|
||||
const lw = ctx.measureText(PILL_LABEL).width
|
||||
|
||||
@@ -27,6 +27,23 @@ export function SendIcon({ className }: P) {
|
||||
)
|
||||
}
|
||||
|
||||
export function CloseIcon({ className }: P) {
|
||||
return (
|
||||
<svg viewBox="0 0 24 24" {...line} strokeWidth="2.4" className={className} aria-hidden="true">
|
||||
<path d="M6 6l12 12M18 6 6 18" />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export function CameraIcon({ className }: P) {
|
||||
return (
|
||||
<svg viewBox="0 0 24 24" {...line} strokeWidth="2" className={className} aria-hidden="true">
|
||||
<path d="M4 8.5A1.5 1.5 0 0 1 5.5 7h2.2l1.5-2h5.6l1.5 2h2.2A1.5 1.5 0 0 1 20 8.5v9a1.5 1.5 0 0 1-1.5 1.5h-13A1.5 1.5 0 0 1 4 17.5z" />
|
||||
<circle cx="12" cy="13" r="3.5" />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export function PinIcon({ className }: P) {
|
||||
return (
|
||||
<svg viewBox="0 0 24 24" {...line} strokeWidth="2.2" className={className} aria-hidden="true">
|
||||
|
||||
+45
-26
@@ -15,11 +15,11 @@ import { API_BASE_URL } from '../api/setup'
|
||||
import { IS_TOSS } from '../lib/platform'
|
||||
import { cx } from '../lib/utils'
|
||||
import { useAuth } from './authContext'
|
||||
import { ago, kst } from '@nalssigak/shared/lib'
|
||||
import { kst } from '@nalssigak/shared/lib'
|
||||
import { useRegion } from './regionContext'
|
||||
import { topicName, TOPICS, useMyTalks } from './talkState'
|
||||
import { useSheet } from './sheetContext'
|
||||
import { HeartIcon } from './svg'
|
||||
import { CameraIcon, HeartIcon } from './svg'
|
||||
import { Avatar, Rail, TAP44 } from './ui'
|
||||
|
||||
const BODY_MAX = 100
|
||||
@@ -171,8 +171,9 @@ function Composer({ onDone }: { onDone?: (t: TalkData) => void }) {
|
||||
</div>
|
||||
<input ref={fileRef} type="file" accept="image/*" onChange={pick} hidden />
|
||||
<div className="mt-1.5 flex items-center gap-2 text-xs font-bold text-(--ink3)">
|
||||
<button type="button" onClick={() => (loggedIn ? fileRef.current?.click() : open({ type: 'login' }))} disabled={busy} className="shrink-0 cursor-pointer rounded-full bg-[#eef4fc] px-3 py-1.5 text-[13px] font-extrabold text-(--ink2) disabled:opacity-40">
|
||||
사진
|
||||
{/* 주제 칩과 헷갈리지 않게 글자 대신 카메라 아이콘 */}
|
||||
<button type="button" onClick={() => (loggedIn ? fileRef.current?.click() : open({ type: 'login' }))} disabled={busy} aria-label="사진 붙이기" className={cx('relative grid size-8 shrink-0 cursor-pointer place-items-center rounded-full bg-[#eef4fc] text-(--ink2) disabled:opacity-40', TAP44)}>
|
||||
<CameraIcon className="size-[18px]" />
|
||||
</button>
|
||||
<span className="min-w-0 truncate">{me ? `${me.nickname} · ${region.name.split(' ').at(-1)} · 지금 날씨가 함께 올라가요` : '로그인하면 쓸 수 있어요'}</span>
|
||||
<span className="ml-auto tabular-nums">
|
||||
@@ -198,7 +199,7 @@ function TalkRow({ t, onGone, compact }: { t: TalkData; onGone?: () => void; com
|
||||
const refresh = useRefreshTalks()
|
||||
const [liked, setLiked] = useState(t.liked)
|
||||
const [count, setCount] = useState(t.like_count)
|
||||
const [menu, setMenu] = useState<'closed' | 'open' | 'report' | 'done'>('closed')
|
||||
const [menu, setMenu] = useState<'closed' | 'open' | 'confirm' | 'report' | 'done'>('closed')
|
||||
const like = useMutation(likeTalkMutation())
|
||||
const unlike = useMutation(unlikeTalkMutation())
|
||||
const remove = useMutation(deleteTalkMutation())
|
||||
@@ -240,7 +241,7 @@ function TalkRow({ t, onGone, compact }: { t: TalkData; onGone?: () => void; com
|
||||
const src = t.image?.startsWith('/v1/') ? API_BASE_URL + t.image : (t.image ?? undefined)
|
||||
|
||||
return (
|
||||
<div className={cx('grid grid-cols-[34px_1fr_24px] gap-2.5 border-b border-(--line) py-2.5 last:border-b-0', compact ? 'h-full w-full items-stretch' : 'items-start')}>
|
||||
<div className={cx('grid grid-cols-[34px_1fr_auto] gap-2.5 border-b border-(--line) py-2.5 last:border-b-0', compact ? 'h-full w-full items-stretch' : 'items-start')}>
|
||||
<span className="self-start">
|
||||
<Avatar character={t.character} color={t.color} mood={t.mood} />
|
||||
</span>
|
||||
@@ -248,6 +249,7 @@ function TalkRow({ t, onGone, compact }: { t: TalkData; onGone?: () => void; com
|
||||
<div className={cx('min-w-0', compact && 'flex flex-col')}>
|
||||
<small className={cx('block text-xs font-bold text-(--ink3)', compact && 'truncate')}>
|
||||
<b className="mr-1 font-extrabold text-(--ink)">{t.nickname}</b>
|
||||
{t.mine && <span className="mr-1 rounded-full bg-[#ffe8dc] px-1.5 py-px text-[11px] font-extrabold text-[#c2471b]">내 글</span>}
|
||||
{[t.region_name, slotWord(t.created_at), t.weather, t.topic && t.topic !== TalkTopic.LOCAL ? topicName(t.topic) : null].filter(Boolean).join(' · ')}
|
||||
</small>
|
||||
{/* 묶음 안 작은 카드는 글이 잘리니, 누르면 창에서 글 전체·큰 사진을 본다 */}
|
||||
@@ -261,22 +263,24 @@ function TalkRow({ t, onGone, compact }: { t: TalkData; onGone?: () => void; com
|
||||
)}
|
||||
{t.image && !compact && <img src={src} alt="" loading="lazy" className="mt-2 aspect-[4/5] w-full rounded-2xl bg-[#eef4fc] object-cover" />}
|
||||
<small className={cx('block text-xs font-bold text-(--ink3)', compact ? 'mt-auto pt-1.5' : 'mt-0.5')}>
|
||||
{ago(t.created_at)} · 좋아요 {count}개
|
||||
{!IS_TOSS && (
|
||||
<>
|
||||
{' · '}
|
||||
<button type="button" onClick={() => setMenu(menu === 'closed' ? 'open' : 'closed')} aria-expanded={menu !== 'closed'} className="cursor-pointer font-bold text-(--ink3)">
|
||||
{t.mine ? '내 글' : '더보기'}
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
{t.ago} · 좋아요 {count}개
|
||||
</small>
|
||||
{menu !== 'closed' && (
|
||||
<div className="mt-1.5 flex flex-wrap gap-1.5 text-[12.5px] font-extrabold" role="group" aria-label="글 메뉴">
|
||||
{menu === 'done' ? (
|
||||
<span className="text-[#1f9d62]">처리했어요</span>
|
||||
) : t.mine && menu === 'confirm' ? (
|
||||
<>
|
||||
<span className="self-center text-(--ink2)">지울까요?</span>
|
||||
<button type="button" onClick={() => remove.mutate({ path: { talk_id: t.talk_id } }, { ...after, onSuccess: (res) => (after.onSuccess(res), res.result?.success && onGone?.()) })} disabled={remove.isPending} className="cursor-pointer rounded-full bg-[#fdecec] px-3 py-1 text-(--heart)">
|
||||
지우기
|
||||
</button>
|
||||
<button type="button" onClick={() => setMenu('closed')} className="cursor-pointer rounded-full bg-[#eef4fc] px-3 py-1">
|
||||
취소
|
||||
</button>
|
||||
</>
|
||||
) : t.mine ? (
|
||||
<button type="button" onClick={() => remove.mutate({ path: { talk_id: t.talk_id } }, { ...after, onSuccess: (res) => (after.onSuccess(res), res.result?.success && onGone?.()) })} disabled={remove.isPending} className="cursor-pointer rounded-full bg-[#fdecec] px-3 py-1 text-(--heart)">
|
||||
<button type="button" onClick={() => setMenu('confirm')} className="cursor-pointer rounded-full bg-[#fdecec] px-3 py-1 text-(--heart)">
|
||||
지우기
|
||||
</button>
|
||||
) : menu === 'report' ? (
|
||||
@@ -303,25 +307,39 @@ function TalkRow({ t, onGone, compact }: { t: TalkData; onGone?: () => void; com
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<button type="button" onClick={toggle} aria-pressed={liked} aria-label="좋아요" className={cx('relative cursor-pointer self-start pt-1', TAP44)}>
|
||||
<HeartIcon className={cx('size-4 stroke-2', liked ? 'fill-(--heart) stroke-(--heart)' : 'fill-none stroke-(--ink3)')} />
|
||||
</button>
|
||||
{/* 글 메뉴(⋯)는 하트 옆 오른쪽 위에: 아래 줄 끝에 두면 말줄임표처럼 읽힌다 */}
|
||||
<span className="flex items-start gap-4 self-start">
|
||||
{!IS_TOSS && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setMenu(menu === 'closed' ? 'open' : 'closed')}
|
||||
aria-expanded={menu !== 'closed'}
|
||||
aria-label="글 메뉴"
|
||||
className={cx('relative cursor-pointer pt-0.5 text-[15px] leading-none font-extrabold tracking-[1px] text-(--ink3)', TAP44)}
|
||||
>
|
||||
⋯
|
||||
</button>
|
||||
)}
|
||||
<button type="button" onClick={toggle} aria-pressed={liked} aria-label="좋아요" className={cx('relative cursor-pointer pt-1', TAP44)}>
|
||||
<HeartIcon className={cx('size-4 stroke-2', liked ? 'fill-(--heart) stroke-(--heart)' : 'fill-none stroke-(--ink3)')} />
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** 이야기 탭: 쓰기 칸과 전국 최신 글 (아래로 더 받기) */
|
||||
/** 피드 위 쓰는 칸. 늘 펼쳐 두고, 방금 올린 글은 바로 아래에 보인다 (피드 사이 글은 새로 받을 때 섞인다) */
|
||||
export function FeedComposer({ onPosted }: { onPosted: (t: TalkData) => void }) {
|
||||
/** 피드 위 쓰는 칸. 늘 펼쳐 두고, 오늘 쓴 내 글은 바로 아래 '오늘 내 글' 묶음에 보인다 */
|
||||
export function FeedComposer() {
|
||||
if (IS_TOSS) return null
|
||||
return (
|
||||
<div className="mt-3.5">
|
||||
<Composer onDone={onPosted} />
|
||||
<Composer />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** 묶음에서 누른 글 하나를 창으로: 글 전체·큰 사진·좋아요·더보기 */
|
||||
/** 묶음에서 누른 글 하나를 창으로: 글 전체·큰 사진·좋아요·글 메뉴 */
|
||||
export function TalkSheet({ talk }: { talk: TalkData }) {
|
||||
return (
|
||||
<div className="flex-1 overflow-auto overscroll-contain px-4 pb-[18px]">
|
||||
@@ -333,19 +351,20 @@ export function TalkSheet({ talk }: { talk: TalkData }) {
|
||||
/** 피드에 끼우는 글 한 장 */
|
||||
export function TalkCard({ t, onGone }: { t: TalkData; onGone?: () => void }) {
|
||||
return (
|
||||
<article className="mt-3.5 border-y border-(--line) bg-white px-3" aria-label={`${t.nickname}의 글`}>
|
||||
<article className="mx-3 mt-3 rounded-[20px] bg-white px-3 shadow-[inset_0_-4px_0_var(--shade)]" aria-label={`${t.nickname}의 글`}>
|
||||
<TalkRow key={`${t.talk_id}:${t.liked}:${t.like_count}`} t={t} onGone={onGone} />
|
||||
</article>
|
||||
)
|
||||
}
|
||||
|
||||
/** 오늘 피드의 사람 글 묶음: 옆으로 넘기는 카드, 끝에 그 주제 전체 보기 */
|
||||
export function TalkGroup({ title, topic, talks }: { title: string; topic?: number; talks: TalkData[] }) {
|
||||
/** href: 오른쪽 위 '전체 보기'가 여는 곳 (없으면 이야기 탭의 그 주제) */
|
||||
export function TalkGroup({ title, topic, talks, href }: { title: string; topic?: number; talks: TalkData[]; href?: string }) {
|
||||
return (
|
||||
<section aria-label={title} className="mt-3.5">
|
||||
<div className="flex items-end justify-between px-4">
|
||||
<h2 className="m-0 font-jua text-[19px] font-normal">{title}</h2>
|
||||
<Link to={topic ? `/talk?topic=${topic}` : '/talk'} className="text-[13px] font-bold text-(--ink2)">
|
||||
<Link to={href ?? (topic ? `/talk?topic=${topic}` : '/talk')} className="text-[13px] font-bold text-(--ink2)">
|
||||
전체 보기
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { useInfiniteQuery, useQuery } from '@tanstack/react-query'
|
||||
import { listMyTalksInfiniteOptions, listTalksInfiniteOptions, talkGroupsOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
|
||||
import { useState } from 'react'
|
||||
import { listMyTalksInfiniteOptions, listMyTalksOptions, listTalksInfiniteOptions, talkGroupsOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
|
||||
import { TalkTopic, type TalkData } from '@nalssigak/shared/api/client/types.gen'
|
||||
import { kst } from '@nalssigak/shared/lib'
|
||||
import { useRegion } from './regionContext'
|
||||
|
||||
// 글 주제와 피드 묶음 이름
|
||||
@@ -37,10 +39,22 @@ export function useTopicTalks(topic?: TalkTopic) {
|
||||
}
|
||||
}
|
||||
|
||||
/** 오늘(한국 날짜) 쓴 내 글, 최신순. 로그인했을 때만 받는다 */
|
||||
export function useTodayMyTalks(loggedIn: boolean) {
|
||||
const q = useQuery({ ...listMyTalksOptions(), enabled: loggedIn })
|
||||
// 오늘 날짜는 화면을 연 때 기준으로 한 번만
|
||||
const [now] = useState(() => kst(new Date()))
|
||||
return (q.data?.talks ?? []).filter((t) => {
|
||||
const d = kst(t.created_at)
|
||||
return d.y === now.y && d.mo === now.mo && d.d === now.d
|
||||
})
|
||||
}
|
||||
|
||||
/** 내가 쓴 글 (최신순) */
|
||||
export function useMyTalks() {
|
||||
export function useMyTalks(enabled = true) {
|
||||
const list = useInfiniteQuery({
|
||||
...listMyTalksInfiniteOptions(),
|
||||
enabled,
|
||||
initialPageParam: {},
|
||||
getNextPageParam: (last) => last.next_cursor ?? undefined,
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user