summaryrefslogtreecommitdiffstats
path: root/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/architecture-examples/inferno/src/base.js
blob: 89a2ca30c8b4924fcad23e7793e180ddc591859b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import Inferno from 'inferno';
import { states } from './share';

/**
 * Stateless Header component
 */
export function Head({onEnter}) {
    return (
        <header className="header">
            <h1>todos</h1>
            <input className="new-todo" autofocus onkeydown={ onEnter }
                autocomplete="off" placeholder="What needs to be done?"
            />
        </header>
    );
}

export const links = [
    {hash: '#/', name: 'All'},
    {hash: '#/active', name: 'Active'},
    {hash: '#/completed', name: 'Completed'}
];

/**
 * Stateless Footer component
 */
export function Foot({left, done, route, onClear}) {
    return (
        <footer className="footer">
                <span className="todo-count">
                    <strong>{ left }</strong> { left > 1 ? 'items' : 'item' } left
                </span>
                <ul className="filters">
                    {
                        links.map(({hash, name}) => (
                            <li>
                                <a href={ hash } className={ name.toLowerCase() === route ? 'selected' : '' }>
                                    { name }
                                </a>
                            </li>
                        ))
                    }
                </ul>
                { done > 0 ? (
                    <button className="clear-completed" onClick={ onClear }>Clear completed</button>
                ) : null }
            </footer>
    );
}