-
-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: implement event grouping in the event timeline
- Loading branch information
Showing
5 changed files
with
226 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 0 additions & 50 deletions
50
.../EventTimeline/EventTimelineEvent/EventTimelineEventTooltip/EventTimelineEventTooltip.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...nd/src/component/events/EventTimeline/EventTimelineEventGroup/EventTimelineEventGroup.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Badge, styled } from '@mui/material'; | ||
import { HtmlTooltip } from 'component/common/HtmlTooltip/HtmlTooltip'; | ||
import { EventTimelineEventTooltip } from './EventTimelineEventTooltip/EventTimelineEventTooltip'; | ||
import type { TimelineEventGroup } from '../EventTimeline'; | ||
import { EventTimelineEventCircle } from './EventTimelineEventCircle'; | ||
|
||
const StyledEvent = styled('div', { | ||
shouldForwardProp: (prop) => prop !== 'position', | ||
})<{ position: string }>(({ position }) => ({ | ||
position: 'absolute', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
left: position, | ||
transform: 'translateX(-50%)', | ||
zIndex: 1, | ||
})); | ||
|
||
interface IEventTimelineEventProps { | ||
group: TimelineEventGroup; | ||
startDate: Date; | ||
endDate: Date; | ||
} | ||
|
||
export const EventTimelineEventGroup = ({ | ||
group, | ||
startDate, | ||
endDate, | ||
}: IEventTimelineEventProps) => { | ||
const timelineDuration = endDate.getTime() - startDate.getTime(); | ||
const eventTime = new Date(group[0].createdAt).getTime(); | ||
|
||
const position = `${((eventTime - startDate.getTime()) / timelineDuration) * 100}%`; | ||
|
||
return ( | ||
<StyledEvent position={position}> | ||
<HtmlTooltip | ||
title={<EventTimelineEventTooltip group={group} />} | ||
maxWidth={320} | ||
arrow | ||
> | ||
<Badge | ||
badgeContent={group.length} | ||
color='primary' | ||
invisible={group.length < 2} | ||
> | ||
<EventTimelineEventCircle group={group} /> | ||
</Badge> | ||
</HtmlTooltip> | ||
</StyledEvent> | ||
); | ||
}; |
Oops, something went wrong.