import React from 'react'; import { Timeline, TimelineConnector, TimelineContent, TimelineDot, TimelineItem, timelineItemClasses, TimelineSeparator, } from '@mui/lab'; import { Typography } from '@mui/material'; import { ThemeOptions, useTheme } from '@mui/material/styles'; import styled from 'styled-components'; export interface TimeLineData { date: string; description?: string; children?: React.ReactNode; } interface TimeLineProps { data: TimeLineData[]; theme?: ThemeOptions; } export const TimeLine: React.FC = ({ data }) => { const muiTheme = useTheme(); const NormaTimeLine = styled(Timeline)` .${timelineItemClasses.root} { padding: 0; &:before { flex: 0; padding: 0; } } .MuiTimelineDot-root { &:last-child { &:before { content: ''; width: 70%; height: 70%; background: ${muiTheme.palette.primary.main}; position: absolute; border-radius: 50%; top: 50%; left: 50%; transform: translate(-50%, -50%); } } } `; const _getDotStyle = (last: boolean) => { const style = { background: 'none', boxShadow: 'none', padding: '6px', margin: '0', border: `3px solid ${muiTheme.palette.primary.main}`, }; const lastStyle = { padding: '8px', position: 'relative', left: '-2px', }; return last ? { ...style, ...lastStyle } : style; }; return ( {data.map((item, key) => { const last = key !== data.length - 1; return ( {last && } {item.date} {item.description && ( {item.description} )} {item.children} ); })} ); };