mattermost-mobile/app/components/markdown/markdown_list_item.js
Harrison Healey 57c602eb79 RN-113/RN-114 Updated markdown styles for lists and code (#851)
* RN-114 Updated markdown list style

* RN-113 Updated code font
2017-08-17 00:43:11 -03:00

62 lines
1.5 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,
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,
level: PropTypes.number
};
static defaultProps = {
startAt: 1
};
render() {
let bullet;
if (this.props.ordered) {
bullet = (this.props.startAt + this.props.index) + '. ';
} else if (this.props.level % 2 === 0) {
bullet = '◦';
} else {
bullet = '•';
}
return (
<View style={style.container}>
<View style={style.bullet}>
<Text style={this.props.bulletStyle}>
{bullet}
</Text>
</View>
<View>
{this.props.children}
</View>
</View>
);
}
}
const style = StyleSheet.create({
bullet: {
width: 15
},
container: {
flexDirection: 'row',
alignItems: 'flex-start'
}
});