Skip to content

Commit 5b69757

Browse files
authored
fix: add ExampleLayout to UserProfile example (#13)
1 parent 5d203e2 commit 5b69757

File tree

1 file changed

+36
-28
lines changed

1 file changed

+36
-28
lines changed

sdk-explorer/src/users/UserProfile/UserProfile.tsx

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { AuthStateType } from '@sanity/sdk'
22
import { useAuthState, useCurrentUser } from '@sanity/sdk-react/hooks'
33
import { Avatar, Card, Container, Flex, Grid, Stack, Text } from '@sanity/ui'
4+
import ExampleLayout from '../../ExampleLayout'
45

56
export default function UserProfile() {
67
// Use the `useAuthState` hook to ensure there's currently a logged in user
@@ -12,34 +13,41 @@ export default function UserProfile() {
1213

1314
// Render a user profile if the authentication state indicated a logged in user and a user object is available
1415
return type === AuthStateType.LOGGED_IN && user ? (
15-
<Container width={1}>
16-
<Card padding={4} margin={2} radius={3} shadow={3}>
17-
<Flex justify='center' marginBottom={5}>
18-
<Avatar src={user?.profileImage} size={3} />
19-
</Flex>
20-
<Text as='h2' size={4} weight='medium' align='center'>
21-
{user?.name}
22-
</Text>
23-
<Stack space={3} marginTop={5} marginBottom={4}>
24-
<Grid columns={2} gap={4} as='dl'>
25-
<Text as='dt' align='right' muted>
26-
Email address
27-
</Text>
28-
<Text as='dd'>{user?.email}</Text>
29-
<Text as='dt' align='right' muted>
30-
Roles
31-
</Text>
32-
<Text as='dd'>
33-
{user?.roles.map((role) => role.title).join(', ')}
34-
</Text>
35-
<Text as='dt' align='right' muted>
36-
Provider
37-
</Text>
38-
<Text as='dd'>{user?.provider}</Text>
39-
</Grid>
40-
</Stack>
41-
</Card>
42-
</Container>
16+
<ExampleLayout
17+
title='User profile'
18+
codeUrl='https://github.com/sanity-io/sdk-examples/blob/main/sdk-explorer/src/users/UserProfile/UserProfile.tsx'
19+
hooks={['useAuthState', 'useCurrentUser']}
20+
styling='Sanity UI'
21+
>
22+
<Container width={1}>
23+
<Card padding={4} margin={2} radius={3} shadow={3}>
24+
<Flex justify='center' marginBottom={5}>
25+
<Avatar src={user?.profileImage} size={3} />
26+
</Flex>
27+
<Text as='h2' size={4} weight='medium' align='center'>
28+
{user?.name}
29+
</Text>
30+
<Stack space={3} marginTop={5} marginBottom={4}>
31+
<Grid columns={2} gap={4} as='dl'>
32+
<Text as='dt' align='right' muted>
33+
Email address
34+
</Text>
35+
<Text as='dd'>{user?.email}</Text>
36+
<Text as='dt' align='right' muted>
37+
Roles
38+
</Text>
39+
<Text as='dd'>
40+
{user?.roles.map((role) => role.title).join(', ')}
41+
</Text>
42+
<Text as='dt' align='right' muted>
43+
Provider
44+
</Text>
45+
<Text as='dd'>{user?.provider}</Text>
46+
</Grid>
47+
</Stack>
48+
</Card>
49+
</Container>
50+
</ExampleLayout>
4351
) : (
4452
// Render a placeholder if there's no user currently logged in
4553
<Container padding={5}>

0 commit comments

Comments
 (0)