feat: 로딩 스켈레톤·행사 사진·전시·주말 예상 점수·노을 탭 재정리 등 화면 전반 개선
- 화면 전체 스켈레톤, 로딩·완료·실패 사이 레이아웃 고정, 값 없음은 '?' - 행사 사진·출처 표시, 문화정보 API 전시 연결, 행사 30km 거리 기준 - 각 상세 점수 칸 오늘/내일/토/일, 단기예보 밖 주말은 중기예보 예상 점수 - 6각 차트 축 이름을 좋은 방향으로, 계산 근거 문구 정리 - 아이콘 오용·뜻 모를 표시·빈 데이터·포스트 본문 반복 수정 - 미세먼지 별도 포스트, 노을 명소 전국 155곳 거리 기준, 노을 탭 결론 중심 재구성 - 밤 다크 테마·별똥별, 댓글·좋아요 대기·실패 표시 - 주말 전국 랭킹·당일치기 카드, 계절 이야기 사진 수집 - 문서: 포스트 타입별 내용, 각 데이터 정리, TODO 진행 순서
This commit is contained in:
1 parent
296a09d6db
commit
ddf05aeb5c
97 files changed
+5475
-720
No files matched your search
+76
-12
@@ -1,13 +1,35 @@
|
||||
import type { CSSProperties, ReactNode } from 'react'
|
||||
import { useState, type CSSProperties, type ReactNode } from 'react'
|
||||
import { Link } from 'react-router'
|
||||
import { cx } from '../lib/utils'
|
||||
import { useCarousel, type Carousel } from './carousel'
|
||||
import { AVATAR_COLORS, iconSrc, moodEmoji } from './lib'
|
||||
import { AVATAR_COLORS, iconSrc, moodEmoji, type Load } from './lib'
|
||||
|
||||
type IcProps = { name: string; className?: string; alt?: string; style?: CSSProperties }
|
||||
|
||||
export function Ic({ name, className, alt = '', style }: IcProps) {
|
||||
return <img src={iconSrc(name)} alt={alt} className={cx('block', className)} style={style} decoding="async" />
|
||||
const src = iconSrc(name)
|
||||
if (!src) return <span aria-hidden className={cx('block', className)} style={style} />
|
||||
return <img src={src} alt={alt} className={cx('block', className)} style={style} decoding="async" />
|
||||
}
|
||||
|
||||
/** 사진 출처 표기 (공공누리 조건). 사진 위에서도 읽히게 반투명 배경. 위치는 className 으로 */
|
||||
export function Credit({ text, className = 'right-1 bottom-1' }: { text: string; className?: string }) {
|
||||
return <small className={cx('pointer-events-none absolute z-[1] rounded-[5px] bg-[rgb(16_20_34/0.5)] px-1 py-px text-[9px] leading-tight font-semibold whitespace-nowrap text-white', className)}>{text}</small>
|
||||
}
|
||||
|
||||
type ThumbProps = { image?: string | null; icon: string; credit?: string | null; className?: string; iconClassName?: string; children?: ReactNode }
|
||||
|
||||
/** 사진이 있으면 사진(+출처), 없거나 못 불러오면 아이콘 */
|
||||
export function Thumb({ image, icon, credit, className, iconClassName, children }: ThumbProps) {
|
||||
const [failed, setFailed] = useState<string | null>(null)
|
||||
const photo = image && image !== failed ? image : null
|
||||
return (
|
||||
<span className={cx('relative grid place-items-center overflow-hidden', className)}>
|
||||
{photo ? <img src={photo} alt="" loading="lazy" decoding="async" onError={() => setFailed(photo)} className="absolute inset-0 size-full object-cover" /> : <Ic name={icon} className={iconClassName} />}
|
||||
{photo && credit && <Credit text={credit} />}
|
||||
{children}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
type AvatarProps = { character: string; color?: string | null; mood?: string | null; size?: number; className?: string }
|
||||
@@ -66,6 +88,15 @@ export function Arrows({ api, prev, next, className }: { api: Carousel; prev: bo
|
||||
|
||||
const STRIP = { align: 'start', dragFree: true, containScroll: 'trimSnaps' } as const
|
||||
|
||||
/** Rail 과 같은 틀(여백·간격)로 스켈레톤 칸을 늘어놓는다. 넘기기·화살표는 없음 */
|
||||
export function SkelRail({ children, className }: { children: ReactNode; className?: string }) {
|
||||
return (
|
||||
<div className="overflow-hidden" aria-hidden="true">
|
||||
<div className={cx('flex gap-2.5 px-4 pt-3 pb-1 *:shrink-0', className)}>{children}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export function Rail({ children, className, label }: { children: ReactNode; className?: string; label?: string }) {
|
||||
const { ref, api, prev, next } = useCarousel(STRIP)
|
||||
return (
|
||||
@@ -110,22 +141,55 @@ function ChipStrip({ children, label }: { children: ReactNode; label: string })
|
||||
)
|
||||
}
|
||||
|
||||
type StateProps = { loading?: boolean; error?: unknown; onRetry?: () => void; empty?: string; className?: string }
|
||||
type SkelProps = { className?: string; shape?: boolean; style?: CSSProperties }
|
||||
|
||||
/** 불러오는 중·실패·빈 목록 안내 */
|
||||
export function StateBox({ loading, error, onRetry, empty, className }: StateProps) {
|
||||
const text = loading ? '불러오는 중이에요…' : error ? '정보를 불러오지 못했어요.' : empty
|
||||
if (!text) return null
|
||||
/**
|
||||
* 불러오는 동안 자리만 잡는 막대. 기본은 글자 자리: 감싼 글자 요소 안에 넣으면 그 줄 높이(1lh)를 그대로 차지한다.
|
||||
* shape 면 className 으로 준 크기의 블록(사진·동그라미 자리).
|
||||
*/
|
||||
export function Skel({ className, shape = false, style }: SkelProps) {
|
||||
return (
|
||||
<div className={cx('mx-3 mt-3 flex flex-col items-center gap-2 rounded-[22px] bg-white px-4 py-6 text-center text-[13.5px] font-semibold text-(--ink2) shadow-[inset_0_-5px_0_var(--shade)]', className)} role={error ? 'alert' : 'status'}>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
style={style}
|
||||
className={cx('bg-(--skel) motion-safe:animate-pulse', shape ? 'block' : 'inline-block h-[1lh] max-w-full rounded-full bg-clip-content py-[0.22lh] align-top', className)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
type StateProps = { load: Load; onRetry?: () => void; empty?: string; className?: string; hold?: ReactNode }
|
||||
|
||||
/**
|
||||
* 실패·빈 목록 안내. 불러오는 중엔 그리지 않는다(그 자리는 스켈레톤).
|
||||
* hold 에 스켈레톤을 주면 그 크기를 보이지 않게 깔고 안내를 그 위에 띄운다 — 로딩·실패·빈 상태의 자리 크기가 같다.
|
||||
* 이때 className 은 안내 상자의 위치(스켈레톤 바깥 여백만큼 inset).
|
||||
*/
|
||||
export function StateBox({ load, onRetry, empty, className, hold }: StateProps) {
|
||||
const failed = load === 'error' || load === 'retrying'
|
||||
const text = failed ? '정보를 불러오지 못했어요.' : load === 'ready' ? empty : undefined
|
||||
if (!text) return null
|
||||
const box = (
|
||||
<div
|
||||
className={cx('flex flex-col items-center justify-center gap-2 rounded-[22px] bg-white px-4 py-6 text-center text-[13.5px] font-semibold text-(--ink2) shadow-[inset_0_-5px_0_var(--shade)]', hold ? cx('absolute', className ?? 'inset-x-3 top-3 bottom-0') : (className ?? 'mx-3 mt-3'))}
|
||||
role={load === 'error' ? 'alert' : 'status'}
|
||||
>
|
||||
<span>{text}</span>
|
||||
{error != null && onRetry && (
|
||||
<button type="button" onClick={onRetry} className="cursor-pointer rounded-full bg-(--ink) px-4 py-1.5 text-[13px] font-bold text-white">
|
||||
다시 시도
|
||||
{failed && onRetry && (
|
||||
<button type="button" onClick={onRetry} disabled={load === 'retrying'} className="cursor-pointer rounded-full bg-(--ink) px-4 py-1.5 text-[13px] font-bold text-white disabled:cursor-default disabled:opacity-60">
|
||||
{load === 'retrying' ? '다시 불러오는 중…' : '다시 시도'}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
if (!hold) return box
|
||||
return (
|
||||
<div className="relative flow-root">
|
||||
<div className="invisible" aria-hidden="true" inert>
|
||||
{hold}
|
||||
</div>
|
||||
{box}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** 줄 목록 (라벨 · 값) */
|
||||
|
||||
Reference in new issue
Block a user