Skip to content

Commit

Permalink
feat(table): add styles and dividers (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximilianoforlenza authored and navarroaxel committed Jan 29, 2018
1 parent 4babf02 commit a2dcc39
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 16 deletions.
22 changes: 13 additions & 9 deletions src/Table/TableHeader.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import React from 'react';
import React, {Fragment} from 'react';
import PropTypes from 'prop-types';
import {Row, Col, TextStrong} from '@indec/react-native-commons';
import {Divider} from 'react-native-elements';
import {Col, Row, TextStrong} from '@indec/react-native-commons';

import columnPropType from './columnPropType';
import styles from './styles';

const TableHeader = ({columns}) => (
<Row>
{columns.map(column => (
<Col key={column.id} style={[styles.col, column.style]}>
<TextStrong style={styles.header}>{column.label}</TextStrong>
</Col>
))}
</Row>
<Fragment>
<Row style={styles.headerContainer}>
{columns.map(column => (
<Col key={column.id} style={[styles.col, column.style]}>
<TextStrong style={styles.header}>{column.label}</TextStrong>
</Col>
))}
</Row>
<Divider style={styles.headerDivider}/>
</Fragment>
);

TableHeader.propTypes = {
Expand Down
16 changes: 10 additions & 6 deletions src/Table/TableRow.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable react/no-typos */
import React from 'react';
import React, {Fragment} from 'react';
import PropTypes from 'prop-types';
import {Divider} from 'react-native-elements';
import {Row} from '@indec/react-native-commons';

import columnPropType from './columnPropType';
Expand All @@ -9,11 +10,14 @@ import datumPropType from './datumPropType';
import styles from './styles';

const TableRow = ({datum, columns}) => (
<Row key={datum._id} style={styles.row}>
{columns.map(column => (
<TableCell key={column.id} datum={datum} column={column}/>
))}
</Row>
<Fragment>
<Row key={datum._id} style={styles.row}>
{columns.map(column => (
<TableCell key={column.id} datum={datum} column={column}/>
))}
</Row>
<Divider style={styles.rowDivider}/>
</Fragment>
);

TableRow.propTypes = {
Expand Down
2 changes: 1 addition & 1 deletion src/Table/datumPropType.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PropTypes from 'prop-types';

export default PropTypes.shape({
_id: PropTypes.number.isRequired
_id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired
});
22 changes: 22 additions & 0 deletions src/Table/styles.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
import {StyleSheet} from 'react-native';

const divider = {
flex: 1,
marginTop: 3,
marginRight: 10,
marginBottom: 3,
marginLeft: 10
};

export default StyleSheet.create({
row: {
marginTop: 20
},
col: {
paddingLeft: 20
},
headerContainer: {
flex: 0.2,
justifyContent: 'center',
alignItems: 'center',
marginTop: 30
},
rowDivider: {
...divider,
backgroundColor: '#dcdcdc'
},
headerDivider: {
...divider,
backgroundColor: '#0e516e'
}
});

0 comments on commit a2dcc39

Please sign in to comment.