124 lines
2.7 KiB
TypeScript
124 lines
2.7 KiB
TypeScript
'use client';
|
|
|
|
import styled from 'styled-components';
|
|
import type { WorkflowEvent } from '@/lib/control/types';
|
|
|
|
const TimelineRoot = styled.section`
|
|
border: 1px solid var(--border-color);
|
|
border-radius: 22px;
|
|
background: rgba(255, 255, 255, 0.025);
|
|
padding: 18px;
|
|
`;
|
|
|
|
const Header = styled.div`
|
|
display: flex;
|
|
justify-content: space-between;
|
|
gap: 12px;
|
|
align-items: center;
|
|
margin-bottom: 14px;
|
|
`;
|
|
|
|
const Title = styled.h2`
|
|
font-size: 15px;
|
|
margin: 0;
|
|
`;
|
|
|
|
const LiveBadge = styled.span`
|
|
font-family: var(--font-mono);
|
|
font-size: 10px;
|
|
color: #ffcc66;
|
|
border: 1px solid rgba(255, 204, 102, 0.35);
|
|
border-radius: 999px;
|
|
padding: 4px 8px;
|
|
`;
|
|
|
|
const EventList = styled.ol`
|
|
list-style: none;
|
|
display: grid;
|
|
gap: 10px;
|
|
`;
|
|
|
|
const EventItem = styled.li<{ $selected: boolean }>`
|
|
display: grid;
|
|
grid-template-columns: 54px 1fr;
|
|
gap: 12px;
|
|
padding: 12px;
|
|
border-radius: 16px;
|
|
border: 1px solid ${({ $selected }) => ($selected ? 'rgba(255,255,255,0.34)' : 'rgba(255,255,255,0.08)')};
|
|
background: ${({ $selected }) => ($selected ? 'rgba(255,255,255,0.07)' : 'rgba(0,0,0,0.16)')};
|
|
cursor: pointer;
|
|
transition: border-color .15s ease, background .15s ease;
|
|
|
|
&:hover {
|
|
border-color: rgba(255,255,255,0.26);
|
|
}
|
|
`;
|
|
|
|
const EventTime = styled.div`
|
|
font-family: var(--font-mono);
|
|
font-size: 11px;
|
|
color: var(--text-secondary);
|
|
`;
|
|
|
|
const EventBody = styled.div`
|
|
min-width: 0;
|
|
`;
|
|
|
|
const EventTitle = styled.div`
|
|
display: flex;
|
|
justify-content: space-between;
|
|
gap: 8px;
|
|
font-size: 13px;
|
|
font-weight: 700;
|
|
`;
|
|
|
|
const EventDetail = styled.p`
|
|
margin: 5px 0 0;
|
|
color: var(--text-secondary);
|
|
font-size: 12px;
|
|
`;
|
|
|
|
const TypeBadge = styled.span`
|
|
flex-shrink: 0;
|
|
font-family: var(--font-mono);
|
|
font-size: 9px;
|
|
color: var(--text-secondary);
|
|
`;
|
|
|
|
export default function WorkflowTimeline({
|
|
events,
|
|
selectedId,
|
|
onSelect,
|
|
}: {
|
|
events: WorkflowEvent[];
|
|
selectedId: string;
|
|
onSelect: (event: WorkflowEvent) => void;
|
|
}) {
|
|
return (
|
|
<TimelineRoot>
|
|
<Header>
|
|
<Title>Workflow Timeline</Title>
|
|
<LiveBadge>mock stream</LiveBadge>
|
|
</Header>
|
|
<EventList>
|
|
{events.map((event) => (
|
|
<EventItem
|
|
key={event.id}
|
|
$selected={event.id === selectedId}
|
|
onClick={() => onSelect(event)}
|
|
>
|
|
<EventTime>{event.at}</EventTime>
|
|
<EventBody>
|
|
<EventTitle>
|
|
<span>{event.title}</span>
|
|
<TypeBadge>{event.type}</TypeBadge>
|
|
</EventTitle>
|
|
<EventDetail>{event.detail}</EventDetail>
|
|
</EventBody>
|
|
</EventItem>
|
|
))}
|
|
</EventList>
|
|
</TimelineRoot>
|
|
);
|
|
}
|