-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.js
52 lines (43 loc) · 1.14 KB
/
index.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
import React from 'react'
import glamorous from 'glamorous-native'
import { getCellColor, toPercent } from '../../../../utils/helpers'
import { TablePropTypes } from '../../../../utils/types'
const Table = glamorous.scrollView()
const Row = glamorous.view({
flexDirection: 'row',
})
const Cell = glamorous.view(
{
flex: 1,
padding: 10,
},
props => ({
backgroundColor: getCellColor(props.opacity),
}),
)
const Text = glamorous.text({
textAlign: 'center',
color: 'white',
})
const TableComponent = ({ table, ...props }) => (
<Table removeClippedSubviews={false} {...props}>
{table.map((row, rowIndex) => (
<Row key={`row-${rowIndex}`}>
{row.map((value, columnIndex) => (
<Cell
key={`row-${rowIndex}-column-${columnIndex}`}
opacity={parseFloat(value)}
>
<Text numberOfLines={1}>{toPercent(value)}</Text>
</Cell>
))}
</Row>
))}
</Table>
)
TableComponent.key = 'glamorous-simple-table'
TableComponent.title = 'Glamorous (Simple)'
TableComponent.propTypes = {
table: TablePropTypes.isRequired,
}
export default TableComponent