mattermost-mobile/app/components/markdown/markdown_list_item.js
Harrison Healey 07af08b74a PLT-5717 Initial markdown support (#354)
* Added CommonMark-based post rendering

* Fixed text wrapping in most block elements

* Fixed paragraphs not being rendered as children of lists

* Replaced markdown images with a placeholder

* Fixed font colour in code spans
2017-03-20 16:27:33 -03:00

55 lines
1.3 KiB
JavaScript

// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import React, {PropTypes, PureComponent} from 'react';
import {
StyleSheet,
Text,
View
} from 'react-native';
import CustomPropTypes from 'app/constants/custom_prop_types';
export default class MarkdownListItem extends PureComponent {
static propTypes = {
children: CustomPropTypes.Children.isRequired,
ordered: PropTypes.bool.isRequired,
startAt: PropTypes.number,
index: PropTypes.number.isRequired,
tight: PropTypes.bool,
bulletStyle: CustomPropTypes.Style
};
static defaultProps = {
startAt: 1
};
render() {
let bullet;
if (this.props.ordered) {
bullet = (this.props.startAt + this.props.index) + '. ';
} else {
bullet = '• ';
}
return (
<View style={style.container}>
<View>
<Text style={this.props.bulletStyle}>
{bullet}
</Text>
</View>
<View>
{this.props.children}
</View>
</View>
);
}
}
const style = StyleSheet.create({
container: {
flexDirection: 'row',
alignItems: 'flex-start'
}
});