11<template >
2- <img :class =" classes" v-bind =" attrs" />
2+ <b- img :class =" classes" v-bind =" attrs" @load = " emit('load', $event) " />
33</template >
44
55<script setup lang="ts">
66// import type {BCardImgProps} from '../../types/components'
7+ import BImg from ' ../BImg.vue'
78import type {Booleanish } from ' ../../types'
89import {useBooleanish } from ' ../../composables'
910import {computed , toRef } from ' vue'
1011
11- // TODO how does this separate from a simple b-img?
12-
1312interface BCardImgProps {
1413 alt? : string
1514 bottom? : Booleanish
@@ -22,42 +21,35 @@ interface BCardImgProps {
2221 start? : Booleanish
2322 top? : Booleanish
2423 width? : number | string
24+ blank? : Booleanish
25+ blankColor? : string
26+ sizes? : string | Array <string >
27+ srcset? : string | Array <string >
2528}
2629
2730const props = withDefaults (defineProps <BCardImgProps >(), {
2831 bottom: false ,
2932 end: false ,
3033 left: false ,
3134 right: false ,
32- alt: undefined ,
3335 lazy: false ,
3436 start: false ,
3537 top: false ,
38+ blank: false ,
3639})
3740
41+ interface Emits {
42+ (e : ' load' , value : Event ): void
43+ }
44+
45+ const emit = defineEmits <Emits >()
46+
3847const bottomBoolean = useBooleanish (toRef (props , ' bottom' ))
3948const endBoolean = useBooleanish (toRef (props , ' end' ))
4049const leftBoolean = useBooleanish (toRef (props , ' left' ))
4150const rightBoolean = useBooleanish (toRef (props , ' right' ))
4251const startBoolean = useBooleanish (toRef (props , ' start' ))
4352const topBoolean = useBooleanish (toRef (props , ' top' ))
44- const lazyBoolean = useBooleanish (toRef (props , ' lazy' ))
45-
46- const attrs = computed (() => ({
47- loading: lazyBoolean .value ? ' lazy' : ' eager' ,
48- src: props .src ,
49- alt: props .alt ,
50- width:
51- (typeof props .width === ' number' ? props .width : parseInt (props .width as string , 10 )) ||
52- undefined ,
53- height:
54- (typeof props .height === ' number' ? props .height : parseInt (props .height as string , 10 )) ||
55- undefined ,
56- }))
57-
58- const alignment = computed (() =>
59- leftBoolean .value ? ' float-start' : rightBoolean .value ? ' float-end' : ' '
60- )
6153
6254const baseClass = computed (() =>
6355 topBoolean .value
@@ -71,8 +63,20 @@ const baseClass = computed(() =>
7163 : ' card-img'
7264)
7365
74- const classes = computed (() => ({
75- [alignment .value ]: !! alignment .value ,
76- [baseClass .value ]: !! baseClass .value ,
66+ /**
67+ * Removes the above baseClass used props so it does not cause potential issues
68+ */
69+ const attrs = computed (() => ({
70+ alt: props .alt ,
71+ height: props .height ,
72+ src: props .src ,
73+ lazy: props .lazy ,
74+ width: props .width ,
75+ blank: props .blank ,
76+ blankColor: props .blankColor ,
77+ sizes: props .sizes ,
78+ srcset: props .srcset ,
7779}))
80+
81+ const classes = computed (() => [baseClass .value ])
7882 </script >
0 commit comments