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
65 lines (61 loc) · 2.02 KB
/
index.tsx
File metadata and controls
65 lines (61 loc) · 2.02 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { css } from 'emotion'
import * as React from 'react'
import SplitPane from 'react-split-pane'
import { useAppState, useActions } from '../../overmind'
import { nameToColor } from '../../overmind/utils'
import * as textStyles from '../../styles/text'
import ActionsTools from '../ActionsTools'
import Chart from '../Chart'
import * as styles from './styles'
const Charts: React.FunctionComponent = () => {
const state = useAppState()
const actions = useActions()
const chartKeys = Object.keys(state.currentApp.charts)
return (
<div className={styles.wrapper}>
<ActionsTools />
{state.currentChart ? (
<div className={styles.columns}>
<SplitPane
split="vertical"
minSize={100}
defaultSize={state.chartsSplitSize}
onChange={(size) => actions.updateChartsSplitSize(size)}
>
<div className={styles.listWrapper}>
{chartKeys.map((path) => {
return (
<div
className={css(
styles.chartItem,
state.currentApp.currentChartId === path &&
styles.selected
)}
key={path}
onClick={() => actions.selectChart(path)}
>
<span
className={styles.chartColor}
style={{
backgroundColor: nameToColor(path),
}}
/>
<span className={textStyles.denseNormal}>
{path || '[ROOT]'}
</span>
</div>
)
})}
</div>
<Chart chart={state.currentChart} statePath={[]} />
</SplitPane>
</div>
) : (
<div className={styles.centerWrapper}>
<span className={textStyles.header}>no charts defined...</span>
</div>
)}
</div>
)
}
export default Charts