Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avatar/AvatarGroup: VR Implementation Changes #3765

Merged
merged 9 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions docs/examples/avatar/colorExample.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Avatar, Box, Flex } from 'gestalt';

type Color = '01' | '02' | '03' | '04' | '05' | '06' | '07' | '08' | '09' | '10';

interface AvatarProps {
name: string;
color: Color;
}

const avatars: AvatarProps[] = [
{ name: 'Alberto', color: '01' },
{ name: 'Andy', color: '02' },
{ name: 'Alexandra', color: '03' },
{ name: 'Alexi', color: '04' },
{ name: 'Alonso', color: '05' },
{ name: 'Arturo', color: '06' },
{ name: 'Amanda', color: '07' },
{ name: 'Angelina', color: '08' },
{ name: 'Adrian', color: '09' },
{ name: 'Amelia', color: '10' },
];

export default function Example() {
return (
<Box maxWidth={900} width="100%">
<Flex alignItems="center" height="50%" justifyContent="evenly" width="100%">
{avatars.map(({ name, color }) => (
<Box key={name} width={40}>
<Avatar color={color} name={name} outline />
</Box>
))}
</Flex>
</Box>
);
}
4 changes: 2 additions & 2 deletions docs/examples/avatar/containerExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ export default function Example() {
<Box maxWidth={900} width="100%">
<Flex>
<Box width={40}>
<Avatar name="Julia" />
<Avatar name="Keerthi" />
</Box>
<Box column={2}>
<Avatar name="Julia" />
<Avatar name="Keethi" />
</Box>
<Box column={4}>
<Avatar name="Keerthi" src="https://i.ibb.co/ZfCZrY8/keerthi.jpg" />
Expand Down
13 changes: 11 additions & 2 deletions docs/examples/avatar/ideasExample.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import { Avatar, Flex, Text } from 'gestalt';
import { Avatar, Flex, Text, useDangerouslyInGestaltExperiment } from 'gestalt';

export default function Example() {
const isInVRExperiment = useDangerouslyInGestaltExperiment({
webExperimentName: 'web_gestalt_visualRefresh',
mwebExperimentName: 'web_gestalt_visualRefresh',
});

const src = isInVRExperiment
? 'https://i.pinimg.com/564x/b9/f0/56/b9f0561e2d7927fa427f2306a41bce11.jpg'
: 'https://i.ibb.co/jVR29XV/stock5.jpg';

return (
<Flex alignItems="center" height="100%" justifyContent="center" width="100%">
<Flex alignItems="center" direction="column" gap={{ column: 2, row: 0 }}>
<Avatar name="Artwork" size="xl" src="https://i.ibb.co/jVR29XV/stock5.jpg" />
<Avatar name="Artwork" size="xl" src={src} />
<Text weight="bold">Explore Typographic Art</Text>
</Flex>
</Flex>
Expand Down
40 changes: 36 additions & 4 deletions docs/examples/avatar/mainExample.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,39 @@
import { Avatar, Flex } from 'gestalt';
import { Avatar, Flex, useDangerouslyInGestaltExperiment } from 'gestalt';

export default function Example() {
return (
const isInVRExperiment = useDangerouslyInGestaltExperiment({
webExperimentName: 'web_gestalt_visualRefresh',
mwebExperimentName: 'web_gestalt_visualRefresh',
});

return isInVRExperiment ? (
<Flex
alignContent="center"
gap={{ row: 4, column: 0 }}
height="100%"
justifyContent="center"
wrap
>
<Avatar
name="Fatima"
size="xs"
src="https://i.pinimg.com/originals/bf/bc/27/bfbc27685d81eb9a8f65c201ea661f0e.jpg"
/>
<Avatar color="01" name="Jamie" size="sm" />
<Avatar
name="Sora"
size="md"
src="https://i.pinimg.com/originals/ab/c5/4a/abc54abd85df131e90ca6b372368b738.jpg"
verified
/>
<Avatar color="07" name="Ayesha" size="lg" />
<Avatar
name="Ayesha"
size="xl"
src="https://i.pinimg.com/originals/c5/5c/ac/c55caca43a7c16766215ec165b649c1c.jpg"
/>
</Flex>
) : (
<Flex
alignContent="center"
gap={{ row: 4, column: 0 }}
Expand All @@ -10,9 +42,9 @@ export default function Example() {
wrap
>
<Avatar name="Keerthi" size="xs" src="https://i.ibb.co/ZfCZrY8/keerthi.jpg" />
<Avatar name="Keerthi" size="sm" />
<Avatar name="Alberto" size="sm" />
<Avatar name="Keerthi" size="md" src="https://i.ibb.co/ZfCZrY8/keerthi.jpg" verified />
<Avatar name="Ayesha" size="lg" />
<Avatar name="Alberto" size="lg" />
<Avatar name="Keerthi" size="xl" src="https://i.ibb.co/ZfCZrY8/keerthi.jpg" />
</Flex>
);
Expand Down
16 changes: 13 additions & 3 deletions docs/examples/avatar/nameExample.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import { Avatar, Flex, Text } from 'gestalt';
import { Avatar, Flex, Text, useDangerouslyInGestaltExperiment } from 'gestalt';

export default function Example() {
const isInVRExperiment = useDangerouslyInGestaltExperiment({
webExperimentName: 'web_gestalt_visualRefresh',
mwebExperimentName: 'web_gestalt_visualRefresh',
});

const name = isInVRExperiment ? 'Ayesha Rashad' : 'Shanice Byles';
const src = isInVRExperiment
? 'https://i.pinimg.com/originals/c5/5c/ac/c55caca43a7c16766215ec165b649c1c.jpg'
: 'https://i.ibb.co/7tGKGvb/shanice.jpg';

return (
<Flex
alignItems="center"
Expand All @@ -10,8 +20,8 @@ export default function Example() {
justifyContent="center"
width="100%"
>
<Avatar name="Shanice Byles" size="xl" src="https://i.ibb.co/7tGKGvb/shanice.jpg" />
<Text weight="bold">Shanice Byles</Text>
<Avatar name={name} size="xl" src={src} />
<Text weight="bold">{name}</Text>
</Flex>
);
}
13 changes: 11 additions & 2 deletions docs/examples/avatar/noEmojiExample.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import { Avatar, Flex } from 'gestalt';
import { Avatar, Flex, useDangerouslyInGestaltExperiment } from 'gestalt';

export default function Example() {
const isInVRExperiment = useDangerouslyInGestaltExperiment({
webExperimentName: 'web_gestalt_visualRefresh',
mwebExperimentName: 'web_gestalt_visualRefresh',
});

return (
<Flex alignItems="center" height="100%" justifyContent="center" width="100%">
<Avatar name="😀" size="lg" />
<Avatar
color={isInVRExperiment ? '01' : undefined}
name={isInVRExperiment ? '🌹' : '😀'}
size="lg"
/>
</Flex>
);
}
13 changes: 11 additions & 2 deletions docs/examples/avatar/noImageSourceExample.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import { Avatar, Flex } from 'gestalt';
import { Avatar, Flex, useDangerouslyInGestaltExperiment } from 'gestalt';

export default function Example() {
const isInVRExperiment = useDangerouslyInGestaltExperiment({
webExperimentName: 'web_gestalt_visualRefresh',
mwebExperimentName: 'web_gestalt_visualRefresh',
});

return (
<Flex alignItems="center" height="100%" justifyContent="center" width="100%">
<Avatar name="Keerthi" size="lg" />
<Avatar
color={isInVRExperiment ? '01' : undefined}
name={isInVRExperiment ? 'Rosa' : 'Keerthi'}
size="lg"
/>
</Flex>
);
}
13 changes: 11 additions & 2 deletions docs/examples/avatar/overExample.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import { Avatar, Box, Flex, Mask, Text } from 'gestalt';
import { Avatar, Box, Flex, Mask, Text, useDangerouslyInGestaltExperiment } from 'gestalt';

export default function Example() {
const isInVRExperiment = useDangerouslyInGestaltExperiment({
webExperimentName: 'web_gestalt_visualRefresh',
mwebExperimentName: 'web_gestalt_visualRefresh',
});

const src = isInVRExperiment
? 'https://i.pinimg.com/564x/8e/fb/f7/8efbf75008c34394104ef9568c038d2d.jpg'
: 'https://i.ibb.co/jVR29XV/stock5.jpg';

return (
<Flex alignItems="center" height="100%" justifyContent="center" width="100%">
<Box position="relative">
<Mask wash>
<Avatar name="Artwork" size="xl" src="https://i.ibb.co/jVR29XV/stock5.jpg" />
<Avatar name="Artwork" size="xl" src={src} />
</Mask>
<Box left position="absolute" top>
<Text weight="bold">Explore Typographic Art</Text>
Expand Down
17 changes: 14 additions & 3 deletions docs/examples/avatar/personExample.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import { Avatar, Flex, Text } from 'gestalt';
import { Avatar, Flex, Text, useDangerouslyInGestaltExperiment } from 'gestalt';

export default function Example() {
const isInVRExperiment = useDangerouslyInGestaltExperiment({
webExperimentName: 'web_gestalt_visualRefresh',
mwebExperimentName: 'web_gestalt_visualRefresh',
});

const firstName = isInVRExperiment ? 'Sora' : 'Keerthi';
const fullName = isInVRExperiment ? 'Sora Suzuki' : 'Keerthi Singh';
const src = isInVRExperiment
? 'https://i.pinimg.com/originals/ab/c5/4a/abc54abd85df131e90ca6b372368b738.jpg'
: 'https://i.ibb.co/ZfCZrY8/keerthi.jpg';

return (
<Flex
alignItems="center"
Expand All @@ -10,8 +21,8 @@ export default function Example() {
justifyContent="center"
width="100%"
>
<Avatar name="Keerthi" size="xl" src="https://i.ibb.co/ZfCZrY8/keerthi.jpg" />
<Text weight="bold">Keerthi Singh</Text>
<Avatar name={firstName} size="xl" src={src} />
<Text weight="bold">{fullName}</Text>
</Flex>
);
}
21 changes: 12 additions & 9 deletions docs/examples/avatar/shapeExample.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import { Flex, Image, Mask } from 'gestalt';
import { Flex, Image, Mask, useDangerouslyInGestaltExperiment } from 'gestalt';

export default function Example() {
const isInVRExperiment = useDangerouslyInGestaltExperiment({
webExperimentName: 'web_gestalt_visualRefresh',
mwebExperimentName: 'web_gestalt_visualRefresh',
});

const alt = isInVRExperiment ? 'Ayesha Avatar' : 'Keerthi Avatar';
const src = isInVRExperiment
? 'https://i.pinimg.com/originals/50/ce/c4/50cec4ca4c65131580c540c65548e0a3.jpg'
: 'https://i.ibb.co/ZfCZrY8/keerthi.jpg';

return (
<Flex alignItems="center" height="100%" justifyContent="center" width="100%">
<Mask height={150} rounding={3} width={150}>
<Image
alt="Keerthi Avatar"
color="#000"
fit="contain"
naturalHeight={1}
naturalWidth={1}
src="https://i.ibb.co/ZfCZrY8/keerthi.jpg"
/>
<Image alt={alt} color="#000" fit="contain" naturalHeight={1} naturalWidth={1} src={src} />
</Mask>
</Flex>
);
Expand Down
22 changes: 16 additions & 6 deletions docs/examples/avatar/sizingExample.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
import { Avatar, Flex } from 'gestalt';
import { Avatar, Flex, useDangerouslyInGestaltExperiment } from 'gestalt';

export default function Example() {
const isInVRExperiment = useDangerouslyInGestaltExperiment({
webExperimentName: 'web_gestalt_visualRefresh',
mwebExperimentName: 'web_gestalt_visualRefresh',
});

const name = isInVRExperiment ? 'Fatima' : 'Keerthi';
const src = isInVRExperiment
? 'https://i.pinimg.com/originals/bf/bc/27/bfbc27685d81eb9a8f65c201ea661f0e.jpg'
: 'https://i.ibb.co/ZfCZrY8/keerthi.jpg';

return (
<Flex alignItems="center" gap={4} height="100%" justifyContent="center" width="100%" wrap>
<Avatar name="Keerthi" size="xs" src="https://i.ibb.co/ZfCZrY8/keerthi.jpg" />
<Avatar name="Keerthi" size="sm" src="https://i.ibb.co/ZfCZrY8/keerthi.jpg" />
<Avatar name="Keerthi" size="md" src="https://i.ibb.co/ZfCZrY8/keerthi.jpg" />
<Avatar name="Keerthi" size="lg" src="https://i.ibb.co/ZfCZrY8/keerthi.jpg" />
<Avatar name="Keerthi" size="xl" src="https://i.ibb.co/ZfCZrY8/keerthi.jpg" />
<Avatar name={name} size="xs" src={src} />
<Avatar name={name} size="sm" src={src} />
<Avatar name={name} size="md" src={src} />
<Avatar name={name} size="lg" src={src} />
<Avatar name={name} size="xl" src={src} />
</Flex>
);
}
18 changes: 14 additions & 4 deletions docs/examples/avatar/verifiedExample.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
import { Avatar, Flex } from 'gestalt';
import { Avatar, Flex, useDangerouslyInGestaltExperiment } from 'gestalt';

export default function Example() {
const isInVRExperiment = useDangerouslyInGestaltExperiment({
webExperimentName: 'web_gestalt_visualRefresh',
mwebExperimentName: 'web_gestalt_visualRefresh',
});

const name = isInVRExperiment ? 'Sora' : 'Shanice';
const src = isInVRExperiment
? 'https://i.pinimg.com/originals/ab/c5/4a/abc54abd85df131e90ca6b372368b738.jpg'
: 'https://i.ibb.co/7tGKGvb/shanice.jpg';

return (
<Flex alignItems="center" height="100%" justifyContent="center" width="100%">
<Avatar
accessibilityLabel="Shanice, Verified account"
name="Shanice"
accessibilityLabel={`${name}, Verified account`}
name={name}
size="lg"
src="https://i.ibb.co/7tGKGvb/shanice.jpg"
src={src}
verified
/>
</Flex>
Expand Down
Loading
Loading