File size: 3,626 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import { Card } from '@automattic/components';
import { Component } from 'react';
import PostComment from 'calypso/blocks/comments/post-comment';
import { POST_COMMENT_DISPLAY_TYPES } from 'calypso/state/comments/constants';

const mockComment = {
	author: {
		avatar_URL: 'https://1.gravatar.com/avatar/767fc9c115a1b989744c755db47feb60?s=96&d=mm&r=G',
		email: 'test@test.com',
		ID: 12345678,
		ip: '127.0.0.1',
		isBlocked: false,
		name: 'Test User',
		nice_name: 'testuser',
		URL: 'http://discover.wordpress.com',
	},
	content:
		'Turnip greens yarrow ricebean rutabaga endive cauliflower sea lettuce kohlrabi amaranth water spinach avocado daikon napa cabbage asparagus winter purslane kale. Celery potato scallion desert raisin horseradish spinach carrot soko. Lotus root water spinach fennel kombu maize bamboo shoot green bean swiss chard seakale pumpkin onion chickpea gram corn pea. Brussels sprout coriander water chestnut gourd swiss chard wakame kohlrabi beetroot carrot watercress. Corn amaranth salsify bunya nuts nori azuki bean chickweed potato bell pepper artichoke.',
	date: '2017-05-12 16:00:00',
	ID: 12345678,
	i_like: false,
	post: {
		author: { name: 'Test User' },
		title: 'Test Post',
		link: 'http://discover.wordpress.com',
	},
	replied: true,
	status: 'approved',
	URL: 'http://discover.wordpress.com',
};

const mockShortComment = {
	...mockComment,
	content: 'Just this',
};

const mockMultipleShortLineComment = {
	...mockComment,
	content: 'A comment<br>with<br>many lines<br>that will<br>overflow',
};

const mockComments = [
	{ ...mockComment, ID: 0 },
	{ ...mockComment, ID: 1, content: mockComment.content.repeat( 5 ) },
	{ ...mockComment, ID: 2, content: mockComment.content.repeat( 5 ) },
	{ ...mockShortComment, ID: 3 },
	{ ...mockMultipleShortLineComment, ID: 4 },
];

const commentsTree = {
	0: {
		children: [ 1 ],
		data: mockComments[ 0 ],
	},
	1: {
		children: [],
		data: mockComments[ 1 ],
	},
	2: {
		children: [],
		data: mockComments[ 2 ],
	},
	3: {
		children: [ 1 ],
		data: mockComments[ 3 ],
	},
	4: {
		children: [ 1 ],
		data: mockComments[ 4 ],
	},
};

const { singleLine, excerpt, full } = POST_COMMENT_DISPLAY_TYPES;
const commentsToShow = {
	0: singleLine,
	1: excerpt,
	2: full,
	3: excerpt,
	4: excerpt,
};

export default class PostCommentExample extends Component {
	static displayName = 'PostCommentExample';

	render() {
		return (
			<div>
				<Card compact>
					<PostComment
						showNestingReplyArrow
						enableCaterpillar
						commentId={ 0 }
						depth={ 0 }
						commentsTree={ commentsTree }
						commentsToShow={ commentsToShow }
					/>
					<PostComment
						showNestingReplyArrow
						enableCaterpillar
						commentId={ 2 }
						depth={ 0 }
						commentsTree={ commentsTree }
						commentsToShow={ commentsToShow }
					/>
					<PostComment
						showNestingReplyArrow
						enableCaterpillar
						commentId={ 3 }
						depth={ 0 }
						commentsTree={ commentsTree }
						commentsToShow={ commentsToShow }
					/>
					<PostComment
						showNestingReplyArrow
						enableCaterpillar
						commentId={ 3 }
						depth={ 0 }
						commentsTree={ commentsTree }
						commentsToShow={ commentsToShow }
					/>
					<PostComment
						showNestingReplyArrow
						enableCaterpillar
						commentId={ 4 }
						depth={ 0 }
						commentsTree={ commentsTree }
						commentsToShow={ commentsToShow }
					/>
					<PostComment
						showNestingReplyArrow
						enableCaterpillar
						commentId={ 4 }
						depth={ 0 }
						commentsTree={ commentsTree }
						commentsToShow={ commentsToShow }
					/>
				</Card>
			</div>
		);
	}
}