MM-10325 Add cell alignment to markdown tables (#1791)

This commit is contained in:
Harrison Healey 2018-06-25 12:17:36 -04:00 committed by GitHub
parent 22727de124
commit 14e13dd6b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,8 +9,8 @@ import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
export default class MarkdownTableCell extends React.PureComponent {
static propTypes = {
align: PropTypes.oneOf(['', 'left', 'center', 'right']),
children: PropTypes.node,
isHeading: PropTypes.bool.isRequired,
theme: PropTypes.object.isRequired,
};
@ -18,13 +18,17 @@ export default class MarkdownTableCell extends React.PureComponent {
const style = getStyleSheet(this.props.theme);
const cellStyle = [style.cell];
if (this.props.isHeading) {
cellStyle.push(style.heading);
let textStyle = null;
if (this.props.align === 'center') {
textStyle = style.alignCenter;
} else if (this.props.align === 'right') {
textStyle = style.alignRight;
}
return (
<View style={cellStyle}>
<Text>
<Text style={textStyle}>
{this.props.children}
</Text>
</View>
@ -42,5 +46,11 @@ const getStyleSheet = makeStyleSheetFromTheme((theme) => {
paddingHorizontal: 13,
paddingVertical: 6,
},
alignCenter: {
textAlign: 'center',
},
alignRight: {
textAlign: 'right',
},
};
});