Skip to content

Commit 882e6de

Browse files
authored
Avatar,AvatarGroup: Update typing on color prop (#3853)
1 parent 7a9672e commit 882e6de

File tree

13 files changed

+50
-50
lines changed

13 files changed

+50
-50
lines changed

docs/examples/avatar/colorExample.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import { Avatar, Box, Flex } from 'gestalt';
22

3-
type Color = '01' | '02' | '03' | '04' | '05' | '06' | '07' | '08' | '09' | '10';
3+
type Color = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
44

55
interface AvatarProps {
66
name: string;
77
color: Color;
88
}
99

1010
const avatars: AvatarProps[] = [
11-
{ name: 'Alberto', color: '01' },
12-
{ name: 'Andy', color: '02' },
13-
{ name: 'Alexandra', color: '03' },
14-
{ name: 'Alexi', color: '04' },
15-
{ name: 'Alonso', color: '05' },
16-
{ name: 'Arturo', color: '06' },
17-
{ name: 'Amanda', color: '07' },
18-
{ name: 'Angelina', color: '08' },
19-
{ name: 'Adrian', color: '09' },
20-
{ name: 'Amelia', color: '10' },
11+
{ name: 'Alberto', color: 1 },
12+
{ name: 'Andy', color: 2 },
13+
{ name: 'Alexandra', color: 3 },
14+
{ name: 'Alexi', color: 4 },
15+
{ name: 'Alonso', color: 5 },
16+
{ name: 'Arturo', color: 6 },
17+
{ name: 'Amanda', color: 7 },
18+
{ name: 'Angelina', color: 8 },
19+
{ name: 'Adrian', color: 9 },
20+
{ name: 'Amelia', color: 10 },
2121
];
2222

2323
export default function Example() {

docs/examples/avatar/mainExample.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ export default function Example() {
1919
size="xs"
2020
src="https://i.pinimg.com/originals/bf/bc/27/bfbc27685d81eb9a8f65c201ea661f0e.jpg"
2121
/>
22-
<Avatar color="01" name="Jamie" size="sm" />
22+
<Avatar color={1} name="Jamie" size="sm" />
2323
<Avatar
2424
name="Sora"
2525
size="md"
2626
src="https://i.pinimg.com/originals/ab/c5/4a/abc54abd85df131e90ca6b372368b738.jpg"
2727
verified
2828
/>
29-
<Avatar color="07" name="Ayesha" size="lg" />
29+
<Avatar color={7} name="Ayesha" size="lg" />
3030
<Avatar
3131
name="Ayesha"
3232
size="xl"

docs/examples/avatar/noEmojiExample.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default function Example() {
99
return (
1010
<Flex alignItems="center" height="100%" justifyContent="center" width="100%">
1111
<Avatar
12-
color={isInVRExperiment ? '01' : undefined}
12+
color={isInVRExperiment ? 1 : undefined}
1313
name={isInVRExperiment ? '🌹' : '😀'}
1414
size="lg"
1515
/>

docs/examples/avatar/noImageSourceExample.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default function Example() {
99
return (
1010
<Flex alignItems="center" height="100%" justifyContent="center" width="100%">
1111
<Avatar
12-
color={isInVRExperiment ? '01' : undefined}
12+
color={isInVRExperiment ? 1 : undefined}
1313
name={isInVRExperiment ? 'Rosa' : 'Keerthi'}
1414
size="lg"
1515
/>

docs/examples/avatarGroup/noEmoji.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ export default function Example() {
2121

2222
const collaboratorsVR = [
2323
{
24-
color: '10',
24+
color: 10,
2525
name: 'Sora',
2626
},
2727
{
28-
color: '04',
28+
color: 4,
2929
name: '🙏🏾',
3030
},
3131
{

docs/pages/web/avatargroup.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export default function AvatarGroupPage({ generatedDocGen }: { generatedDocGen:
184184
src: 'https://i.pinimg.com/originals/bf/bc/27/bfbc27685d81eb9a8f65c201ea661f0e.jpg',
185185
},
186186
{
187-
color: '08',
187+
color: 8,
188188
name: 'Zola',
189189
},
190190
{
@@ -203,7 +203,7 @@ export default function AvatarGroupPage({ generatedDocGen }: { generatedDocGen:
203203
],
204204
[
205205
{
206-
color: '10',
206+
color: 10,
207207
name: 'Benito',
208208
},
209209
{
@@ -214,19 +214,19 @@ export default function AvatarGroupPage({ generatedDocGen }: { generatedDocGen:
214214
],
215215
[
216216
{
217-
color: '04',
217+
color: 4,
218218
name: 'Alanna',
219219
},
220220
{
221-
color: '06',
221+
color: 6,
222222
name: 'Elliot',
223223
},
224224
{
225-
color: '08',
225+
color: 8,
226226
name: 'Ricardo',
227227
},
228228
{
229-
color: '10',
229+
color: 10,
230230
name: 'Ricardo',
231231
},
232232
...new Array(10),

packages/gestalt/src/Avatar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type Props = {
88
/**
99
* The background color chosen by the user. A default color will be used if none is selected.
1010
*/
11-
color?: '01' | '02' | '03' | '04' | '05' | '06' | '07' | '08' | '09' | '10';
11+
color?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
1212
/**
1313
* The name of the user. This is used for the placeholder treatment if an image is not available.
1414
*/

packages/gestalt/src/Avatar/DefaultAvatar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import AvatarFoundation from './Foundation';
22

33
type Props = {
44
accessibilityLabel?: string;
5-
color?: '01' | '02' | '03' | '04' | '05' | '06' | '07' | '08' | '09' | '10';
5+
color?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
66
isHovered?: boolean;
77
isPressed?: boolean;
88
name: string;

packages/gestalt/src/Avatar/Foundation.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import useInExperiment from '../useInExperiment';
1313
const ICON_SIZE_RATIO = (20 / 48) * 100; // For pixel perfect icon button, we use the icon (20px) to parent container (48px) size ratio
1414

1515
type ResponsiveFitSizeBoxProps = {
16-
color?: '01' | '02' | '03' | '04' | '05' | '06' | '07' | '08' | '09' | '10';
16+
color?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
1717
children: ReactNode;
1818
content: string;
1919
isCollaboratorCount?: boolean;
@@ -88,7 +88,7 @@ function ResponsiveFitSizeBox({
8888
}
8989

9090
type AvatarFoundationProps = {
91-
color?: '01' | '02' | '03' | '04' | '05' | '06' | '07' | '08' | '09' | '10';
91+
color?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
9292
children?: string | number;
9393
isCollaboratorCount?: boolean;
9494
isHovered?: boolean;

packages/gestalt/src/Avatar/InternalAvatar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const sizes = {
1919

2020
type Props = {
2121
accessibilityLabel?: string;
22-
color?: '01' | '02' | '03' | '04' | '05' | '06' | '07' | '08' | '09' | '10';
22+
color?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
2323
isHovered?: boolean;
2424
isPressed?: boolean;
2525
name: string;

0 commit comments

Comments
 (0)