mattermost-mobile/app/components/markdown/markdown_table_cell/markdown_table_cell.js
Andre Vasconcelos f7bed8dcdb MM-15635 - Making markdown tables more responsive (#3249)
* Making markdown tables more responsive

* Changing implementation of isTablet and isLandscape

* Fixing variable names & added more table styles

* Adding header backgrounds & iOS fixes

* Changing cell padding to 8

* Fixing positioning of expand table buttons

* Fixed android issues and flex render conditions

- Centered icon in expand button instead of using fixed paddings (icon was slightly off center)
- Fixed expand button rendering on android
- Separated full table view into ios / android to allow for separate styling

* Merging table back to single file

* Resolving conflicts & improving full table view

- Made the full table view scrollable through any part of the screen, as opposed to only the table area (only works on iOS)
- Resolved conflicts with PR that limits tables to 5 columns visible on channel view
- Made changes to keep behavior of tables consistent on table view
- Added logic to render "moreRight" element if table was cut in channel view
- Updated snapshot
2019-11-30 14:27:02 -03:00

64 lines
1.7 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import PropTypes from 'prop-types';
import React from 'react';
import {Text, View} from 'react-native';
import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
export const CELL_MIN_WIDTH = 96;
export const CELL_MAX_WIDTH = 192;
export default class MarkdownTableCell extends React.PureComponent {
static propTypes = {
align: PropTypes.oneOf(['', 'left', 'center', 'right']),
children: PropTypes.node,
isLastCell: PropTypes.bool,
theme: PropTypes.object.isRequired,
};
render() {
const style = getStyleSheet(this.props.theme);
const cellStyle = [style.cell];
if (!this.props.isLastCell) {
cellStyle.push(style.cellRightBorder);
}
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 style={textStyle}>
{this.props.children}
</Text>
</View>
);
}
}
const getStyleSheet = makeStyleSheetFromTheme((theme) => {
return {
cell: {
flex: 1,
borderColor: changeOpacity(theme.centerChannelColor, 0.2),
justifyContent: 'flex-start',
padding: 8,
},
cellRightBorder: {
borderRightWidth: 1,
},
alignCenter: {
textAlign: 'center',
},
alignRight: {
textAlign: 'right',
},
};
});