-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.js
51 lines (41 loc) · 1.17 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
import React from 'react'
import styled from 'styled-components/native'
import { getCellColor, toPercent } from '../../../../utils/helpers'
import { TablePropTypes } from '../../../../utils/types'
const Table = styled.ScrollView``
const Row = styled.View`
flex-direction: row;
`
const CellDefault = styled.View`
flex: 1;
padding: 10px;
`
const Cell = styled(CellDefault)`
background: ${props => getCellColor(props.opacity)};
`
const Text = styled.Text`
text-align: 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 = 'styled-components-decoupled-cell-table'
TableComponent.title = 'Styled Components (Decoupled Cell)'
TableComponent.propTypes = {
table: TablePropTypes.isRequired,
}
export default TableComponent