import * as React from 'react'; import { IHistoryState } from '../../App'; interface IHistoryProps { history: IHistoryState[], historyCurrentStep: number, isOpen: boolean, onClick: () => void, jumpTo: (move: number) => void } export class History extends React.Component { public render() { const isOpenClasses = this.props.isOpen ? 'right-0' : '-right-64'; const states = this.props.history.map((step, move) => { const desc = move ? `Go to modification n°${move}` : 'Go to the beginning'; const isCurrent = move === this.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 (
History
{ states }
); } }