Skip to content

Commit

Permalink
fix(#3990): use fallback if no src
Browse files Browse the repository at this point in the history
  • Loading branch information
m0ksem committed Nov 6, 2023
1 parent aa98a34 commit 3b90f26
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/ui/src/components/va-avatar/VaAvatar.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export default {
export const Default = () => ({
components: { VaAvatar },
template: `
<VaAvatar
src="https://randomuser.me/api/portraits/women/5.jpg"
<VaAvatar
src="https://randomuser.me/api/portraits/women/5.jpg"
alt="image"
/>
`,
Expand Down Expand Up @@ -62,21 +62,21 @@ export const SizesConfig = () => ({
components: { VaAvatar },
template: `
[small: 16px]
<VaAvatar
<VaAvatar
:sizesConfig="{ 'defaultSize': 24, 'sizes': { 'small': 16, 'medium': 24, 'large': 32 } }"
size="small"
>
Text
</VaAvatar>
[medium: 24px]
<VaAvatar
<VaAvatar
:sizesConfig="{ 'defaultSize': 24, 'sizes': { 'small': 16, 'medium': 24, 'large': 32 } }"
size="medium"
>
Text
</VaAvatar>
[large: 32px]
<VaAvatar
<VaAvatar
:sizesConfig="{ 'defaultSize': 24, 'sizes': { 'small': 16, 'medium': 24, 'large': 32 } }"
size="large"
>
Expand Down Expand Up @@ -123,6 +123,11 @@ export const FallbackText = () => ({
template: '<VaAvatar src="https://not-exist" fallbackText="Text"/>',
})

export const FallbackTextNoSrc = () => ({
components: { VaAvatar },
template: '<VaAvatar fallbackText="Text" />',
})

export const fallbackRender = () => ({
components: { VaAvatar },
methods: {
Expand Down
3 changes: 3 additions & 0 deletions packages/ui/src/components/va-avatar/VaAvatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
v-else-if="$props.icon"
:name="$props.icon"
/>
<slot v-else name="fallback">
<va-fallback v-bind="VaFallbackProps" @fallback="$emit('fallback')" />
</slot>
</slot>
</div>
</template>
Expand Down

0 comments on commit 3b90f26

Please sign in to comment.