feat: add GIF Mood Board workshop
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 4m5s
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 4m5s
- New workshop where each team member shares up to 5 GIFs with notes to express their weekly mood - Per-user week rating (1-5 stars) visible next to each member's section - Masonry-style grid with adjustable column count (3/4/5) toggle - Handwriting font (Caveat) for GIF notes - Full real-time collaboration via SSE - Clean migration (add_gif_mood_workshop) safe for production deploy - DB backup via cp before each migration in docker-entrypoint Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
112
src/components/gif-mood/GifMoodCard.tsx
Normal file
112
src/components/gif-mood/GifMoodCard.tsx
Normal file
@@ -0,0 +1,112 @@
|
||||
'use client';
|
||||
|
||||
import { memo, useState, useTransition } from 'react';
|
||||
import { updateGifMoodItem, deleteGifMoodItem } from '@/actions/gif-mood';
|
||||
|
||||
interface GifMoodCardProps {
|
||||
sessionId: string;
|
||||
item: {
|
||||
id: string;
|
||||
gifUrl: string;
|
||||
note: string | null;
|
||||
userId: string;
|
||||
};
|
||||
currentUserId: string;
|
||||
canEdit: boolean;
|
||||
}
|
||||
|
||||
export const GifMoodCard = memo(function GifMoodCard({
|
||||
sessionId,
|
||||
item,
|
||||
currentUserId,
|
||||
canEdit,
|
||||
}: GifMoodCardProps) {
|
||||
const [note, setNote] = useState(item.note || '');
|
||||
const [itemVersion, setItemVersion] = useState(item);
|
||||
const [isPending, startTransition] = useTransition();
|
||||
const [imgError, setImgError] = useState(false);
|
||||
|
||||
if (itemVersion !== item) {
|
||||
setItemVersion(item);
|
||||
setNote(item.note || '');
|
||||
}
|
||||
|
||||
const isOwner = item.userId === currentUserId;
|
||||
const canEditThis = canEdit && isOwner;
|
||||
|
||||
function handleNoteBlur() {
|
||||
if (!canEditThis) return;
|
||||
startTransition(async () => {
|
||||
await updateGifMoodItem(sessionId, item.id, { note: note.trim() || undefined });
|
||||
});
|
||||
}
|
||||
|
||||
function handleDelete() {
|
||||
if (!canEditThis) return;
|
||||
startTransition(async () => {
|
||||
await deleteGifMoodItem(sessionId, item.id);
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`group relative rounded-2xl overflow-hidden bg-card shadow-sm hover:shadow-md transition-all duration-200 ${
|
||||
isPending ? 'opacity-50 scale-95' : ''
|
||||
}`}
|
||||
>
|
||||
{/* GIF */}
|
||||
{imgError ? (
|
||||
<div className="flex flex-col items-center justify-center gap-2 min-h-[120px] bg-card-hover">
|
||||
<span className="text-3xl opacity-40">🖼️</span>
|
||||
<p className="text-xs text-muted">Image non disponible</p>
|
||||
</div>
|
||||
) : (
|
||||
// eslint-disable-next-line @next/next/no-img-element
|
||||
<img
|
||||
src={item.gifUrl}
|
||||
alt="GIF"
|
||||
className="w-full block"
|
||||
onError={() => setImgError(true)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Gradient overlay on hover (for delete affordance) */}
|
||||
{canEditThis && (
|
||||
<div className="absolute inset-0 bg-gradient-to-b from-black/20 via-transparent to-transparent opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none" />
|
||||
)}
|
||||
|
||||
{/* Delete button — visible on hover */}
|
||||
{canEditThis && (
|
||||
<button
|
||||
onClick={handleDelete}
|
||||
disabled={isPending}
|
||||
className="absolute top-2 right-2 p-1.5 rounded-full bg-black/50 text-white opacity-0 group-hover:opacity-100 hover:bg-black/70 transition-all backdrop-blur-sm"
|
||||
title="Supprimer ce GIF"
|
||||
>
|
||||
<svg className="w-3 h-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2.5} d="M6 18L18 6M6 6l12 12" />
|
||||
</svg>
|
||||
</button>
|
||||
)}
|
||||
|
||||
{/* Note */}
|
||||
{canEditThis ? (
|
||||
<div className="px-3 pt-2 pb-3 bg-card">
|
||||
<textarea
|
||||
value={note}
|
||||
onChange={(e) => setNote(e.target.value)}
|
||||
onBlur={handleNoteBlur}
|
||||
placeholder="Ajouter une note…"
|
||||
rows={1}
|
||||
className="w-full text-foreground/70 bg-transparent resize-none outline-none placeholder:text-muted/40 leading-relaxed text-center"
|
||||
style={{ fontFamily: 'var(--font-caveat)', fontSize: '1.2rem' }}
|
||||
/>
|
||||
</div>
|
||||
) : note ? (
|
||||
<div className="px-3 py-2.5 bg-card">
|
||||
<p className="text-foreground/70 leading-relaxed text-center" style={{ fontFamily: 'var(--font-caveat)', fontSize: '1.2rem' }}>{note}</p>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user