From 14e13dd6b60906efd3f3f134b3ad1dda4016909d Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Mon, 25 Jun 2018 12:17:36 -0400 Subject: [PATCH] MM-10325 Add cell alignment to markdown tables (#1791) --- .../markdown_table_cell/markdown_table_cell.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/components/markdown/markdown_table_cell/markdown_table_cell.js b/app/components/markdown/markdown_table_cell/markdown_table_cell.js index a79f33f5b..878eeac0b 100644 --- a/app/components/markdown/markdown_table_cell/markdown_table_cell.js +++ b/app/components/markdown/markdown_table_cell/markdown_table_cell.js @@ -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 ( - + {this.props.children} @@ -42,5 +46,11 @@ const getStyleSheet = makeStyleSheetFromTheme((theme) => { paddingHorizontal: 13, paddingVertical: 6, }, + alignCenter: { + textAlign: 'center', + }, + alignRight: { + textAlign: 'right', + }, }; });