feat(AvatarGroup): preset support (#69)

This commit is contained in:
Sylvain Marroufin
2022-07-11 16:21:56 +02:00
committed by GitHub
parent 0e1b9087af
commit 00b9a0839b
3 changed files with 26 additions and 2 deletions

View File

@@ -78,6 +78,7 @@ const components = [
to: '/components/AvatarGroup', to: '/components/AvatarGroup',
nuxt3: true, nuxt3: true,
capi: true, capi: true,
preset: true,
typescript: true typescript: true
}, },
{ {

View File

@@ -4,21 +4,23 @@
v-for="(avatar, index) of displayedGroup" v-for="(avatar, index) of displayedGroup"
:key="index" :key="index"
v-bind="avatar" v-bind="avatar"
class="ring-2 u-ring-white -ml-1.5 first:ml-0"
:size="size" :size="size"
:class="avatarClass"
/> />
<Avatar <Avatar
v-if="remainingGroupSize > 0" v-if="remainingGroupSize > 0"
class="ring-2 u-ring-white -ml-1.5 first:ml-0 text-[10px]"
:size="size" :size="size"
:text="`+${remainingGroupSize}`" :text="`+${remainingGroupSize}`"
:class="avatarClass"
/> />
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { computed } from 'vue' import { computed } from 'vue'
import { classNames } from '../../utils/'
import Avatar from './Avatar' import Avatar from './Avatar'
import $ui from '#build/ui'
const props = defineProps({ const props = defineProps({
group: { group: {
@@ -35,6 +37,14 @@ const props = defineProps({
max: { max: {
type: Number, type: Number,
default: null default: null
},
ringClass: {
type: String,
default: () => $ui.avatarGroup.ring
},
marginClass: {
type: String,
default: () => $ui.avatarGroup.margin
} }
}) })
@@ -55,6 +65,13 @@ const remainingGroupSize = computed(() => {
return avatars.value.length - props.max return avatars.value.length - props.max
}) })
const avatarClass = computed(() => {
return classNames(
props.ringClass,
props.marginClass
)
})
</script> </script>
<script lang="ts"> <script lang="ts">

View File

@@ -373,6 +373,11 @@ export default (variantColors: string[]) => {
} }
} }
const avatarGroup = {
ring: 'ring-2 u-ring-white',
margin: '-ml-1.5 first:ml-0'
}
const slideover = { const slideover = {
overlay: 'bg-gray-500/75 dark:bg-gray-600/75', overlay: 'bg-gray-500/75 dark:bg-gray-600/75',
base: 'relative flex-1 flex flex-col w-full focus:outline-none', base: 'relative flex-1 flex flex-col w-full focus:outline-none',
@@ -404,6 +409,7 @@ export default (variantColors: string[]) => {
tabs, tabs,
pills, pills,
avatar, avatar,
avatarGroup,
slideover slideover
} }
} }