mattermost-mobile/app/components/markdown/markdown_table_cell/markdown_table_cell.js
Daniel Espino García 4c8594d330
Add linter rules for import order and type member delimiters (#5514)
* Add linter rules for import order and type member delimiters

* Remove unneeded group

* Group all app/* imports before the internal imports

* Move app/ imports before parent imports

* Separate @node_modules imports into a different group

* Substitute app paths by aliases

* Fix @node_modules import order and add test related modules

* Add aliases for types and test, and group import types
2021-07-23 11:06:04 +02:00

62 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 '@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, textStyle]}>
{this.props.children}
</View>
);
}
}
const getStyleSheet = makeStyleSheetFromTheme((theme) => {
return {
cell: {
flex: 1,
borderColor: changeOpacity(theme.centerChannelColor, 0.2),
justifyContent: 'flex-start',
padding: 8,
},
cellRightBorder: {
borderRightWidth: 1,
},
alignCenter: {
alignItems: 'center',
},
alignRight: {
alignItems: 'flex-end',
},
};
});