added a dream page

This commit is contained in:
2025-07-03 22:26:48 +02:00
parent 29b8768f0a
commit 5a24298114
4 changed files with 147 additions and 31 deletions

5
.gitignore vendored
View File

@@ -25,3 +25,8 @@ dist-ssr
/public/assets/profiles/anja.png
/public/assets/profiles/kim.png
/public/assets/profiles/matthias.jpg
/public/assets/dreampics/01.png
/public/assets/dreampics/02.png
/public/assets/dreampics/03.png
/public/assets/dreampics/04.png
/public/assets/dreampics/05.png

View File

@@ -1,7 +1,8 @@
import './App.css';
import Navbar from './components/Navbar';
import {BrowserRouter, Routes, Route} from 'react-router-dom';
import {BrowserRouter, Route, Routes} from 'react-router-dom';
import Feed from "./pages/Feed.tsx";
import DreamPage from "./pages/DreamPage.tsx";
function Home() {
return <div className="p-4">Home Page</div>;
@@ -22,15 +23,18 @@ function Profile() {
export default function App() {
return (
<BrowserRouter>
<div className="pb-16">
<Navbar/>
<Routes>
<Route path="/" element={<Home/>}/>
<Route path="/feed" element={<Feed/>}/>
<Route path="/record" element={<Record/>}/>
<Route path="/archive" element={<Archive/>}/>
<Route path="/profile" element={<Profile/>}/>
</Routes>
<div className="pb-16 min-h-screen">
<div className="mx-auto w-full max-w-md">
<Navbar/>
<Routes>
<Route path="/" element={<Home/>}/>
<Route path="/feed" element={<Feed/>}/>
<Route path="/record" element={<Record/>}/>
<Route path="/archive" element={<Archive/>}/>
<Route path="/profile" element={<Profile/>}/>
<Route path="/dream/:id" element={<DreamPage/>}/>
</Routes>
</div>
</div>
</BrowserRouter>
);

104
src/pages/DreamPage.tsx Normal file
View File

@@ -0,0 +1,104 @@
// src/pages/DreamPage.tsx
import {type NavigateFunction, useNavigate, useParams} from 'react-router-dom';
import {mockDreams} from '../data/MockDreams';
import MockUsers from '../data/MockUsers';
import User from '../types/User';
import type Dream from "../types/Dream.ts";
export default function DreamPage() {
const {id} = useParams<{ id: string }>();
const navigate: NavigateFunction = useNavigate();
const dream: Dream | undefined = mockDreams.find(d => d.id === Number(id));
const user: User | undefined = dream ? MockUsers.find(u => u.id === dream.userId) : undefined;
if (!dream) {
return (<div className="page p-4">
<button
onClick={() => navigate(-1)}
className="mb-4 hover:underline"
style={{ color: 'var(--accent)' }}
>
Zurück
</button>
<p style={{ color: 'var(--text-muted)' }}>Traum nicht gefunden.</p>
</div>);
}
return (<div className="page min-h-screen">
{/* Header */}
<div className="relative" style={{ background: 'var(--accent-gradient)' }}>
<div className="p-6 text-white">
<button
onClick={() => navigate(-1)}
className="absolute top-4 left-4 p-2 rounded-full bg-white/20 backdrop-blur-sm"
>
</button>
<div className="flex items-center space-x-4 mt-8">
{user && (<img
src={`/assets/profiles/${user.profilePicture}`}
alt={user.name}
className="w-16 h-16 rounded-full border-4 border-white/30 object-cover"
/>)}
<div>
<h1 className="font-bold !text-xl sm:!text-2xl md:!text-3xl lg:!text-4xl">
{dream.title}
</h1>
{user && (<p className="mt-1 text-white/80">
{user.name} {' '}
{dream.date.toLocaleDateString('de-DE', {
day: '2-digit',
month: '2-digit',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
})}
</p>)}
</div>
</div>
</div>
</div>
{/* Inhalt */}
<div className="p-4 space-y-6">
<div className="dream-card rounded-2xl p-6">
<div className="flex items-center mb-4">
<span className="font-medium" style={{ color: 'var(--accent)' }}>Traum-Beschreibung</span>
</div>
<p className="leading-relaxed text-lg">
{dream.input}
</p>
</div>
{dream.ai?.interpretation && (<div
className="dreamPanel rounded-2xl p-6">
<div className="flex items-center mb-4">
<span className="font-medium" style={{ color: 'var(--accent)' }}>KI-Interpretation</span>
</div>
<p className="leading-relaxed">
{dream.ai.interpretation}
</p>
</div>)}
<div className="dream-card rounded-2xl p-6">
<h2 className="text-lg font-semibold mb-3">Details</h2>
<div className="space-y-2" style={{ color: 'var(--text-muted)' }}>
<div className="flex justify-between">
<span>Eingabetyp</span>
<span className="capitalize">{dream.inputType}</span>
</div>
<div className="flex justify-between">
<span>Datum</span>
<span>
{dream.date.toLocaleDateString('de-DE', {
day: '2-digit', month: '2-digit', year: 'numeric',
})}
</span>
</div>
</div>
</div>
</div>
</div>);
}

View File

@@ -3,6 +3,7 @@ import {mockDreams} from '../data/MockDreams';
import Dream from '../types/Dream';
import type User from "../types/User.ts";
import {MockUserMap} from "../data/MockUsers.ts";
import {NavLink} from "react-router-dom";
export default function Feed() {
const sortedDreams = [...mockDreams].sort((a, b) => b.date.getTime() - a.date.getTime());
@@ -13,27 +14,29 @@ export default function Feed() {
{sortedDreams.map((dream: Dream) => {
const user: User | undefined = MockUserMap.get(dream.userId);
return (
<li key={dream.id} className="dream-card mb-4">
<div className="flex rounded items-center mb-2"><img
src={`/assets/profiles/${user?.profilePicture}`}
alt={user?.name}
className="w-10 h-10 rounded-full"/>
<span className="ml-4 font-semibold">{user?.name} hat geträumt:</span>
</div>
<h2 className="title">
{dream.title}
</h2>
<p className="mt-2 line-clamp-2">{dream.input}</p>
<p className="timestamp mt-2">
{dream.date.toLocaleDateString('de-DE', {
day: '2-digit',
month: '2-digit',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
})}
</p>
</li>
<NavLink key={dream.id} to={`/dream/${dream.id}`}>
<li className="dream-card mb-4">
<div className="flex rounded items-center mb-2"><img
src={`/assets/profiles/${user?.profilePicture}`}
alt={user?.name}
className="w-10 h-10 rounded-full"/>
<span className="ml-4 font-semibold">{user?.name} hat geträumt:</span>
</div>
<h2 className="title">
{dream.title}
</h2>
<p className="mt-2 line-clamp-2">{dream.input}</p>
<p className="timestamp mt-2">
{dream.date.toLocaleDateString('de-DE', {
day: '2-digit',
month: '2-digit',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
})}
</p>
</li>
</NavLink>
)
})}
</ul>