-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathOrderedListItem.js
71 lines (60 loc) · 1.66 KB
/
OrderedListItem.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* Copyright (c) 2017, Globo.com (https://github.com/globocom)
*
* License: MIT
*/
// @flow
import React from 'react';
import {
Text,
View,
StyleSheet,
} from 'react-native';
import DraftJsText from '../components/DraftJsText';
import type { OrderedListItemPropsType } from './types';
const styles = StyleSheet.create({
orderedListItemContainer: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
},
orderedListItemNumber: {
fontSize: 12,
fontWeight: 'bold',
alignSelf: 'center',
},
});
const OrderedListItem = (props: OrderedListItemPropsType): any => {
const {
counter,
separator,
customStyles,
depth,
defaultMarginLeft,
} = props;
const orderedListItemCustomStyleContainer = customStyles && customStyles.orderedListItemContainer;
const orderedListItemCustomStyleNumber = customStyles && customStyles.orderedListItemNumber;
const marginLeftWithDepth =
orderedListItemCustomStyleNumber && orderedListItemCustomStyleNumber.marginLeft ?
depth * orderedListItemCustomStyleNumber.marginLeft : depth * defaultMarginLeft;
const marginLeftWithoutDepth = 24;
const marginLeft = depth > 0 ? marginLeftWithDepth : marginLeftWithoutDepth;
return (
<View style={[styles.orderedListItemContainer, orderedListItemCustomStyleContainer]}>
<Text
style={[styles.orderedListItemNumber, orderedListItemCustomStyleNumber, { marginLeft }]}
>
{counter}{separator}
</Text>
<DraftJsText
{...props}
/>
</View>);
};
OrderedListItem.defaultProps = {
counter: 1,
depth: 0,
separator: '.',
defaultMarginLeft: 8,
};
export default OrderedListItem;