-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview.js
64 lines (58 loc) · 1.59 KB
/
view.js
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import React from 'react';
import ACTIVE_TAB from './model';
import CounterSimple from '../counter-simple';
import CounterMessages from '../counter-messages';
import HackerNewsHeadline from '../hacker-news-headline';
import ManyHackers from '../many-hackers';
import HackersAndCounters from '../hackers-and-counters';
import JustInput from '../just-input';
import styles from './styles.css';
const tabs = {
SIMPLE_COUNTER: {
title: 'Simple Counter',
component: <CounterSimple/>
},
MESSAGES_COUNTER: {
title: 'Counter with messages',
component: <CounterMessages/>
},
ASYNC_WITH_MESSAGES: {
title: 'async actions with messages example',
desc: 'Hacker news top story loader',
component: <HackerNewsHeadline/>
},
LIST_OF_HEALDINES: {
title: 'list of hacker news',
component: <ManyHackers/>
},
HEADLINES_AND_COUNTERS: {
title: 'Hacker news and Counters',
component: <HackersAndCounters/>
},
JUST_INPUT: {
title: 'Just Simple Input',
component: <JustInput/>
}
};
export default ({ activeTab, switchTab }) =>
<div>
<div className={styles.navigation}>
{ Object.keys(tabs).map(tabId =>
<button
key={tabId}
onClick={switchTab(tabId)}
className={tabId === activeTab ? styles.active : ''}
>
{tabs[tabId].title}
</button>
) }
</div>
{ tabs[activeTab] ?
<div>
<h2>{tabs[activeTab].title}</h2>
{ tabs[activeTab].desc && <p>{tabs[activeTab].desc}</p> }
{ tabs[activeTab].component }
</div> :
<div>Tab not found</div>
}
</div>;