mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 10:46:29 +00:00
Add status-colored milestone timeline
Connect milestones with status-colored gradient segments and improve node hover styling. Remove debug logging from the task page and timeline.
This commit is contained in:
@@ -23,6 +23,16 @@ interface GroupedMilestone {
|
||||
items: IClientMilestone[];
|
||||
}
|
||||
|
||||
interface GradientSegment {
|
||||
fromPercent: number;
|
||||
toPercent: number;
|
||||
fromHex: string;
|
||||
toHex: string;
|
||||
}
|
||||
|
||||
// Starting color for active milestone line: Merah rose (Development)
|
||||
const START_LINE_HEX = '#f43f5e';
|
||||
|
||||
export default function ClientMilestoneTimeline({ client, variant = 'list' }: ClientMilestoneTimelineProps) {
|
||||
const today = dayjs().startOf('day');
|
||||
const maxDate = today.add(2, 'month').startOf('day');
|
||||
@@ -60,6 +70,34 @@ export default function ClientMilestoneTimeline({ client, variant = 'list' }: Cl
|
||||
|
||||
const groups = Object.values(groupsMap).sort((a, b) => a.diffDays - b.diffDays);
|
||||
|
||||
// Compute sequential line gradient segments:
|
||||
// Starts at Hari Ini (0%, Merah Rose) -> Agenda 1 -> Agenda 2 -> ... -> Agenda N
|
||||
const gradientSegments: GradientSegment[] = [];
|
||||
|
||||
if (groups.length > 0) {
|
||||
let currentPercent = 0;
|
||||
let currentHex = START_LINE_HEX;
|
||||
|
||||
for (let i = 0; i < groups.length; i++) {
|
||||
const group = groups[i];
|
||||
const targetPercent = group.percent;
|
||||
const targetMeta = resolveTechnicalStatusMeta(group.items[0]?.project_assignment_status?.name);
|
||||
const targetHex = targetMeta.hexColor;
|
||||
|
||||
if (targetPercent > currentPercent) {
|
||||
gradientSegments.push({
|
||||
fromPercent: currentPercent,
|
||||
toPercent: targetPercent,
|
||||
fromHex: currentHex,
|
||||
toHex: targetHex,
|
||||
});
|
||||
}
|
||||
|
||||
currentPercent = targetPercent;
|
||||
currentHex = targetHex;
|
||||
}
|
||||
}
|
||||
|
||||
// Compute month boundaries for tick lines along the 2-month rail
|
||||
const nextMonthStart = today.add(1, 'month').startOf('month');
|
||||
const month2Start = today.add(2, 'month').startOf('month');
|
||||
@@ -82,7 +120,7 @@ export default function ClientMilestoneTimeline({ client, variant = 'list' }: Cl
|
||||
}
|
||||
|
||||
const isGrid = variant === 'grid';
|
||||
console.log(groups)
|
||||
const hasAgendas = groups.length > 0;
|
||||
|
||||
return (
|
||||
<div className={cn("w-full flex flex-col gap-2 min-w-0", isGrid ? "pt-2" : "")}>
|
||||
@@ -98,7 +136,7 @@ export default function ClientMilestoneTimeline({ client, variant = 'list' }: Cl
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-1.5">
|
||||
{groups.length > 0 ? (
|
||||
{hasAgendas ? (
|
||||
<span className="text-[10px] px-2 py-0.5 rounded-full bg-primary/10 text-primary font-bold">
|
||||
{validMilestones.length} {validMilestones.length === 1 ? 'Agenda' : 'Agendas'}
|
||||
</span>
|
||||
@@ -110,20 +148,44 @@ export default function ClientMilestoneTimeline({ client, variant = 'list' }: Cl
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Timeline Viewport Container */}
|
||||
{/* Timeline Viewport Container with group/rail for sibling hover coordination */}
|
||||
<div className={cn("w-full min-w-0", isGrid ? "" : "overflow-x-auto scrollbar-hide")}>
|
||||
<div className={cn("relative pt-3", groups.length > 0 ? 'mb-14' : 'mb-4', isGrid ? "px-3" : "min-w-105 px-6")}>
|
||||
<div
|
||||
className={cn(
|
||||
"relative pt-3 group/rail",
|
||||
hasAgendas ? 'mb-14' : 'mb-4',
|
||||
isGrid ? "px-3" : "min-w-105 px-6"
|
||||
)}
|
||||
>
|
||||
{/* Continuous 2-Month Horizontal Rail */}
|
||||
<div className="relative h-1.5 w-full bg-muted/70 dark:bg-zinc-800 rounded-full">
|
||||
{/* Start Pin (Today) */}
|
||||
<div className="relative h-1.5 sm:h-2 w-full bg-muted/70 dark:bg-zinc-800 rounded-full">
|
||||
{/* Gradient Segments connecting Hari Ini -> Agenda 1 -> Agenda 2 -> ... */}
|
||||
<div className="absolute inset-0 rounded-full overflow-hidden pointer-events-none">
|
||||
{gradientSegments.map((seg, idx) => (
|
||||
<div
|
||||
key={idx}
|
||||
className="absolute top-0 h-full transition-all duration-300"
|
||||
style={{
|
||||
left: `${seg.fromPercent}%`,
|
||||
width: `${Math.max(0, seg.toPercent - seg.fromPercent)}%`,
|
||||
background: `linear-gradient(to right, ${seg.fromHex}, ${seg.toHex})`,
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Start Pin (Today) - Rose if active progression, gray if default */}
|
||||
<div
|
||||
className="absolute -left-1 top-1/2 -translate-y-1/2 size-2.5 rounded-full bg-primary/40 ring-2 ring-background"
|
||||
className={cn(
|
||||
"absolute -left-1 top-1/2 -translate-y-1/2 size-2.5 rounded-full ring-2 ring-background z-10 transition-colors",
|
||||
hasAgendas ? "bg-rose-500 shadow-xs" : "bg-muted-foreground/40"
|
||||
)}
|
||||
title={`Today: ${today.format('DD MMM YYYY')}`}
|
||||
/>
|
||||
|
||||
{/* End Pin (+2 Months) */}
|
||||
<div
|
||||
className="absolute -right-1 top-1/2 -translate-y-1/2 size-2.5 rounded-full bg-muted-foreground/40 ring-2 ring-background"
|
||||
className="absolute -right-1 top-1/2 -translate-y-1/2 size-2.5 rounded-full bg-muted-foreground/40 ring-2 ring-background z-10"
|
||||
title={`End: ${maxDate.format('DD MMM YYYY')}`}
|
||||
/>
|
||||
|
||||
@@ -142,7 +204,7 @@ export default function ClientMilestoneTimeline({ client, variant = 'list' }: Cl
|
||||
))}
|
||||
|
||||
{/* If no milestones in range, show gentle notice */}
|
||||
{groups.length === 0 && (
|
||||
{!hasAgendas && (
|
||||
<div className="absolute inset-0 flex items-center justify-center pointer-events-none">
|
||||
<span className="text-[10px] text-muted-foreground/70 italic mt-6 select-none whitespace-nowrap">
|
||||
No upcoming milestones in the next 2 months
|
||||
@@ -159,33 +221,58 @@ export default function ClientMilestoneTimeline({ client, variant = 'list' }: Cl
|
||||
return (
|
||||
<div
|
||||
key={group.dateKey}
|
||||
className="absolute -translate-x-1/2 -top-1 z-20 flex flex-col items-center group/node"
|
||||
className={cn(
|
||||
"absolute -translate-x-1/2 -top-1 flex flex-col items-center group/node",
|
||||
"transition-all duration-200",
|
||||
// Stacking order: default z-20, leaps to z-50 on hover
|
||||
"z-20 hover:z-50 focus-within:z-50",
|
||||
// When any node is hovered, soften non-hovered siblings
|
||||
"group-hover/rail:opacity-40 group-hover/rail:scale-95",
|
||||
// Actively hovered node is fully opaque, prominent, and scaled up
|
||||
"hover:!opacity-100 hover:!scale-115",
|
||||
"focus-within:!opacity-100 focus-within:!scale-115"
|
||||
)}
|
||||
style={{ left: `${group.percent}%` }}
|
||||
>
|
||||
{/* Vertical Tick Line connecting Rail to Dot */}
|
||||
<div
|
||||
className={cn(
|
||||
"w-0.5 h-3.5 sm:h-4 rounded-full transition-all duration-200 group-hover/node:scale-y-125",
|
||||
"w-0.5 h-3.5 sm:h-4 rounded-full transition-all duration-200",
|
||||
"group-hover/node:w-1 group-hover/node:h-4.5 group-hover/node:shadow-sm",
|
||||
isMulti ? "bg-amber-400 dark:bg-amber-500" : primaryMeta.tickLine
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* HoverCard Trigger (Dot + Short Badge + Date) */}
|
||||
<HoverCard openDelay={40} closeDelay={150}>
|
||||
<HoverCard openDelay={30} closeDelay={150}>
|
||||
<HoverCardTrigger asChild>
|
||||
<Link
|
||||
href={`/task/client-detail/${client.id}/${firstItem.project_assignment_id}`}
|
||||
className="flex flex-col items-center cursor-pointer transition-transform hover:scale-110 focus:outline-none hover:bg-white hover:z-9999"
|
||||
className={cn(
|
||||
"flex flex-col items-center cursor-pointer focus:outline-none",
|
||||
"px-2 py-1 rounded-xl transition-all duration-200",
|
||||
// Normal state: transparent
|
||||
"bg-transparent border border-transparent",
|
||||
// Hover state: solid high-contrast backdrop card with shadow
|
||||
// Completely covers any adjacent date text underneath it
|
||||
"group-hover/node:bg-card/95 dark:group-hover/node:bg-zinc-900/95",
|
||||
"group-hover/node:shadow-xl group-hover/node:shadow-black/20 dark:group-hover/node:shadow-black/70",
|
||||
"group-hover/node:backdrop-blur-md"
|
||||
)}
|
||||
aria-label={`Milestones on ${group.date.format('DD MMM YYYY')}`}
|
||||
>
|
||||
{/* Dot / Multi-Dot Indicator */}
|
||||
{isMulti ? (
|
||||
<div
|
||||
className="relative size-4 sm:size-4.5 rounded-full bg-linear-to-br from-amber-400 via-rose-500 to-violet-600 p-[1.5px] shadow-sm ring-2 ring-background hover:ring-primary/40 transition-shadow"
|
||||
className={cn(
|
||||
"relative size-4 sm:size-4.5 rounded-full p-[1.5px] shadow-sm ring-2 ring-background transition-all duration-200",
|
||||
"group-hover/node:size-5 group-hover/node:ring-4 group-hover/node:ring-amber-500/40 group-hover/node:shadow-md",
|
||||
"bg-gradient-to-br from-amber-400 via-rose-500 to-violet-600"
|
||||
)}
|
||||
title={`${group.items.length} agendas on this date`}
|
||||
>
|
||||
<div className="w-full h-full rounded-full bg-background flex items-center justify-center">
|
||||
<span className="text-[9px] font-black text-foreground leading-none">
|
||||
<span className="text-[9px] group-hover/node:text-[10px] font-black text-foreground leading-none">
|
||||
{group.items.length}
|
||||
</span>
|
||||
</div>
|
||||
@@ -193,7 +280,8 @@ export default function ClientMilestoneTimeline({ client, variant = 'list' }: Cl
|
||||
) : (
|
||||
<div
|
||||
className={cn(
|
||||
"size-3 sm:size-3.5 rounded-full ring-2 ring-background shadow-xs transition-all duration-200 group-hover/node:ring-4",
|
||||
"size-3 sm:size-3.5 rounded-full ring-2 ring-background shadow-xs transition-all duration-200",
|
||||
"group-hover/node:size-4.5 group-hover/node:ring-4 group-hover/node:ring-offset-2 group-hover/node:ring-offset-background group-hover/node:shadow-md",
|
||||
primaryMeta.dotBg,
|
||||
primaryMeta.ringColor
|
||||
)}
|
||||
@@ -204,17 +292,28 @@ export default function ClientMilestoneTimeline({ client, variant = 'list' }: Cl
|
||||
{/* Short Badge underneath dot */}
|
||||
<div
|
||||
className={cn(
|
||||
"mt-1 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider border whitespace-nowrap shadow-2xs leading-none transition-colors",
|
||||
"mt-1 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider border whitespace-nowrap shadow-2xs leading-none transition-all duration-200",
|
||||
"group-hover/node:px-2 group-hover/node:py-0.5 group-hover/node:text-[10px] group-hover/node:font-black group-hover/node:shadow-xs",
|
||||
isMulti
|
||||
? "bg-amber-500/15 dark:bg-amber-950/60 text-amber-700 dark:text-amber-300 border-amber-500/40"
|
||||
: cn(primaryMeta.badgeBg, primaryMeta.badgeText, primaryMeta.badgeBorder)
|
||||
? "bg-amber-500/15 dark:bg-amber-950/60 text-amber-700 dark:text-amber-300 border-amber-500/40 group-hover/node:bg-amber-500 group-hover/node:text-white dark:group-hover/node:text-zinc-950"
|
||||
: cn(
|
||||
primaryMeta.badgeBg,
|
||||
primaryMeta.badgeText,
|
||||
primaryMeta.badgeBorder,
|
||||
"group-hover/node:brightness-110"
|
||||
)
|
||||
)}
|
||||
>
|
||||
{isMulti ? `${group.items.length} Agendas` : primaryMeta.shortName}
|
||||
</div>
|
||||
|
||||
{/* Date Label strictly underneath */}
|
||||
<span className="text-[9px] sm:text-[10px] text-muted-foreground font-medium whitespace-nowrap mt-0.5 select-none">
|
||||
<span
|
||||
className={cn(
|
||||
"text-[9px] sm:text-[10px] text-muted-foreground font-medium whitespace-nowrap mt-0.5 select-none transition-all duration-200",
|
||||
"group-hover/node:text-foreground group-hover/node:font-bold"
|
||||
)}
|
||||
>
|
||||
{group.date.format('DD MMM')}
|
||||
</span>
|
||||
</Link>
|
||||
|
||||
@@ -29,7 +29,6 @@ export default async function ClientsPage({ searchParams }: Props) {
|
||||
const filteredClients = getFilteredClients(allClients, query, sortBy)
|
||||
// const filterAssignments = getFilteredAssignments(allAssignments, query, sortBy)
|
||||
|
||||
console.log(allClients)
|
||||
return (
|
||||
<div className="flex-1 space-y-8 p-4 sm:p-8 pt-4 sm:pt-6">
|
||||
|
||||
|
||||
@@ -154,6 +154,7 @@ export function getProjectStatusBreakdown(client: IClient): StatusStage[] {
|
||||
export interface TechnicalStatusMeta {
|
||||
shortName: string;
|
||||
fullName: string;
|
||||
hexColor: string;
|
||||
dotBg: string;
|
||||
dotBorder: string;
|
||||
ringColor: string;
|
||||
@@ -170,6 +171,7 @@ export function resolveTechnicalStatusMeta(statusName?: string): TechnicalStatus
|
||||
return {
|
||||
shortName: 'UAT',
|
||||
fullName: 'User Acceptance Testing (UAT)',
|
||||
hexColor: '#eab308', // Yellow 500
|
||||
dotBg: 'bg-yellow-400 dark:bg-yellow-500',
|
||||
dotBorder: 'border-yellow-300 dark:border-yellow-500',
|
||||
ringColor: 'ring-yellow-400/30 dark:ring-yellow-500/30',
|
||||
@@ -183,6 +185,7 @@ export function resolveTechnicalStatusMeta(statusName?: string): TechnicalStatus
|
||||
return {
|
||||
shortName: 'SIT',
|
||||
fullName: 'System Integration Testing (SIT)',
|
||||
hexColor: '#f97316', // Orange 500
|
||||
dotBg: 'bg-orange-400 dark:bg-orange-600',
|
||||
dotBorder: 'border-orange-300 dark:border-orange-500',
|
||||
ringColor: 'ring-orange-400/30 dark:ring-orange-600/30',
|
||||
@@ -196,6 +199,7 @@ export function resolveTechnicalStatusMeta(statusName?: string): TechnicalStatus
|
||||
return {
|
||||
shortName: 'PTR',
|
||||
fullName: 'Production Trial Run (PTR)',
|
||||
hexColor: '#10b981', // Emerald 500
|
||||
dotBg: 'bg-emerald-400 dark:bg-emerald-600',
|
||||
dotBorder: 'border-emerald-300 dark:border-emerald-500',
|
||||
ringColor: 'ring-emerald-400/30 dark:ring-emerald-600/30',
|
||||
@@ -209,6 +213,7 @@ export function resolveTechnicalStatusMeta(statusName?: string): TechnicalStatus
|
||||
return {
|
||||
shortName: 'LIVE',
|
||||
fullName: 'Go-Live',
|
||||
hexColor: '#06b6d4', // Cyan 500
|
||||
dotBg: 'bg-cyan-400 dark:bg-cyan-600',
|
||||
dotBorder: 'border-cyan-300 dark:border-cyan-500',
|
||||
ringColor: 'ring-cyan-400/30 dark:ring-cyan-600/30',
|
||||
@@ -222,6 +227,7 @@ export function resolveTechnicalStatusMeta(statusName?: string): TechnicalStatus
|
||||
return {
|
||||
shortName: 'BAST',
|
||||
fullName: 'Project Handover & BAST',
|
||||
hexColor: '#8b5cf6', // Violet 500
|
||||
dotBg: 'bg-violet-400 dark:bg-violet-600',
|
||||
dotBorder: 'border-violet-300 dark:border-violet-500',
|
||||
ringColor: 'ring-violet-400/30 dark:ring-violet-600/30',
|
||||
@@ -235,6 +241,7 @@ export function resolveTechnicalStatusMeta(statusName?: string): TechnicalStatus
|
||||
return {
|
||||
shortName: 'WAR',
|
||||
fullName: 'Warranty',
|
||||
hexColor: '#d946ef', // Fuchsia 500
|
||||
dotBg: 'bg-fuchsia-400 dark:bg-fuchsia-600',
|
||||
dotBorder: 'border-fuchsia-300 dark:border-fuchsia-500',
|
||||
ringColor: 'ring-fuchsia-400/30 dark:ring-fuchsia-600/30',
|
||||
@@ -248,6 +255,7 @@ export function resolveTechnicalStatusMeta(statusName?: string): TechnicalStatus
|
||||
return {
|
||||
shortName: 'DEV',
|
||||
fullName: statusName || 'Development',
|
||||
hexColor: '#f43f5e', // Rose 500
|
||||
dotBg: 'bg-rose-400 dark:bg-rose-600',
|
||||
dotBorder: 'border-rose-300 dark:border-rose-500',
|
||||
ringColor: 'ring-rose-400/30 dark:ring-rose-600/30',
|
||||
|
||||
Reference in New Issue
Block a user