Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ebbd5d457 |
No files matched your search
@@ -1,242 +1,119 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useState, useEffect } from 'react';
|
import { useRef } from 'react';
|
||||||
import CommentModal from '../CommentModal/CommentModal';
|
|
||||||
|
|
||||||
type Comment = {
|
export type PostCardData = {
|
||||||
id: number;
|
id: number;
|
||||||
author: string;
|
petName: string;
|
||||||
|
petType: 'Hund' | 'Katze';
|
||||||
|
authorName: string;
|
||||||
|
createdAt: string;
|
||||||
text: string;
|
text: string;
|
||||||
};
|
likesCount: number;
|
||||||
|
commentsCount: number;
|
||||||
type Media = {
|
|
||||||
type: 'image' | 'video';
|
|
||||||
url: string;
|
|
||||||
aspect: '1:1' | '9:16';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
type PostCardProps = {
|
type PostCardProps = {
|
||||||
petName: string;
|
post: PostCardData;
|
||||||
petType: 'Hund' | 'Katze';
|
isDiscovery?: boolean
|
||||||
ownerName?: string;
|
onOpenPreview: (post: PostCardData) => void;
|
||||||
text: string;
|
onCommentClick?: (post: PostCardData) => void;
|
||||||
createdAt: string;
|
|
||||||
media?: Media;
|
|
||||||
likes: number;
|
|
||||||
likedByCurrentUser?: boolean;
|
|
||||||
commentsCount: number;
|
|
||||||
commentsList: Comment[];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 🔐 Simulierter eingeloggter User
|
|
||||||
const CURRENT_USER_ID = 1;
|
|
||||||
|
|
||||||
export default function PostCard({
|
export default function PostCard({
|
||||||
petName,
|
post,
|
||||||
petType,
|
onOpenPreview,
|
||||||
ownerName,
|
onCommentClick,
|
||||||
text,
|
isDiscovery,
|
||||||
createdAt,
|
|
||||||
media,
|
|
||||||
likes,
|
|
||||||
likedByCurrentUser,
|
|
||||||
commentsCount,
|
|
||||||
commentsList,
|
|
||||||
}: PostCardProps) {
|
}: PostCardProps) {
|
||||||
const [showComments, setShowComments] = useState(false);
|
const likeRef = useRef<HTMLButtonElement | null>(null);
|
||||||
const [showMediaFullscreen, setShowMediaFullscreen] = useState(false);
|
const commentRef = useRef<HTMLButtonElement | null>(null);
|
||||||
|
|
||||||
const [localLikes, setLocalLikes] = useState(likes);
|
function animate(
|
||||||
const [liked, setLiked] = useState(!!likedByCurrentUser);
|
ref: React.RefObject<HTMLButtonElement>,
|
||||||
|
animation: string
|
||||||
const isSquare = media?.aspect === '1:1';
|
) {
|
||||||
|
if (!ref.current) return;
|
||||||
// ⛔ Scroll sperren bei Vollbild
|
const el = ref.current;
|
||||||
useEffect(() => {
|
el.style.animation = animation;
|
||||||
if (showMediaFullscreen) {
|
el.addEventListener(
|
||||||
document.body.style.overflow = 'hidden';
|
'animationend',
|
||||||
} else {
|
() => {
|
||||||
document.body.style.overflow = '';
|
el.style.animation = '';
|
||||||
}
|
},
|
||||||
}, [showMediaFullscreen]);
|
{ once: true }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<article
|
||||||
<article
|
className={`postcard ${
|
||||||
style={{
|
isDiscovery ? 'postcard--discovery' : ''
|
||||||
border: '1px solid #e5e5e5',
|
}`}
|
||||||
borderRadius: '16px',
|
>
|
||||||
backgroundColor: 'white',
|
|
||||||
overflow: 'hidden',
|
{/* Klickbarer Bereich → Preview */}
|
||||||
}}
|
<div
|
||||||
|
className="postcard-main"
|
||||||
|
onClick={() => onOpenPreview(post)}
|
||||||
>
|
>
|
||||||
{/* HEADER */}
|
<div className="postcard-media" />
|
||||||
<header style={{ padding: '1rem', display: 'grid', gap: '0.2rem' }}>
|
|
||||||
<div style={{ fontWeight: 800, fontSize: '1.1rem' }}>
|
|
||||||
{petName}{' '}
|
|
||||||
<span style={{ fontWeight: 500, color: '#666' }}>
|
|
||||||
({petType})
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style={{ fontSize: '0.8rem', color: '#777' }}>
|
<div className="postcard-content">
|
||||||
{createdAt}
|
<div className="postcard-header">
|
||||||
{ownerName && (
|
{isDiscovery && (
|
||||||
<>
|
<div className="post-discovery-wrapper">
|
||||||
{' · '}
|
|
||||||
<span style={{ fontStyle: 'italic' }}>
|
</div>
|
||||||
verwaltet von {ownerName}
|
)}
|
||||||
</span>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
{/* MEDIA */}
|
<div className="postcard-title-row">
|
||||||
{media && (
|
<strong className="postcard-title">
|
||||||
<div
|
{post.petName}
|
||||||
onClick={() => setShowMediaFullscreen(true)}
|
</strong>
|
||||||
style={{
|
<span className="postcard-meta">
|
||||||
width: '100%',
|
· {post.petType} · {post.authorName} · {post.createdAt}
|
||||||
aspectRatio: isSquare ? '1 / 1' : '9 / 16',
|
</span>
|
||||||
backgroundColor: '#000',
|
</div>
|
||||||
cursor: 'pointer',
|
</div>
|
||||||
}}
|
|
||||||
>
|
|
||||||
{media.type === 'image' && (
|
|
||||||
<img
|
|
||||||
src={media.url}
|
|
||||||
alt={petName}
|
|
||||||
style={{
|
|
||||||
width: '100%',
|
|
||||||
height: '100%',
|
|
||||||
objectFit: 'cover',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{media.type === 'video' && (
|
<p className="postcard-text">{post.text}</p>
|
||||||
<video
|
|
||||||
src={media.url}
|
|
||||||
muted
|
|
||||||
style={{
|
|
||||||
width: '100%',
|
|
||||||
height: '100%',
|
|
||||||
objectFit: 'cover',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* TEXT */}
|
|
||||||
<div style={{ padding: '1rem', fontSize: '0.95rem' }}>
|
|
||||||
{text}
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* FOOTER */}
|
{/* Interaktionen */}
|
||||||
<footer
|
<div className="postcard-actions">
|
||||||
style={{
|
<button
|
||||||
padding: '0 1rem 1rem',
|
ref={likeRef}
|
||||||
display: 'flex',
|
type="button"
|
||||||
gap: '1.2rem',
|
className="postcard-action"
|
||||||
fontSize: '0.85rem',
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
animate(likeRef, 'heart-pop 0.3s ease');
|
||||||
|
// später: Like-Logik
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<button
|
<span aria-hidden>❤️</span>
|
||||||
type="button"
|
<span>{post.likesCount}</span>
|
||||||
onClick={() => {
|
</button>
|
||||||
setLiked(!liked);
|
|
||||||
setLocalLikes((prev) => (liked ? prev - 1 : prev + 1));
|
|
||||||
|
|
||||||
console.log('LIKE', {
|
<button
|
||||||
byUser: CURRENT_USER_ID,
|
ref={commentRef}
|
||||||
pet: petName,
|
type="button"
|
||||||
});
|
className="postcard-action"
|
||||||
}}
|
onClick={(e) => {
|
||||||
style={{
|
e.stopPropagation();
|
||||||
background: 'none',
|
animate(commentRef, 'comment-wiggle 0.25s ease');
|
||||||
border: 'none',
|
onCommentClick?.(post);
|
||||||
cursor: 'pointer',
|
|
||||||
fontWeight: 600,
|
|
||||||
color: liked ? '#d32f2f' : '#555',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
❤️ {localLikes}
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={() => setShowComments(true)}
|
|
||||||
style={{
|
|
||||||
background: 'none',
|
|
||||||
border: 'none',
|
|
||||||
cursor: 'pointer',
|
|
||||||
fontWeight: 600,
|
|
||||||
color: '#2E7D32',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
💬 {commentsCount} Kommentare
|
|
||||||
</button>
|
|
||||||
</footer>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
{/* 💬 Kommentare */}
|
|
||||||
{showComments && (
|
|
||||||
<CommentModal
|
|
||||||
comments={commentsList}
|
|
||||||
onClose={() => setShowComments(false)}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* 🖼️ MEDIA FULLSCREEN */}
|
|
||||||
{showMediaFullscreen && media && (
|
|
||||||
<div
|
|
||||||
onClick={() => setShowMediaFullscreen(false)}
|
|
||||||
style={{
|
|
||||||
position: 'fixed',
|
|
||||||
inset: 0,
|
|
||||||
backgroundColor: 'rgba(0,0,0,0.9)',
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
zIndex: 2000,
|
|
||||||
cursor: 'zoom-out',
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<span aria-hidden>💬</span>
|
||||||
onClick={(e) => e.stopPropagation()}
|
<span>{post.commentsCount}</span>
|
||||||
style={{
|
</button>
|
||||||
maxWidth: '95vw',
|
</div>
|
||||||
maxHeight: '95vh',
|
</article>
|
||||||
}}
|
|
||||||
>
|
|
||||||
{media.type === 'image' && (
|
|
||||||
<img
|
|
||||||
src={media.url}
|
|
||||||
alt={petName}
|
|
||||||
style={{
|
|
||||||
maxWidth: '100%',
|
|
||||||
maxHeight: '100%',
|
|
||||||
objectFit: 'contain',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{media.type === 'video' && (
|
|
||||||
<video
|
|
||||||
src={media.url}
|
|
||||||
controls
|
|
||||||
autoPlay
|
|
||||||
style={{
|
|
||||||
maxWidth: '100%',
|
|
||||||
maxHeight: '100%',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
+89
-335
@@ -1,26 +1,15 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useRef, useState } from 'react';
|
import { useRef, useState } from 'react';
|
||||||
|
import PostCard, {
|
||||||
|
PostCardData,
|
||||||
|
} from '@/app/components/PostCard/PostCard';
|
||||||
|
|
||||||
type ExplorePet = {
|
/* =======================
|
||||||
id: number;
|
MOCK DATA
|
||||||
name: string;
|
======================= */
|
||||||
type: 'Hund' | 'Katze';
|
|
||||||
};
|
|
||||||
|
|
||||||
type ExplorePost = {
|
const trendingPets = [
|
||||||
id: number;
|
|
||||||
petId: number;
|
|
||||||
petName: string;
|
|
||||||
petType: 'Hund' | 'Katze';
|
|
||||||
authorName: string;
|
|
||||||
createdAt: string;
|
|
||||||
text: string;
|
|
||||||
likesCount: number;
|
|
||||||
commentsCount: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
const trendingPets: ExplorePet[] = [
|
|
||||||
{ id: 1, name: 'Luna', type: 'Katze' },
|
{ id: 1, name: 'Luna', type: 'Katze' },
|
||||||
{ id: 2, name: 'Bello', type: 'Hund' },
|
{ id: 2, name: 'Bello', type: 'Hund' },
|
||||||
{ id: 3, name: 'Milo', type: 'Katze' },
|
{ id: 3, name: 'Milo', type: 'Katze' },
|
||||||
@@ -29,10 +18,9 @@ const trendingPets: ExplorePet[] = [
|
|||||||
{ id: 6, name: 'Leo', type: 'Hund' },
|
{ id: 6, name: 'Leo', type: 'Hund' },
|
||||||
];
|
];
|
||||||
|
|
||||||
const latestPosts: ExplorePost[] = [
|
const latestPosts: PostCardData[] = [
|
||||||
{
|
{
|
||||||
id: 101,
|
id: 101,
|
||||||
petId: 1,
|
|
||||||
petName: 'Luna',
|
petName: 'Luna',
|
||||||
petType: 'Katze',
|
petType: 'Katze',
|
||||||
authorName: 'Anna',
|
authorName: 'Anna',
|
||||||
@@ -43,7 +31,6 @@ const latestPosts: ExplorePost[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 102,
|
id: 102,
|
||||||
petId: 2,
|
|
||||||
petName: 'Bello',
|
petName: 'Bello',
|
||||||
petType: 'Hund',
|
petType: 'Hund',
|
||||||
authorName: 'Markus',
|
authorName: 'Markus',
|
||||||
@@ -54,7 +41,6 @@ const latestPosts: ExplorePost[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 103,
|
id: 103,
|
||||||
petId: 3,
|
|
||||||
petName: 'Milo',
|
petName: 'Milo',
|
||||||
petType: 'Katze',
|
petType: 'Katze',
|
||||||
authorName: 'Sophie',
|
authorName: 'Sophie',
|
||||||
@@ -65,7 +51,6 @@ const latestPosts: ExplorePost[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 104,
|
id: 104,
|
||||||
petId: 4,
|
|
||||||
petName: 'Rocky',
|
petName: 'Rocky',
|
||||||
petType: 'Hund',
|
petType: 'Hund',
|
||||||
authorName: 'Timo',
|
authorName: 'Timo',
|
||||||
@@ -76,15 +61,20 @@ const latestPosts: ExplorePost[] = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/* =======================
|
||||||
|
PAGE
|
||||||
|
======================= */
|
||||||
|
|
||||||
export default function ExplorePage() {
|
export default function ExplorePage() {
|
||||||
const [activeFilter, setActiveFilter] = useState<
|
const [activeFilter, setActiveFilter] =
|
||||||
'ALLE' | 'HUND' | 'KATZE'
|
useState<'ALLE' | 'HUND' | 'KATZE'>('ALLE');
|
||||||
>('ALLE');
|
|
||||||
|
|
||||||
const [previewPost, setPreviewPost] = useState<ExplorePost | null>(null);
|
const [previewPost, setPreviewPost] =
|
||||||
const [openComments, setOpenComments] = useState(false);
|
useState<PostCardData | null>(null);
|
||||||
|
|
||||||
// Swipe-Down Handling fürs Modal
|
const [openComments, setOpenComments] = useState(false);
|
||||||
|
|
||||||
|
// Swipe-Down fürs Modal
|
||||||
const startY = useRef<number | null>(null);
|
const startY = useRef<number | null>(null);
|
||||||
|
|
||||||
const filteredPosts = latestPosts.filter((p) => {
|
const filteredPosts = latestPosts.filter((p) => {
|
||||||
@@ -96,90 +86,46 @@ const [openComments, setOpenComments] = useState(false);
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* ================= HEADER / FILTER ================= */}
|
{/* ================= HEADER / FILTER ================= */}
|
||||||
<section
|
<section className="explore-header">
|
||||||
style={{
|
|
||||||
padding: '1rem',
|
|
||||||
display: 'grid',
|
|
||||||
gap: '1rem',
|
|
||||||
maxWidth: '720px',
|
|
||||||
margin: '0 auto',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<header>
|
<header>
|
||||||
<h1 style={{ marginBottom: '0.3rem' }}>Entdecken</h1>
|
<h1>Entdecken</h1>
|
||||||
<p style={{ margin: 0, color: '#666' }}>
|
<p>Neue Tiere, Trends & besondere Momente</p>
|
||||||
Neue Tiere, Trends & besondere Momente
|
|
||||||
</p>
|
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div style={{ display: 'flex', gap: '0.5rem' }}>
|
<div className="explore-filter">
|
||||||
{[
|
{[
|
||||||
{ key: 'ALLE', label: 'Alle' },
|
{ key: 'ALLE', label: 'Alle' },
|
||||||
{ key: 'HUND', label: 'Hunde' },
|
{ key: 'HUND', label: 'Hunde' },
|
||||||
{ key: 'KATZE', label: 'Katzen' },
|
{ key: 'KATZE', label: 'Katzen' },
|
||||||
].map((f) => {
|
].map((f) => (
|
||||||
const active = activeFilter === f.key;
|
<button
|
||||||
return (
|
key={f.key}
|
||||||
<button
|
className={
|
||||||
key={f.key}
|
activeFilter === f.key
|
||||||
onClick={() =>
|
? 'filter-button active'
|
||||||
setActiveFilter(f.key as 'ALLE' | 'HUND' | 'KATZE')
|
: 'filter-button'
|
||||||
}
|
}
|
||||||
style={{
|
onClick={() =>
|
||||||
padding: '0.45rem 0.9rem',
|
setActiveFilter(f.key as 'ALLE' | 'HUND' | 'KATZE')
|
||||||
borderRadius: '999px',
|
}
|
||||||
border: active ? 'none' : '1px solid #ccc',
|
>
|
||||||
backgroundColor: active ? '#2E7D32' : 'white',
|
{f.label}
|
||||||
color: active ? 'white' : 'inherit',
|
</button>
|
||||||
fontSize: '0.75rem',
|
))}
|
||||||
fontWeight: active ? 600 : 400,
|
|
||||||
cursor: 'pointer',
|
|
||||||
transform: active ? 'scale(1.05)' : 'scale(1)',
|
|
||||||
transition:
|
|
||||||
'background-color 0.2s ease, transform 0.15s ease',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{f.label}
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{/* ================= BELIEBTE TIERE ================= */}
|
{/* ================= BELIEBTE TIERE ================= */}
|
||||||
<section style={{ paddingLeft: '1rem', marginBottom: '1.5rem' }}>
|
<section className="explore-trending">
|
||||||
<strong style={{ display: 'block', marginBottom: '0.6rem' }}>
|
<strong>Beliebte Tiere</strong>
|
||||||
Beliebte Tiere
|
|
||||||
</strong>
|
|
||||||
|
|
||||||
<div
|
<div className="trending-scroll hide-scrollbar">
|
||||||
className="hide-scrollbar"
|
|
||||||
style={{
|
|
||||||
display: 'flex',
|
|
||||||
gap: '0.8rem',
|
|
||||||
overflowX: 'auto',
|
|
||||||
WebkitOverflowScrolling: 'touch',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{trendingPets.map((pet) => (
|
{trendingPets.map((pet) => (
|
||||||
<div key={pet.id} style={{ width: '84px', flex: '0 0 auto' }}>
|
<div key={pet.id} className="trending-item">
|
||||||
<div
|
<div className="trending-avatar">🐾</div>
|
||||||
style={{
|
<div className="trending-meta">
|
||||||
width: '84px',
|
|
||||||
height: '84px',
|
|
||||||
borderRadius: '18px',
|
|
||||||
backgroundColor: '#f2f2f2',
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
fontSize: '1.4rem',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
🐾
|
|
||||||
</div>
|
|
||||||
<div style={{ marginTop: '0.4rem', fontSize: '0.72rem' }}>
|
|
||||||
<strong>{pet.name}</strong>
|
<strong>{pet.name}</strong>
|
||||||
<div style={{ color: '#777' }}>{pet.type}</div>
|
<span>{pet.type}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
@@ -187,151 +133,23 @@ const [openComments, setOpenComments] = useState(false);
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
{/* ================= POSTS ================= */}
|
{/* ================= POSTS ================= */}
|
||||||
<section
|
<section className="explore-posts">
|
||||||
style={{
|
<strong>Neueste Beiträge</strong>
|
||||||
padding: '0 1rem 1rem',
|
|
||||||
maxWidth: '720px',
|
|
||||||
margin: '0 auto',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<strong style={{ display: 'block', marginBottom: '0.6rem' }}>
|
|
||||||
Neueste Beiträge
|
|
||||||
</strong>
|
|
||||||
|
|
||||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.9rem' }}>
|
<div className="post-list">
|
||||||
{filteredPosts.map((post) => (
|
{filteredPosts.map((post) => (
|
||||||
<article
|
<PostCard
|
||||||
key={post.id}
|
key={post.id}
|
||||||
style={{
|
post={post}
|
||||||
border: '1px solid #eee',
|
onOpenPreview={(p) => {
|
||||||
borderRadius: '18px',
|
setOpenComments(false);
|
||||||
overflow: 'hidden',
|
setPreviewPost(p);
|
||||||
backgroundColor: 'white',
|
|
||||||
}}
|
}}
|
||||||
>
|
onCommentClick={(p) => {
|
||||||
{/* ✅ Nur dieser Bereich öffnet das Modal */}
|
setOpenComments(true);
|
||||||
<div
|
setPreviewPost(p);
|
||||||
onClick={() => setPreviewPost(post)}
|
}}
|
||||||
style={{ cursor: 'pointer' }}
|
/>
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
width: '100%',
|
|
||||||
aspectRatio: '3 / 2',
|
|
||||||
backgroundColor: '#eaeaea',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div style={{ padding: '0.8rem', display: 'grid', gap: '0.35rem' }}>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
gap: '0.6rem',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div>
|
|
||||||
<strong>{post.petName}</strong>{' '}
|
|
||||||
<span style={{ color: '#777', fontSize: '0.8rem' }}>
|
|
||||||
· {post.petType} · {post.authorName}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<span
|
|
||||||
style={{
|
|
||||||
color: '#777',
|
|
||||||
fontSize: '0.8rem',
|
|
||||||
whiteSpace: 'nowrap',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{post.createdAt}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p style={{ margin: 0, fontSize: '0.9rem' }}>{post.text}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* ✅ Interaktionszeile (öffnet KEIN Modal) */}
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
padding: '0 0.8rem 0.8rem',
|
|
||||||
display: 'flex',
|
|
||||||
gap: '1rem',
|
|
||||||
fontSize: '0.85rem',
|
|
||||||
color: '#555',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
|
|
||||||
const el = e.currentTarget;
|
|
||||||
el.style.animation = 'heart-pop 0.3s ease';
|
|
||||||
el.addEventListener(
|
|
||||||
'animationend',
|
|
||||||
() => {
|
|
||||||
el.style.animation = '';
|
|
||||||
},
|
|
||||||
{ once: true }
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log('LIKE CLICK', post.id);
|
|
||||||
}}
|
|
||||||
style={{
|
|
||||||
border: 'none',
|
|
||||||
background: 'transparent',
|
|
||||||
padding: 0,
|
|
||||||
cursor: 'pointer',
|
|
||||||
display: 'flex',
|
|
||||||
gap: '0.35rem',
|
|
||||||
alignItems: 'center',
|
|
||||||
color: 'inherit',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<span aria-hidden>❤️</span>
|
|
||||||
<span>{post.likesCount}</span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
|
|
||||||
// Animation
|
|
||||||
const el = e.currentTarget;
|
|
||||||
el.style.animation = 'comment-wiggle 0.25s ease';
|
|
||||||
el.addEventListener(
|
|
||||||
'animationend',
|
|
||||||
() => {
|
|
||||||
el.style.animation = '';
|
|
||||||
},
|
|
||||||
{ once: true }
|
|
||||||
);
|
|
||||||
|
|
||||||
// 👉 LOGIK
|
|
||||||
setOpenComments(true);
|
|
||||||
setPreviewPost(post);
|
|
||||||
}}
|
|
||||||
style={{
|
|
||||||
border: 'none',
|
|
||||||
background: 'transparent',
|
|
||||||
padding: 0,
|
|
||||||
cursor: 'pointer',
|
|
||||||
display: 'flex',
|
|
||||||
gap: '0.35rem',
|
|
||||||
alignItems: 'center',
|
|
||||||
color: 'inherit',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<span aria-hidden>💬</span>
|
|
||||||
<span>{post.commentsCount}</span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
@@ -339,127 +157,63 @@ const [openComments, setOpenComments] = useState(false);
|
|||||||
{/* ================= PREVIEW MODAL ================= */}
|
{/* ================= PREVIEW MODAL ================= */}
|
||||||
{previewPost && (
|
{previewPost && (
|
||||||
<div
|
<div
|
||||||
onClick={() => setPreviewPost(null)}
|
className="post-preview-overlay"
|
||||||
style={{
|
onClick={() => {
|
||||||
position: 'fixed',
|
setPreviewPost(null);
|
||||||
inset: 0,
|
setOpenComments(false);
|
||||||
backgroundColor: 'rgba(0,0,0,0.4)',
|
|
||||||
zIndex: 50,
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'center',
|
|
||||||
alignItems: 'flex-end',
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
className="post-preview-modal"
|
||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
onTouchStart={(e) => (startY.current = e.touches[0].clientY)}
|
onTouchStart={(e) =>
|
||||||
|
(startY.current = e.touches[0].clientY)
|
||||||
|
}
|
||||||
onTouchEnd={(e) => {
|
onTouchEnd={(e) => {
|
||||||
if (
|
if (
|
||||||
startY.current &&
|
startY.current &&
|
||||||
e.changedTouches[0].clientY - startY.current > 80
|
e.changedTouches[0].clientY - startY.current > 80
|
||||||
) {
|
) {
|
||||||
setPreviewPost(null);
|
setPreviewPost(null);
|
||||||
setOpenComments(false);
|
setOpenComments(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
style={{
|
|
||||||
backgroundColor: 'white',
|
|
||||||
width: '100%',
|
|
||||||
maxWidth: '720px',
|
|
||||||
borderTopLeftRadius: '22px',
|
|
||||||
borderTopRightRadius: '22px',
|
|
||||||
padding: '1rem',
|
|
||||||
animation: 'slideUp 0.25s ease',
|
|
||||||
paddingBottom: '5rem',
|
|
||||||
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<div
|
<div className="modal-handle" />
|
||||||
style={{
|
|
||||||
width: '36px',
|
|
||||||
height: '4px',
|
|
||||||
borderRadius: '999px',
|
|
||||||
backgroundColor: '#ccc',
|
|
||||||
margin: '0 auto 0.8rem',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div
|
<div className="modal-media" />
|
||||||
style={{
|
|
||||||
width: '100%',
|
|
||||||
aspectRatio: '3 / 2',
|
|
||||||
backgroundColor: '#eaeaea',
|
|
||||||
borderRadius: '14px',
|
|
||||||
marginBottom: '0.8rem',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<strong>{previewPost.petName}</strong>{' '}
|
<strong>{previewPost.petName}</strong>{' '}
|
||||||
<span style={{ color: '#777', fontSize: '0.85rem' }}>
|
<span className="modal-meta">
|
||||||
· {previewPost.petType} · {previewPost.authorName}
|
· {previewPost.petType} · {previewPost.authorName}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<p style={{ marginTop: '0.6rem' }}>{previewPost.text}</p>
|
<p className="modal-text">{previewPost.text}</p>
|
||||||
{openComments && (
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
marginTop: '1rem',
|
|
||||||
paddingTop: '0.8rem',
|
|
||||||
borderTop: '1px solid #eee',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<strong style={{ fontSize: '0.9rem' }}>Kommentare</strong>
|
|
||||||
|
|
||||||
<div
|
<div className="modal-stats">
|
||||||
style={{
|
<span>❤️ {previewPost.likesCount}</span>
|
||||||
marginTop: '0.6rem',
|
<span>💬 {previewPost.commentsCount}</span>
|
||||||
fontSize: '0.85rem',
|
</div>
|
||||||
color: '#666',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Noch keine Kommentare.
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<input
|
{openComments && (
|
||||||
placeholder="Kommentar schreiben…"
|
<div className="modal-comments">
|
||||||
style={{
|
<strong>Kommentare</strong>
|
||||||
marginTop: '0.6rem',
|
<p className="modal-comment-empty">
|
||||||
width: '100%',
|
Noch keine Kommentare.
|
||||||
padding: '0.6rem 0.8rem',
|
</p>
|
||||||
borderRadius: '999px',
|
|
||||||
border: '1px solid #ccc',
|
|
||||||
fontSize: '0.85rem',
|
|
||||||
}}
|
|
||||||
autoFocus
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div
|
<input
|
||||||
style={{
|
className="modal-comment-input"
|
||||||
display: 'flex',
|
placeholder="Kommentar schreiben…"
|
||||||
justifyContent: 'space-between',
|
autoFocus
|
||||||
alignItems: 'center',
|
/>
|
||||||
marginTop: '1rem',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div style={{ fontSize: '0.9rem', color: '#555', display: 'flex', gap: '1rem' }}>
|
|
||||||
<span>❤️ {previewPost.likesCount}</span>
|
|
||||||
<span>💬 {previewPost.commentsCount}</span>
|
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div className="modal-actions">
|
||||||
<a
|
<a
|
||||||
href={`/post/${previewPost.id}`}
|
href={`/post/${previewPost.id}`}
|
||||||
style={{
|
className="modal-open-post"
|
||||||
padding: '0.5rem 0.9rem',
|
|
||||||
borderRadius: '999px',
|
|
||||||
backgroundColor: '#2E7D32',
|
|
||||||
color: 'white',
|
|
||||||
textDecoration: 'none',
|
|
||||||
fontSize: '0.85rem',
|
|
||||||
fontWeight: 600,
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
Zum Beitrag
|
Zum Beitrag
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
+207
-149
@@ -1,179 +1,237 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useState } from 'react';
|
import { useRef, useState } from 'react';
|
||||||
import PostCard from '../components/PostCard/PostCard';
|
import PostCard, {
|
||||||
import FreshPostsSlider from '../components/FreshPostsSlider/FreshPostsSlider';
|
PostCardData,
|
||||||
|
} from '@/app/components/PostCard/PostCard';
|
||||||
|
|
||||||
/* ---------------- TYPES ---------------- */
|
/* =======================
|
||||||
|
MOCK: USER KONTEXT
|
||||||
|
======================= */
|
||||||
|
|
||||||
type Comment = {
|
const myPets = [
|
||||||
id: number;
|
|
||||||
author: string;
|
|
||||||
text: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
type Media = {
|
|
||||||
type: 'image' | 'video';
|
|
||||||
url: string;
|
|
||||||
aspect: '1:1' | '9:16';
|
|
||||||
};
|
|
||||||
|
|
||||||
type FeedPost = {
|
|
||||||
id: number;
|
|
||||||
|
|
||||||
// 🐾 Tier (Absender)
|
|
||||||
petId: number;
|
|
||||||
petName: string;
|
|
||||||
petType: 'Hund' | 'Katze';
|
|
||||||
|
|
||||||
// 👤 Admin (sekundär)
|
|
||||||
ownerId: number;
|
|
||||||
ownerName: string;
|
|
||||||
|
|
||||||
// 📝 Inhalt
|
|
||||||
text: string;
|
|
||||||
createdAt: string;
|
|
||||||
|
|
||||||
// 📸 / 🎥 Media
|
|
||||||
media?: Media;
|
|
||||||
|
|
||||||
// ❤️ Interaktion
|
|
||||||
likes: number;
|
|
||||||
//likedByCurrentUser: number; // ✅ FEHLTE
|
|
||||||
commentsCount: number;
|
|
||||||
commentsList: Comment[];
|
|
||||||
};
|
|
||||||
|
|
||||||
type FeedAdmin = {
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
avatar: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ---------------- MOCK ADMINS ---------------- */
|
|
||||||
|
|
||||||
const mockAdmins: FeedAdmin[] = [
|
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'Anna',
|
petType: 'Katze',
|
||||||
avatar: 'https://i.pravatar.cc/100?img=12',
|
breed: 'Bengal',
|
||||||
},
|
ageMonths: 24,
|
||||||
{
|
|
||||||
id: 2,
|
|
||||||
name: 'Markus',
|
|
||||||
avatar: 'https://i.pravatar.cc/100?img=32',
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
/* ---------------- MOCK POSTS ---------------- */
|
const followedPetIds = [1, 3, 5];
|
||||||
|
|
||||||
const mockPosts: FeedPost[] = [
|
/* =======================
|
||||||
|
MOCK: POSTS
|
||||||
|
======================= */
|
||||||
|
|
||||||
|
type FeedPost = PostCardData & {
|
||||||
|
petId: number;
|
||||||
|
breed: string;
|
||||||
|
ageMonths: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
const allPosts: FeedPost[] = [
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 401,
|
||||||
petId: 1,
|
petId: 1,
|
||||||
petName: 'Luna',
|
petName: 'Luna',
|
||||||
petType: 'Katze',
|
petType: 'Katze',
|
||||||
|
breed: 'Bengal',
|
||||||
ownerId: 1,
|
ageMonths: 26,
|
||||||
ownerName: 'Anna',
|
authorName: 'Anna',
|
||||||
|
createdAt: 'vor 10 Minuten',
|
||||||
text: 'Luna genießt die Sonne auf dem Balkon ☀️',
|
text: 'Luna liebt den neuen Kratzbaum.',
|
||||||
createdAt: 'vor 2 Stunden',
|
likesCount: 8,
|
||||||
|
|
||||||
media: {
|
|
||||||
type: 'image',
|
|
||||||
url: 'https://placekitten.com/600/600',
|
|
||||||
aspect: '1:1',
|
|
||||||
},
|
|
||||||
|
|
||||||
likes: 12,
|
|
||||||
commentsCount: 2,
|
commentsCount: 2,
|
||||||
commentsList: [
|
|
||||||
{ id: 1, author: 'Lisa', text: 'Wie süß 😍' },
|
|
||||||
{ id: 2, author: 'Tom', text: 'Typisch Katze!' },
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 402,
|
||||||
petId: 2,
|
petId: 2,
|
||||||
petName: 'Bello',
|
petName: 'Rocky',
|
||||||
petType: 'Hund',
|
petType: 'Hund',
|
||||||
|
breed: 'Labrador',
|
||||||
ownerId: 2,
|
ageMonths: 30,
|
||||||
ownerName: 'Markus',
|
authorName: 'Tim',
|
||||||
|
createdAt: 'vor 1 Stunde',
|
||||||
text: 'Spaziergang im Park – jemand hatte sehr viel Energie 🐕',
|
text: 'Rocky war schwimmen 🐕🦺',
|
||||||
createdAt: 'heute Morgen',
|
likesCount: 15,
|
||||||
|
commentsCount: 4,
|
||||||
media: {
|
},
|
||||||
type: 'video',
|
{
|
||||||
url: 'https://www.w3schools.com/html/mov_bbb.mp4',
|
id: 403,
|
||||||
aspect: '9:16',
|
petId: 3,
|
||||||
},
|
petName: 'Milo',
|
||||||
|
petType: 'Katze',
|
||||||
likes: 20,
|
breed: 'Bengal',
|
||||||
|
ageMonths: 22,
|
||||||
|
authorName: 'Sophie',
|
||||||
commentsCount: 0,
|
createdAt: 'heute',
|
||||||
commentsList: [],
|
text: 'Milo entdeckt den Balkon.',
|
||||||
|
likesCount: 11,
|
||||||
|
commentsCount: 3,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 404,
|
||||||
|
petId: 4,
|
||||||
|
petName: 'Nala',
|
||||||
|
petType: 'Katze',
|
||||||
|
breed: 'Maine Coon',
|
||||||
|
ageMonths: 40,
|
||||||
|
authorName: 'Laura',
|
||||||
|
createdAt: 'gestern',
|
||||||
|
text: 'Nala beobachtet alles ganz ruhig.',
|
||||||
|
likesCount: 6,
|
||||||
|
commentsCount: 1,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
/* ---------------- PAGE ---------------- */
|
/* =======================
|
||||||
|
RELEVANZ LOGIK
|
||||||
|
======================= */
|
||||||
|
|
||||||
|
function relevanceScore(post: FeedPost) {
|
||||||
|
let score = 0;
|
||||||
|
|
||||||
|
myPets.forEach((pet) => {
|
||||||
|
if (post.petType === pet.petType) score += 3;
|
||||||
|
if (post.breed === pet.breed) score += 5;
|
||||||
|
if (Math.abs(post.ageMonths - pet.ageMonths) <= 6) score += 2;
|
||||||
|
});
|
||||||
|
|
||||||
|
score += Math.min(post.likesCount / 10, 3);
|
||||||
|
score += Math.min(post.commentsCount / 5, 2);
|
||||||
|
|
||||||
|
return score;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* =======================
|
||||||
|
PAGE
|
||||||
|
======================= */
|
||||||
|
|
||||||
export default function FeedPage() {
|
export default function FeedPage() {
|
||||||
const [selectedOwnerId, setSelectedOwnerId] = useState<number | null>(null);
|
const [previewPost, setPreviewPost] =
|
||||||
|
useState<PostCardData | null>(null);
|
||||||
|
const [openComments, setOpenComments] = useState(false);
|
||||||
|
|
||||||
const visiblePosts = selectedOwnerId
|
const startY = useRef<number | null>(null);
|
||||||
? mockPosts.filter((post) => post.ownerId === selectedOwnerId)
|
|
||||||
: mockPosts;
|
/* =======================
|
||||||
|
FEED ZUSAMMENSTELLEN
|
||||||
|
======================= */
|
||||||
|
|
||||||
|
const subscribedPosts = allPosts.filter((post) =>
|
||||||
|
followedPetIds.includes(post.petId)
|
||||||
|
);
|
||||||
|
|
||||||
|
const discoveryPosts = allPosts
|
||||||
|
.filter((post) => !followedPetIds.includes(post.petId))
|
||||||
|
.sort((a, b) => relevanceScore(b) - relevanceScore(a));
|
||||||
|
|
||||||
|
const FEED_SIZE = 20;
|
||||||
|
const DISCOVERY_RATIO = 0.15;
|
||||||
|
|
||||||
|
const discoveryCount = Math.max(
|
||||||
|
1,
|
||||||
|
Math.round(FEED_SIZE * DISCOVERY_RATIO)
|
||||||
|
);
|
||||||
|
|
||||||
|
const finalFeed = [
|
||||||
|
...subscribedPosts
|
||||||
|
.slice(0, FEED_SIZE - discoveryCount)
|
||||||
|
.map((p) => ({ ...p, isDiscovery: false })),
|
||||||
|
|
||||||
|
...discoveryPosts
|
||||||
|
.slice(0, discoveryCount)
|
||||||
|
.map((p) => ({ ...p, isDiscovery: true })),
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section
|
<>
|
||||||
style={{
|
{/* ================= HEADER ================= */}
|
||||||
maxWidth: '600px',
|
<section className="feed-header">
|
||||||
margin: '0 auto',
|
<header>
|
||||||
display: 'grid',
|
<h1>Feed</h1>
|
||||||
gap: '1.5rem',
|
<p>Beiträge deiner Tiere & Abos</p>
|
||||||
}}
|
</header>
|
||||||
>
|
|
||||||
{/* HEADER */}
|
|
||||||
<header>
|
|
||||||
<h1 style={{ marginBottom: '0.3rem' }}>Feed</h1>
|
|
||||||
<p style={{ margin: 0, color: '#555' }}>
|
|
||||||
Neueste Beiträge aus der OnlyPets-Community
|
|
||||||
</p>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
{/* 🔄 Frische Tier-Admins Slider */}
|
|
||||||
<FreshPostsSlider
|
|
||||||
users={mockAdmins}
|
|
||||||
onSelectUser={setSelectedOwnerId}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* 📰 FEED */}
|
|
||||||
<section style={{ display: 'grid', gap: '1.5rem' }}>
|
|
||||||
{visiblePosts.length === 0 && (
|
|
||||||
<p style={{ color: '#777' }}>
|
|
||||||
Keine Beiträge von diesen Tier-Admins.
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{visiblePosts.map((post) => (
|
|
||||||
<PostCard
|
|
||||||
key={post.id}
|
|
||||||
petName={post.petName}
|
|
||||||
petType={post.petType}
|
|
||||||
ownerName={post.ownerName}
|
|
||||||
text={post.text}
|
|
||||||
createdAt={post.createdAt}
|
|
||||||
media={post.media}
|
|
||||||
likes={post.likes}
|
|
||||||
commentsCount={post.commentsCount}
|
|
||||||
commentsList={post.commentsList}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</section>
|
</section>
|
||||||
</section>
|
|
||||||
|
{/* ================= POSTS ================= */}
|
||||||
|
<section className="feed-posts">
|
||||||
|
<div className="post-list">
|
||||||
|
{finalFeed.map((post) => (
|
||||||
|
<PostCard
|
||||||
|
key={post.id}
|
||||||
|
post={post}
|
||||||
|
isDiscovery={post.isDiscovery}
|
||||||
|
onOpenPreview={(p) => {
|
||||||
|
setOpenComments(false);
|
||||||
|
setPreviewPost(p);
|
||||||
|
}}
|
||||||
|
onCommentClick={(p) => {
|
||||||
|
setOpenComments(true);
|
||||||
|
setPreviewPost(p);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
{/* ================= PREVIEW MODAL ================= */}
|
||||||
|
{previewPost && (
|
||||||
|
<div
|
||||||
|
className="post-preview-overlay"
|
||||||
|
onClick={() => {
|
||||||
|
setPreviewPost(null);
|
||||||
|
setOpenComments(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="post-preview-modal"
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
onTouchStart={(e) =>
|
||||||
|
(startY.current = e.touches[0].clientY)
|
||||||
|
}
|
||||||
|
onTouchEnd={(e) => {
|
||||||
|
if (
|
||||||
|
startY.current &&
|
||||||
|
e.changedTouches[0].clientY - startY.current > 80
|
||||||
|
) {
|
||||||
|
setPreviewPost(null);
|
||||||
|
setOpenComments(false);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className="modal-handle" />
|
||||||
|
<div className="modal-media" />
|
||||||
|
|
||||||
|
<strong>{previewPost.petName}</strong>{' '}
|
||||||
|
<span className="modal-meta">
|
||||||
|
· {previewPost.petType} · {previewPost.authorName}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<p className="modal-text">{previewPost.text}</p>
|
||||||
|
|
||||||
|
<div className="modal-stats">
|
||||||
|
<span>❤️ {previewPost.likesCount}</span>
|
||||||
|
<span>💬 {previewPost.commentsCount}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{openComments && (
|
||||||
|
<div className="modal-comments">
|
||||||
|
<strong>Kommentare</strong>
|
||||||
|
<p className="modal-comment-empty">
|
||||||
|
Noch keine Kommentare.
|
||||||
|
</p>
|
||||||
|
<input
|
||||||
|
className="modal-comment-input"
|
||||||
|
placeholder="Kommentar schreiben…"
|
||||||
|
autoFocus
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
+191
-8
@@ -1,16 +1,49 @@
|
|||||||
@import "tailwindcss";
|
@import "tailwindcss";
|
||||||
|
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
:root {
|
:root {
|
||||||
--background: #ffffff;
|
/* ===== COLORS ===== */
|
||||||
--foreground: #171717;
|
--color-primary: #2e7d32;
|
||||||
|
--color-primary-soft: #e6efe9;
|
||||||
|
|
||||||
|
--color-bg: #f6faf7;
|
||||||
|
--color-surface: #ffffff;
|
||||||
|
|
||||||
|
--color-text-main: #1f2d24;
|
||||||
|
--color-text-secondary: #5f6f66;
|
||||||
|
--color-text-muted: #8a9b92;
|
||||||
|
|
||||||
|
--color-border: rgba(0, 0, 0, 0.06);
|
||||||
|
|
||||||
|
/* ===== SHADOWS ===== */
|
||||||
|
--shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.05);
|
||||||
|
--shadow-md: 0 8px 20px rgba(0, 0, 0, 0.08);
|
||||||
|
--shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.12);
|
||||||
|
|
||||||
|
/* ===== RADIUS ===== */
|
||||||
|
--radius-sm: 10px;
|
||||||
|
--radius-md: 14px;
|
||||||
|
--radius-lg: 18px;
|
||||||
|
|
||||||
|
/* ===== SPACING ===== */
|
||||||
|
--space-xs: 0.25rem;
|
||||||
|
--space-sm: 0.5rem;
|
||||||
|
--space-md: 1rem;
|
||||||
|
--space-lg: 1.5rem;
|
||||||
|
--space-xl: 2rem;
|
||||||
|
}
|
||||||
|
html, body {
|
||||||
|
background: var(--color-bg);
|
||||||
|
color: var(--color-text-main);
|
||||||
|
font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
|
||||||
|
line-height: 1.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
@theme inline {
|
|
||||||
--color-background: var(--background);
|
|
||||||
--color-foreground: var(--foreground);
|
|
||||||
--font-sans: var(--font-geist-sans);
|
|
||||||
--font-mono: var(--font-geist-mono);
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) {
|
@media (prefers-color-scheme: dark) {
|
||||||
:root {
|
:root {
|
||||||
@@ -96,4 +129,154 @@ body {
|
|||||||
transform: translateY(0);
|
transform: translateY(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.postcard {
|
||||||
|
background: var(--color-surface);
|
||||||
|
border-radius: var(--radius-lg);
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
box-shadow: var(--shadow-sm);
|
||||||
|
padding: var(--space-md);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--space-sm);
|
||||||
|
transition: box-shadow 0.2s ease, transform 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.postcard:hover {
|
||||||
|
box-shadow: var(--shadow-md);
|
||||||
|
transform: translateY(-1px);
|
||||||
|
}
|
||||||
|
.postcard {
|
||||||
|
background: var(--color-surface);
|
||||||
|
border-radius: var(--radius-lg);
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
box-shadow: var(--shadow-sm);
|
||||||
|
padding: var(--space-md);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--space-sm);
|
||||||
|
transition: box-shadow 0.2s ease, transform 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.postcard:hover {
|
||||||
|
box-shadow: var(--shadow-md);
|
||||||
|
transform: translateY(-1px);
|
||||||
|
}
|
||||||
|
.postcard-content {
|
||||||
|
font-size: 0.95rem;
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
}
|
||||||
|
.postcard-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: var(--space-md);
|
||||||
|
align-items: center;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.postcard-action {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.3rem;
|
||||||
|
cursor: pointer;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.postcard-action:hover {
|
||||||
|
color: var(--color-text-main);
|
||||||
|
}
|
||||||
|
.postcard--discovery {
|
||||||
|
border: 1px solid var(--color-primary);
|
||||||
|
box-shadow:
|
||||||
|
0 0 0 1px rgba(46, 125, 50, 0.15),
|
||||||
|
var(--shadow-sm);
|
||||||
|
}
|
||||||
|
.feed-header,
|
||||||
|
.explore-header {
|
||||||
|
padding: var(--space-lg) var(--space-md) var(--space-md);
|
||||||
|
}
|
||||||
|
|
||||||
|
.feed-header p,
|
||||||
|
.explore-header p {
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
margin: 0.25rem 0 0;
|
||||||
|
}
|
||||||
|
.post-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--space-md);
|
||||||
|
padding: 0 var(--space-md) var(--space-xl);
|
||||||
|
}
|
||||||
|
.fresh-scroll,
|
||||||
|
.trending-scroll {
|
||||||
|
display: flex;
|
||||||
|
gap: var(--space-sm);
|
||||||
|
overflow-x: auto;
|
||||||
|
padding: var(--space-sm) var(--space-md);
|
||||||
|
}
|
||||||
|
|
||||||
|
.hide-scrollbar {
|
||||||
|
scrollbar-width: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hide-scrollbar::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.fresh-item,
|
||||||
|
.trending-item {
|
||||||
|
background: var(--color-surface);
|
||||||
|
border-radius: var(--radius-md);
|
||||||
|
padding: var(--space-sm);
|
||||||
|
min-width: 80px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.3rem;
|
||||||
|
box-shadow: var(--shadow-sm);
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
}
|
||||||
|
.profile-header {
|
||||||
|
display: flex;
|
||||||
|
gap: var(--space-lg);
|
||||||
|
padding: var(--space-lg);
|
||||||
|
background: var(--color-surface);
|
||||||
|
border-radius: var(--radius-lg);
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
box-shadow: var(--shadow-sm);
|
||||||
|
margin: var(--space-md);
|
||||||
|
}
|
||||||
|
.profile-stats {
|
||||||
|
display: flex;
|
||||||
|
gap: var(--space-lg);
|
||||||
|
margin-top: var(--space-sm);
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-stats div {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-stats strong {
|
||||||
|
font-size: 1.1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-stats span {
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
}
|
||||||
|
.post-preview-overlay {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
background: rgba(0, 0, 0, 0.35);
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: flex-end;
|
||||||
|
z-index: 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-preview-modal {
|
||||||
|
background: var(--color-surface);
|
||||||
|
width: 100%;
|
||||||
|
max-width: 600px;
|
||||||
|
border-radius: var(--radius-lg) var(--radius-lg) 0 0;
|
||||||
|
padding: var(--space-lg);
|
||||||
|
box-shadow: var(--shadow-lg);
|
||||||
|
}
|
||||||
@@ -1,3 +1,157 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import PostCard, {
|
||||||
|
PostCardData,
|
||||||
|
} from '@/app/components/PostCard/PostCard';
|
||||||
|
|
||||||
|
/* =======================
|
||||||
|
MOCK: USER
|
||||||
|
======================= */
|
||||||
|
|
||||||
|
const user = {
|
||||||
|
id: 1,
|
||||||
|
name: 'Laura',
|
||||||
|
username: '@laura_pets',
|
||||||
|
bio: 'Liebt Tiere, Natur & ruhige Momente.',
|
||||||
|
stats: {
|
||||||
|
pets: 2,
|
||||||
|
posts: 6,
|
||||||
|
follows: 18,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
/* =======================
|
||||||
|
MOCK: PETS
|
||||||
|
======================= */
|
||||||
|
|
||||||
|
const pets = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: 'Nala',
|
||||||
|
type: 'Katze',
|
||||||
|
breed: 'Maine Coon',
|
||||||
|
age: '3 Jahre',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
name: 'Rocky',
|
||||||
|
type: 'Hund',
|
||||||
|
breed: 'Labrador',
|
||||||
|
age: '4 Jahre',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
/* =======================
|
||||||
|
MOCK: POSTS
|
||||||
|
======================= */
|
||||||
|
|
||||||
|
const posts: PostCardData[] = [
|
||||||
|
{
|
||||||
|
id: 501,
|
||||||
|
petName: 'Nala',
|
||||||
|
petType: 'Katze',
|
||||||
|
authorName: 'Laura',
|
||||||
|
createdAt: 'gestern',
|
||||||
|
text: 'Nala beobachtet alles ganz ruhig.',
|
||||||
|
likesCount: 6,
|
||||||
|
commentsCount: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 502,
|
||||||
|
petName: 'Rocky',
|
||||||
|
petType: 'Hund',
|
||||||
|
authorName: 'Laura',
|
||||||
|
createdAt: 'vor 2 Tagen',
|
||||||
|
text: 'Rocky liebt lange Spaziergänge.',
|
||||||
|
likesCount: 9,
|
||||||
|
commentsCount: 2,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
/* =======================
|
||||||
|
PAGE
|
||||||
|
======================= */
|
||||||
|
|
||||||
export default function ProfilePage() {
|
export default function ProfilePage() {
|
||||||
return <h1>Profil</h1>;
|
return (
|
||||||
|
<>
|
||||||
|
{/* ================= USER HEADER ================= */}
|
||||||
|
<section className="profile-header">
|
||||||
|
<div className="profile-avatar">
|
||||||
|
<span>👤</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="profile-info">
|
||||||
|
<h1>{user.name}</h1>
|
||||||
|
<span className="profile-username">
|
||||||
|
{user.username}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
{user.bio && (
|
||||||
|
<p className="profile-bio">
|
||||||
|
{user.bio}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div className="profile-stats">
|
||||||
|
<div>
|
||||||
|
<strong>{user.stats.pets}</strong>
|
||||||
|
<span>Tiere</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<strong>{user.stats.posts}</strong>
|
||||||
|
<span>Beiträge</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<strong>{user.stats.follows}</strong>
|
||||||
|
<span>Abos</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
{/* ================= PETS ================= */}
|
||||||
|
<section className="profile-pets">
|
||||||
|
<h2>Meine Tiere</h2>
|
||||||
|
|
||||||
|
<div className="pets-grid">
|
||||||
|
{pets.map((pet) => (
|
||||||
|
<a
|
||||||
|
key={pet.id}
|
||||||
|
href={`/pets/${pet.id}`}
|
||||||
|
className="pet-card"
|
||||||
|
>
|
||||||
|
<div className="pet-avatar">🐾</div>
|
||||||
|
|
||||||
|
<strong className="pet-name">
|
||||||
|
{pet.name}
|
||||||
|
</strong>
|
||||||
|
|
||||||
|
<span className="pet-meta">
|
||||||
|
{pet.type} · {pet.breed}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span className="pet-age">
|
||||||
|
{pet.age}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
{/* ================= POSTS ================= */}
|
||||||
|
<section className="profile-posts">
|
||||||
|
<h2>Beiträge</h2>
|
||||||
|
|
||||||
|
<div className="post-list">
|
||||||
|
{posts.map((post) => (
|
||||||
|
<PostCard
|
||||||
|
key={post.id}
|
||||||
|
post={post}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user