Skip to content
This repository was archived by the owner on Sep 24, 2024. It is now read-only.

Commit c80da2f

Browse files
authored
Merge pull request #111 from selemondev/fix-image-src
feat(app): #110 remove image validation
2 parents a8419ec + 398212f commit c80da2f

File tree

1 file changed

+4
-15
lines changed
  • packages/nuxt-ui-vue/src/components/elements/Avatar

1 file changed

+4
-15
lines changed

packages/nuxt-ui-vue/src/components/elements/Avatar/UAvatar.vue

+4-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang='ts'>
22
import type { PropType } from 'vue'
3-
import { computed, defineComponent, ref, watchEffect } from 'vue'
3+
import { computed, defineComponent } from 'vue'
44
import classNames from 'classnames'
55
import { Icon } from '@iconify/vue'
66
import type { VariantJSWithClassesListProps } from '../../../utils/getVariantProps'
@@ -60,17 +60,6 @@ const props = defineProps({
6060
6161
})
6262
63-
const avatarUrl = ref('')
64-
65-
watchEffect(() => {
66-
const img = new Image()
67-
img.src = props.src
68-
img.decode().then(() => (avatarUrl.value = props.src)).catch((err: string) => {
69-
avatarUrl.value = ''
70-
throw err
71-
})
72-
})
73-
7463
const placeholder = computed(() => {
7564
return (props.alt || '').split(' ').map(word => word.charAt(0)).join('').substring(0, 2)
7665
})
@@ -143,9 +132,9 @@ export default defineComponent({
143132

144133
<template>
145134
<span :class="[avatarWrapperClasses, avatarClasses]" :title="props.name">
146-
<img v-if="avatarUrl" :class="avatarClasses" :src="avatarUrl" :alt="props.name">
147-
<span v-else-if="!avatarUrl" :class="variant.avatarPlaceholderClass">{{ placeholder }}</span>
148-
<Icon v-if="!avatarUrl && !placeholder" :icon="props.icon" :class="[avatarIconSize, variant.avatarIconColor]" />
135+
<img v-if="props.src" :class="avatarClasses" :src="props.src" :alt="props.name">
136+
<span v-else-if="!props.src" :class="variant.avatarPlaceholderClass">{{ placeholder }}</span>
137+
<Icon v-if="!props.src && !placeholder" :icon="props.icon" :class="[avatarIconSize, variant.avatarIconColor]" />
149138
<span v-if="props.chipColor" :style="avatarChipColorStyles" :class="[avatarChipClass, avatarChipSize]">
150139
{{ chipText }}
151140
</span>

0 commit comments

Comments
 (0)