-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
Shimmer.CustomElements.Example.tsx
111 lines (104 loc) · 3.93 KB
/
Shimmer.CustomElements.Example.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
import * as React from 'react';
import {
Shimmer,
ShimmerElementsGroup,
ShimmerElementType as ElemType,
ShimmerElementVerticalAlign as ElemVerticalAlign
} from '@uifabric/experiments/lib/Shimmer';
import './Shimmer.Example.scss';
export class ShimmerCustomElementsExample extends React.Component<{}, {}> {
constructor(props: {}) {
super(props);
}
public render(): JSX.Element {
return (
<div className="shimmerBasicExample-container">
Using ShimmerElementsGroup component to build complex structures of the placeholder you need.
<Shimmer customElementsGroup={this._getCustomElementsExampleOne()} widthInPixel={350} />
<Shimmer customElementsGroup={this._getCustomElementsExampleTwo()} widthInPixel={550} />
<Shimmer customElementsGroup={this._getCustomElementsExampleThree()} widthInPercentage={90} />
</div>
);
}
private _getCustomElementsExampleOne = (): JSX.Element => {
return (
<div
// tslint:disable-next-line:jsx-ban-props
style={{ display: 'flex' }}
>
<ShimmerElementsGroup
shimmerElements={[{ type: ElemType.line, widthInPixel: 40, height: 40 }, { type: ElemType.gap, widthInPixel: 10, height: 40 }]}
/>
<ShimmerElementsGroup
flexWrap={true}
shimmerElements={[
{ type: ElemType.line, widthInPixel: 300, height: 10 },
{ type: ElemType.line, widthInPixel: 200, height: 10 },
{ type: ElemType.gap, widthInPixel: 100, height: 20 }
]}
/>
</div>
);
};
private _getCustomElementsExampleTwo = (): JSX.Element => {
return (
<div
// tslint:disable-next-line:jsx-ban-props
style={{ display: 'flex' }}
>
<ShimmerElementsGroup
shimmerElements={[{ type: ElemType.circle, height: 40 }, { type: ElemType.gap, widthInPixel: 10, height: 40 }]}
/>
<ShimmerElementsGroup
flexWrap={true}
shimmerElements={[
{ type: ElemType.line, widthInPixel: 400, height: 10 },
{ type: ElemType.gap, widthInPixel: 100, height: 20 },
{ type: ElemType.line, widthInPixel: 500, height: 10 }
]}
/>
</div>
);
};
private _getCustomElementsExampleThree = (): JSX.Element => {
return (
<div
// tslint:disable-next-line:jsx-ban-props
style={{ display: 'flex' }}
>
<ShimmerElementsGroup
width={'90px'}
shimmerElements={[{ type: ElemType.line, height: 80, widthInPixel: 80 }, { type: ElemType.gap, widthInPixel: 10, height: 80 }]}
/>
<div
// tslint:disable-next-line:jsx-ban-props
style={{ display: 'flex', flexWrap: 'wrap', width: '100%' }}
>
<ShimmerElementsGroup
shimmerElements={[{ type: ElemType.circle, height: 40 }, { type: ElemType.gap, widthInPixel: 10, height: 40 }]}
/>
<ShimmerElementsGroup
flexWrap={true}
width={'calc(100% - 50px)'}
shimmerElements={[
{ type: ElemType.line, widthInPercentage: 90, height: 10 },
{ type: ElemType.gap, widthInPercentage: 10, height: 20 },
{ type: ElemType.line, widthInPercentage: 100, height: 10 }
]}
/>
<ShimmerElementsGroup
flexWrap={true}
width={'100%'}
shimmerElements={[
{ type: ElemType.line, widthInPercentage: 80, height: 10, verticalAlign: ElemVerticalAlign.bottom },
{ type: ElemType.gap, widthInPercentage: 20, height: 20 },
{ type: ElemType.line, widthInPercentage: 40, height: 10, verticalAlign: ElemVerticalAlign.bottom },
{ type: ElemType.gap, widthInPercentage: 2, height: 20 },
{ type: ElemType.line, widthInPercentage: 58, height: 10, verticalAlign: ElemVerticalAlign.bottom }
]}
/>
</div>
</div>
);
};
}