-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added app-image with loader * optimized app-image --------- Co-authored-by: Yehor Podporinov <[email protected]>
- Loading branch information
1 parent
a958f04
commit 6992f76
Showing
2 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<template> | ||
<div class="app-image"> | ||
<div v-if="isLoading" class="app-image__loader-wrp"> | ||
<template v-if="$slots.loading"> | ||
<slot name="loading" /><!--THERE IS A SLOT HERE--> | ||
</template> | ||
<template v-else> | ||
<app-loader /> | ||
</template> | ||
</div> | ||
<template v-else-if="error && $slots.error"> | ||
<slot name="error" :error="error" /><!--THERE IS A SLOT HERE--> | ||
</template> | ||
<template v-else> | ||
<img v-bind="$attrs" class="app-image__img" :alt="alt" :src="src" /> | ||
</template> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { AppLoader } from '#components' | ||
import { useImage } from '@vueuse/core' | ||
const props = withDefaults( | ||
defineProps<{ | ||
src?: string | ||
alt?: string | ||
}>(), | ||
{ | ||
src: '', | ||
alt: '', | ||
}, | ||
) | ||
const { error, isLoading } = useImage(props) | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.app-image { | ||
display: flex; | ||
object-fit: cover; | ||
overflow: hidden; | ||
background: var(--background-primary-main); | ||
border-radius: var(--border-radius-main); | ||
} | ||
.app-image__loader-wrp { | ||
margin: auto; | ||
} | ||
.app-image__img { | ||
all: inherit; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters