/
App.tsx
613 lines (595 loc) · 16.7 KB
/
App.tsx
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
import React, { useState } from 'react';
import {
Tab,
Icon,
Image,
Badge,
Popup,
Toast,
Button,
Loading,
Overlay,
BackTop,
LoadMore,
TextAlign,
Switch,
} from './components';
import './styles/index.scss';
import { throttle } from './utils/throttle-debounce'
import Sunset from './sunset.jpg';
function App() {
const [show, setShow] = useState(false);
const [shows, setShows] = useState(false);
const [showss, setShowss] = useState(true);
const [active, setActive] = useState(false);
const throttleFunc = throttle(3000, true, (num:number) => {
console.log('num:', num++);
});
return (
<div
className='App'
style={{
padding: '0 16px',
}}
>
<div onClick={()=>{
console.log(111)
throttleFunc(1); // Will execute the callback
}}>
测试throttle
</div>
<h2 className='van-doc-demo-block__title'>Switch</h2>
<div className='flex-wrap'>
<div
className='flex-column-center'
style={{
width: '20%',
}}
>
<Switch active={active} onClick={(check) => setActive(check)} />
<h2 className='van-doc-demo-block__title'>基础用法</h2>
</div>
<div
className='flex-column-center'
style={{
width: '20%',
}}
>
<Switch
disabled
active={active}
onClick={(check) => setActive(check)}
/>
<h2 className='van-doc-demo-block__title'>disabled</h2>
</div>
<div
className='flex-column-center'
style={{
width: '20%',
}}
>
<Switch
color={'red'}
bgColor={'#03a9f4'}
active={active}
onClick={(check) => setActive(check)}
/>
<h2 className='van-doc-demo-block__title'>自定颜色</h2>
</div>
<div
className='flex-column-center'
style={{
width: '20%',
}}
>
<Switch
active={active}
onClick={(check) => {
console.log('无限回调');
setActive(check);
}}
/>
<h2 className='van-doc-demo-block__title'>无限回调</h2>
</div>
</div>
<h2 className='van-doc-demo-block__title'>TextAlign</h2>
<TextAlign length={'5'}>
<TextAlign.Item text={'台式'} />
<TextAlign.Item text={'台式机'} />
<TextAlign.Item text={'台式机器'} />
<TextAlign.Item text={'台式台式台'} />
</TextAlign>
<h2 className='van-doc-demo-block__title'>Badge</h2>
<Badge text={1}>
<div className='sw-demo-child' />
</Badge>
<i className='p-l-30' />
<Badge dot>
<div className='sw-demo-child' />
</Badge>
<i className='p-l-30' />
<Badge text='100' max={99}>
<div className='sw-demo-child' />
</Badge>
<h2 className='van-doc-demo-block__title'>自定义颜色</h2>
<Badge color={'#836c68'} text='100' max={99}>
<div className='sw-demo-child' />
</Badge>
<i className='p-l-30' />
<Badge type={'primary'} text='100' max={99}>
<div className='sw-demo-child' />
</Badge>
<i className='p-l-30' />
<Badge type={'info'} text='100' max={99}>
<div className='sw-demo-child' />
</Badge>
<i className='p-l-30' />
<Badge type={'success'} text='100' max={99}>
<div className='sw-demo-child' />
</Badge>
<i className='p-l-30' />
<Badge type={'warning'} text='100' max={99}>
<div className='sw-demo-child' />
</Badge>
<i className='p-l-30' />
<Badge type={'danger'} text='100' max={99}>
<div className='sw-demo-child' />
</Badge>
<h2 className='van-doc-demo-block__title'>基础用法</h2>
<Image width='100' height='100' src={Sunset} alt='cat' />
<h2 className='van-doc-demo-block__title'>填充模式</h2>
<div className='flex-wrap'>
<div
className='flex-column-center'
style={{
width: '33.3%',
}}
>
<Image
width='100'
height='100'
src={Sunset}
alt='cat'
fit={'contain'}
/>
<h2 className='van-doc-demo-block__title'>contain</h2>
</div>
<div
className='flex-column-center'
style={{
width: '33.3%',
}}
>
<Image
width='100'
height='100'
src={Sunset}
alt='cat'
fit={'cover'}
/>
<h2 className='van-doc-demo-block__title'>cover</h2>
</div>
<div
className='flex-column-center'
style={{
width: '33.3%',
}}
>
<Image width='100' height='100' src={Sunset} alt='cat' fit={'fill'} />
<h2 className='van-doc-demo-block__title'>fill</h2>
</div>
<div
className='flex-column-center'
style={{
width: '33.3%',
}}
>
<Image width='100' height='100' src={Sunset} alt='cat' fit={'none'} />
<h2 className='van-doc-demo-block__title'>none</h2>
</div>
<div
className='flex-column-center'
style={{
width: '33.3%',
}}
>
<Image
width='100'
height='100'
src={Sunset}
alt='cat'
fit={'scale-down'}
/>
<h2 className='van-doc-demo-block__title'>scale-down</h2>
</div>
</div>
<div>
<h2 className='van-doc-demo-block__title'>圆形图片</h2>
<div className='flex-wrap'>
<div
className='flex-column-center'
style={{
width: '33.3%',
}}
>
<Image
width='100'
height='100'
src={Sunset}
alt='cat'
fit={'contain'}
round
/>
<h2 className='van-doc-demo-block__title'>contain</h2>
</div>
<div
className='flex-column-center'
style={{
width: '33.3%',
}}
>
<Image
width='100'
height='100'
src={Sunset}
alt='cat'
fit={'cover'}
round
/>
<h2 className='van-doc-demo-block__title'>cover</h2>
</div>
<div
className='flex-column-center'
style={{
width: '33.3%',
}}
>
<Image
width='100'
height='100'
src={Sunset}
alt='cat'
fit={'fill'}
round
/>
<h2 className='van-doc-demo-block__title'>fill</h2>
</div>
<div
className='flex-column-center'
style={{
width: '33.3%',
}}
>
<Image
width='100'
height='100'
src={Sunset}
alt='cat'
fit={'none'}
round
/>
<h2 className='van-doc-demo-block__title'>none</h2>
</div>
<div
className='flex-column-center'
style={{
width: '33.3%',
}}
>
<Image
width='100'
height='100'
src={Sunset}
alt='cat'
fit={'scale-down'}
round
/>
<h2 className='van-doc-demo-block__title'>scale-down</h2>
</div>
</div>
<h2 className='van-doc-demo-block__title'>Radius</h2>
<div className='flex-wrap'>
<div
className='flex-column-center'
style={{
width: '33.3%',
}}
>
<Image
width='100'
height='100'
radius='30'
src={Sunset}
alt='cat'
fit={'cover'}
/>
<h2 className='van-doc-demo-block__title'>contain</h2>
</div>
</div>
</div>
<h2 className='van-doc-demo-block__title'>其他</h2>
<div className='flex-wrap'>
<div
className='flex-column-center'
style={{
width: '33.3%',
}}
>
<Image
width='100'
height='100'
radius='30'
src={'https://avatars2.githubusercontent.com/u/5787110?s=80&v=4'}
alt='cat'
fit={'cover'}
/>
<h2 className='van-doc-demo-block__title'>Error</h2>
</div>
<div
className='flex-column-center'
style={{
width: '33.3%',
}}
>
<Image
width='100'
height='100'
radius='30'
src={Sunset}
alt='cat'
fit={'cover'}
loading
/>
<h2 className='van-doc-demo-block__title'>Loading</h2>
</div>
</div>
<Tab
data={[
'每日更新',
'精品首推',
'时尚包包',
'T恤',
'运动品牌',
'香水化妆品',
'阿迪达斯',
'耐克',
'范思哲',
'古驰',
'李宁',
'索尼',
'苹果手机',
'IPad',
'Iphone',
'IPad1',
'IPad2',
'IPad3',
'IPad4',
'IPad5',
]}
/>
{/* <Button text="加载状态" btnType="success" onClick={() => getWz(1)} style={{
position: 'fixed',
top: 0,
right: 0
}} />
<Button text="加载状态" btnType="success" onClick={() => getWz(2)} style={{
position: 'fixed',
top: 44,
right: 0
}} />
<Button text="加载状态" btnType="success" onClick={() => getWz(3)} style={{
position: 'fixed',
top: 88,
right: 0
}} />
<Button text="加载状态" btnType="success" onClick={() => getWz(4)} style={{
position: 'fixed',
top: 122,
right: 0
}} />
<Button text="加载状态" btnType="success" onClick={() => getWz(5)} style={{
position: 'fixed',
top: 166,
right: 0
}} />
{[1, 2, 3, 4, 5].map((item) => (
<div
key={item}
style={{
height: 500,
backgroundColor: `${color16()}`,
}}
ref={node}
id={`weizhi_${item}`}
>
{item}
</div>
))} */}
<Icon name={'wechat'} color={'green'} />
<Icon name={'arrow'} />
<Icon name={'arrow-up'} />
<BackTop />
<h2 className='van-doc-demo-block__title'>LoadMore</h2>
<LoadMore />
<LoadMore tip='暂无数据' />
<LoadMore loading={showss} tip='暂无数据' />
<LoadMore loading={showss} loadingType={'circle-side'} tip='暂无数据' />
<LoadMore
loading={showss}
loadingType={'circle-multiple'}
tip='暂无数据'
/>
<LoadMore loading={showss} loadingType={'circle-pulse'} tip='暂无数据' />
<LoadMore loading={showss} loadingType={'circle-box'} tip='暂无数据' />
<Button
text='加载状态'
btnType='success'
onClick={() => setShowss(!showss)}
/>
<h2 className='van-doc-demo-block__title'>Overlay遮罩层</h2>
<Overlay
zIndex={2}
show={show}
onClick={(e) => {
setShow(!show);
}}
>
<div className='wrapper'>
<div
className='block'
onClick={(e) => {
setShow(!show);
}}
>
我是嵌入内容
</div>
</div>
</Overlay>
<Button
text='显示遮罩层'
btnType='success'
onClick={() => setShow(!show)}
/>
<h2 className='van-doc-demo-block__title'>Popup遮罩层</h2>
<Button
text='显示Popup'
btnType='success'
onClick={() => setShows(!shows)}
/>
<Popup
show={shows}
position={'right'}
onClose={() => setShows(!shows)}
style={{
width: 300,
}}
>
1111
</Popup>
<h2 className='van-doc-demo-block__title'>Toast</h2>
<Button
text='显示Toast'
btnType='success'
onClick={() => Toast.info('提示内容')}
/>
<h2 className='van-doc-demo-block__title'>Loading</h2>
<div
className='d-flex flex-wrap p-tb-30'
style={{
background: '#40479a',
}}
>
<Loading color='red' text='加载中...' />
<i className='p-l-30' />
<Loading type='circle-side' color='green' text='加载中...' />
<i className='p-l-30' />
<Loading type='circle-side' size={20} text='side...' />
<i className='p-l-30' />
<Loading type='circle-multiple' text='multiple...' />
<i className='p-l-30' />
<Loading type='circle-pulse' size={20} text='pulse...' />
<i className='p-l-30' />
<Loading
type='circle-box'
size={20}
vertical
color='#fff'
text='box加载文案...'
/>
</div>
<h2 className='van-doc-demo-block__title'>按钮类型</h2>
<div className='flex-row flex-wrap'>
<Button text='成功按钮' btnType='success' />
<Button text='主要按钮' btnType='primary' />
<Button text='信息按钮' btnType='info' />
<Button text='默认按钮' />
<Button text='危险按钮' btnType='danger' />
<Button text='警告按钮' btnType='warning' />
<Button
text='是一个百度链接'
btnType='link'
href='http://www.baidu.com'
target='_bank'
/>
<Button
text='渐变色按钮'
style={{
color: '#fff',
background:
'linear-gradient(to right, rgb(255, 96, 52), rgb(238, 10, 36))',
}}
/>
</div>
<h2 className='van-doc-demo-block__title'>加载按钮</h2>
<div className='flex-ai-center flex-wrap'>
<Button text='方形按钮' btnType='success' square loading />
<Button
text='方形按钮'
btnType='success'
square
loading
loadingText='loading...'
loadingType='circle-side'
/>
<Button
text='方形按钮'
btnType='success'
square
loading
loadingText='加载...'
loadingType='circle'
/>
<Button
text='方形按钮'
btnType='success'
square
loading
loadingText='加载...'
loadingType='circle-multiple'
/>
<Button
text='方形按钮'
btnType='success'
square
loading
loadingText='加载...'
loadingType='circle-pulse'
/>
<Button
text='方形按钮'
btnType='success'
square
loading
loadingText='加载...'
loadingType='circle-box'
/>
</div>
<h2 className='van-doc-demo-block__title'>按钮形状</h2>
<div className='flex-ai-center flex-row'>
<Button text='方形按钮' btnType='success' square />
<Button text='圆形按钮' btnType='success' round />
</div>
<h2 className='van-doc-demo-block__title'>边框按钮</h2>
<div className='flex-wrap flex-row'>
<Button text='成功按钮' btnType='success' plain />
<Button text='主要按钮' btnType='primary' plain />
<Button text='信息按钮' btnType='info' plain />
<Button text='默认按钮' plain />
<Button text='危险按钮' btnType='danger' plain />
<Button text='警告按钮' btnType='warning' plain />
</div>
<h2 className='van-doc-demo-block__title'>按钮尺寸大小</h2>
<Button text='大号按钮' btnType='success' size='large' />
<div className='flex-ai-center flex-row'>
<Button text='普通按钮' btnType='success' />
<Button text='小型按钮' btnType='success' size='small' />
<Button text='迷你按钮' btnType='success' size='mini' />
</div>
<h2 className='van-doc-demo-block__title'>块级按钮</h2>
<Button text='大号按钮' btnType='success' block />
<h2 className='van-doc-demo-block__title'>禁用按钮</h2>
<Button text='禁用状态' btnType='success' disabled />
</div>
);
}
export default App;