mattermost-mobile/app/components/markdown/markdown_list.js
Jesse Hallam 58b72302d6 update eslint's comma-dangle rule to always-multiline (#1457)
* update eslint's `comma-dangle` rule to `always-multiline`

* add check and fix scripts to package.json

* Invoke `yarn fix` to adopt the updated eslint rules. No other changes are included.
2018-02-23 09:06:02 -05:00

47 lines
1.2 KiB
JavaScript

// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import {StyleSheet, View} from 'react-native';
export default class MarkdownList extends PureComponent {
static propTypes = {
children: PropTypes.node.isRequired,
ordered: PropTypes.bool.isRequired,
start: PropTypes.number,
tight: PropTypes.bool,
};
static defaultProps = {
start: 1,
};
render() {
let bulletWidth = 15;
if (this.props.ordered) {
const lastNumber = (this.props.start + this.props.children.length) - 1;
bulletWidth = (9 * lastNumber.toString().length) + 7;
}
const children = React.Children.map(this.props.children, (child) => {
return React.cloneElement(child, {
bulletWidth,
ordered: this.props.ordered,
tight: this.props.tight,
});
});
return (
<View style={style.indent}>
{children}
</View>
);
}
}
const style = StyleSheet.create({
indent: {
marginRight: 20,
},
});