feat: integrate TagDisplay component into TaskCard

- Replaced badge rendering with TagDisplay for improved tag visualization.
- Added showDot prop to control dot display alongside tag colors.
This commit is contained in:
Julien Froidefond
2025-09-30 10:26:34 +02:00
parent 884139f8f7
commit f145bed97d
2 changed files with 12 additions and 24 deletions

View File

@@ -9,6 +9,7 @@ interface TagDisplayProps {
size?: 'sm' | 'md' | 'lg'; size?: 'sm' | 'md' | 'lg';
maxTags?: number; maxTags?: number;
showColors?: boolean; showColors?: boolean;
showDot?: boolean;
onClick?: (tagName: string) => void; onClick?: (tagName: string) => void;
className?: string; className?: string;
} }
@@ -19,6 +20,7 @@ export function TagDisplay({
size = 'sm', size = 'sm',
maxTags, maxTags,
showColors = true, showColors = true,
showDot = true,
onClick, onClick,
className = "" className = ""
}: TagDisplayProps) { }: TagDisplayProps) {
@@ -60,7 +62,7 @@ export function TagDisplay({
color: showColors ? color : undefined color: showColors ? color : undefined
}} }}
> >
{showColors && ( {showColors && showDot && (
<div <div
className="w-2 h-2 rounded-full" className="w-2 h-2 rounded-full"
style={{ backgroundColor: color }} style={{ backgroundColor: color }}

View File

@@ -2,6 +2,7 @@ import { HTMLAttributes, forwardRef, useState, useEffect, useRef } from 'react';
import { cn } from '@/lib/utils'; import { cn } from '@/lib/utils';
import { Card } from './Card'; import { Card } from './Card';
import { Badge } from './Badge'; import { Badge } from './Badge';
import { TagDisplay } from './TagDisplay';
import { formatDateForDisplay } from '@/lib/date-utils'; import { formatDateForDisplay } from '@/lib/date-utils';
interface TaskCardProps extends HTMLAttributes<HTMLDivElement> { interface TaskCardProps extends HTMLAttributes<HTMLDivElement> {
@@ -415,29 +416,14 @@ const TaskCard = forwardRef<HTMLDivElement, TaskCardProps>(
{/* Tags avec couleurs personnalisées */} {/* Tags avec couleurs personnalisées */}
{tags.length > 0 && ( {tags.length > 0 && (
<div className="mb-3"> <div className="mb-3">
<div className="flex flex-wrap gap-1"> <TagDisplay
{tags.slice(0, 3).map((tag, index) => { tags={tags}
const tagConfig = availableTags.find(t => t.name === tag); availableTags={availableTags}
return ( maxTags={3}
<Badge size="sm"
key={index} showColors={true}
variant="outline" showDot={false}
size="sm" />
style={tagConfig?.color ? {
borderColor: `${tagConfig.color}40`,
color: tagConfig.color
} : undefined}
>
{tag}
</Badge>
);
})}
{tags.length > 3 && (
<Badge variant="outline" size="sm">
+{tags.length - 3}
</Badge>
)}
</div>
</div> </div>
)} )}