1 | <example name="List">
|
2 | <file type="html">
|
3 | <div id='list'></div>
|
4 | </file>
|
5 |
|
6 | <file type="js">
|
7 | import React from 'react';
|
8 | import {render} from 'react-dom';
|
9 | import List from '@jetbrains/ring-ui/components/list/list';
|
10 |
|
11 | var listData = [];
|
12 | for (var i = 0; i < 1000; i++) {
|
13 | listData.push({
|
14 | label: 'Item ' + i,
|
15 | rgItemType: List.ListProps.Type.ITEM
|
16 | });
|
17 | }
|
18 |
|
19 | render(
|
20 | <List
|
21 | maxHeight={400}
|
22 | data={listData}
|
23 | shortcuts
|
24 | compact
|
25 | onSelect={console.log.bind(console)}
|
26 | />,
|
27 | document.getElementById('list')
|
28 | );
|
29 | </file>
|
30 | </example>
|
31 |
|
32 | <example name="List with a hint below">
|
33 | <file type="html">
|
34 | <div id='list'></div>
|
35 | </file>
|
36 |
|
37 | <file type="js">
|
38 | import React from 'react';
|
39 | import {render} from 'react-dom';
|
40 | import List from '@jetbrains/ring-ui/components/list/list';
|
41 |
|
42 | var listData = [
|
43 | {'label': 'One', 'rgItemType': List.ListProps.Type.ITEM},
|
44 | {'label': 'Two', 'rgItemType': List.ListProps.Type.ITEM},
|
45 | {'label': 'Active as default', 'rgItemType': List.ListProps.Type.ITEM},
|
46 | {'label': 'Four', 'rgItemType': List.ListProps.Type.ITEM},
|
47 | {
|
48 | 'label': 'Five (disabled)',
|
49 | 'rgItemType': List.ListProps.Type.ITEM,
|
50 | disabled: true
|
51 | }
|
52 | ];
|
53 |
|
54 | render(
|
55 | <List
|
56 | data={listData}
|
57 | shortcuts
|
58 | onSelect={console.log.bind(console)}
|
59 | activeIndex={2}
|
60 | hint="Hint about the list"
|
61 | />,
|
62 | document.getElementById('list')
|
63 | );
|
64 | </file>
|
65 | </example>
|
66 |
|
67 | <example name="List #2">
|
68 | <file type="html">
|
69 | <div id='list'></div>
|
70 | </file>
|
71 |
|
72 | <file type="js">
|
73 | import React from 'react';
|
74 | import {render} from 'react-dom';
|
75 | import List from '@jetbrains/ring-ui/components/list/list';
|
76 |
|
77 | var listData = [
|
78 | {'label': 'One', href: 'http://example.com', 'rgItemType': List.ListProps.Type.LINK},
|
79 | {'label': 'Two', 'rgItemType': List.ListProps.Type.ITEM},
|
80 | {'label': 'Active as default', 'rgItemType': List.ListProps.Type.ITEM},
|
81 | {'label': 'Four', 'rgItemType': List.ListProps.Type.ITEM},
|
82 | {'label': 'Five', 'rgItemType': List.ListProps.Type.ITEM}
|
83 | ];
|
84 |
|
85 | render(
|
86 | <List
|
87 | data={listData}
|
88 | activeIndex={2}
|
89 | shortcuts
|
90 | onSelect={console.log.bind(console)}
|
91 | />,
|
92 | document.getElementById('list')
|
93 | );
|
94 | </file>
|
95 | </example>
|
96 |
|
97 | <example name="List #3">
|
98 | <file type="html">
|
99 | <div id='list'></div>
|
100 | </file>
|
101 |
|
102 | <file type="js">
|
103 | import React from 'react';
|
104 | import {render} from 'react-dom';
|
105 | import List from '@jetbrains/ring-ui/components/list/list';
|
106 |
|
107 | var listData = [
|
108 | {
|
109 | 'rgItemType': List.ListProps.Type.SEPARATOR,
|
110 | 'description': 'First separator'
|
111 | },
|
112 | {'label': 'Item 1', 'rgItemType': List.ListProps.Type.ITEM},
|
113 | {
|
114 | 'rgItemType': List.ListProps.Type.SEPARATOR,
|
115 | 'description': 'Second sep'
|
116 | },
|
117 | {'label': 'Item 2', 'rgItemType': List.ListProps.Type.ITEM},
|
118 | {
|
119 | 'rgItemType': List.ListProps.Type.TITLE,
|
120 | 'label': 'Group title',
|
121 | 'description': 'With description'
|
122 | },
|
123 | {
|
124 | 'label': 'Item 3',
|
125 | 'rgItemType': List.ListProps.Type.ITEM,
|
126 | 'description': 'Foo bar'
|
127 | },
|
128 | {
|
129 | 'label': 'Item 4',
|
130 | 'rgItemType': List.ListProps.Type.ITEM,
|
131 | 'description': 'Item description'
|
132 | },
|
133 | {
|
134 | 'label': 'Item 5',
|
135 | 'rgItemType': List.ListProps.Type.ITEM,
|
136 | 'description': 'Item description',
|
137 | details: 'Additional details line'
|
138 | },
|
139 | {
|
140 | 'label': 'Item 6',
|
141 | 'rgItemType': List.ListProps.Type.ITEM,
|
142 | 'description': 'Item description',
|
143 | details: 'Additional details line, a long long text. And once again, additional details line, a long long text. And once again, additional details line, a long long text. And once again, additional details line, a long long text. And once again, additional details line, a long long text.'
|
144 | },
|
145 | ];
|
146 |
|
147 | render(
|
148 | <List
|
149 | data={listData}
|
150 | shortcuts
|
151 | onSelect={console.log.bind(console)}
|
152 | />,
|
153 | document.getElementById('list')
|
154 | );
|
155 | </file>
|
156 | </example>
|
157 |
|
158 | <example name="List with item icons">
|
159 | <file type="html">
|
160 | <div id='list' style="width: 300px;"></div>
|
161 | </file>
|
162 |
|
163 | <file type="js">
|
164 | import React from 'react';
|
165 | import {render} from 'react-dom';
|
166 | import List from '@jetbrains/ring-ui/components/list/list';
|
167 | import {WarningIcon} from '@jetbrains/ring-ui/components/icon';
|
168 |
|
169 | var listData = [
|
170 | {
|
171 | label: 'Some item',
|
172 | description: 'Long long long long long long long long long long long long long long long description',
|
173 | key: '1',
|
174 | 'rgItemType': List.ListProps.Type.ITEM,
|
175 | glyph: WarningIcon,
|
176 | rightGlyph: WarningIcon
|
177 | },
|
178 | {
|
179 | label: 'Some item with a long long label, much longer than description',
|
180 | key: '2',
|
181 | 'rgItemType': List.ListProps.Type.ITEM,
|
182 | description: 'Test item',
|
183 | icon: 'http://icons.iconarchive.com/icons/osiris/world-flags/16/00-cctld-ac-icon.png'
|
184 | },
|
185 | {
|
186 | label: 'Some item with a long long label',
|
187 | key: '3',
|
188 | 'rgItemType': List.ListProps.Type.ITEM,
|
189 | description: 'Long long long long long long long long long long long long long long long description',
|
190 | checkbox: true
|
191 | },
|
192 | //Link doesn't support icons
|
193 | {
|
194 | label: 'Some item',
|
195 | key: '4',
|
196 | 'rgItemType': List.ListProps.Type.LINK,
|
197 | description: 'Test item',
|
198 | icon: 'http://www.thg.ru/forum/images/icons/icon6.gif'
|
199 | },
|
200 | {
|
201 | label: 'Some item',
|
202 | key: '5',
|
203 | href: 'http://localhost:9999',
|
204 | description: 'Test item',
|
205 | icon: 'http://www.thg.ru/forum/images/icons/icon6.gif'
|
206 | }
|
207 | ];
|
208 |
|
209 | render(
|
210 | <List
|
211 | data={listData}
|
212 | shortcuts
|
213 | onSelect={console.log.bind(console)}
|
214 | />,
|
215 | document.getElementById('list')
|
216 | );
|
217 | </file>
|
218 | </example>
|
219 |
|
220 | <example name="List should support the deprecated item.type parameter">
|
221 | <file type="html">
|
222 | <div id='list'></div>
|
223 | </file>
|
224 |
|
225 | <file type="js">
|
226 | import React from 'react';
|
227 | import {render} from 'react-dom';
|
228 | import List from '@jetbrains/ring-ui/components/list/list';
|
229 |
|
230 | var listData = [
|
231 | {'label': 'One', 'type': List.ListProps.Type.ITEM},
|
232 | {'label': 'Two', 'type': List.ListProps.Type.ITEM},
|
233 | {'label': 'Three', 'type': List.ListProps.Type.ITEM},
|
234 | {'label': 'Four', 'type': List.ListProps.Type.ITEM},
|
235 | {'label': 'Five', 'type': List.ListProps.Type.ITEM}
|
236 | ];
|
237 |
|
238 | render(
|
239 | <List
|
240 | data={listData}
|
241 | shortcuts
|
242 | onSelect={console.log.bind(console)}
|
243 | />,
|
244 | document.getElementById('list')
|
245 | );
|
246 | </file>
|
247 | </example>
|
248 |
|
249 | <example name="List with custom items">
|
250 | <file type="html">
|
251 | <div id='list'></div>
|
252 | </file>
|
253 | <file type="js">
|
254 | import React from 'react';
|
255 | import {render} from 'react-dom';
|
256 | import List from '@jetbrains/ring-ui/components/list/list';
|
257 |
|
258 | var listData = [
|
259 | {
|
260 | key: '1',
|
261 | rgItemType: List.ListProps.Type.CUSTOM,
|
262 | template: React.createElement('span', {}, 'custom item')
|
263 | },
|
264 | {
|
265 | key: '2',
|
266 | rgItemType: List.ListProps.Type.CUSTOM,
|
267 | template: React.createElement('span', {}, 'custom item (disabled)'),
|
268 | disabled: true
|
269 | },
|
270 | {
|
271 | key: '3',
|
272 | rgItemType: List.ListProps.Type.CUSTOM,
|
273 | template: React.createElement('span', {}, 'custom item 3')
|
274 | },
|
275 | ];
|
276 |
|
277 | render(
|
278 | <List
|
279 | data={listData}
|
280 | shortcuts
|
281 | onSelect={console.log.bind(console)}
|
282 | />,
|
283 | document.getElementById('list')
|
284 | );
|
285 | </file>
|
286 | </example>
|
287 |
|
288 | <example name="List of users">
|
289 | <file type="html">
|
290 | <div id='list'></div>
|
291 | </file>
|
292 | <file type="js">
|
293 | import {render} from 'react-dom';
|
294 | import List from '@jetbrains/ring-ui/components/list/list';
|
295 | import Code from '@jetbrains/ring-ui/components/code/code';
|
296 | import ContentLayout, {Sidebar} from '@jetbrains/ring-ui/components/content-layout/content-layout';
|
297 | import Loader from '@jetbrains/ring-ui/components/loader-inline/loader-inline'
|
298 | import React, {Component} from 'react';
|
299 | import Source from '@jetbrains/ring-ui/components/list/list__users-groups-source';
|
300 | import hubConfig from '@ring-ui/docs/components/hub-config';
|
301 | import Auth from '@jetbrains/ring-ui/components/auth/auth';
|
302 |
|
303 | class UserList extends Component {
|
304 | state = {
|
305 | listData: null,
|
306 | selected: null
|
307 | };
|
308 | auth = new Auth(hubConfig);
|
309 | source = new Source(this.auth);
|
310 |
|
311 | componentDidMount() {
|
312 | this.loadUsers();
|
313 | }
|
314 |
|
315 | async loadUsers() {
|
316 | await this.auth.init();
|
317 | const listData = await this.source.getForList('ring', Source.Filter.USERS);
|
318 | this.setState({listData});
|
319 | }
|
320 |
|
321 | handleSelect = selected => this.setState({selected});
|
322 |
|
323 | render() {
|
324 | const {listData, selected} = this.state;
|
325 | return listData ? (
|
326 | <ContentLayout>
|
327 | <Sidebar>
|
328 | <List
|
329 | className="list"
|
330 | data={this.state.listData}
|
331 | shortcuts
|
332 | onSelect={this.handleSelect}
|
333 | />
|
334 | </Sidebar>
|
335 | {selected && (
|
336 | <Code
|
337 | className="selected"
|
338 | language="json"
|
339 | code={JSON.stringify(selected, null, 2)}
|
340 | />
|
341 | )}
|
342 | </ContentLayout>
|
343 | ) : <Loader />;
|
344 | }
|
345 | }
|
346 |
|
347 | render(<UserList/>, document.getElementById('list'));
|
348 | </file>
|
349 | </example>
|
350 |
|