/
index.stories.tsx
186 lines (174 loc) · 7.77 KB
/
index.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
175
176
177
178
179
180
181
182
183
184
185
186
import * as React from 'react';
import type {Story} from '@storybook/react';
import {Stack} from '@twilio-paste/stack';
import {Box} from '@twilio-paste/box';
import {CustomizationProvider} from '@twilio-paste/customization';
import {UserIcon} from '@twilio-paste/icons/esm/UserIcon';
import {BusinessIcon} from '@twilio-paste/icons/esm/BusinessIcon';
import {useTheme} from '@twilio-paste/theme';
import {Avatar} from '../src';
// eslint-disable-next-line import/no-default-export
export default {
title: 'Components/Avatar',
component: Avatar,
// Sets the diffThreshold for all stories
chromatic: {diffThreshold: 0.3},
};
export const Initials = (): React.ReactNode => {
return (
<Stack orientation="vertical" spacing="space100">
<Stack orientation="horizontal" spacing="space40">
<Avatar size="sizeIcon10" name="William Wallace" />
<Avatar size="sizeIcon20" name="William Wallace" />
<Avatar size="sizeIcon30" name="William Wallace" />
<Avatar size="sizeIcon40" name="William Wallace" />
<Avatar size="sizeIcon50" name="William Wallace" />
<Avatar size="sizeIcon60" name="William Wallace" />
<Avatar size="sizeIcon70" name="William Wallace" />
<Avatar size="sizeIcon80" name="William Wallace" />
<Avatar size="sizeIcon90" name="William Wallace" />
<Avatar size="sizeIcon100" name="William Wallace" />
<Avatar size="sizeIcon110" name="William Wallace" />
</Stack>
<Stack orientation="horizontal" spacing="space40">
<Avatar size="sizeIcon10" name="Tamir Rice" />
<Avatar size="sizeIcon20" name="Philando Castile" />
<Avatar size="sizeIcon30" name="Trayvon Martin" />
<Avatar size="sizeIcon40" name="Breonna Taylor" />
<Avatar size="sizeIcon50" name="Shantel Davis" />
<Avatar size="sizeIcon60" name="Walter Scott" />
<Avatar size="sizeIcon70" name="James Baldwin" />
<Avatar size="sizeIcon80" name="Toni Morrison" />
<Avatar size="sizeIcon90" name="Chimamanda Ngozi Adichie" />
<Avatar size="sizeIcon100" name="Sarah Li" />
<Avatar size="sizeIcon110" name="Katie Porter" />
</Stack>
</Stack>
);
};
export const Image = (): React.ReactNode => {
return (
<Stack orientation="horizontal" spacing="space40">
<Avatar size="sizeIcon10" name="avatar example" src="./avatars/avatar-sizeIcon10.png" />
<Avatar size="sizeIcon20" name="avatar example" src="./avatars/avatar-sizeIcon20.png" />
<Avatar size="sizeIcon30" name="avatar example" src="./avatars/avatar-sizeIcon30.png" />
<Avatar size="sizeIcon40" name="avatar example" src="./avatars/avatar-sizeIcon40.png" />
<Avatar size="sizeIcon50" name="avatar example" src="./avatars/avatar-sizeIcon50.png" />
<Avatar size="sizeIcon60" name="avatar example" src="./avatars/avatar-sizeIcon60.png" />
<Avatar size="sizeIcon70" name="avatar example" src="./avatars/avatar-sizeIcon70.png" />
<Avatar size="sizeIcon80" name="avatar example" src="./avatars/avatar-sizeIcon80.png" />
<Avatar size="sizeIcon90" name="avatar example" src="./avatars/avatar-sizeIcon90.png" />
<Avatar size="sizeIcon100" name="avatar example" src="./avatars/avatar-sizeIcon100.png" />
<Avatar size="sizeIcon110" name="avatar example" src="./avatars/avatar-sizeIcon110.png" />
</Stack>
);
};
Image.story = {
parameters: {chromatic: {delay: 3000}},
};
export const Icon = (): React.ReactNode => {
return (
<Stack orientation="horizontal" spacing="space40">
<Avatar size="sizeIcon10" name="avatar example" icon={UserIcon} />
<Avatar size="sizeIcon20" name="avatar example" icon={UserIcon} />
<Avatar size="sizeIcon30" name="avatar example" icon={UserIcon} />
<Avatar size="sizeIcon40" name="avatar example" icon={UserIcon} />
<Avatar size="sizeIcon50" name="avatar example" icon={UserIcon} />
<Avatar size="sizeIcon60" name="avatar example" icon={UserIcon} />
<Avatar size="sizeIcon70" name="avatar example" icon={UserIcon} />
<Avatar size="sizeIcon80" name="avatar example" icon={UserIcon} />
<Avatar size="sizeIcon90" name="avatar example" icon={UserIcon} />
<Avatar size="sizeIcon100" name="avatar example" icon={UserIcon} />
<Avatar size="sizeIcon110" name="avatar example" icon={UserIcon} />
</Stack>
);
};
export const ColorVariants = (): React.ReactNode => {
return (
<Stack orientation="horizontal" spacing="space40">
<Avatar color="default" name="avatar example" icon={UserIcon} />
<Avatar color="decorative10" name="avatar example" icon={UserIcon} />
<Avatar color="decorative20" name="avatar example" icon={UserIcon} />
<Avatar color="decorative30" name="avatar example" icon={UserIcon} />
<Avatar color="decorative40" name="avatar example" icon={UserIcon} />
</Stack>
);
};
export const Variants = (): React.ReactNode => {
return (
<Stack orientation="horizontal" spacing="space40">
<Avatar variant="user" name="avatar example" />
<Avatar variant="user" name="avatar example" icon={UserIcon} />
<Avatar variant="user" name="avatar example" src="./avatars/avatar-sizeIcon70.png" />
<Avatar variant="entity" name="entity example" />
<Avatar variant="entity" name="entity example" icon={BusinessIcon} />
<Avatar variant="entity" name="entity example" src="./avatars/avatar-sizeIcon70.png" />
</Stack>
);
};
export const ResponsiveInitials = (): React.ReactNode => {
return (
<Stack orientation="horizontal" spacing="space40">
<Avatar size={['sizeIcon10', 'sizeIcon50', 'sizeIcon110']} name="Simon Taggart" />
</Stack>
);
};
export const ResponsiveImage = (): React.ReactNode => {
return (
<Stack orientation="horizontal" spacing="space40">
<Avatar
size={['sizeIcon10', 'sizeIcon50', 'sizeIcon110']}
name="avatar example"
src="./avatars/avatar-sizeIcon50.png"
/>
</Stack>
);
};
export const ResponsiveIcon = (): React.ReactNode => {
return (
<Stack orientation="horizontal" spacing="space40">
<Avatar size={['sizeIcon10', 'sizeIcon50', 'sizeIcon110']} name="avatar example" icon={UserIcon} />
</Stack>
);
};
ResponsiveImage.story = {
parameters: {chromatic: {delay: 3000}},
};
export const CustomAvatar: Story = (_args, {parameters: {isTestEnvironment}}) => {
const currentTheme = useTheme();
return (
<>
<Stack orientation="horizontal" spacing="space40">
<Avatar size="sizeIcon40" name="Breonna Taylor" />
<Avatar size="sizeIcon50" name="avatar example" src="./avatars/avatar-sizeIcon50.png" />
<Avatar size="sizeIcon60" name="avatar example" icon={UserIcon} />
</Stack>
<CustomizationProvider
disableAnimations={isTestEnvironment}
theme={currentTheme}
elements={{
AVATAR: {
backgroundColor: 'colorBackgroundTrial',
},
AANG: {
color: 'colorTextWeakest',
backgroundColor: 'colorBackgroundPrimaryStrong',
},
}}
>
<Box marginBottom="space60" marginTop="space60">
<Stack orientation="horizontal" spacing="space40">
<Avatar size="sizeIcon40" name="Breonna Taylor" />
<Avatar size="sizeIcon50" name="avatar example" src="./avatars/avatar-sizeIcon50.png" />
<Avatar size="sizeIcon60" name="avatar example" icon={UserIcon} />
</Stack>
</Box>
<Stack orientation="horizontal" spacing="space40">
<Avatar element="AANG" size="sizeIcon40" name="Breonna Taylor" />
<Avatar element="AANG" size="sizeIcon50" name="avatar example" src="./avatars/avatar-sizeIcon50.png" />
<Avatar element="AANG" size="sizeIcon60" name="avatar example" icon={UserIcon} />
</Stack>
</CustomizationProvider>
</>
);
};