import * as React from 'react'; import { Pivot, PivotItem, IPivotProps, PivotLinkSize } from 'office-ui-fabric-react/lib/Pivot'; import { FocusZone, FocusZoneDirection } from 'office-ui-fabric-react/lib/FocusZone'; import { List } from 'office-ui-fabric-react/lib/List'; import { KeyCodes } from 'office-ui-fabric-react/lib/Utilities'; import TodoItem from './TodoItem'; import { ITodoItem, ITodoItemProps, ITodoTabsProps } from '../types/index'; import * as stylesImport from './Todo.scss'; const styles: any = stylesImport; import strings from './../strings'; /** * The TodoTabs component using fabric-react component . * * Link of : https://fabricreact.azurewebsites.net/fabric-react/master/#/examples/pivot * Link of : https://fabricreact.azurewebsites.net/fabric-react/master/#/examples/list * Link of : https://fabricreact.azurewebsites.net/fabric-react/master/#examples/focuszone */ export default class TodoTabs extends React.Component { public render(): React.ReactElement | null { const pivotArray: React.ReactElement[] = []; const activeTasks: ITodoItem[] = this.props.items.filter((task: ITodoItem) => task.isComplete === false); const completedTasks: ITodoItem[] = this.props.items.filter((task: ITodoItem) => task.isComplete === true); const allTasks: ITodoItem[] = activeTasks.concat(completedTasks); this._onRenderTodoItem = this._onRenderTodoItem.bind(this); if (activeTasks.length > 0) { pivotArray.push(this._renderPivotItemList(activeTasks, strings.todoListTabNameActive)); } if (completedTasks.length > 0) { pivotArray.push(this._renderPivotItemList(completedTasks, strings.todoListTabNameCompleted)); } if (allTasks.length > 0) { pivotArray.push(this._renderPivotItemList(allTasks, strings.todoListTabNameAllTasks)); } return pivotArray.length > 0 ? (
{pivotArray}
) : null; } private _renderPivotItemList(tasks: ITodoItem[], tabName: string): React.ReactElement { // @todo #219004 make shouldEnterInnerZone be rtl safe. return ( ); } private _shouldEnterInnerZone = (ev: React.KeyboardEvent): boolean => { return ev.which === KeyCodes.right; }; private _onRenderTodoItem(item?: ITodoItem): React.ReactElement | null { if (item) { return ( ); } return null; } }