Refactor help page status tables into component

[MAILPOET-1459]
This commit is contained in:
Rostislav Wolny
2018-07-25 11:10:20 +02:00
parent 1252f35a23
commit 490ea67d18
3 changed files with 92 additions and 85 deletions

View File

@@ -0,0 +1,31 @@
import React from 'react';
const KeyValueTable = props => (
<table className={'widefat fixed'} style={{ maxWidth: props.max_width }}>
<tbody>
{props.children.map(row => (
<tr key={`row_${row.key}`}>
<td className={'row-title'}>{ row.key }</td><td>{ row.value }</td>
</tr>
))}
</tbody>
</table>
);
KeyValueTable.propTypes = {
max_width: React.PropTypes.string,
children: React.PropTypes.arrayOf(React.PropTypes.shape({
key: React.PropTypes.string.isRequired,
value: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.number,
React.PropTypes.element,
]).isRequired,
})).isRequired,
};
KeyValueTable.defaultProps = {
max_width: 'auto',
};
module.exports = KeyValueTable;