Skip to content

Commit

Permalink
feat(profile): avatar components
Browse files Browse the repository at this point in the history
  • Loading branch information
prazdevs committed Dec 1, 2024
1 parent 6d7efb6 commit 4d677e2
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 1 deletion.
33 changes: 33 additions & 0 deletions components/profile/ProfileAvatar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<script setup lang="ts">
import type { ProfileView } from './types'
defineProps<{
profile: ProfileView
square?: boolean
big?: boolean
}>()
const defaultAvatar = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'
const loaded = ref(false)
const error = ref(false)
</script>

<template>
<img
:key="profile.avatar"
:src="(error || !loaded) ? defaultAvatar : profile.avatar"
:alt="$t('account.avatar_description', [profile.displayName ?? profile.handle])"
:class="[
loaded ? 'bg-base' : 'bg-gray:10',
square ? '' : 'rounded-full',
]"
:style="{ 'clip-path': square ? `url(#avatar-mask)` : 'none' }"
loading="lazy"
width="400"
height="400"
select-none
@load="loaded = true"
@error="error = true"
>
</template>
23 changes: 23 additions & 0 deletions components/profile/ProfileBigAvatar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script setup lang="ts">
import type { ProfileView } from './types'
// Avatar with a background base achieving a 3px border to be used in status cards
// The border is used for Avatar on Avatar for reblogs and connecting replies
defineProps<{
profile: ProfileView
square?: boolean
}>()
</script>

<template>
<div
:key="profile.avatar"
:style="{ 'clip-path': square ? `url(#avatar-mask)` : 'none' }"
:class="{ 'rounded-full': !square }"
bg-base w-54px h-54px
flex items-center justify-center
>
<ProfileAvatar :profile w-48px h-48px :square="square" />
</div>
</template>
5 changes: 5 additions & 0 deletions components/profile/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { AppBskyActorDefs } from '@atcute/client/lexicons'

export type ProfileView = AppBskyActorDefs.ProfileView
| AppBskyActorDefs.ProfileViewBasic
| AppBskyActorDefs.ProfileViewDetailed
28 changes: 27 additions & 1 deletion utils/dummy-data.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// this is just some hardcoded WIP dummy data

import type { AppBskyFeedPost } from '@atcute/client/lexicons'
import type { AppBskyActorDefs, AppBskyFeedPost } from '@atcute/client/lexicons'

export const bskyRecordWithRichText = {
$type: 'app.bsky.feed.post',
Expand Down Expand Up @@ -57,3 +57,29 @@ export const bskyRecordWithRichText = {
],
text: 'unicode-segmenter has recently become even smaller. It only takes 5.3 KB to be aware of #Unicode graphemes, like emojis!\n\nAnd is now @e18e.dev recommendation!\n\ngithub.com/es-tooling/m...',
} as AppBskyFeedPost.Record

export const bksyProfile = {
did: 'did:plc:n3bayyluz2vnoj7ztrje7tfe',
handle: 'praz.dev',
displayName: 'Sacha — prazdevs',
avatar: 'https://cdn.bsky.app/img/avatar/plain/did:plc:n3bayyluz2vnoj7ztrje7tfe/bafkreiesxm2rugweab2vi5b5ko6bcugvh4qoludpsz4mfxrixqq6mowkte@jpeg',
associated: {
lists: 0,
feedgens: 0,
starterPacks: 0,
labeler: false,
},
viewer: {
muted: false,
blockedBy: false,
knownFollowers: { count: 11, followers: [{ did: 'did:plc:ia76kvnndjutgedggx2ibrem', handle: 'mary.my.id', displayName: 'mary🐇', avatar: 'https://cdn.bsky.app/img/avatar/plain/did:plc:ia76kvnndjutgedggx2ibrem/bafkreiesgyo7ukzqhs5mmtulvovzrbbru7ztvopwdwfsvllu553qgfmxd4@jpeg', associated: { chat: { allowIncoming: 'all' } }, viewer: { muted: false, blockedBy: false, following: 'at://did:plc:n3bayyluz2vnoj7ztrje7tfe/app.bsky.graph.follow/3l74cjrlbtn2i', followedBy: 'at://did:plc:ia76kvnndjutgedggx2ibrem/app.bsky.graph.follow/3l72yhwxncn2d' }, labels: [{ cts: '2024-11-13T04:46:40.254Z', neg: false, src: 'did:plc:wkoofae5uytcm7bjncmev6n6', uri: 'did:plc:ia76kvnndjutgedggx2ibrem', val: 'she-it', ver: 1 }], createdAt: '2023-10-14T22:32:58.570Z' }, { did: 'did:plc:2gkh62xvzokhlf6li4ol3b3d', handle: 'patak.dev', displayName: 'patak', avatar: 'https://cdn.bsky.app/img/avatar/plain/did:plc:2gkh62xvzokhlf6li4ol3b3d/bafkreifgzl4e5jqlakd77ajvnilsb5tufsv24h2sxfwmitkzxrh3sk6mhq@jpeg', viewer: { muted: false, blockedBy: false, following: 'at://did:plc:n3bayyluz2vnoj7ztrje7tfe/app.bsky.graph.follow/3l6wvmqy4as2f', followedBy: 'at://did:plc:2gkh62xvzokhlf6li4ol3b3d/app.bsky.graph.follow/3l6wzfp2q5a2y' }, labels: [], createdAt: '2023-04-28T20:13:36.804Z' }, { did: 'did:plc:5x4dxgyqvx3ohkqdcnainkmg', handle: 'jeanphi-baconnais.gitlab.io', displayName: 'Jean-Phi Baconnais 🦎', avatar: 'https://cdn.bsky.app/img/avatar/plain/did:plc:5x4dxgyqvx3ohkqdcnainkmg/bafkreifelkzbwxg63csyosheo2apxhh7zixwadkmwbl26p2wf2wis5pmqq@jpeg', associated: { chat: { allowIncoming: 'all' } }, viewer: { muted: false, blockedBy: false, following: 'at://did:plc:n3bayyluz2vnoj7ztrje7tfe/app.bsky.graph.follow/3l6zec4g7uh2a', followedBy: 'at://did:plc:5x4dxgyqvx3ohkqdcnainkmg/app.bsky.graph.follow/3l6zlgux5fk2i' }, labels: [], createdAt: '2023-07-03T05:19:22.061Z' }, { did: 'did:plc:2pdiyh6lip2aomv7kia3f2jo', handle: 'antfu.me', displayName: 'Anthony Fu', avatar: 'https://cdn.bsky.app/img/avatar/plain/did:plc:2pdiyh6lip2aomv7kia3f2jo/bafkreiaglmlv3di5wv7lvbhizgdhlmzf5eog42k5tawigi6vu6vowr3oiy@jpeg', viewer: { muted: false, blockedBy: false, following: 'at://did:plc:n3bayyluz2vnoj7ztrje7tfe/app.bsky.graph.follow/3l6uv5ajjci2w', followedBy: 'at://did:plc:2pdiyh6lip2aomv7kia3f2jo/app.bsky.graph.follow/3l7rspxj7e52g' }, labels: [{ cts: '2024-11-11T11:40:26.861Z', neg: false, src: 'did:plc:wkoofae5uytcm7bjncmev6n6', uri: 'did:plc:2pdiyh6lip2aomv7kia3f2jo', val: 'he', ver: 1 }], createdAt: '2023-05-13T12:02:02.777Z' }, { did: 'did:plc:5g4pymss6ca4uv33t2fiwjlz', handle: 'shellelittle.bsky.social', displayName: 'Shell Little', avatar: 'https://cdn.bsky.app/img/avatar/plain/did:plc:5g4pymss6ca4uv33t2fiwjlz/bafkreianwtyi5jkp6kj6hcfq6psm3nq5ew5nbkbg5acm2m3wrzfwldzp5a@jpeg', viewer: { muted: false, blockedBy: false, following: 'at://did:plc:n3bayyluz2vnoj7ztrje7tfe/app.bsky.graph.follow/3l6uumjlv7l2q', followedBy: 'at://did:plc:5g4pymss6ca4uv33t2fiwjlz/app.bsky.graph.follow/3lawpvhsypk2a' }, labels: [{ cts: '2024-10-25T18:29:15.528Z', neg: false, src: 'did:plc:wkoofae5uytcm7bjncmev6n6', uri: 'did:plc:5g4pymss6ca4uv33t2fiwjlz', val: 'she-they', ver: 1 }], createdAt: '2023-04-28T18:42:18.520Z' }] },
},
labels: [{ cts: '2024-11-12T13:18:46.642Z', neg: false, src: 'did:plc:wkoofae5uytcm7bjncmev6n6', uri: 'did:plc:n3bayyluz2vnoj7ztrje7tfe', val: 'they', ver: 1 }],
createdAt: '2024-10-19T15:57:24.512Z',
description: 'They/them 🏳️‍🌈\n\n28 y-o French pragmatic developer & a11y advocate with AuDHD.\nJavascript & Vue & frontend things.\n\nI (should) write things at praz.dev.',
indexedAt: '2024-11-12T13:17:51.404Z',
banner: 'https://cdn.bsky.app/img/banner/plain/did:plc:n3bayyluz2vnoj7ztrje7tfe/bafkreiafvka3yaest7r6zestmucaoiwbxhmhkypbgisgl4j4uc34d7qe5a@jpeg',
followersCount: 128,
followsCount: 92,
postsCount: 31,
} as AppBskyActorDefs.ProfileViewDetailed

0 comments on commit 4d677e2

Please sign in to comment.