diff --git a/src/components/appcom/vocabulary/Avatar.tsx b/src/components/appcom/vocabulary/Avatar.tsx new file mode 100644 index 0000000000..585dc2f3be --- /dev/null +++ b/src/components/appcom/vocabulary/Avatar.tsx @@ -0,0 +1,24 @@ +import React from 'react' +import {AtUri} from '@atproto/api' +import {z} from 'zod' + +import {useProfileQuery} from '#/state/queries/profile' +import {useResolveDidQuery} from '#/state/queries/resolve-uri' +import {UserAvatar} from '#/view/com/util/UserAvatar' + +const avatarProps = z.object({ + uri: z.string(), + size: z.number().default(50), +}) + +export type AvatarProps = z.infer + +export function Avatar(props: React.PropsWithChildren) { + const propsParsed = avatarProps.parse(props) + const urip = new AtUri(propsParsed.uri) + + const {data: did} = useResolveDidQuery(urip.host) + const {data: profile} = useProfileQuery({did}) + + return +} diff --git a/src/components/appcom/vocabulary/Embed.tsx b/src/components/appcom/vocabulary/Embed.tsx index a32af80489..8a612c8551 100644 --- a/src/components/appcom/vocabulary/Embed.tsx +++ b/src/components/appcom/vocabulary/Embed.tsx @@ -14,12 +14,11 @@ const embedProps = z.object({ uri: z.string(), }) -export type ProfileCardProps = z.infer +export type EmbedProps = z.infer -export function Embed(props: React.PropsWithChildren) { +export function Embed(props: React.PropsWithChildren) { const propsParsed = embedProps.parse(props) const urip = new AtUri(propsParsed.uri) - console.log(urip) if (!urip.pathname || urip.pathname === '/') { return diff --git a/src/components/appcom/vocabulary/index.tsx b/src/components/appcom/vocabulary/index.tsx index 70f4cf5e1e..ab10bebbab 100644 --- a/src/components/appcom/vocabulary/index.tsx +++ b/src/components/appcom/vocabulary/index.tsx @@ -5,6 +5,7 @@ import {ZodError} from 'zod' import {Text} from '#/components/Typography' import type {AppComNode} from '../types' +import {Avatar} from './Avatar' import {Box} from './Box' import {Embed} from './Embed' import {Expandable} from './Expandable' @@ -13,6 +14,7 @@ import {Stack} from './Stack' import {Tabs} from './Tabs' export const VOCAB: Record> = { + Avatar, Box, Embed, Expandable, diff --git a/src/view/screens/DebugAppcom.tsx b/src/view/screens/DebugAppcom.tsx index cc125dafd0..5bc5ff0bcc 100644 --- a/src/view/screens/DebugAppcom.tsx +++ b/src/view/screens/DebugAppcom.tsx @@ -75,6 +75,16 @@ const DEFAULT_AC = h('Stack', {gap: 10}, [ h('Label', {text: 'Inputs TODO'}), h('Label', {text: 'Forms TODO'}), h('Stack', {gap: 10, pad: {t: 20}}, [ + h('Box', {pad: {x: 10}}, [ + h('Label', {text: 'Avatar', size: 10, weight: 'bold'}), + ]), + h('Box', {border: 'secondary', corner: 8, pad: {x: 16, y: 12}}, [ + h('Stack', {direction: 'row', gap: 10}, [ + h('Avatar', {uri: 'bsky.app'}), + h('Avatar', {uri: 'at://atproto.com'}), + h('Avatar', {uri: 'at://pfrazee.com/'}), + ]), + ]), h('Box', {pad: {x: 10}}, [ h('Label', {text: 'Embed (Actor)', size: 10, weight: 'bold'}), ]),