UI: полноценный красивый интерфейс, iOS-style дизайн, все страницы

This commit is contained in:
2026-05-29 11:12:53 +03:00
parent b277e0f177
commit a67b8c3341
13 changed files with 969 additions and 465 deletions

View File

@@ -4,6 +4,7 @@ import { useAuth } from '@/hooks/useAuth';
import { useLikeCat, useUnlikeCat } from '@/hooks/useLikes'; import { useLikeCat, useUnlikeCat } from '@/hooks/useLikes';
import { useToast } from '@/components/Toast'; import { useToast } from '@/components/Toast';
import { Avatar, AvatarFallback } from '@/components/ui/avatar'; import { Avatar, AvatarFallback } from '@/components/ui/avatar';
import { Heart, MessageCircle } from 'lucide-react';
interface CatCardProps { interface CatCardProps {
cat: Cat; cat: Cat;
@@ -33,90 +34,99 @@ export default function CatCard({ cat, onOpen }: CatCardProps) {
} else { } else {
setLiked(true); setLiked(true);
setLikeCount((c) => c + 1); setLikeCount((c) => c + 1);
toast('Нравится', 'like'); toast('Нравится ❤️');
try { await likeMutation.mutateAsync(); } try { await likeMutation.mutateAsync(); }
catch { setLiked(false); setLikeCount((c) => c - 1); } catch { setLiked(false); setLikeCount((c) => c - 1); }
} }
}; };
const timeAgo = new Date(cat.created_at).toLocaleDateString('ru-RU', {
day: 'numeric', month: 'short', hour: '2-digit', minute: '2-digit',
});
return ( return (
<div className="animate-fade-in mb-2.5 last:mb-0"> <article className="animate-fade-in-up mb-4 last:mb-0">
<div className="tg-bubble border shadow-[0_1px_2px_rgba(0,0,0,0.04)]"> <div className="card overflow-hidden">
{/* Header */} {/* Header */}
<div className="flex items-center justify-between px-3.5 py-2.5"> <div className="flex items-center justify-between px-4 py-3">
<div <div
className="flex items-center gap-2.5 cursor-pointer" className="flex items-center gap-3 cursor-pointer group"
onClick={() => onOpen(cat.id)} onClick={() => onOpen(cat.id)}
> >
<Avatar className="h-8 w-8"> <Avatar className="h-10 w-10">
<AvatarFallback className="text-xs bg-[#2aabee] text-white"> <AvatarFallback className="text-sm avatar-initials">
{cat.username.charAt(0).toUpperCase()} {cat.username.charAt(0).toUpperCase()}
</AvatarFallback> </AvatarFallback>
</Avatar> </Avatar>
<div> <div>
<span className="text-[15px] font-medium leading-none block">@{cat.username}</span> <h3 className="text-[15px] font-semibold group-hover:text-[var(--primary)] transition-colors">
<span className="text-[12px] text-[#8e8e93] leading-none mt-0.5 block"> @{cat.username}
{new Date(cat.created_at).toLocaleDateString('ru-RU', { </h3>
day: 'numeric', month: 'short', hour: '2-digit', minute: '2-digit', <time className="text-[11px] text-[var(--foreground-tertiary)]">{timeAgo}</time>
})}
</span>
</div> </div>
</div> </div>
</div> </div>
{/* Image */} {/* Image */}
<div <figure
className="cursor-pointer bg-[#f0f0f0]" className="cursor-pointer bg-[var(--secondary)] img-loading"
onClick={() => onOpen(cat.id)} onClick={() => onOpen(cat.id)}
> >
<img <img
src={cat.image_url} src={cat.image_url}
alt={cat.caption || 'Фото кота'} alt={cat.caption || 'Фото кота'}
className="w-full max-h-[460px] object-contain select-none" className="w-full max-h-[500px] object-contain select-none mx-auto transition-opacity"
draggable={false} draggable={false}
loading="lazy" loading="lazy"
/> />
</div> </figure>
{/* Caption */} {/* Caption */}
{cat.caption && ( {cat.caption && (
<div className="px-3.5 pt-2.5" onClick={() => onOpen(cat.id)}> <div className="px-4 pt-3 pb-1 cursor-pointer" onClick={() => onOpen(cat.id)}>
<span className="text-[15px] leading-[1.3]"> <p className="text-[15px] leading-[1.4]">
<span className="font-semibold mr-1.5">@{cat.username}</span> <span className="font-semibold mr-1.5">@{cat.username}</span>
{cat.caption} {cat.caption}
</span> </p>
</div> </div>
)} )}
{/* Actions row */} {/* Actions */}
<div className="flex items-center justify-between px-3.5 py-2.5"> <div className="flex items-center justify-between px-4 py-3">
<div className="flex items-center gap-3"> <div className="flex items-center gap-5">
<button <button
onClick={toggleLike} onClick={toggleLike}
disabled={isOwner || !user} disabled={isOwner || !user}
className={`flex items-center gap-1.5 text-[13px] font-medium transition-colors ${ className={`btn-icon flex items-center gap-1.5 text-[14px] font-medium ${
liked ? 'text-[#ff3b30]' : 'text-[#8e8e93] hover:text-black' isOwner
? 'text-[var(--foreground-tertiary)] cursor-not-allowed'
: liked
? 'text-[var(--danger)]'
: 'text-[var(--foreground-secondary)] hover:text-[var(--foreground)]'
}`} }`}
> >
<span className={`text-base leading-none ${liked ? 'heart-animate' : ''}`}> <Heart
{liked ? '❤️' : '🤍'} className={`h-5 w-5 transition-all ${liked ? 'fill-[var(--danger)] stroke-[var(--danger)] animate-heart' : 'stroke-[1.5]'}`}
</span> />
{likeCount > 0 && <span>{likeCount}</span>} {likeCount > 0 && <span className="tabular-nums">{likeCount}</span>}
</button> </button>
<button <button
onClick={() => onOpen(cat.id)} onClick={() => onOpen(cat.id)}
className="flex items-center gap-1.5 text-[13px] font-medium text-[#8e8e93] hover:text-black transition-colors" className="btn-icon flex items-center gap-1.5 text-[14px] font-medium text-[var(--foreground-secondary)] hover:text-[var(--foreground)]"
> >
<span className="text-base leading-none">💬</span> <MessageCircle className="h-5 w-5 stroke-[1.5]" />
<span>Комментарии</span> <span className="hidden sm:inline text-[13px]">Комментарии</span>
</button> </button>
</div> </div>
{cat.user_points > 0 && ( <span className="flex items-center gap-1 text-[12px] text-[var(--foreground-tertiary)]">
<span className="text-[12px] text-[#8e8e93]">🏆 {cat.user_points}</span> <span>🏆</span>
)} <span className="font-medium">{cat.user_points}</span>
<span className="hidden sm:inline">баллов</span>
</span>
</div> </div>
</div> </div>
</div> </article>
); );
} }

View File

@@ -4,7 +4,7 @@ import { useLikeStatus, useLikeCat, useUnlikeCat } from '@/hooks/useLikes';
import { useAuth } from '@/hooks/useAuth'; import { useAuth } from '@/hooks/useAuth';
import { useToast } from '@/components/Toast'; import { useToast } from '@/components/Toast';
import { Avatar, AvatarFallback } from '@/components/ui/avatar'; import { Avatar, AvatarFallback } from '@/components/ui/avatar';
import { X } from 'lucide-react'; import { X, Heart, Trash2 } from 'lucide-react';
interface CatModalProps { interface CatModalProps {
catId: number; catId: number;
@@ -22,10 +22,14 @@ export default function CatModal({ catId, onClose }: CatModalProps) {
const [liked, setLiked] = useState(false); const [liked, setLiked] = useState(false);
const [likeCount, setLikeCount] = useState(0); const [likeCount, setLikeCount] = useState(0);
const [imageLoaded, setImageLoaded] = useState(false);
useEffect(() => { if (likeData) setLiked(likeData.liked); }, [likeData]); useEffect(() => { if (likeData) setLiked(likeData.liked); }, [likeData]);
useEffect(() => { if (data?.cat) setLikeCount(data.cat.likes_count); }, [data]); useEffect(() => { if (data?.cat) setLikeCount(data.cat.likes_count); }, [data]);
useEffect(() => { document.body.style.overflow = 'hidden'; return () => { document.body.style.overflow = ''; }; }, []); useEffect(() => {
document.body.style.overflow = 'hidden';
return () => { document.body.style.overflow = ''; };
}, []);
const cat = data?.cat; const cat = data?.cat;
const isOwner = cat && user && cat.user_id === user.id; const isOwner = cat && user && cat.user_id === user.id;
@@ -37,13 +41,14 @@ export default function CatModal({ catId, onClose }: CatModalProps) {
setLikeCount((c) => c - 1); setLikeCount((c) => c - 1);
try { try {
const res = await unlikeMutation.mutateAsync(); const res = await unlikeMutation.mutateAsync();
if (res.ownerPoints !== undefined && cat.user_id === user.id) updateUser({ ...user, points: res.ownerPoints }); if (res.ownerPoints !== undefined && cat.user_id === user.id)
updateUser({ ...user, points: res.ownerPoints });
refetchLike(); refetchLike();
} catch { setLiked(true); setLikeCount((c) => c + 1); } } catch { setLiked(true); setLikeCount((c) => c + 1); }
} else { } else {
setLiked(true); setLiked(true);
setLikeCount((c) => c + 1); setLikeCount((c) => c + 1);
toast('Нравится', 'like'); toast('Нравится ❤️');
try { await likeMutation.mutateAsync(); refetchLike(); } try { await likeMutation.mutateAsync(); refetchLike(); }
catch { setLiked(false); setLikeCount((c) => c - 1); } catch { setLiked(false); setLikeCount((c) => c - 1); }
} }
@@ -53,97 +58,135 @@ export default function CatModal({ catId, onClose }: CatModalProps) {
if (!isOwner || !cat) return; if (!isOwner || !cat) return;
try { try {
await deleteMutation.mutateAsync(cat.id); await deleteMutation.mutateAsync(cat.id);
toast('Удалено', 'success'); toast('Удалено');
onClose(); onClose();
} catch { toast('Ошибка удаления', 'error'); } } catch { toast('Ошибка удаления', 'error'); }
}; };
// Close on Escape
useEffect(() => {
const handler = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); };
window.addEventListener('keydown', handler);
return () => window.removeEventListener('keydown', handler);
}, [onClose]);
if (isLoading || !cat) { if (isLoading || !cat) {
return ( return (
<div className="fixed inset-0 z-[60] bg-black/60" onClick={onClose}> <div className="fixed inset-0 z-[60] bg-black/50 backdrop-blur-sm flex items-center justify-center" onClick={onClose}>
<div className="flex h-full items-center justify-center"> <div className="flex items-center gap-3 px-6 py-4 bg-white rounded-full shadow-lg animate-scale-in">
<div className="h-5 w-5 animate-spin rounded-full border-2 border-white/40 border-t-white" /> <div className="h-5 w-5 rounded-full border-2 border-[var(--primary)]/30 border-t-[var(--primary)] animate-spin" />
<span className="text-[14px] font-medium text-[var(--foreground-secondary)]">Загрузка...</span>
</div> </div>
</div> </div>
); );
} }
const dateStr = new Date(cat.created_at).toLocaleDateString('ru-RU', {
year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit',
});
return ( return (
<div className="fixed inset-0 z-[60] bg-black/60 flex items-end sm:items-center justify-center" onClick={onClose}> <div
className="fixed inset-0 z-[60] bg-black/50 backdrop-blur-sm flex items-end sm:items-center justify-center"
onClick={onClose}
>
<div <div
className="animate-scale-in w-full sm:max-w-lg bg-white sm:rounded-2xl sm:mx-4 max-h-[92vh] flex flex-col overflow-hidden" className="w-full sm:max-w-xl bg-white sm:rounded-xl sm:mx-4 max-h-[92vh] flex flex-col overflow-hidden shadow-xl animate-scale-in"
onClick={(e) => e.stopPropagation()} onClick={(e) => e.stopPropagation()}
> >
{/* Header */} {/* Header */}
<div className="flex items-center justify-between px-4 py-3 border-b shrink-0"> <div className="flex items-center justify-between px-5 py-4 border-b shrink-0">
<div className="flex items-center gap-2.5"> <div className="flex items-center gap-3">
<Avatar className="h-8 w-8"> <Avatar className="h-9 w-9">
<AvatarFallback className="text-xs bg-[#2aabee] text-white"> <AvatarFallback className="text-sm avatar-initials">
{cat.username.charAt(0).toUpperCase()} {cat.username.charAt(0).toUpperCase()}
</AvatarFallback> </AvatarFallback>
</Avatar> </Avatar>
<span className="text-[15px] font-semibold">@{cat.username}</span> <div>
<span className="text-[15px] font-semibold">@{cat.username}</span>
<p className="text-[11px] text-[var(--foreground-tertiary)]">{dateStr}</p>
</div>
</div> </div>
<div className="flex items-center gap-2"> <div className="flex items-center gap-1">
{isOwner && ( {isOwner && (
<button <button
onClick={handleDelete} onClick={handleDelete}
className="text-[13px] text-[#8e8e93] hover:text-[#ff3b30] transition-colors px-2 py-1" className="btn-icon h-9 w-9 text-[var(--foreground-secondary)] hover:text-[var(--danger)] hover:bg-[var(--danger-light)]"
title="Удалить"
> >
Удалить <Trash2 className="h-4 w-4" strokeWidth={1.5} />
</button> </button>
)} )}
<button onClick={onClose} className="text-[#8e8e93] hover:text-black transition-colors p-1"> <button
onClick={onClose}
className="btn-icon h-9 w-9 text-[var(--foreground-secondary)] hover:text-[var(--foreground)] hover:bg-[var(--secondary)]"
>
<X className="h-5 w-5" strokeWidth={1.5} /> <X className="h-5 w-5" strokeWidth={1.5} />
</button> </button>
</div> </div>
</div> </div>
{/* Image */} {/* Image */}
<div className="bg-[#f0f0f0] flex items-center justify-center shrink-0"> <div className="bg-[var(--secondary)] flex items-center justify-center shrink-0 relative">
<img src={cat.image_url} alt={cat.caption || 'Фото кота'} className="w-full max-h-[50vh] object-contain" /> {!imageLoaded && (
<div className="absolute inset-0 flex items-center justify-center">
<div className="h-8 w-8 rounded-full border-2 border-[var(--foreground-tertiary)]/30 border-t-[var(--primary)] animate-spin" />
</div>
)}
<img
src={cat.image_url}
alt={cat.caption || 'Фото кота'}
className={`w-full max-h-[55vh] object-contain transition-opacity duration-300 ${imageLoaded ? 'opacity-100' : 'opacity-0'}`}
onLoad={() => setImageLoaded(true)}
/>
</div> </div>
{/* Info */} {/* Info */}
<div className="flex-1 overflow-y-auto px-4 py-3 space-y-2"> <div className="flex-1 overflow-y-auto px-5 py-4 space-y-3">
<div className="flex items-start gap-2.5"> <div className="flex items-start gap-3">
<Avatar className="h-7 w-7 shrink-0"> <Avatar className="h-8 w-8 shrink-0 mt-0.5">
<AvatarFallback className="text-[10px] bg-[#2aabee] text-white"> <AvatarFallback className="text-[10px] avatar-initials">
{cat.username.charAt(0).toUpperCase()} {cat.username.charAt(0).toUpperCase()}
</AvatarFallback> </AvatarFallback>
</Avatar> </Avatar>
<div> <div>
<p className="text-[15px] leading-[1.3]"> <p className="text-[15px] leading-[1.4]">
<span className="font-semibold mr-1.5">@{cat.username}</span> <span className="font-semibold mr-1.5">@{cat.username}</span>
{cat.caption || 'Без подписи'} {cat.caption || 'Без подписи'}
</p> </p>
</div> </div>
</div> </div>
<p className="text-[12px] text-[#8e8e93]">
{new Date(cat.created_at).toLocaleDateString('ru-RU', {
year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit',
})}
</p>
</div> </div>
{/* Actions */} {/* Actions */}
<div className="border-t px-4 py-3 shrink-0"> <div className="border-t px-5 py-4 shrink-0">
<div className="flex items-center gap-4"> <div className="flex items-center justify-between">
<button <div className="flex items-center gap-5">
onClick={toggleLike} <button
disabled={isOwner || !user} onClick={toggleLike}
className={`flex items-center gap-1.5 text-[15px] font-medium transition-colors ${ disabled={isOwner || !user}
liked ? 'text-[#ff3b30]' : 'text-[#8e8e93] hover:text-black' className={`btn-icon flex items-center gap-1.5 text-[15px] font-medium ${
}`} isOwner
> ? 'text-[var(--foreground-tertiary)] cursor-not-allowed'
<span className="text-xl leading-none">{liked ? '❤️' : '🤍'}</span> : liked
{likeCount > 0 && <span>{likeCount}</span>} ? 'text-[var(--danger)]'
</button> : 'text-[var(--foreground-secondary)] hover:text-[var(--foreground)]'
<span className="text-[12px] text-[#8e8e93]">🏆 {cat.user_points} баллов</span> }`}
>
<Heart
className={`h-6 w-6 transition-all ${liked ? 'fill-[var(--danger)] stroke-[var(--danger)] animate-heart' : 'stroke-[1.5]'}`}
/>
{likeCount > 0 && <span className="tabular-nums">{likeCount}</span>}
</button>
</div>
<span className="flex items-center gap-1.5 text-[13px] text-[var(--foreground-secondary)]">
<span>🏆</span>
<span className="font-semibold">{cat.user_points}</span>
<span>баллов</span>
</span>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
); );
} }

View File

@@ -2,7 +2,7 @@ import { useAuth } from '@/hooks/useAuth';
import { useCats } from '@/hooks/useCats'; import { useCats } from '@/hooks/useCats';
import { Avatar, AvatarFallback } from '@/components/ui/avatar'; import { Avatar, AvatarFallback } from '@/components/ui/avatar';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { Trophy } from 'lucide-react'; import { Trophy, Sparkles } from 'lucide-react';
export default function FeedSidebar() { export default function FeedSidebar() {
const { user } = useAuth(); const { user } = useAuth();
@@ -21,53 +21,87 @@ export default function FeedSidebar() {
.slice(0, 5); .slice(0, 5);
return ( return (
<div className="space-y-5"> <div className="space-y-6">
{/* Current user */}
{user && ( {user && (
<Link to="/profile" className="flex items-center gap-3 group"> <Link
to="/profile"
className="card flex items-center gap-3 p-3 hover:shadow-md transition-all group"
>
<Avatar className="h-11 w-11"> <Avatar className="h-11 w-11">
<AvatarFallback className="bg-[#2aabee] text-white text-sm font-semibold"> <AvatarFallback className="text-sm font-semibold avatar-initials">
{user.username.charAt(0).toUpperCase()} {user.username.charAt(0).toUpperCase()}
</AvatarFallback> </AvatarFallback>
</Avatar> </Avatar>
<div> <div className="min-w-0 flex-1">
<p className="text-[15px] font-medium group-hover:text-[#2aabee] transition-colors">{user.username}</p> <p className="text-[14px] font-semibold truncate group-hover:text-[var(--primary)] transition-colors">
<p className="text-[12px] text-[#8e8e93]">🏆 {user.points} баллов</p> {user.username}
</p>
<p className="text-[12px] text-[var(--foreground-secondary)]">
🏆 {user.points} баллов
</p>
</div> </div>
</Link> </Link>
)} )}
<div> {/* Top users */}
<div className="flex items-center gap-1.5 mb-3"> <div className="card p-4">
<Trophy className="h-4 w-4 text-[#8e8e93]" strokeWidth={1.5} /> <div className="flex items-center gap-2 mb-4">
<h3 className="text-[13px] font-semibold text-[#8e8e93] uppercase tracking-wider">Лидеры</h3> <Trophy className="h-4 w-4 text-amber-500" strokeWidth={1.5} />
<h3 className="text-[12px] font-bold text-[var(--foreground-secondary)] uppercase tracking-widest">
Лидеры
</h3>
</div> </div>
{topUsers.length === 0 ? ( {topUsers.length === 0 ? (
<p className="text-[13px] text-[#8e8e93]">Пока нет пользователей</p> <p className="text-[13px] text-[var(--foreground-tertiary)] text-center py-4">
Пока нет пользователей
</p>
) : ( ) : (
<div className="space-y-2.5"> <div className="space-y-3">
{topUsers.map(([id, u], i) => ( {topUsers.map(([id, u], i) => (
<Link key={id} to={`/profile/${id}`} className="flex items-center gap-3 group"> <Link
<span className={`w-5 text-center text-[13px] font-bold ${ key={id}
i === 0 ? 'text-[#2aabee]' : 'text-[#8e8e93]' to={`/profile/${id}`}
}`}>{i + 1}</span> className="flex items-center gap-3 group"
>
<span
className={`w-6 h-6 rounded-full flex items-center justify-center text-[11px] font-bold ${
i === 0
? 'bg-amber-100 text-amber-600'
: i === 1
? 'bg-gray-100 text-gray-500'
: i === 2
? 'bg-orange-100 text-orange-600'
: 'text-[var(--foreground-tertiary)]'
}`}
>
{i + 1}
</span>
<Avatar className="h-8 w-8"> <Avatar className="h-8 w-8">
<AvatarFallback className="text-[10px] bg-[#2aabee] text-white"> <AvatarFallback className="text-[10px] avatar-initials">
{u.username.charAt(0).toUpperCase()} {u.username.charAt(0).toUpperCase()}
</AvatarFallback> </AvatarFallback>
</Avatar> </Avatar>
<span className="text-[14px] flex-1 truncate font-medium group-hover:text-[#2aabee] transition-colors"> <span className="text-[14px] flex-1 truncate font-medium group-hover:text-[var(--primary)] transition-colors">
{u.username} {u.username}
</span> </span>
<span className="text-[12px] font-medium text-[#8e8e93]">{u.points}</span> <span className="text-[12px] font-semibold text-[var(--foreground-secondary)] tabular-nums">
{u.points}
</span>
</Link> </Link>
))} ))}
</div> </div>
)} )}
</div> </div>
<div className="pt-2 text-[11px] text-[#8e8e93]/60 space-y-0.5"> {/* Info */}
<p>Catstagram · Делись фото котов</p> <div className="px-1 text-[11px] text-[var(--foreground-tertiary)] space-y-1">
<div className="flex items-center gap-1.5">
<Sparkles className="h-3 w-3" strokeWidth={1.5} />
<span>Catstagram · Сообщество котоводов</span>
</div>
</div> </div>
</div> </div>
); );
} }

View File

@@ -1,43 +1,53 @@
import { Link, useNavigate, useLocation } from 'react-router-dom'; import { Link, useLocation } from 'react-router-dom';
import { useAuth } from '@/hooks/useAuth'; import { useAuth } from '@/hooks/useAuth';
import { Avatar, AvatarFallback } from '@/components/ui/avatar'; import { Avatar, AvatarFallback } from '@/components/ui/avatar';
import { House, Plus } from 'lucide-react';
export default function Navbar() { export default function Navbar() {
const { user, logout } = useAuth(); const { user } = useAuth();
const navigate = useNavigate();
const location = useLocation(); const location = useLocation();
if (!user) return null; if (!user) return null;
const navItems = [
{ to: '/feed', label: 'Лента', icon: House },
{ to: '/upload', label: 'Добавить', icon: Plus },
];
return ( return (
<nav className="sticky top-0 z-50 border-b bg-white"> <nav className="sticky top-0 z-50 bg-[var(--surface)]/90 backdrop-blur-xl border-b border-[var(--border)]">
<div className="mx-auto flex h-11 max-w-[660px] items-center justify-between px-4"> <div className="mx-auto flex h-14 max-w-[660px] items-center justify-between px-4">
<Link to="/feed" className="text-[17px] font-semibold tracking-tight"> <Link
to="/feed"
className="text-[18px] font-bold tracking-tight"
style={{ background: 'linear-gradient(135deg, #007aff, #5856d6)', WebkitBackgroundClip: 'text', WebkitTextFillColor: 'transparent' }}
>
Catstagram Catstagram
</Link> </Link>
<div className="flex items-center gap-1.5"> <div className="flex items-center gap-1">
<Link {navItems.map((item) => {
to="/feed" const Icon = item.icon;
className={`flex items-center gap-1 px-3 py-1.5 rounded-full text-[13px] font-medium transition-colors ${ const isActive = location.pathname === item.to;
location.pathname === '/feed' ? 'bg-[#2aabee] text-white' : 'text-[#8e8e93] hover:text-black' return (
}`} <Link
> key={item.to}
<span className="text-base leading-none">🏠</span> to={item.to}
<span className="hidden sm:inline">Лента</span> className={`flex items-center gap-1.5 px-3.5 py-2 rounded-full text-[13px] font-medium transition-all ${
</Link> isActive
<Link ? 'bg-[var(--primary-light)] text-[var(--primary)]'
to="/upload" : 'text-[var(--foreground-secondary)] hover:text-[var(--foreground)] hover:bg-[var(--secondary)]'
className={`flex items-center gap-1 px-3 py-1.5 rounded-full text-[13px] font-medium transition-colors ${ }`}
location.pathname === '/upload' ? 'bg-[#2aabee] text-white' : 'text-[#8e8e93] hover:text-black' >
}`} <Icon className={`h-4 w-4 ${isActive ? 'stroke-[2.5]' : 'stroke-[1.5]'}`} />
> <span className="hidden sm:inline">{item.label}</span>
<span className="text-base leading-none"></span> </Link>
<span className="hidden sm:inline">Добавить</span> );
</Link> })}
<Link to="/profile">
<Avatar className="h-7 w-7 ml-0.5"> <Link to="/profile" className="ml-1">
<AvatarFallback className="text-[9px] bg-[#2aabee] text-white"> <Avatar className="h-8 w-8 border-2 border-transparent hover:border-[var(--primary)] transition-all">
<AvatarFallback className="text-[11px] avatar-initials">
{user.username.charAt(0).toUpperCase()} {user.username.charAt(0).toUpperCase()}
</AvatarFallback> </AvatarFallback>
</Avatar> </Avatar>
@@ -46,4 +56,4 @@ export default function Navbar() {
</div> </div>
</nav> </nav>
); );
} }

View File

@@ -8,16 +8,16 @@ interface StoryCircleProps {
export default function StoryCircle({ user }: StoryCircleProps) { export default function StoryCircle({ user }: StoryCircleProps) {
return ( return (
<div className="flex flex-col items-center gap-1.5 w-16 shrink-0 group cursor-pointer"> <div className="flex flex-col items-center gap-1.5 w-16 shrink-0 group cursor-pointer">
<div className="rounded-full p-0.5 bg-gradient-to-br from-orange-400 to-rose-500"> <div className="rounded-full p-0.5" style={{ background: 'linear-gradient(135deg, #007aff 0%, #5856d6 100%)' }}>
<Avatar className="h-13 w-13 border-2 border-white"> <Avatar className="h-14 w-14 border-2 border-white">
<AvatarFallback className="bg-foreground text-background text-sm font-medium"> <AvatarFallback className="text-sm font-semibold bg-white text-[var(--primary)]">
{user.username.charAt(0).toUpperCase()} {user.username.charAt(0).toUpperCase()}
</AvatarFallback> </AvatarFallback>
</Avatar> </Avatar>
</div> </div>
<span className="text-[11px] text-muted-foreground truncate w-full text-center group-hover:text-foreground transition-colors"> <span className="text-[11px] text-[var(--foreground-tertiary)] truncate w-full text-center group-hover:text-[var(--foreground)] transition-colors">
{user.username} {user.username}
</span> </span>
</div> </div>
); );
} }

View File

@@ -18,18 +18,22 @@ export function ToastProvider({ children }: { children: ReactNode }) {
setTimeout(() => setToasts((prev) => prev.filter((t) => t.id !== id)), 2000); setTimeout(() => setToasts((prev) => prev.filter((t) => t.id !== id)), 2000);
}, []); }, []);
const remove = (id: number) => setToasts((prev) => prev.filter((t) => t.id !== id));
return ( return (
<ToastContext.Provider value={{ toast: addToast }}> <ToastContext.Provider value={{ toast: addToast }}>
{children} {children}
<div className="fixed bottom-6 left-1/2 -translate-x-1/2 z-[100] flex flex-col items-center gap-2"> <div className="fixed bottom-8 left-1/2 -translate-x-1/2 z-[100] flex flex-col items-center gap-2 pointer-events-none">
{toasts.map((t) => ( {toasts.map((t) => (
<div <div
key={t.id} key={t.id}
className="animate-slide-up rounded-full px-5 py-2.5 text-[14px] font-medium shadow-lg bg-[#2aabee] text-white" className="animate-toast-in rounded-full px-6 py-2.5 text-[14px] font-medium shadow-lg pointer-events-auto"
style={{
background: t.type === 'error'
? 'var(--danger)'
: 'linear-gradient(135deg, #007aff, #5856d6)',
color: 'white',
}}
> >
<span>{t.message}</span> {t.message}
</div> </div>
))} ))}
</div> </div>
@@ -37,4 +41,4 @@ export function ToastProvider({ children }: { children: ReactNode }) {
); );
} }
export function useToast() { return useContext(ToastContext); } export function useToast() { return useContext(ToastContext); }

View File

@@ -2,118 +2,218 @@
@plugin "tailwindcss-animate"; @plugin "tailwindcss-animate";
:root { :root {
--background: #f5f5f5; --background: #f5f5f7;
--foreground: #000000; --surface: #ffffff;
--card: #ffffff; --surface-hover: #f8f8fa;
--card-foreground: #000000; --foreground: #1c1c1e;
--popover: #ffffff; --foreground-secondary: #8a8a8e;
--popover-foreground: #000000; --foreground-tertiary: #aeaeb2;
--primary: #2aabee; --primary: #007aff;
--primary-hover: #0066d6;
--primary-light: #e8f2ff;
--primary-foreground: #ffffff; --primary-foreground: #ffffff;
--secondary: #eff2f5; --secondary: #f2f2f5;
--secondary-foreground: #000000; --secondary-foreground: #1c1c1e;
--muted: #f0f0f0;
--muted-foreground: #8e8e93;
--accent: #e8f5ff;
--accent-foreground: #2aabee;
--destructive: #ff3b30;
--destructive-foreground: #ffffff;
--border: #e5e5ea; --border: #e5e5ea;
--input: #e5e5ea; --border-light: #f0f0f3;
--ring: #2aabee; --danger: #ff3b30;
--radius: 0; --danger-hover: #d6342b;
--danger-light: #ffe8e6;
--tg-blue: #2aabee; --success: #34c759;
--tg-blue-light: #e8f5ff; --success-light: #e8f8ed;
--tg-separator: #e5e5ea; --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);
--tg-bg: #f5f5f5; --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.03);
--tg-bubble: #ffffff; --shadow-lg: 0 12px 32px rgba(0,0,0,0.08), 0 4px 8px rgba(0,0,0,0.04);
--tg-muted: #8e8e93; --radius-sm: 8px;
--radius-md: 14px;
--radius-lg: 20px;
--radius-full: 9999px;
} }
* { border-color: var(--tg-separator); } * { border-color: var(--border); }
body { body {
background-color: var(--tg-bg); background: var(--background);
color: var(--foreground); color: var(--foreground);
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif; font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
line-height: 1.5;
letter-spacing: -0.01em;
} }
::selection { background: var(--tg-blue); color: white; } ::selection { background: var(--primary); color: white; }
/* Heart animation */ /* ── Animations ── */
@keyframes heart-pop {
0% { transform: scale(1); }
40% { transform: scale(1.2); }
100% { transform: scale(1); }
}
.heart-animate { animation: heart-pop 0.3s ease-out; }
/* Fade in */
@keyframes fade-in { @keyframes fade-in {
from { opacity: 0; transform: translateY(4px); } from { opacity: 0; }
to { opacity: 1; }
}
@keyframes fade-in-up {
from { opacity: 0; transform: translateY(6px); }
to { opacity: 1; transform: translateY(0); } to { opacity: 1; transform: translateY(0); }
} }
.animate-fade-in { animation: fade-in 0.25s ease-out; }
/* Scale in */
@keyframes scale-in { @keyframes scale-in {
from { opacity: 0; transform: scale(0.97); } from { opacity: 0; transform: scale(0.96); }
to { opacity: 1; transform: scale(1); } to { opacity: 1; transform: scale(1); }
} }
.animate-scale-in { animation: scale-in 0.15s ease-out; }
/* Slide up for toasts */
@keyframes slide-up { @keyframes slide-up {
from { opacity: 0; transform: translateY(8px); } from { opacity: 0; transform: translateY(100%); }
to { opacity: 1; transform: translateY(0); } to { opacity: 1; transform: translateY(0); }
} }
.animate-slide-up { animation: slide-up 0.2s ease-out; } @keyframes heart-bounce {
0% { transform: scale(1); }
/* Shimmer */ 25% { transform: scale(1.3); }
50% { transform: scale(0.95); }
75% { transform: scale(1.1); }
100% { transform: scale(1); }
}
@keyframes spin-slow {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
@keyframes shimmer { @keyframes shimmer {
0% { background-position: -200% 0; } 0% { background-position: -200% 0; }
100% { background-position: 200% 0; } 100% { background-position: 200% 0; }
} }
.skeleton-shimmer { @keyframes toast-in {
background: linear-gradient(90deg, #e8e8e8 25%, #f5f5f5 50%, #e8e8e8 75%); from { opacity: 0; transform: translateY(12px) scale(0.96); }
background-size: 200% 100%; to { opacity: 1; transform: translateY(0) scale(1); }
animation: shimmer 1.2s ease-in-out infinite; }
@keyframes toast-out {
from { opacity: 1; transform: translateY(0) scale(1); }
to { opacity: 0; transform: translateY(-8px) scale(0.96); }
} }
/* Page transition */ .animate-fade-in { animation: fade-in 0.15s ease-out; }
.page-enter { opacity: 0; } .animate-fade-in-up { animation: fade-in-up 0.25s cubic-bezier(0.16, 1, 0.3, 1); }
.page-enter-active { opacity: 1; transition: opacity 0.12s ease-out; } .animate-scale-in { animation: scale-in 0.2s cubic-bezier(0.16, 1, 0.3, 1); }
.animate-slide-up { animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
.animate-heart { animation: heart-bounce 0.35s cubic-bezier(0.16, 1, 0.3, 1); }
.animate-spin-slow { animation: spin-slow 1s linear infinite; }
.animate-toast-in { animation: toast-in 0.25s cubic-bezier(0.16, 1, 0.3, 1); }
/* Like button */ /* ── Shared UI ── */
.like-btn { transition: transform 0.08s; cursor: pointer; }
.like-btn:active { transform: scale(0.82); }
/* Telegram-style avatar ring */ .card {
.tg-avatar { background: var(--surface);
border-radius: var(--radius-md);
box-shadow: var(--shadow-sm);
border: 1px solid var(--border);
transition: box-shadow 0.2s ease;
}
.card:hover {
box-shadow: var(--shadow-md);
}
.avatar-initials {
border-radius: 50%; border-radius: 50%;
background: var(--tg-blue);
color: white;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
font-weight: 600; font-weight: 600;
color: white;
background: var(--primary);
user-select: none;
} }
/* Telegram-style bubble */ .btn-icon {
.tg-bubble { display: inline-flex;
background: white; align-items: center;
border-radius: 12px; justify-content: center;
overflow: hidden; border-radius: var(--radius-full);
transition: background 0.15s ease, transform 0.1s ease;
cursor: pointer;
border: none;
}
.btn-icon:active {
transform: scale(0.92);
} }
/* Telegram-style separator */ .link-blue {
.tg-divider { color: var(--primary);
height: 1px; font-weight: 600;
background: var(--tg-separator); transition: opacity 0.15s;
}
.link-blue:hover {
opacity: 0.8;
text-decoration: underline;
} }
/* Scrollbar hide */ .text-secondary { color: var(--foreground-secondary); }
.text-tertiary { color: var(--foreground-tertiary); }
/* ── Utility ── */
.skeleton-shimmer {
background: linear-gradient(90deg, #e8e8ec 25%, #f2f2f5 50%, #e8e8ec 75%);
background-size: 200% 100%;
animation: shimmer 1.2s ease-in-out infinite;
}
/* ── Modal backdrop ── */
.backdrop-blur {
backdrop-filter: blur(8px);
-webkit-backdrop-filter: blur(8px);
}
/* ── Button base ── */
.btn-primary {
display: inline-flex;
align-items: center;
justify-content: center;
font-weight: 600;
border-radius: var(--radius-full);
background: var(--primary);
color: white;
transition: background 0.15s, transform 0.1s;
cursor: pointer;
border: none;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled {
opacity: 0.5;
cursor: not-allowed;
transform: none;
}
.btn-outline {
display: inline-flex;
align-items: center;
justify-content: center;
font-weight: 500;
border-radius: var(--radius-full);
background: transparent;
color: var(--foreground);
border: 1px solid var(--border);
transition: background 0.15s, border-color 0.15s;
cursor: pointer;
}
.btn-outline:hover { background: var(--secondary); border-color: var(--foreground-tertiary); }
.btn-outline:active { transform: scale(0.97); }
/* ── Scrollbar ── */
.scrollbar-none::-webkit-scrollbar { display: none; } .scrollbar-none::-webkit-scrollbar { display: none; }
.scrollbar-none { -ms-overflow-style: none; scrollbar-width: none; } .scrollbar-none { -ms-overflow-style: none; scrollbar-width: none; }
/* ── Image loading ── */
.img-loading {
background: var(--secondary);
position: relative;
overflow: hidden;
}
.img-loading::after {
content: '';
position: absolute;
inset: 0;
background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
animation: shimmer 1.5s infinite;
background-size: 200% 100%;
}

View File

@@ -1,5 +1,5 @@
import { useState, useEffect } from 'react'; import { useState, useEffect } from 'react';
import { useParams, useNavigate } from 'react-router-dom'; import { useParams, useNavigate, Link } from 'react-router-dom';
import { useCat, useDeleteCat } from '@/hooks/useCats'; import { useCat, useDeleteCat } from '@/hooks/useCats';
import { useLikeStatus, useLikeCat, useUnlikeCat } from '@/hooks/useLikes'; import { useLikeStatus, useLikeCat, useUnlikeCat } from '@/hooks/useLikes';
import { useAuth } from '@/hooks/useAuth'; import { useAuth } from '@/hooks/useAuth';
@@ -7,7 +7,7 @@ import { useToast } from '@/components/Toast';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import { Avatar, AvatarFallback } from '@/components/ui/avatar'; import { Avatar, AvatarFallback } from '@/components/ui/avatar';
import { Skeleton } from '@/components/ui/skeleton'; import { Skeleton } from '@/components/ui/skeleton';
import { ArrowLeft } from 'lucide-react'; import { ArrowLeft, Heart, Trash2 } from 'lucide-react';
export default function CatPage() { export default function CatPage() {
const { id } = useParams<{ id: string }>(); const { id } = useParams<{ id: string }>();
@@ -23,6 +23,7 @@ export default function CatPage() {
const deleteMutation = useDeleteCat(); const deleteMutation = useDeleteCat();
const [liked, setLiked] = useState(false); const [liked, setLiked] = useState(false);
const [imageLoaded, setImageLoaded] = useState(false);
const cat = data?.cat; const cat = data?.cat;
const isOwner = cat && user && cat.user_id === user.id; const isOwner = cat && user && cat.user_id === user.id;
const isLiked = likeData?.liked ?? false; const isLiked = likeData?.liked ?? false;
@@ -35,12 +36,13 @@ export default function CatPage() {
setLiked(false); setLiked(false);
try { try {
const res = await unlikeMutation.mutateAsync(); const res = await unlikeMutation.mutateAsync();
if (res.ownerPoints !== undefined && cat.user_id === user.id) updateUser({ ...user, points: res.ownerPoints }); if (res.ownerPoints !== undefined && cat.user_id === user.id)
updateUser({ ...user, points: res.ownerPoints });
refetchLike(); refetchLike();
} catch { setLiked(true); } } catch { setLiked(true); }
} else { } else {
setLiked(true); setLiked(true);
toast('Нравится', 'like'); toast('Нравится ❤️');
try { await likeMutation.mutateAsync(); refetchLike(); } try { await likeMutation.mutateAsync(); refetchLike(); }
catch { setLiked(false); } catch { setLiked(false); }
} }
@@ -60,9 +62,10 @@ export default function CatPage() {
<div className="mx-auto max-w-[580px] px-4 py-8"> <div className="mx-auto max-w-[580px] px-4 py-8">
<Skeleton className="mb-4 h-5 w-20 rounded-full" /> <Skeleton className="mb-4 h-5 w-20 rounded-full" />
<Skeleton className="aspect-[4/3] w-full rounded-2xl" /> <Skeleton className="aspect-[4/3] w-full rounded-2xl" />
<div className="mt-4 space-y-2"> <div className="mt-5 space-y-3">
<Skeleton className="h-5 w-32 rounded-full" /> <Skeleton className="h-5 w-32 rounded-full" />
<Skeleton className="h-4 w-48 rounded-full" /> <Skeleton className="h-4 w-48 rounded-full" />
<Skeleton className="h-4 w-24 rounded-full" />
</div> </div>
</div> </div>
); );
@@ -70,79 +73,132 @@ export default function CatPage() {
if (isError || !cat) { if (isError || !cat) {
return ( return (
<div className="flex flex-col items-center justify-center py-20"> <div className="flex flex-col items-center justify-center py-24 animate-fade-in">
<p className="text-[15px] text-[#8e8e93] mb-4">Кот не найден</p> <div className="mb-5 flex h-16 w-16 items-center justify-center rounded-full bg-[var(--secondary)]">
<Button variant="outline" onClick={() => navigate('/feed')} className="rounded-full text-[13px]">Перейти в ленту</Button> <span className="text-2xl">🔍</span>
</div>
<p className="text-[17px] font-semibold mb-1.5">Кот не найден</p>
<p className="text-[14px] text-[var(--foreground-secondary)] mb-6">
Возможно, публикация была удалена
</p>
<Button
variant="outline"
onClick={() => navigate('/feed')}
className="rounded-full text-[13px]"
>
Перейти в ленту
</Button>
</div> </div>
); );
} }
const dateStr = new Date(cat.created_at).toLocaleDateString('ru-RU', {
year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit',
});
return ( return (
<div className="mx-auto max-w-[580px] px-4 py-6 animate-fade-in"> <div className="mx-auto max-w-[580px] px-4 py-6 animate-fade-in">
<button <button
onClick={() => navigate(-1)} onClick={() => navigate(-1)}
className="mb-4 flex items-center gap-1.5 text-[14px] text-[#8e8e93] hover:text-black transition-colors" className="mb-5 flex items-center gap-1.5 text-[14px] text-[var(--foreground-secondary)] hover:text-[var(--foreground)] transition-colors group"
> >
<ArrowLeft className="h-4 w-4" strokeWidth={1.5} /> <ArrowLeft className="h-4 w-4 stroke-[1.5] group-hover:-translate-x-0.5 transition-transform" />
Назад Назад
</button> </button>
<div className="tg-bubble border shadow-[0_1px_2px_rgba(0,0,0,0.04)]"> <div className="card overflow-hidden">
<div className="bg-[#f0f0f0]"> {/* Image */}
<img src={cat.image_url} alt={cat.caption || 'Фото кота'} className="w-full max-h-[60vh] object-contain mx-auto" /> <div className="bg-[var(--secondary)] relative img-loading">
{!imageLoaded && (
<div className="absolute inset-0 flex items-center justify-center">
<div className="h-8 w-8 rounded-full border-2 border-[var(--foreground-tertiary)]/30 border-t-[var(--primary)] animate-spin" />
</div>
)}
<img
src={cat.image_url}
alt={cat.caption || 'Фото кота'}
className={`w-full max-h-[60vh] object-contain mx-auto transition-opacity duration-300 ${imageLoaded ? 'opacity-100' : 'opacity-0'}`}
onLoad={() => setImageLoaded(true)}
/>
</div> </div>
<div className="p-4 space-y-3"> <div className="p-5 space-y-4">
{/* Header */} {/* Header */}
<div className="flex items-center justify-between"> <div className="flex items-start justify-between">
<div className="flex items-center gap-3"> <Link to={`/profile/${cat.user_id}`} className="flex items-center gap-3 group">
<Avatar className="h-9 w-9"> <Avatar className="h-10 w-10">
<AvatarFallback className="text-sm bg-[#2aabee] text-white font-semibold"> <AvatarFallback className="text-sm avatar-initials">
{cat.username.charAt(0).toUpperCase()} {cat.username.charAt(0).toUpperCase()}
</AvatarFallback> </AvatarFallback>
</Avatar> </Avatar>
<div> <div>
<span className="text-[15px] font-semibold">@{cat.username}</span> <span className="text-[15px] font-semibold group-hover:text-[var(--primary)] transition-colors">
<p className="text-[12px] text-[#8e8e93]"> @{cat.username}
{new Date(cat.created_at).toLocaleDateString('ru-RU', { </span>
year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit', <p className="text-[12px] text-[var(--foreground-tertiary)]">{dateStr}</p>
})}
</p>
</div> </div>
</div> </Link>
{isOwner && ( {isOwner && (
<button onClick={handleDelete} className="text-[13px] text-[#8e8e93] hover:text-[#ff3b30] transition-colors px-2 py-1"> <button
Удалить onClick={handleDelete}
className="btn-icon h-9 w-9 text-[var(--foreground-secondary)] hover:text-[var(--danger)] hover:bg-[var(--danger-light)]"
title="Удалить"
>
<Trash2 className="h-4 w-4" strokeWidth={1.5} />
</button> </button>
)} )}
</div> </div>
{/* Caption */} {/* Caption */}
{cat.caption && ( {cat.caption && (
<p className="text-[15px] leading-[1.3]"> <p className="text-[15px] leading-[1.4]">
<span className="font-semibold mr-1.5">@{cat.username}</span> <span className="font-semibold mr-1.5">@{cat.username}</span>
{cat.caption} {cat.caption}
</p> </p>
)} )}
{/* Divider */}
<div className="border-t border-[var(--border)]" />
{/* Actions */} {/* Actions */}
<div className="flex items-center gap-3 pt-1"> <div className="flex items-center gap-6">
<button <button
onClick={toggleLike} onClick={toggleLike}
disabled={isOwner || !user} disabled={isOwner || !user}
className={`flex items-center gap-1.5 text-[15px] font-medium transition-colors ${ className={`btn-icon flex items-center gap-2 text-[15px] font-medium ${
isLiked ? 'text-[#ff3b30]' : 'text-[#8e8e93] hover:text-black' isOwner
? 'text-[var(--foreground-tertiary)] cursor-not-allowed'
: liked
? 'text-[var(--danger)]'
: 'text-[var(--foreground-secondary)] hover:text-[var(--foreground)]'
}`} }`}
> >
<span className={`text-xl leading-none ${isLiked ? 'heart-animate' : ''}`}> <Heart
{isLiked ? '❤️' : '🤍'} className={`h-6 w-6 transition-all ${liked ? 'fill-[var(--danger)] stroke-[var(--danger)] animate-heart' : 'stroke-[1.5]'}`}
</span> />
{cat.likes_count > 0 && <span>{cat.likes_count}</span>} {cat.likes_count > 0 && <span className="tabular-nums">{cat.likes_count}</span>}
</button> </button>
<span className="text-[12px] text-[#8e8e93]">🏆 {cat.user_points} баллов</span>
<span className="flex items-center gap-1.5 text-[14px] text-[var(--foreground-secondary)]">
<span>🏆</span>
<span className="font-semibold">{cat.user_points}</span>
<span className="text-[var(--foreground-tertiary)]">баллов</span>
</span>
</div>
{/* Back to feed button */}
<div className="pt-2">
<Button
variant="outline"
size="sm"
onClick={() => navigate('/feed')}
className="rounded-full text-[12px] h-8"
>
В ленту
</Button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
); );
} }

View File

@@ -1,26 +1,28 @@
import { useState } from 'react'; import { useState } from 'react';
import { useCats } from '@/hooks/useCats'; import { useCats } from '@/hooks/useCats';
import { useAuth } from '@/hooks/useAuth';
import CatCard from '@/components/CatCard'; import CatCard from '@/components/CatCard';
import FeedSidebar from '@/components/FeedSidebar'; import FeedSidebar from '@/components/FeedSidebar';
import CatModal from '@/components/CatModal'; import CatModal from '@/components/CatModal';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import { Skeleton } from '@/components/ui/skeleton'; import { Skeleton } from '@/components/ui/skeleton';
import { ChevronLeft, ChevronRight } from 'lucide-react'; import { ChevronLeft, ChevronRight, RefreshCw } from 'lucide-react';
function FeedSkeleton() { function FeedSkeleton() {
return ( return (
<div className="space-y-2.5"> <div className="space-y-4">
{Array.from({ length: 3 }).map((_, i) => ( {Array.from({ length: 3 }).map((_, i) => (
<div key={i} className="tg-bubble border"> <div key={i} className="card overflow-hidden">
<div className="flex items-center gap-2.5 px-3.5 py-2.5"> <div className="flex items-center gap-3 px-4 py-3">
<Skeleton className="h-8 w-8 rounded-full" /> <Skeleton className="h-10 w-10 rounded-full" />
<Skeleton className="h-4 w-24 rounded" /> <div className="space-y-1.5">
<Skeleton className="h-4 w-28 rounded-full" />
<Skeleton className="h-3 w-16 rounded-full" />
</div>
</div> </div>
<Skeleton className="aspect-[4/3] w-full" /> <Skeleton className="aspect-[4/3] w-full" />
<div className="p-3 space-y-1.5"> <div className="p-4 space-y-2">
<Skeleton className="h-4 w-32 rounded" /> <Skeleton className="h-4 w-40 rounded-full" />
<Skeleton className="h-4 w-20 rounded" /> <Skeleton className="h-4 w-20 rounded-full" />
</div> </div>
</div> </div>
))} ))}
@@ -31,27 +33,59 @@ function FeedSkeleton() {
export default function FeedPage() { export default function FeedPage() {
const [page, setPage] = useState(1); const [page, setPage] = useState(1);
const [modalCatId, setModalCatId] = useState<number | null>(null); const [modalCatId, setModalCatId] = useState<number | null>(null);
const { data, isLoading, isError } = useCats(page); const { data, isLoading, isError, refetch } = useCats(page);
return ( return (
<div className="mx-auto max-w-[660px] px-4 py-4"> <div className="mx-auto max-w-[660px] px-4 py-4">
<div className="flex gap-6"> <div className="flex gap-6">
{/* Feed */} <main className="flex-1 min-w-0">
<div className="flex-1 min-w-0"> {/* Page indicator */}
{data && data.totalPages > 0 && (
<div className="flex items-center justify-between mb-4">
<h2 className="text-[13px] font-semibold text-[var(--foreground-secondary)] uppercase tracking-wider">
Лента
</h2>
<span className="text-[12px] text-[var(--foreground-tertiary)] tabular-nums">
{data.total} публикаций
</span>
</div>
)}
{isLoading && <FeedSkeleton />} {isLoading && <FeedSkeleton />}
{isError && ( {isError && (
<div className="flex flex-col items-center justify-center py-20 text-center"> <div className="flex flex-col items-center justify-center py-24 text-center animate-fade-in">
<p className="text-[15px] text-[#8e8e93] mb-4">Не удалось загрузить котов</p> <div className="mb-5 flex h-16 w-16 items-center justify-center rounded-full bg-[var(--danger-light)]">
<Button variant="outline" onClick={() => setPage(1)} className="rounded-full text-[13px]">Попробовать снова</Button> <span className="text-2xl">😿</span>
</div>
<p className="text-[17px] font-semibold mb-1.5">Не удалось загрузить</p>
<p className="text-[14px] text-[var(--foreground-secondary)] mb-6 max-w-xs">
Проверьте подключение к интернету и попробуйте снова
</p>
<Button
variant="outline"
onClick={() => refetch()}
className="rounded-full text-[13px] gap-1.5"
>
<RefreshCw className="h-3.5 w-3.5" strokeWidth={1.5} />
Попробовать снова
</Button>
</div> </div>
)} )}
{data && data.cats.length === 0 && ( {data && data.cats.length === 0 && (
<div className="flex flex-col items-center justify-center py-20 text-center"> <div className="flex flex-col items-center justify-center py-24 text-center animate-fade-in">
<p className="text-[17px] font-semibold mb-1">Пока нет котов</p> <div className="mb-5 flex h-16 w-16 items-center justify-center rounded-full bg-[var(--primary-light)]">
<p className="text-[14px] text-[#8e8e93] mb-5">Будьте первым, кто загрузит фото кота</p> <span className="text-2xl">🐱</span>
<Button onClick={() => window.location.href = '/upload'} className="rounded-full text-[13px] bg-[#2aabee] hover:bg-[#1d9bd9]"> </div>
<p className="text-[17px] font-semibold mb-1.5">Пока нет котов</p>
<p className="text-[14px] text-[var(--foreground-secondary)] mb-6">
Будьте первым, кто загрузит фото кота
</p>
<Button
onClick={() => window.location.href = '/upload'}
className="rounded-full text-[13px] bg-[var(--primary)] hover:bg-[var(--primary-hover)]"
>
Загрузить кота Загрузить кота
</Button> </Button>
</div> </div>
@@ -59,36 +93,63 @@ export default function FeedPage() {
{data && data.cats.length > 0 && ( {data && data.cats.length > 0 && (
<> <>
{data.cats.map((cat) => ( {data.cats.map((cat, index) => (
<CatCard key={cat.id} cat={cat} onOpen={setModalCatId} /> <CatCard key={cat.id} cat={cat} onOpen={setModalCatId} />
))} ))}
{data.totalPages > 1 && ( {data.totalPages > 1 && (
<div className="flex items-center justify-center gap-4 mt-4 pb-4"> <nav className="flex items-center justify-center gap-4 mt-6 pb-6">
<Button variant="outline" size="sm" onClick={() => setPage((p) => Math.max(1, p - 1))} disabled={page === 1} className="rounded-full text-[13px] h-8"> <Button
<ChevronLeft className="h-3.5 w-3.5" /> variant="outline"
size="sm"
onClick={() => setPage((p) => Math.max(1, p - 1))}
disabled={page === 1}
className="rounded-full text-[13px] h-9 px-4 gap-1"
>
<ChevronLeft className="h-4 w-4" strokeWidth={1.5} />
Назад Назад
</Button> </Button>
<span className="text-[13px] text-[#8e8e93]">{data.page} из {data.totalPages}</span>
<Button variant="outline" size="sm" onClick={() => setPage((p) => p + 1)} disabled={page >= data.totalPages} className="rounded-full text-[13px] h-8"> <div className="flex gap-1.5">
{Array.from({ length: data.totalPages }, (_, i) => i + 1).map((p) => (
<button
key={p}
onClick={() => setPage(p)}
className={`h-8 w-8 rounded-full text-[13px] font-medium transition-all ${
p === page
? 'bg-[var(--primary)] text-white'
: 'text-[var(--foreground-secondary)] hover:bg-[var(--secondary)]'
}`}
>
{p}
</button>
))}
</div>
<Button
variant="outline"
size="sm"
onClick={() => setPage((p) => p + 1)}
disabled={page >= data.totalPages}
className="rounded-full text-[13px] h-9 px-4 gap-1"
>
Вперёд Вперёд
<ChevronRight className="h-3.5 w-3.5" /> <ChevronRight className="h-4 w-4" strokeWidth={1.5} />
</Button> </Button>
</div> </nav>
)} )}
</> </>
)} )}
</div> </main>
{/* Sidebar — hidden on mobile */} <aside className="hidden lg:block w-[240px] shrink-0">
<div className="hidden lg:block w-[220px] shrink-0"> <div className="sticky top-20">
<div className="sticky top-16">
<FeedSidebar /> <FeedSidebar />
</div> </div>
</div> </aside>
</div> </div>
{modalCatId && <CatModal catId={modalCatId} onClose={() => setModalCatId(null)} />} {modalCatId && <CatModal catId={modalCatId} onClose={() => setModalCatId(null)} />}
</div> </div>
); );
} }

View File

@@ -26,50 +26,86 @@ export default function LoginPage() {
}; };
return ( return (
<div className="flex min-h-screen items-center justify-center p-4 bg-[#f5f5f5]"> <div className="flex min-h-screen items-center justify-center p-5 bg-[#f5f5f7]">
<div className="w-full max-w-sm animate-fade-in"> <div className="w-full max-w-sm animate-fade-in-up">
<div className="text-center mb-8"> <div className="text-center mb-10">
<div className="mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-[#2aabee]"> <div className="mx-auto mb-5 flex h-20 w-20 items-center justify-center rounded-full"
<Cat className="h-7 w-7 text-white" /> style={{ background: 'linear-gradient(135deg, #007aff 0%, #5856d6 100%)' }}>
<Cat className="h-10 w-10 text-white" strokeWidth={1.5} />
</div> </div>
<h1 className="text-[24px] font-bold">Catstagram</h1> <h1 className="text-[28px] font-bold tracking-tight">Catstagram</h1>
<p className="text-[14px] text-[#8e8e93] mt-1">Войдите, чтобы смотреть котов</p> <p className="text-[15px] text-[var(--foreground-secondary)] mt-1.5">
Войдите, чтобы смотреть котов
</p>
</div> </div>
<div className="space-y-3"> <form onSubmit={handleSubmit} className="space-y-3.5">
<Input <div className="space-y-1">
value={username} <label className="text-[13px] font-medium text-[var(--foreground-secondary)] ml-1">
onChange={(e) => setUsername(e.target.value)} Имя пользователя
placeholder="Имя пользователя" </label>
required <Input
autoFocus value={username}
className="h-11 text-[15px] rounded-xl bg-white border-[#d1d1d6]" onChange={(e) => setUsername(e.target.value)}
/> placeholder="your_cat_lover"
<Input required
type="password" autoFocus
value={password} className="h-12 text-[15px] rounded-xl bg-white border focus:border-[var(--primary)] focus:ring-2 focus:ring-[var(--primary)]/20 transition-all"
onChange={(e) => setPassword(e.target.value)} />
placeholder="Пароль" </div>
required <div className="space-y-1">
className="h-11 text-[15px] rounded-xl bg-white border-[#d1d1d6]" <label className="text-[13px] font-medium text-[var(--foreground-secondary)] ml-1">
/> Пароль
{error && <p className="text-[13px] text-[#ff3b30] text-center">{error}</p>} </label>
<Input
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
placeholder="••••••••"
required
className="h-12 text-[15px] rounded-xl bg-white border focus:border-[var(--primary)] focus:ring-2 focus:ring-[var(--primary)]/20 transition-all"
/>
</div>
{error && (
<div className="flex items-center gap-2 px-4 py-3 rounded-xl bg-[var(--danger-light)] text-[var(--danger)] text-[13px] font-medium animate-fade-in">
<span></span>
<span>{error}</span>
</div>
)}
<Button <Button
type="submit" type="submit"
className="w-full h-11 rounded-xl text-[15px] font-semibold bg-[#2aabee] hover:bg-[#1d9bd9]"
disabled={loading} disabled={loading}
className="w-full h-12 rounded-xl text-[15px] font-semibold bg-[var(--primary)] hover:bg-[var(--primary-hover)] disabled:opacity-60 transition-all"
> >
{loading ? 'Вход...' : 'Войти'} {loading ? (
<span className="flex items-center gap-2">
<span className="h-4 w-4 rounded-full border-2 border-white/30 border-t-white animate-spin" />
Вход...
</span>
) : 'Войти'}
</Button> </Button>
</form>
<div className="relative my-8">
<div className="absolute inset-0 flex items-center">
<div className="w-full border-t border-[var(--border)]"></div>
</div>
<div className="relative flex justify-center">
<span className="px-4 text-[13px] text-[var(--foreground-tertiary)] bg-[#f5f5f7]">
или
</span>
</div>
</div> </div>
<p className="mt-6 text-center text-[14px] text-[#8e8e93]"> <p className="text-center text-[14px] text-[var(--foreground-secondary)]">
Нет аккаунта?{' '} Нет аккаунта?{' '}
<Link to="/register" className="font-medium text-[#2aabee] hover:underline"> <Link to="/register" className="link-blue">
Зарегистрироваться Зарегистрироваться
</Link> </Link>
</p> </p>
</div> </div>
</div> </div>
); );
} }

View File

@@ -6,13 +6,14 @@ import CatModal from '@/components/CatModal';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import { Skeleton } from '@/components/ui/skeleton'; import { Skeleton } from '@/components/ui/skeleton';
import { Avatar, AvatarFallback } from '@/components/ui/avatar'; import { Avatar, AvatarFallback } from '@/components/ui/avatar';
import { ArrowLeft, Plus, Heart } from 'lucide-react'; import { ArrowLeft, Plus, LogOut, Heart } from 'lucide-react';
export default function ProfilePage() { export default function ProfilePage() {
const { id: paramId } = useParams<{ id?: string }>(); const { id: paramId } = useParams<{ id?: string }>();
const navigate = useNavigate(); const navigate = useNavigate();
const { user: me } = useAuth(); const { user: me, logout } = useAuth();
const [modalCatId, setModalCatId] = useState<number | null>(null); const [modalCatId, setModalCatId] = useState<number | null>(null);
const [tab, setTab] = useState<'photos' | 'likes'>('photos');
const profileUserId = paramId ? parseInt(paramId) : me?.id; const profileUserId = paramId ? parseInt(paramId) : me?.id;
const isMe = !paramId || (me && profileUserId === me.id); const isMe = !paramId || (me && profileUserId === me.id);
@@ -28,15 +29,17 @@ export default function ProfilePage() {
if (isLoading) { if (isLoading) {
return ( return (
<div className="mx-auto max-w-[660px] px-4 py-8"> <div className="mx-auto max-w-[660px] px-4 py-8">
<div className="flex items-center gap-4 mb-8"> <div className="flex items-center gap-5 mb-10">
<Skeleton className="h-16 w-16 rounded-full" /> <Skeleton className="h-20 w-20 rounded-full" />
<div className="space-y-2"> <div className="space-y-2.5 flex-1">
<Skeleton className="h-5 w-32 rounded" /> <Skeleton className="h-6 w-36 rounded-full" />
<Skeleton className="h-4 w-40 rounded" /> <Skeleton className="h-4 w-48 rounded-full" />
</div> </div>
</div> </div>
<div className="grid grid-cols-3 gap-1"> <div className="grid grid-cols-3 gap-2">
{Array.from({ length: 6 }).map((_, i) => (<Skeleton key={i} className="aspect-square rounded-lg" />))} {Array.from({ length: 6 }).map((_, i) => (
<Skeleton key={i} className="aspect-square rounded-xl" />
))}
</div> </div>
</div> </div>
); );
@@ -44,9 +47,14 @@ export default function ProfilePage() {
if (!profileUser && !isMe) { if (!profileUser && !isMe) {
return ( return (
<div className="flex flex-col items-center justify-center py-20"> <div className="flex flex-col items-center justify-center py-24 animate-fade-in">
<p className="text-[15px] text-[#8e8e93] mb-4">Пользователь не найден</p> <div className="mb-5 flex h-16 w-16 items-center justify-center rounded-full bg-[var(--secondary)]">
<Button variant="outline" onClick={() => navigate('/feed')} className="rounded-full text-[13px]">Перейти в ленту</Button> <span className="text-2xl">🔍</span>
</div>
<p className="text-[17px] font-semibold mb-1.5">Пользователь не найден</p>
<Button variant="outline" onClick={() => navigate('/feed')} className="rounded-full text-[13px] mt-2">
Вернуться в ленту
</Button>
</div> </div>
); );
} }
@@ -56,91 +64,146 @@ export default function ProfilePage() {
const totalLikes = cats.reduce((sum, c) => sum + c.likes_count, 0); const totalLikes = cats.reduce((sum, c) => sum + c.likes_count, 0);
return ( return (
<div className="mx-auto max-w-[660px] px-4 py-8"> <div className="mx-auto max-w-[660px] px-4 py-6">
{!isMe && ( {!isMe && (
<button onClick={() => navigate(-1)} className="mb-5 flex items-center gap-1.5 text-[14px] text-[#8e8e93] hover:text-black transition-colors"> <button
onClick={() => navigate(-1)}
className="mb-4 flex items-center gap-1.5 text-[14px] text-[var(--foreground-secondary)] hover:text-[var(--foreground)] transition-colors"
>
<ArrowLeft className="h-4 w-4" strokeWidth={1.5} /> <ArrowLeft className="h-4 w-4" strokeWidth={1.5} />
Назад Назад
</button> </button>
)} )}
{/* Profile header */} {/* Profile header */}
<div className="flex items-center gap-5 mb-8"> <div className="flex items-center gap-6 mb-8">
<Avatar className="h-16 w-16 shrink-0"> <Avatar className="h-20 w-20 shrink-0 ring-2 ring-[var(--primary)]/20 ring-offset-2">
<AvatarFallback className="text-xl font-semibold bg-[#2aabee] text-white"> <AvatarFallback className="text-[26px] font-bold avatar-initials">
{initials} {initials}
</AvatarFallback> </AvatarFallback>
</Avatar> </Avatar>
<div className="flex-1 min-w-0"> <div className="flex-1 min-w-0">
<div className="flex items-center gap-3 mb-1.5"> <div className="flex items-center gap-3 mb-2">
<h1 className="text-[18px] font-semibold">@{profileUser?.username}</h1> <h1 className="text-[20px] font-bold truncate">@{profileUser?.username}</h1>
{isMe && ( {isMe && (
<Button variant="outline" size="sm" className="rounded-full text-[12px] h-7 px-3"> <button
Редактировать onClick={logout}
</Button> className="btn-icon h-8 w-8 text-[var(--foreground-secondary)] hover:text-[var(--danger)] hover:bg-[var(--danger-light)] ml-auto"
title="Выйти"
>
<LogOut className="h-4 w-4" strokeWidth={1.5} />
</button>
)} )}
</div> </div>
<div className="flex items-center gap-4 text-[14px]">
<div> <div className="flex items-center gap-6 text-[14px] mb-3">
<span className="font-semibold">{cats.length}</span>{' '} <div className="text-center">
<span className="text-[#8e8e93]">публикаций</span> <p className="font-bold text-[16px]">{cats.length}</p>
<p className="text-[12px] text-[var(--foreground-secondary)]">публикаций</p>
</div> </div>
<div> <div className="text-center">
<span className="font-semibold">{totalLikes}</span>{' '} <p className="font-bold text-[16px]">{totalLikes}</p>
<span className="text-[#8e8e93]">лайков</span> <p className="text-[12px] text-[var(--foreground-secondary)]">лайков</p>
</div> </div>
<div> <div className="text-center">
<span className="font-semibold">🏆{profileUser?.points ?? 0}</span>{' '} <p className="font-bold text-[16px]">🏆{profileUser?.points ?? 0}</p>
<span className="text-[#8e8e93]">баллов</span> <p className="text-[12px] text-[var(--foreground-secondary)]">баллов</p>
</div> </div>
</div> </div>
{isMe && ( {isMe && (
<div className="mt-3"> <Link to="/upload">
<Link to="/upload"> <Button size="sm" className="rounded-full text-[13px] h-8 bg-[var(--primary)] hover:bg-[var(--primary-hover)] gap-1.5">
<Button size="sm" className="rounded-full text-[13px] h-8 bg-[#2aabee] hover:bg-[#1d9bd9] gap-1"> <Plus className="h-3.5 w-3.5" strokeWidth={2} />
<Plus className="h-3.5 w-3.5" strokeWidth={2} /> Новая публикация
Новая публикация </Button>
</Button> </Link>
</Link>
</div>
)} )}
</div> </div>
</div> </div>
{/* Grid */} {/* Tabs */}
{cats.length === 0 ? ( <div className="flex gap-1 mb-5 border-b border-[var(--border)]">
<div className="flex flex-col items-center justify-center py-16 text-center"> <button
<p className="text-[15px] font-medium mb-1">Пока нет котов</p> onClick={() => setTab('photos')}
<p className="text-[13px] text-[#8e8e93] mb-4"> className={`px-5 py-3 text-[14px] font-medium border-b-2 transition-all ${
{isMe ? 'Поделитесь первым фото кота' : 'У пользователя пока нет котов'} tab === 'photos'
</p> ? 'border-[var(--primary)] text-[var(--primary)]'
{isMe && ( : 'border-transparent text-[var(--foreground-secondary)] hover:text-[var(--foreground)]'
<Link to="/upload"> }`}
<Button size="sm" className="rounded-full text-[13px] bg-[#2aabee] hover:bg-[#1d9bd9]">Загрузить кота</Button> >
</Link> Фото
)} </button>
</div> <button
) : ( onClick={() => setTab('likes')}
<div className="grid grid-cols-3 gap-1"> className={`px-5 py-3 text-[14px] font-medium border-b-2 transition-all ${
{cats.map((cat) => ( tab === 'likes'
<button ? 'border-[var(--primary)] text-[var(--primary)]'
key={cat.id} : 'border-transparent text-[var(--foreground-secondary)] hover:text-[var(--foreground)]'
onClick={() => setModalCatId(cat.id)} }`}
className="group relative aspect-square overflow-hidden bg-[#f0f0f0]" >
> Избранное
<img src={cat.image_url} alt={cat.caption || 'Фото кота'} className="h-full w-full object-cover transition-transform group-hover:scale-105" loading="lazy" /> </button>
<div className="absolute inset-0 flex items-center justify-center bg-black/10 opacity-0 group-hover:opacity-100 transition-opacity"> </div>
<div className="flex items-center gap-1 text-white text-[13px] font-semibold drop-shadow-lg">
<Heart className="h-4 w-4 fill-white" strokeWidth={2} /> {/* Content */}
<span>{cat.likes_count}</span> {tab === 'photos' && (
cats.length === 0 ? (
<div className="flex flex-col items-center justify-center py-16 text-center animate-fade-in">
<div className="mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-[var(--secondary)]">
<span className="text-xl">📸</span>
</div>
<p className="text-[15px] font-medium mb-1">Пока нет котов</p>
<p className="text-[13px] text-[var(--foreground-secondary)] mb-5 max-w-xs">
{isMe ? 'Поделитесь первым фото кота' : 'У пользователя пока нет котов'}
</p>
{isMe && (
<Link to="/upload">
<Button size="sm" className="rounded-full text-[13px] bg-[var(--primary)] hover:bg-[var(--primary-hover)]">
Загрузить кота
</Button>
</Link>
)}
</div>
) : (
<div className="grid grid-cols-3 gap-2">
{cats.map((cat) => (
<button
key={cat.id}
onClick={() => setModalCatId(cat.id)}
className="group relative aspect-square overflow-hidden bg-[var(--secondary)] rounded-xl"
>
<img
src={cat.image_url}
alt={cat.caption || 'Фото кота'}
className="h-full w-full object-cover transition-all duration-300 group-hover:scale-105"
loading="lazy"
/>
<div className="absolute inset-0 bg-gradient-to-t from-black/40 via-transparent to-transparent opacity-0 group-hover:opacity-100 transition-opacity flex items-end p-3">
<div className="flex items-center gap-1.5 text-white text-[13px] font-semibold">
<Heart className="h-4 w-4 fill-white" strokeWidth={2} />
<span>{cat.likes_count}</span>
</div>
</div> </div>
</div> </button>
</button> ))}
))} </div>
)
)}
{tab === 'likes' && (
<div className="flex flex-col items-center justify-center py-16 text-center animate-fade-in">
<div className="mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-[var(--primary-light)]">
<Heart className="h-6 w-6 text-[var(--primary)]" strokeWidth={1.5} />
</div>
<p className="text-[15px] font-medium mb-1">Скоро</p>
<p className="text-[13px] text-[var(--foreground-secondary)]">
Здесь появятся понравившиеся коты
</p>
</div> </div>
)} )}
{modalCatId && <CatModal catId={modalCatId} onClose={() => setModalCatId(null)} />} {modalCatId && <CatModal catId={modalCatId} onClose={() => setModalCatId(null)} />}
</div> </div>
); );
} }

View File

@@ -33,60 +33,101 @@ export default function RegisterPage() {
}; };
return ( return (
<div className="flex min-h-screen items-center justify-center p-4 bg-[#f5f5f5]"> <div className="flex min-h-screen items-center justify-center p-5 bg-[#f5f5f7]">
<div className="w-full max-w-sm animate-fade-in"> <div className="w-full max-w-sm animate-fade-in-up">
<div className="text-center mb-8"> <div className="text-center mb-10">
<div className="mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-[#2aabee]"> <div className="mx-auto mb-5 flex h-20 w-20 items-center justify-center rounded-full"
<Cat className="h-7 w-7 text-white" /> style={{ background: 'linear-gradient(135deg, #007aff 0%, #5856d6 100%)' }}>
<Cat className="h-10 w-10 text-white" strokeWidth={1.5} />
</div> </div>
<h1 className="text-[24px] font-bold">Catstagram</h1> <h1 className="text-[28px] font-bold tracking-tight">Catstagram</h1>
<p className="text-[14px] text-[#8e8e93] mt-1">Присоединяйтесь к сообществу</p> <p className="text-[15px] text-[var(--foreground-secondary)] mt-1.5">
Присоединяйтесь к сообществу
</p>
</div> </div>
<div className="space-y-3"> <form onSubmit={handleSubmit} className="space-y-3.5">
<Input <div className="space-y-1">
value={username} <label className="text-[13px] font-medium text-[var(--foreground-secondary)] ml-1">
onChange={(e) => setUsername(e.target.value)} Имя пользователя
placeholder="Имя пользователя" </label>
minLength={3} <Input
required value={username}
autoFocus onChange={(e) => setUsername(e.target.value)}
className="h-11 text-[15px] rounded-xl bg-white border-[#d1d1d6]" placeholder="your_cat_lover"
/> minLength={3}
<Input required
type="password" autoFocus
value={password} className="h-12 text-[15px] rounded-xl bg-white border focus:border-[var(--primary)] focus:ring-2 focus:ring-[var(--primary)]/20 transition-all"
onChange={(e) => setPassword(e.target.value)} />
placeholder="Пароль" </div>
minLength={4} <div className="space-y-1">
required <label className="text-[13px] font-medium text-[var(--foreground-secondary)] ml-1">
className="h-11 text-[15px] rounded-xl bg-white border-[#d1d1d6]" Пароль
/> </label>
<Input <Input
type="password" type="password"
value={confirm} value={password}
onChange={(e) => setConfirm(e.target.value)} onChange={(e) => setPassword(e.target.value)}
placeholder="Подтвердите пароль" placeholder="Минимум 4 символа"
required minLength={4}
className="h-11 text-[15px] rounded-xl bg-white border-[#d1d1d6]" required
/> className="h-12 text-[15px] rounded-xl bg-white border focus:border-[var(--primary)] focus:ring-2 focus:ring-[var(--primary)]/20 transition-all"
{error && <p className="text-[13px] text-[#ff3b30] text-center">{error}</p>} />
</div>
<div className="space-y-1">
<label className="text-[13px] font-medium text-[var(--foreground-secondary)] ml-1">
Подтвердите пароль
</label>
<Input
type="password"
value={confirm}
onChange={(e) => setConfirm(e.target.value)}
placeholder="Повторите пароль"
required
className="h-12 text-[15px] rounded-xl bg-white border focus:border-[var(--primary)] focus:ring-2 focus:ring-[var(--primary)]/20 transition-all"
/>
</div>
{error && (
<div className="flex items-center gap-2 px-4 py-3 rounded-xl bg-[var(--danger-light)] text-[var(--danger)] text-[13px] font-medium animate-fade-in">
<span></span>
<span>{error}</span>
</div>
)}
<Button <Button
type="submit" type="submit"
className="w-full h-11 rounded-xl text-[15px] font-semibold bg-[#2aabee] hover:bg-[#1d9bd9]"
disabled={loading} disabled={loading}
className="w-full h-12 rounded-xl text-[15px] font-semibold bg-[var(--primary)] hover:bg-[var(--primary-hover)] disabled:opacity-60 transition-all"
> >
{loading ? 'Создание...' : 'Создать аккаунт'} {loading ? (
<span className="flex items-center gap-2">
<span className="h-4 w-4 rounded-full border-2 border-white/30 border-t-white animate-spin" />
Создание...
</span>
) : 'Создать аккаунт'}
</Button> </Button>
</form>
<div className="relative my-8">
<div className="absolute inset-0 flex items-center">
<div className="w-full border-t border-[var(--border)]"></div>
</div>
<div className="relative flex justify-center">
<span className="px-4 text-[13px] text-[var(--foreground-tertiary)] bg-[#f5f5f7]">
или
</span>
</div>
</div> </div>
<p className="mt-6 text-center text-[14px] text-[#8e8e93]"> <p className="text-center text-[14px] text-[var(--foreground-secondary)]">
Уже есть аккаунт?{' '} Уже есть аккаунт?{' '}
<Link to="/login" className="font-medium text-[#2aabee] hover:underline"> <Link to="/login" className="link-blue">
Войти Войти
</Link> </Link>
</p> </p>
</div> </div>
</div> </div>
); );
} }

View File

@@ -6,7 +6,7 @@ import { useAuth } from '@/hooks/useAuth';
import { useToast } from '@/components/Toast'; import { useToast } from '@/components/Toast';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import { Avatar, AvatarFallback } from '@/components/ui/avatar'; import { Avatar, AvatarFallback } from '@/components/ui/avatar';
import { ArrowLeft, Upload, X } from 'lucide-react'; import { ArrowLeft, Upload, X, Image } from 'lucide-react';
export default function UploadPage() { export default function UploadPage() {
const navigate = useNavigate(); const navigate = useNavigate();
@@ -42,9 +42,11 @@ export default function UploadPage() {
try { try {
const result = await uploadMutation.mutateAsync(fd); const result = await uploadMutation.mutateAsync(fd);
if (user) updateUser({ ...user, points: (user.points || 0) + 10 }); if (user) updateUser({ ...user, points: (user.points || 0) + 10 });
toast('+10 баллов'); toast('+10 баллов 🎉');
navigate(`/cat/${result.cat.id}`); navigate(`/cat/${result.cat.id}`);
} catch { toast('Ошибка загрузки', 'error'); } } catch {
toast('Ошибка загрузки', 'error');
}
}; };
const clearFile = () => { const clearFile = () => {
@@ -57,81 +59,125 @@ export default function UploadPage() {
<div className="mx-auto max-w-[580px] px-4 py-6"> <div className="mx-auto max-w-[580px] px-4 py-6">
<button <button
onClick={() => navigate(-1)} onClick={() => navigate(-1)}
className="mb-4 flex items-center gap-1.5 text-[14px] text-[#8e8e93] hover:text-black transition-colors" className="mb-5 flex items-center gap-1.5 text-[14px] text-[var(--foreground-secondary)] hover:text-[var(--foreground)] transition-colors group"
> >
<ArrowLeft className="h-4 w-4" strokeWidth={1.5} /> <ArrowLeft className="h-4 w-4 stroke-[1.5] group-hover:-translate-x-0.5 transition-transform" />
Назад Назад
</button> </button>
<h1 className="text-[20px] font-semibold mb-5">Новая публикация</h1> <h1 className="text-[22px] font-bold mb-6">Новая публикация</h1>
{!preview ? ( {!preview ? (
<div <div
{...getRootProps()} {...getRootProps()}
className={`border border-dashed rounded-2xl p-16 text-center cursor-pointer transition-colors ${ className={`border-2 border-dashed rounded-2xl p-16 text-center cursor-pointer transition-all ${
isDragActive ? 'border-[#2aabee] bg-[#e8f5ff]' : 'hover:bg-[#f0f0f0] border-[#d1d1d6]' isDragActive
? 'border-[var(--primary)] bg-[var(--primary-light)] scale-[1.02]'
: 'border-[var(--border)] hover:bg-[var(--secondary)] hover:border-[var(--foreground-tertiary)]'
}`} }`}
> >
<input {...getInputProps()} /> <input {...getInputProps()} />
<div className="mb-4"> <div className="mb-5 flex justify-center">
<Upload className="mx-auto h-8 w-8 text-[#8e8e93]" strokeWidth={1.5} /> <div className="h-16 w-16 rounded-full bg-[var(--secondary)] flex items-center justify-center">
{isDragActive ? (
<Image className="h-7 w-7 text-[var(--primary)]" strokeWidth={1.5} />
) : (
<Upload className="h-7 w-7 text-[var(--foreground-secondary)]" strokeWidth={1.5} />
)}
</div>
</div> </div>
<p className="text-[15px] font-medium mb-1"> <p className="text-[16px] font-semibold mb-1">
{isDragActive ? 'Отпустите фото' : 'Перетащите фото сюда'} {isDragActive ? 'Отпустите фото' : 'Перетащите фото сюда'}
</p> </p>
<p className="text-[13px] text-[#8e8e93] mb-5">или нажмите, чтобы выбрать</p> <p className="text-[14px] text-[var(--foreground-secondary)] mb-6">
<Button variant="outline" size="sm" className="rounded-full text-[13px]">Выбрать файл</Button> или нажмите, чтобы выбрать
<p className="mt-4 text-[12px] text-[#8e8e93]">JPG, PNG, GIF, WebP · до 10 МБ</p> </p>
<Button
variant="outline"
size="sm"
className="rounded-full text-[13px] px-6"
>
Выбрать файл
</Button>
<p className="mt-5 text-[12px] text-[var(--foreground-tertiary)]">
JPG, PNG, GIF, WebP · до 10 МБ
</p>
</div> </div>
) : ( ) : (
<div className="space-y-4"> <div className="space-y-5 animate-fade-in-up">
<div className="relative bg-[#f0f0f0] rounded-2xl overflow-hidden"> {/* Preview */}
<img src={preview} alt="Preview" className="max-h-[400px] w-full object-contain" /> <div className="relative bg-[var(--secondary)] rounded-2xl overflow-hidden shadow-sm">
<img
src={preview!}
alt="Preview"
className="max-h-[420px] w-full object-contain"
/>
<button <button
onClick={clearFile} onClick={clearFile}
className="absolute right-3 top-3 flex h-8 w-8 items-center justify-center rounded-full bg-black/50 text-white hover:bg-black/70 transition-colors" className="absolute right-3 top-3 flex h-9 w-9 items-center justify-center rounded-full bg-black/40 text-white hover:bg-black/60 transition-all backdrop-blur-sm"
> >
<X className="h-4 w-4" /> <X className="h-4 w-4" strokeWidth={2} />
</button> </button>
</div> </div>
{/* Caption input */}
<div className="flex items-start gap-3"> <div className="flex items-start gap-3">
<Avatar className="h-8 w-8 shrink-0"> <Avatar className="h-9 w-9 shrink-0">
<AvatarFallback className="text-xs bg-[#2aabee] text-white"> <AvatarFallback className="text-xs avatar-initials">
{user?.username?.charAt(0).toUpperCase() || '?'} {user?.username?.charAt(0).toUpperCase() || '?'}
</AvatarFallback> </AvatarFallback>
</Avatar> </Avatar>
<div className="flex-1"> <div className="flex-1">
<p className="text-[13px] font-medium mb-1">{user?.username}</p> <p className="text-[14px] font-semibold mb-1.5">{user?.username}</p>
<textarea <textarea
placeholder="Подпись к фото..." placeholder="Напишите подпись к фото..."
value={caption} value={caption}
onChange={(e) => setCaption(e.target.value)} onChange={(e) => setCaption(e.target.value)}
maxLength={200} maxLength={200}
rows={2} rows={3}
className="w-full resize-none text-[15px] bg-transparent outline-none placeholder:text-[#8e8e93]" className="w-full resize-none text-[15px] bg-transparent outline-none placeholder:text-[var(--foreground-tertiary)] leading-[1.4]"
/> />
<p className="text-right text-[11px] text-[#8e8e93] mt-0.5">{caption.length}/200</p> <div className="flex items-center justify-between mt-1">
<span className="text-[11px] text-[var(--foreground-tertiary)]">
{caption.length > 150 ? `Осталось ${200 - caption.length} символов` : ''}
</span>
<span className="text-[11px] text-[var(--foreground-tertiary)] tabular-nums">
{caption.length}/200
</span>
</div>
</div> </div>
</div> </div>
<div className="flex items-center justify-between pt-2"> {/* Submit */}
<span className="text-[13px] text-[#8e8e93]">+10 баллов</span> <div className="flex items-center justify-between pt-2 border-t border-[var(--border)]">
<div className="flex items-center gap-2 text-[13px] text-[var(--foreground-secondary)]">
<span>🏆</span>
<span className="font-medium">+10 баллов</span>
<span className="text-[var(--foreground-tertiary)]">за публикацию</span>
</div>
<Button <Button
onClick={handleUpload} onClick={handleUpload}
disabled={uploadMutation.isPending} disabled={uploadMutation.isPending}
size="sm" size="sm"
className="rounded-full text-[14px] bg-[#2aabee] hover:bg-[#1d9bd9] px-6" className="rounded-full text-[14px] bg-[var(--primary)] hover:bg-[var(--primary-hover)] px-6 h-10 disabled:opacity-60"
> >
{uploadMutation.isPending ? 'Публикация...' : 'Опубликовать'} {uploadMutation.isPending ? (
<span className="flex items-center gap-2">
<span className="h-4 w-4 rounded-full border-2 border-white/30 border-t-white animate-spin" />
Публикация...
</span>
) : 'Опубликовать'}
</Button> </Button>
</div> </div>
</div>
)}
{uploadMutation.isError && ( {uploadMutation.isError && (
<p className="mt-3 text-center text-[13px] text-[#ff3b30]">Не удалось загрузить. Попробуйте снова.</p> <div className="flex items-center gap-2 px-4 py-3 rounded-xl bg-[var(--danger-light)] text-[var(--danger)] text-[13px] font-medium animate-fade-in">
<span></span>
<span>Не удалось загрузить. Попробуйте снова.</span>
</div>
)}
</div>
)} )}
</div> </div>
); );
} }