feat: 앱 오늘 피드를 웹과 맞춤 — 히어로 오늘/내일 전환·좋아요·댓글·보내기·점수 근거 창, 오늘의 각 카드(gak_post), 날씨각 카드(그림 슬라이드), 행사·TOP5 띠 없앰, 좋아요·댓글 로그인 없이 (GA hero_day_switch, like hero_post·gak_post)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
e8b8cc79b6
commit
01b5f917b9
16 files changed
+449
-156
No files matched your search
@@ -14,7 +14,6 @@ import { Dots, Pager } from '@/components/post/pager';
|
||||
import { slideBg, SlideView, type Slide } from '@/components/post/slides';
|
||||
import { Ic, Skel } from '@/components/ui';
|
||||
import { track } from '@/lib/analytics';
|
||||
import { useAuth } from '@/lib/auth';
|
||||
import { useSheet } from '@/lib/sheet';
|
||||
import { shareView } from '@/lib/share-image';
|
||||
import { SITE_URL } from '@/lib/site';
|
||||
@@ -35,12 +34,11 @@ const ACCOUNTS: Partial<Record<PostType, readonly [string, string]>> = {
|
||||
[PostType.DAY_TRIP]: ['당일치기', 'picnic'],
|
||||
[PostType.MOON]: ['오늘 밤 달', 'moon'],
|
||||
[PostType.UV]: ['자외선', 'glasses'],
|
||||
[PostType.CARD]: ['날씨각 카드', 'stars'],
|
||||
};
|
||||
|
||||
const isSlide = (s: PostData['slides'][number]): s is Slide => s.kind !== 'image';
|
||||
|
||||
/** 앱이 그릴 줄 아는 글만 (웹 전용 글 종류·이미지 슬라이드가 든 글은 뺀다) */
|
||||
export const isAppPost = (p: PostData) => p.post_type in ACCOUNTS && p.slides.every(isSlide);
|
||||
/** 앱이 그릴 줄 아는 글 종류만 (히어로·띠처럼 피드 반응 칸으로만 오는 종류는 뺀다) */
|
||||
export const isAppPost = (p: PostData) => p.post_type in ACCOUNTS;
|
||||
|
||||
type PostProps = { post: PostData };
|
||||
|
||||
@@ -118,7 +116,6 @@ function HeartPop() {
|
||||
|
||||
function FullCard({ post }: PostProps) {
|
||||
const { open } = useSheet();
|
||||
const { loggedIn } = useAuth();
|
||||
const [ink, heart] = useCSSVariable(['--color-ink', '--color-heart']).map(String);
|
||||
const liked = !!post.liked;
|
||||
const likeCount = post.like_count;
|
||||
@@ -145,8 +142,8 @@ function FullCard({ post }: PostProps) {
|
||||
}, [likeFailed]);
|
||||
|
||||
// 화면을 먼저 바꾸고, 실패하면 되돌린다 (서버는 실패도 200 + result.success=false 로 준다)
|
||||
// 좋아요는 로그인 없이 된다 (웹과 같이)
|
||||
const setLike = (on: boolean) => {
|
||||
if (!loggedIn) return open({ type: 'login' });
|
||||
if (on === liked || like.isPending || unlike.isPending) return;
|
||||
if (on) setPop((p) => p + 1);
|
||||
setLikeFailed(0);
|
||||
@@ -171,7 +168,7 @@ function FullCard({ post }: PostProps) {
|
||||
const onTap = () => {
|
||||
const now = Date.now();
|
||||
if (now - lastTap.current < 320) {
|
||||
if (liked && loggedIn) setPop((p) => p + 1);
|
||||
if (liked) setPop((p) => p + 1);
|
||||
else setLike(true);
|
||||
}
|
||||
lastTap.current = now;
|
||||
@@ -195,7 +192,7 @@ function FullCard({ post }: PostProps) {
|
||||
<View ref={shot} collapsable={false}>
|
||||
{width > 0 && (
|
||||
<Pager width={width} height={(width * 5) / 4} onIndex={setIndex}>
|
||||
{post.slides.filter(isSlide).map((s, i) => (
|
||||
{post.slides.map((s: Slide, i) => (
|
||||
<SlideView key={i} slide={s} bg={slideBg(post, s)} />
|
||||
))}
|
||||
</Pager>
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
import type { PostReaction } from '@nalssigak/shared/api/client/types.gen';
|
||||
import type { PinnedKey } from '@nalssigak/shared/lib/analytics';
|
||||
import { LinearGradient } from 'expo-linear-gradient';
|
||||
import { useRef, type ReactNode } from 'react';
|
||||
import { Pressable, View } from 'react-native';
|
||||
import { useCSSVariable } from 'uniwind';
|
||||
|
||||
import { CommentIcon, HeartIcon, SendIcon } from '@/components/post/icons';
|
||||
import { Text } from '@/components/text';
|
||||
import { Ic } from '@/components/ui';
|
||||
import { usePinnedLike } from '@/lib/pinned-like';
|
||||
import { useSheet } from '@/lib/sheet';
|
||||
import { shareView } from '@/lib/share-image';
|
||||
import { SITE_URL } from '@/lib/site';
|
||||
|
||||
type Props = { title: string; account: string; avatar: string; caption?: string; more?: ReactNode; pinned?: { key: PinnedKey; post?: PostReaction | null }; children: ReactNode };
|
||||
|
||||
/** 오늘의 각처럼 포스트 틀(머리줄·버튼줄·글 한 줄)만 빌려 쓰는 카드 (웹 PostFrame). 좋아요·댓글은 피드의 반응 칸(pinned)에 붙는다 */
|
||||
export function PostFrame({ title, account, avatar, caption, more, pinned, children }: Props) {
|
||||
const { open } = useSheet();
|
||||
const [ink, heart] = useCSSVariable(['--color-ink', '--color-heart']).map(String);
|
||||
const like = usePinnedLike(pinned?.key ?? 'gak_post', pinned?.post);
|
||||
const postId = pinned?.post?.post_id;
|
||||
const shot = useRef<View>(null);
|
||||
const share = () => void shareView(shot, { title, message: `${title} · 날씨각 ${SITE_URL}` });
|
||||
|
||||
return (
|
||||
<View className="mt-3.5 border-y border-line bg-card" accessibilityLabel={title}>
|
||||
<View className="flex-row items-center gap-2.5 px-3 py-2.5">
|
||||
<View className="size-[34px] rounded-full p-0.5">
|
||||
<LinearGradient colors={['#ff7a45', '#ffc86e', '#8fcaff']} start={{ x: 0, y: 0 }} end={{ x: 1, y: 1 }} style={{ position: 'absolute', inset: 0, borderRadius: 17 }} />
|
||||
<View className="flex-1 items-center justify-center rounded-full bg-card">
|
||||
<Ic name={avatar} size={22} />
|
||||
</View>
|
||||
</View>
|
||||
<View>
|
||||
<Text className="text-sm leading-tight font-extrabold text-ink">날씨각</Text>
|
||||
<Text className="text-xs font-semibold text-ink2">{account}</Text>
|
||||
</View>
|
||||
</View>
|
||||
<View ref={shot} collapsable={false}>
|
||||
{children}
|
||||
</View>
|
||||
<View className="flex-row items-center gap-3.5 px-3 pt-2.5 pb-1">
|
||||
{postId != null && (
|
||||
<>
|
||||
<Pressable onPress={like.toggle} hitSlop={8} accessibilityRole="button" accessibilityState={{ selected: like.liked }} accessibilityLabel="좋아요">
|
||||
<HeartIcon size={26} color={like.liked ? heart : ink} filled={like.liked} />
|
||||
</Pressable>
|
||||
<Pressable onPress={() => open({ type: 'comments', postId })} hitSlop={8} accessibilityRole="button" accessibilityLabel="댓글 보기">
|
||||
<CommentIcon size={26} color={ink} />
|
||||
</Pressable>
|
||||
</>
|
||||
)}
|
||||
<Pressable onPress={share} hitSlop={8} accessibilityRole="button" accessibilityLabel="보내기">
|
||||
<SendIcon size={26} color={ink} />
|
||||
</Pressable>
|
||||
{more != null && <View className="ml-auto">{more}</View>}
|
||||
</View>
|
||||
{postId != null && (
|
||||
<Text className={`px-3 py-0.5 text-sm font-extrabold ${like.failed ? 'text-heart' : 'text-ink'}`} accessibilityRole={like.failed ? 'alert' : undefined}>
|
||||
{like.failed ? '좋아요를 반영하지 못했어요. 다시 해 주세요.' : `좋아요 ${like.count.toLocaleString()}개`}
|
||||
</Text>
|
||||
)}
|
||||
{!!caption && (
|
||||
<Text className="px-3 pt-0.5 pb-3 text-sm text-ink">
|
||||
<Text className="font-extrabold">날씨각 </Text>
|
||||
{caption}
|
||||
</Text>
|
||||
)}
|
||||
{postId != null && (
|
||||
<Pressable onPress={() => open({ type: 'comments', postId })}>
|
||||
<Text className="px-3 pb-3 text-sm font-semibold text-ink3">{pinned?.post?.comment_count ? `댓글 ${pinned.post.comment_count}개 모두 보기` : '첫 댓글 남기기'}</Text>
|
||||
</Pressable>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { GakSlide, HoursSlide, PlanSlide, PostData, RowsSlide, SunsetSlide, WeekSlide } from '@nalssigak/shared/api/client/types.gen';
|
||||
import type { GakSlide, HoursSlide, ImageSlide, PlanSlide, PostData, RowsSlide, SunsetSlide, WeekSlide } from '@nalssigak/shared/api/client/types.gen';
|
||||
import { PostType, SlotTone } from '@nalssigak/shared/api/client/types.gen';
|
||||
import { cardBg, clockShort } from '@nalssigak/shared/lib';
|
||||
import type { SlideBg } from '@nalssigak/shared/lib/types';
|
||||
@@ -14,10 +14,10 @@ import { MoonArt } from '@/components/moon';
|
||||
import { Credit, Ic, Rows, Thumb } from '@/components/ui';
|
||||
import { CARD_BG } from '@/lib/colors';
|
||||
import { useSheet } from '@/lib/sheet';
|
||||
import { imageUri } from '@/lib/site';
|
||||
import { apiUri, imageUri } from '@/lib/site';
|
||||
import { useSky } from '@/lib/sky';
|
||||
|
||||
export type Slide = HoursSlide | RowsSlide | GakSlide | SunsetSlide | WeekSlide | PlanSlide;
|
||||
export type Slide = HoursSlide | RowsSlide | GakSlide | SunsetSlide | WeekSlide | PlanSlide | ImageSlide;
|
||||
|
||||
type Stops = readonly [string, string, ...string[]];
|
||||
|
||||
@@ -50,7 +50,7 @@ const HOUR_TONE: Record<string, { bg: string; edge: string }> = {
|
||||
|
||||
/** 배경색은 API에 없어 글 종류·아이콘으로 고른다 */
|
||||
export function slideBg(post: PostData, slide: Slide): SlideBg {
|
||||
if (slide.kind === 'hours') return 'sky';
|
||||
if (slide.kind === 'hours' || slide.kind === 'image') return 'sky';
|
||||
if (slide.kind === 'sunset') return 'dusk';
|
||||
if (slide.kind === 'week') return 'mint';
|
||||
if (slide.kind === 'plan') return slide.eyebrow.startsWith('일') ? 'peach' : 'butter';
|
||||
@@ -254,6 +254,8 @@ export function SlideView({ slide, bg }: { slide: Slide; bg: SlideBg }) {
|
||||
</Base>
|
||||
);
|
||||
}
|
||||
// 카드뉴스: 관리자가 만든 4:5 그림 한 장 (/v1/card/... 는 API 서버 경로)
|
||||
if (slide.kind === 'image') return <Image source={{ uri: apiUri(slide.url) }} accessibilityLabel={slide.alt ?? undefined} style={{ flex: 1 }} contentFit="cover" />;
|
||||
if (slide.kind === 'rows' && slide.image)
|
||||
return (
|
||||
<View className="flex-1 justify-end">
|
||||
|
||||
Reference in new issue
Block a user