feat: refactor color management in charts and dashboard
- Replaced hardcoded priority colors in `PriorityDistributionChart` and `DashboardStats` with centralized configuration functions for better maintainability. - Updated `RecentTasks` to utilize new status badge classes and labels from the centralized configuration. - Enhanced `status-config.ts` with new functions for retrieving colors and styles, ensuring consistency across components. - Marked the task for refactoring priority colors in TODO.md as complete.
This commit is contained in:
@@ -190,12 +190,77 @@ export const getPriorityColor = (priority: TaskPriority): PriorityConfig['color'
|
||||
return PRIORITY_CONFIG[priority].color;
|
||||
};
|
||||
|
||||
// Configuration des couleurs HEX pour les priorités (cohérente avec le design)
|
||||
export const PRIORITY_COLOR_MAP = {
|
||||
blue: '#60a5fa', // blue-400 (low priority)
|
||||
yellow: '#fbbf24', // amber-400 (medium priority)
|
||||
purple: '#a78bfa', // violet-400 (high priority)
|
||||
red: '#f87171' // red-400 (urgent priority)
|
||||
} as const;
|
||||
|
||||
// Couleurs alternatives pour les graphiques et charts
|
||||
export const PRIORITY_CHART_COLORS = {
|
||||
'Faible': '#10b981', // green-500 (plus lisible dans les charts)
|
||||
'Moyenne': '#f59e0b', // amber-500
|
||||
'Élevée': '#8b5cf6', // violet-500
|
||||
'Urgente': '#ef4444', // red-500
|
||||
'Non définie': '#6b7280' // gray-500
|
||||
} as const;
|
||||
|
||||
export const getPriorityColorHex = (color: PriorityConfig['color']): string => {
|
||||
const colorMap = {
|
||||
blue: '#60a5fa',
|
||||
yellow: '#fbbf24',
|
||||
purple: '#a78bfa',
|
||||
red: '#f87171'
|
||||
};
|
||||
return colorMap[color];
|
||||
return PRIORITY_COLOR_MAP[color];
|
||||
};
|
||||
|
||||
// Fonction pour récupérer la couleur d'un chart basée sur le label
|
||||
export const getPriorityChartColor = (priorityLabel: string): string => {
|
||||
return PRIORITY_CHART_COLORS[priorityLabel as keyof typeof PRIORITY_CHART_COLORS] || PRIORITY_CHART_COLORS['Non définie'];
|
||||
};
|
||||
|
||||
// Configuration des couleurs pour les badges de statut
|
||||
export const STATUS_BADGE_COLORS = {
|
||||
backlog: 'bg-gray-100 text-gray-800',
|
||||
todo: 'bg-gray-100 text-gray-800',
|
||||
in_progress: 'bg-orange-100 text-orange-800',
|
||||
freeze: 'bg-purple-100 text-purple-800',
|
||||
done: 'bg-green-100 text-green-800',
|
||||
cancelled: 'bg-red-100 text-red-800',
|
||||
archived: 'bg-gray-100 text-gray-600'
|
||||
} as const;
|
||||
|
||||
// Fonction pour récupérer les classes CSS d'un badge de statut
|
||||
export const getStatusBadgeClasses = (status: TaskStatus): string => {
|
||||
return STATUS_BADGE_COLORS[status] || STATUS_BADGE_COLORS.todo;
|
||||
};
|
||||
|
||||
// Configuration des couleurs pour les cartes de statistiques du dashboard
|
||||
export const DASHBOARD_STAT_COLORS = {
|
||||
total: {
|
||||
color: 'bg-blue-500',
|
||||
textColor: 'text-blue-600',
|
||||
progressColor: 'bg-blue-500',
|
||||
dotColor: 'bg-blue-500'
|
||||
},
|
||||
todo: {
|
||||
color: 'bg-gray-500',
|
||||
textColor: 'text-gray-600',
|
||||
progressColor: 'bg-gray-500',
|
||||
dotColor: 'bg-gray-500'
|
||||
},
|
||||
inProgress: {
|
||||
color: 'bg-orange-500',
|
||||
textColor: 'text-orange-600',
|
||||
progressColor: 'bg-orange-500',
|
||||
dotColor: 'bg-orange-500'
|
||||
},
|
||||
completed: {
|
||||
color: 'bg-green-500',
|
||||
textColor: 'text-green-600',
|
||||
progressColor: 'bg-green-500',
|
||||
dotColor: 'bg-green-500'
|
||||
}
|
||||
} as const;
|
||||
|
||||
// Fonction pour récupérer les couleurs d'une stat du dashboard
|
||||
export const getDashboardStatColors = (statType: keyof typeof DASHBOARD_STAT_COLORS) => {
|
||||
return DASHBOARD_STAT_COLORS[statType];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user