From 8979970a9043ef23773af3879773fbf6afcc5be8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20FAMIBELLE-PRONZOLA?= Date: Sun, 5 Jul 2026 19:50:54 +0400 Subject: [PATCH] feat: refonte visuelle des commentaires (cartes, compteur, date) --- components/teks/komante.jsx | 91 +++++++++++++++++++++++++------------ 1 file changed, 61 insertions(+), 30 deletions(-) diff --git a/components/teks/komante.jsx b/components/teks/komante.jsx index 65702a7..2b17c38 100644 --- a/components/teks/komante.jsx +++ b/components/teks/komante.jsx @@ -2,10 +2,13 @@ import PropTypes from 'prop-types' import Box from '@mui/material/Box' +import Stack from '@mui/material/Stack' import Avatar from '@mui/material/Avatar' import Typography from '@mui/material/Typography' import Chip from '@mui/material/Chip' import Link from 'next/link' +import {format} from 'date-fns' +import {fr} from 'date-fns/locale' import {Mastodon} from '@icons-pack/react-simple-icons' function formatAuteur(commentaire) { @@ -16,6 +19,14 @@ function formatAuteur(commentaire) { return commentaire.user?.username || 'Anonim' } +function formatDat(commentaire) { + if (!commentaire.datePublication) { + return null + } + + return format(new Date(commentaire.datePublication), 'P', {locale: fr}) +} + export default function Komante({commentaires}) { if (!commentaires || commentaires.length === 0) { return null @@ -24,41 +35,61 @@ export default function Komante({commentaires}) { return ( - Komantè + Komantè ({commentaires.length}) - {commentaires.map(commentaire => { - const auteur = formatAuteur(commentaire) - const estFedere = commentaire.origine === 'activitypub' + + {commentaires.map(commentaire => { + const auteur = formatAuteur(commentaire) + const estFedere = commentaire.origine === 'activitypub' + const dat = formatDat(commentaire) - return ( - - - - - {estFedere && commentaire.auteurProfilUrl ? ( - - {auteur} + return ( + + + + + + + {estFedere && commentaire.auteurProfilUrl ? ( + + {auteur} + + ) : auteur} + + {estFedere && ( + } + /> + )} + + {dat && ( + + {dat} + + )} + + {commentaire.contenu} + {estFedere && commentaire.remoteUrl && ( + + Voir sur Mastodon - ) : auteur} - {estFedere && ( - } - sx={{ml: 1}} - /> )} - - {commentaire.contenu} - {estFedere && commentaire.remoteUrl && ( - - Voir sur Mastodon - - )} + - - ) - })} + ) + })} + ) }