mattermost-mobile/app/components/markdown/markdown_list_item/index.tsx
Joseph Baylon 6a3c600c8a
Detox/E2E: Messaging (at-mentions, channel mentions, autocomplete etc) e2e tests in Gekidou (#6428)
* Detox/E2E: Messaging (at-mentions, channel mentions, autocomplete etc) e2e tests in Gekidou

* Enable other failing tests so they're visible

* Detox/E2E: Messaging markdown e2e tests in Gekidou (#6450)

* Detox/E2E: Messaging markdown e2e tests in Gekidou

* Added zephyr test ids

* Added markdown smoke test

* Enable disabled tests

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-07-05 10:01:46 -07:00

63 lines
1.5 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {ReactNode} from 'react';
import {StyleSheet, Text, TextStyle, View} from 'react-native';
type MarkdownListItemProps = {
bulletStyle: TextStyle;
bulletWidth: number;
children: ReactNode | ReactNode[];
continue: boolean;
index: number;
ordered: boolean;
level: number;
}
const style = StyleSheet.create({
container: {
flexDirection: 'row',
alignItems: 'flex-start',
},
bullet: {
alignItems: 'flex-end',
marginRight: 5,
},
contents: {
flex: 1,
},
});
const MarkdownListItem = ({index, level, bulletWidth, bulletStyle, children, continue: doContinue, ordered}: MarkdownListItemProps) => {
let bullet;
if (doContinue) {
bullet = '';
} else if (ordered) {
bullet = index + '.';
} else if (level % 2 === 0) {
bullet = '◦';
} else {
bullet = '•';
}
return (
<View
style={style.container}
testID='markdown_list_item'
>
<View style={[{width: bulletWidth}, style.bullet]}>
<Text
style={bulletStyle}
testID='markdown_list_item.bullet'
>
{bullet}
</Text>
</View>
<View style={style.contents}>
{children}
</View>
</View>
);
};
export default MarkdownListItem;