forked from microsoft/fluentui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BadgeSize.stories.tsx
181 lines (157 loc) · 5.34 KB
/
BadgeSize.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
import * as React from 'react';
import { Badge, BadgeProps } from '@fluentui/react-badge';
import { CircleRegular } from '@fluentui/react-icons';
import { propValues, useStyles } from './utils';
import { ComponentMeta } from '@storybook/react';
import { getStoryVariant, RTL } from '../../utilities';
const BadgeSampleRow: React.FC<BadgeProps> = props => {
const styles = useStyles();
// Text content is not supported for tiny and extra-small
if (props.size === 'tiny' || props.size === 'extra-small') {
return (
<div className={styles.row}>
<Badge {...props} icon={props.size === 'tiny' ? null : <CircleRegular />} />
</div>
);
}
return (
<div className={styles.row}>
<Badge {...props}>1</Badge>
<Badge {...props} icon={<CircleRegular />} />
<Badge {...props}>BADGE</Badge>
<Badge {...props} icon={<CircleRegular />}>
BADGE
</Badge>
<Badge {...props} icon={<CircleRegular />} iconPosition="after">
BADGE
</Badge>
{props.children}
</div>
);
};
export default {
title: 'Badge Converged',
} as ComponentMeta<typeof Badge>;
export const SizeTiny = () => {
const styles = useStyles();
return (
<div className={styles.groupSet}>
{propValues.appearance.map(appearance =>
// tiny + ghost is not supported
appearance === 'ghost' ? null : (
<div key={appearance} className={styles.group}>
<span className={styles.groupLabel}>appearance: {appearance}</span>
{propValues.shape.map(shape => (
<BadgeSampleRow key={shape} shape={shape} appearance={appearance} size={'tiny'} />
))}
</div>
),
)}
</div>
);
};
SizeTiny.storyName = 'size: tiny';
export const SizeTinyRTL = getStoryVariant(SizeTiny, RTL);
export const SizeExtraSmall = () => {
const styles = useStyles();
return (
<div className={styles.groupSet}>
{propValues.appearance.map(appearance => (
<div key={appearance} className={styles.group}>
<span className={styles.groupLabel}>appearance: {appearance}</span>
{propValues.shape.map(shape => (
<BadgeSampleRow key={shape} shape={shape} appearance={appearance} size={'extra-small'} />
))}
</div>
))}
</div>
);
};
SizeExtraSmall.storyName = 'size: extra-small';
export const SizeExtraSmallRTL = getStoryVariant(SizeExtraSmall, RTL);
export const SizeSmall = () => {
const styles = useStyles();
return (
<div className={styles.groupSet}>
{propValues.appearance.map(appearance => (
<div key={appearance} className={styles.group}>
<span className={styles.groupLabel}>appearance: {appearance}</span>
{propValues.shape.map(shape => (
<BadgeSampleRow key={shape} shape={shape} appearance={appearance} size={'small'} />
))}
</div>
))}
</div>
);
};
SizeSmall.storyName = 'size: small';
export const SizeSmallRTL = getStoryVariant(SizeSmall, RTL);
export const SizeMedium = () => {
const styles = useStyles();
return (
<div className={styles.groupSet}>
{propValues.appearance.map(appearance => (
<div key={appearance} className={styles.group}>
<span className={styles.groupLabel}>appearance: {appearance}</span>
{propValues.shape.map(shape => (
<BadgeSampleRow key={shape} shape={shape} appearance={appearance} size={'medium'} />
))}
</div>
))}
</div>
);
};
SizeMedium.storyName = 'size: medium';
export const SizeMediumRTL = getStoryVariant(SizeMedium, RTL);
export const SizeLarge = () => {
const styles = useStyles();
return (
<div className={styles.groupSet}>
{propValues.appearance.map(appearance => (
<div key={appearance} className={styles.group}>
<span className={styles.groupLabel}>appearance: {appearance}</span>
{propValues.shape.map(shape => (
<BadgeSampleRow key={shape} shape={shape} appearance={appearance} size={'large'} />
))}
</div>
))}
</div>
);
};
SizeLarge.storyName = 'size: large';
export const SizeLargeRTL = getStoryVariant(SizeLarge, RTL);
export const SizeExtraLarge = () => {
const styles = useStyles();
return (
<div className={styles.groupSet}>
{propValues.appearance.map(appearance => (
<div key={appearance} className={styles.group}>
<span className={styles.groupLabel}>appearance: {appearance}</span>
{propValues.shape.map(shape => (
<BadgeSampleRow key={shape} shape={shape} appearance={appearance} size={'extra-large'} />
))}
</div>
))}
</div>
);
};
SizeExtraLarge.storyName = 'size: extra-large';
export const SizeExtraLargeRTL = getStoryVariant(SizeExtraLarge, RTL);
export const WidthConstrained = () => {
const styles = useStyles();
return (
<div className={styles.group}>
<div className={styles.widthConstrained}>
<Badge>1</Badge>
<Badge icon={<CircleRegular />} />
<Badge>BADGE</Badge>
<Badge icon={<CircleRegular />}>BADGE</Badge>
<Badge icon={<CircleRegular />} iconPosition="after">
BADGE
</Badge>
</div>
<span className={styles.description}>Badges should not clip their content when space constrained.</span>
</div>
);
};
WidthConstrained.storyName = 'width constrained';