@@ -19,7 +19,9 @@ interface BImgProps {
1919 fluidGrow? : Booleanish
2020 height? : number | string
2121 left? : Booleanish
22+ start? : Booleanish
2223 right? : Booleanish
24+ end? : Booleanish
2325 rounded? : boolean | string
2426 sizes? : string | Array <string >
2527 src? : string
@@ -38,6 +40,8 @@ const props = withDefaults(defineProps<BImgProps>(), {
3840 fluidGrow: false ,
3941 left: false ,
4042 right: false ,
43+ end: false ,
44+ start: false ,
4145 rounded: false ,
4246 thumbnail: false ,
4347})
@@ -55,7 +59,9 @@ const centerBoolean = useBooleanish(toRef(props, 'center'))
5559const fluidBoolean = useBooleanish (toRef (props , ' fluid' ))
5660const fluidGrowBoolean = useBooleanish (toRef (props , ' fluidGrow' ))
5761const leftBoolean = useBooleanish (toRef (props , ' left' ))
62+ const startBoolean = useBooleanish (toRef (props , ' start' ))
5863const rightBoolean = useBooleanish (toRef (props , ' right' ))
64+ const endBoolean = useBooleanish (toRef (props , ' end' ))
5965const thumbnailBoolean = useBooleanish (toRef (props , ' thumbnail' ))
6066
6167const BLANK_TEMPLATE =
@@ -99,20 +105,22 @@ const computedSizes = computed<string | undefined>(() =>
99105)
100106
101107const computedDimentions = computed <{height: number | undefined ; width: number | undefined }>(() => {
102- const width =
103- typeof props .width === ' number' ? props .width : parseInt (props .width as string , 10 ) || undefined
104- const height =
105- typeof props .height === ' number'
106- ? props .height
107- : parseInt (props .height as string , 10 ) || undefined
108+ const parser = (str : string | number | undefined ): number | undefined =>
109+ str === undefined
110+ ? undefined
111+ : typeof str === ' number'
112+ ? str
113+ : Number .parseInt (str , 10 ) || undefined
114+ const width = parser (props .width )
115+ const height = parser (props .height )
108116 if (blankBoolean .value ) {
109- if (!! width && ! height ) {
117+ if (width !== undefined && height === undefined ) {
110118 return {height: width , width }
111119 }
112- if (! width && !! height ) {
120+ if (width === undefined && height !== undefined ) {
113121 return {height , width: height }
114122 }
115- if (! width && ! height ) {
123+ if (width === undefined && height === undefined ) {
116124 return {height: 1 , width: 1 }
117125 }
118126 }
@@ -123,11 +131,7 @@ const computedDimentions = computed<{height: number | undefined; width: number |
123131})
124132
125133const computedBlankImgSrc = computed (() =>
126- makeBlankImgSrc (
127- computedDimentions .value .width ,
128- computedDimentions .value .height ,
129- props .blankColor || ' transparent'
130- )
134+ makeBlankImgSrc (computedDimentions .value .width , computedDimentions .value .height , props .blankColor )
131135)
132136
133137const attrs = computed (() => ({
@@ -141,9 +145,9 @@ const attrs = computed(() => ({
141145}))
142146
143147const alignment = computed <' float-start' | ' float-end' | ' mx-auto' | undefined >(() =>
144- leftBoolean .value
148+ leftBoolean .value || startBoolean . value
145149 ? ' float-start'
146- : rightBoolean .value
150+ : rightBoolean .value || endBoolean . value
147151 ? ' float-end'
148152 : centerBoolean .value
149153 ? ' mx-auto'
0 commit comments