forked from cerebral/overmind
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.tsx
More file actions
45 lines (42 loc) · 1.26 KB
/
index.tsx
File metadata and controls
45 lines (42 loc) · 1.26 KB
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
import * as React from 'react'
import { useAppState, useActions } from '../../overmind'
import { getAppShortName, nameToColor } from '../../overmind/utils'
import * as styles from './styles'
import { css } from 'emotion'
const Apps: React.FunctionComponent = () => {
const state = useAppState()
const actions = useActions()
if (!state.currentApp) {
return <div className={styles.wrapper}>N/A</div>
}
return (
<div className={styles.wrapper}>
<div
className={styles.currentApp(nameToColor(state.currentAppName))}
onClick={actions.toggleShowApps}
>
{getAppShortName(state.currentAppName)}
</div>
{state.showApps ? (
<>
<div className={styles.overlay} onClick={actions.toggleShowApps} />
<div className={styles.appsList}>
{Object.keys(state.apps).map((appName) => (
<div
className={css(
styles.app,
state.currentAppName === appName && styles.appSelected
)}
key={appName}
onClick={() => actions.selectApp(appName)}
>
{appName}
</div>
))}
</div>
</>
) : null}
</div>
)
}
export default Apps