import * as React from 'react'; import { HistoryState } from "../../Interfaces/HistoryState"; interface IHistoryProps { history: HistoryState[] historyCurrentStep: number isOpen: boolean jumpTo: (move: number) => void } export const History: React.FC = (props: IHistoryProps) => { const isOpenClasses = props.isOpen ? 'right-0' : '-right-64'; const states = props.history.map((step, move) => { const desc = move > 0 ? `Go to modification n°${move}` : 'Go to the beginning'; const isCurrent = move === props.historyCurrentStep; const selectedClass = isCurrent ? 'bg-blue-500 hover:bg-blue-600' : 'bg-slate-500 hover:bg-slate-700'; const isCurrentText = isCurrent ? ' (current)' : ''; return ( ); }); // recent first states.reverse(); return (
Timeline
{ states }
); };