-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
Copy pathDocumentCard.stories.tsx
174 lines (168 loc) · 4.97 KB
/
DocumentCard.stories.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
import * as React from 'react';
import Screener from 'screener-storybook/src/screener';
import { storiesOf } from '@storybook/react';
import { FabricDecorator, FabricDecoratorFullWidth } from '../utilities/index';
import {
DocumentCard,
DocumentCardPreview,
DocumentCardTitle,
DocumentCardActivity,
DocumentCardType,
ImageFit,
DocumentCardDetails,
Fabric,
IDocumentCardPreviewProps,
} from '@fluentui/react';
import { TestImages } from '@fluentui/example-data';
const previewProps: IDocumentCardPreviewProps = {
previewImages: [
{
name: 'Revenue stream proposal fiscal year 2016 version02.pptx',
linkProps: {
href: 'http://bing.com',
},
previewImageSrc: TestImages.documentPreview,
iconSrc: TestImages.iconPpt,
imageFit: ImageFit.cover,
width: 318,
height: 196,
},
],
};
const previewPropsCompact: IDocumentCardPreviewProps = {
getOverflowDocumentCountText: (overflowCount: number) => `+${overflowCount} more`,
previewImages: [
{
name: 'Revenue stream proposal fiscal year 2016 version02.pptx',
linkProps: {
href: 'http://bing.com',
},
previewImageSrc: TestImages.documentPreview,
iconSrc: TestImages.iconPpt,
width: 144,
},
{
name: 'New Contoso Collaboration for Conference Presentation Draft',
linkProps: {
href: 'http://bing.com',
},
previewImageSrc: TestImages.documentPreviewTwo,
iconSrc: TestImages.iconPpt,
width: 144,
},
{
name: 'Spec Sheet for design',
linkProps: {
href: 'http://bing.com',
},
previewImageSrc: TestImages.documentPreviewThree,
iconSrc: TestImages.iconPpt,
width: 144,
},
{
name: 'Contoso Marketing Presentation',
linkProps: {
href: 'http://bing.com',
},
previewImageSrc: TestImages.documentPreview,
iconSrc: TestImages.iconPpt,
width: 144,
},
],
};
const docActivity = (
<Fabric>
<DocumentCardActivity
activity="Created a few minutes ago"
people={[{ name: 'Annie Lindqvist', profileImageSrc: TestImages.personaFemale }]}
/>
</Fabric>
);
storiesOf('DocumentCard', module)
.addDecorator(FabricDecorator)
.addDecorator(story =>
// prettier-ignore
<Screener
steps={new Screener.Steps()
.snapshot('default', { cropTo: '.testWrapper' })
.end()}
>
{story()}
</Screener>,
)
// Commenting out this story as it has some racing issues with the truncation logic
// and causes the test to fail on unrelated PRs
// .addStory('Root', () => (
// <Fabric>
// <DocumentCard onClickHref="http://bing.com">
// <DocumentCardPreview {...previewProps} />
// <DocumentCardTitle
// eslint-disable-next-line @fluentui/max-len
// title="Large_file_name_with_underscores_used_to_separate_all_of_the_words_and_there_are_so_many_words_it_needs_truncating.pptx"
// shouldTruncate={true}
// />
// {docActivity}
// </DocumentCard>
// </Fabric>
// ))
.addStory('Not truncated', () => (
<Fabric>
<DocumentCard onClickHref="http://bing.com">
<DocumentCardPreview {...previewProps} />
<DocumentCardTitle
title={
'Large_file_name_with_underscores_used_to_separate_all_of_the_' +
'words_and_there_are_so_many_words_it_needs_truncating.pptx'
}
shouldTruncate={false}
/>
{docActivity}
</DocumentCard>
</Fabric>
))
.addStory('With secondary title style', () => (
<Fabric>
<DocumentCard onClickHref="http://bing.com">
<DocumentCardPreview {...previewProps} />
<DocumentCardTitle title="4 files were uploaded" showAsSecondaryTitle={true} />
{docActivity}
</DocumentCard>
</Fabric>
));
storiesOf('DocumentCard', module)
.addDecorator(FabricDecoratorFullWidth)
.addDecorator(story =>
// prettier-ignore
<Screener
steps={new Screener.Steps()
.snapshot('default', { cropTo: '.testWrapper' })
.end()}
>
{story()}
</Screener>,
)
.addStory('Compact with preview list', () => (
<Fabric>
<DocumentCard type={DocumentCardType.compact} onClickHref="http://bing.com">
<DocumentCardPreview {...previewPropsCompact} />
<DocumentCardDetails>
<DocumentCardTitle title="4 files were uploaded" shouldTruncate={true} />
{docActivity}
</DocumentCardDetails>
</DocumentCard>
</Fabric>
))
.addStory('Compact with preview image', () => (
<Fabric>
<DocumentCard type={DocumentCardType.compact} onClickHref="http://bing.com">
<DocumentCardPreview previewImages={[previewProps.previewImages[0]]} />
<DocumentCardDetails>
<DocumentCardTitle
title="Revenue stream proposal fiscal year 2016 version02.pptx"
shouldTruncate={true}
/>
{docActivity}
</DocumentCardDetails>
</DocumentCard>
</Fabric>
));