Skip to content

Commit

Permalink
feat(table): add styles and dividers
Browse files Browse the repository at this point in the history
  • Loading branch information
maximilianoforlenza committed Jan 28, 2018
1 parent 4babf02 commit c57084f
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 15 deletions.
21 changes: 13 additions & 8 deletions src/Table/TableHeader.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import React from 'react';
import React, {Fragment} from 'react';
import PropTypes from 'prop-types';
import {StyleSheet} from 'react-native';
import {Divider} from 'react-native-elements';
import {Row, Col, 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={StyleSheet.flatten([styles.itemsDivider, styles.headerDivider])}/>
</Fragment>
);

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

import columnPropType from './columnPropType';
Expand All @@ -9,11 +11,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={StyleSheet.flatten([styles.itemsDivider, 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
});
19 changes: 19 additions & 0 deletions src/Table/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,24 @@ export default StyleSheet.create({
},
col: {
paddingLeft: 20
},
itemsDivider: {
flex: 1,
marginTop: 3,
marginRight: 10,
marginBottom: 3,
marginLeft: 10
},
headerContainer: {
flex: 0.2,
justifyContent: 'center',
alignItems: 'center',
marginTop: 30
},
rowDivider: {
backgroundColor: '#dcdcdc'
},
headerDivider: {
backgroundColor: '#0e516e'
}
});

0 comments on commit c57084f

Please sign in to comment.