Files
frontend-bootcamp/step2-03/exercise/src/components/TodoFooter.tsx
2019-02-28 01:13:28 -08:00

25 lines
803 B
TypeScript

import React from 'react';
import { Store } from '../store';
import { DefaultButton, Stack, Text } from 'office-ui-fabric-react';
interface TodoFooterProps {
clear: () => void;
todos: Store['todos'];
}
export const TodoFooter = (props: TodoFooterProps) => {
const itemCount = Object.keys(props.todos).filter(id => !props.todos[id].completed).length;
// TODO: play around with the DefaultButton component below with a "styles" prop
// - try it with an object: styles={{ ... }}
// - try it with a function: styles={props => ({ ... })}
return (
<Stack horizontal horizontalAlign="space-between">
<Text>
{itemCount} item{itemCount === 1 ? '' : 's'} left
</Text>
<DefaultButton onClick={() => props.clear()}>Clear Completed</DefaultButton>
</Stack>
);
};