mattermost-mobile/app/components/markdown/markdown_table_row/markdown_table_row.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

55 lines
1.6 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 {View} from 'react-native';
import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
export default class MarkdownTableRow extends React.PureComponent {
static propTypes = {
children: PropTypes.node,
isLastRow: PropTypes.bool,
isFirstRow: PropTypes.bool,
theme: PropTypes.object.isRequired,
};
render() {
const style = getStyleSheet(this.props.theme);
const rowStyle = [style.row];
if (!this.props.isLastRow) {
rowStyle.push(style.rowBottomBorder);
}
if (this.props.isFirstRow) {
rowStyle.push(style.rowTopBackground);
}
// Add an extra prop to the last cell so that it knows not to render a right border since the container
// will handle that
const children = React.Children.toArray(this.props.children);
children[children.length - 1] = React.cloneElement(children[children.length - 1], {
isLastCell: true,
});
return <View style={rowStyle}>{children}</View>;
}
}
const getStyleSheet = makeStyleSheetFromTheme((theme) => {
return {
row: {
flex: 1,
flexDirection: 'row',
},
rowTopBackground: {
backgroundColor: changeOpacity(theme.centerChannelColor, 0.1),
},
rowBottomBorder: {
borderColor: changeOpacity(theme.centerChannelColor, 0.2),
borderBottomWidth: 1,
},
};
});