Skip to content

Commit

Permalink
feat: add avatar circle component
Browse files Browse the repository at this point in the history
  • Loading branch information
selemondev committed Oct 8, 2024
1 parent 4f3ca60 commit 5eec89f
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,5 @@ import Demos from './src/components/Demos.vue'
<demo src="./src/example/particles/Demo.vue" />

<demo src="./src/example/dotPattern/Demo.vue" />

<demo src="./src/example/avatarCircle/Demo.vue" />
33 changes: 33 additions & 0 deletions docs/src/components/spark-ui/avatarCircle/AvatarCircles.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<script setup lang='ts'>
import { cn } from '../../../lib/utils'
interface AvatarCirclesProps {
class?: string
numPeople?: number
avatarUrls: string[]
}
const props = defineProps<AvatarCirclesProps>()
const className = cn(
'z-10 flex -space-x-4 rtl:space-x-reverse',
props.class,
)
</script>

<template>
<div :class="className">
<div v-for="(imageUrl, idx) in props.avatarUrls" :key="idx">
<img
:key="idx" class="h-10 w-10 rounded-full border-2 border-white dark:border-gray-800" :src="imageUrl"
:height="40" :width="40" :alt="`Avatar ${idx + 1}`"
>
</div>
<a
class="flex h-10 w-10 items-center justify-center rounded-full border-2 border-white bg-black text-center text-xs font-medium text-white hover:bg-gray-600 dark:border-gray-800 dark:bg-white dark:text-black"
href=""
>
+{{ props.numPeople }}
</a>
</div>
</template>
32 changes: 32 additions & 0 deletions docs/src/example/avatarCircle/AvatarCircles.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<script setup lang='ts'>
import { cn } from '../../lib/utils'
interface AvatarCirclesProps {
class?: string
numPeople?: number
avatarUrls: string[]
}
const props = defineProps<AvatarCirclesProps>()
const className = cn(
'z-10 flex -space-x-4 rtl:space-x-reverse',
props.class,
)
</script>

<template>
<div :class="className">
<div v-for="(imageUrl, idx) in props.avatarUrls" :key="idx">
<img
:key="idx" class="h-10 w-10 rounded-full border-2 border-white dark:border-gray-800" :src="imageUrl"
:height="40" :width="40" :alt="`Avatar ${idx + 1}`"
>
</div>
<span
class="flex h-10 w-10 items-center justify-center rounded-full border-2 border-white bg-black text-center text-xs font-medium text-white hover:bg-gray-600 dark:border-gray-800 dark:bg-white dark:hover:bg-white dark:text-black"
>
+{{ props.numPeople }}
</span>
</div>
</template>
16 changes: 16 additions & 0 deletions docs/src/example/avatarCircle/Demo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<script setup lang='ts'>
import AvatarCircles from './AvatarCircles.vue'
const avatarUrls = [
'https://github.com/selemondev.png',
'https://avatars.githubusercontent.com/u/20110627',
'https://avatars.githubusercontent.com/u/106103625',
'https://avatars.githubusercontent.com/u/59228569',
]
</script>

<template>
<div class="grid place-items-center w-full min-h-screen">
<AvatarCircles :num-people="99" :avatar-urls="avatarUrls" />
</div>
</template>

0 comments on commit 5eec89f

Please sign in to comment.