-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.js
61 lines (52 loc) · 1.46 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
53
54
55
56
57
58
59
60
61
import React from 'react'
import { createComponent } from 'react-fela'
import { ScrollView, Text, View, ViewPropTypes } from 'react-native'
import * as colors from '../../../../utils/colors'
import { getCellColor, toPercent } from '../../../../utils/helpers'
import { TablePropTypes } from '../../../../utils/types'
import { wrapRenderer } from '../helpers'
const Table = createComponent(() => ({}), ScrollView)
const Row = createComponent(
() => ({
flexDirection: 'row',
}),
View,
)
const Cell = createComponent(
state => ({
flex: 1,
padding: 10,
backgroundColor: getCellColor(state.opacity),
}),
View,
)
const CellText = createComponent(
() => ({
textAlign: 'center',
color: colors.white,
}),
Text,
)
const TableComponent = ({ table, ...props }) => (
<Table removeClippedSubviews={false} {...props} style={props.style}>
{table.map((row, rowIndex) => (
<Row key={`row-${rowIndex}`}>
{row.map((value, columnIndex) => (
<Cell
key={`row-${rowIndex}-column-${columnIndex}`}
style={{ opacity: parseFloat(value) }}
>
<CellText numberOfLines={1}>{toPercent(value)}</CellText>
</Cell>
))}
</Row>
))}
</Table>
)
TableComponent.key = 'fela-primitives-table'
TableComponent.title = 'Fela (Primitives)'
TableComponent.propTypes = {
style: ViewPropTypes.style,
table: TablePropTypes.isRequired,
}
export default wrapRenderer(TableComponent)