Skip to content

Commit bd8319d

Browse files
authored
fix(b-card): properly support header/footer with body image overlay (#5872)
1 parent 267cd0c commit bd8319d

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/components/card/card.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@ export const BCard = /*#__PURE__*/ Vue.extend({
3636
props,
3737
render(h, { props, data, slots, scopedSlots }) {
3838
const {
39+
imgSrc,
3940
imgLeft,
4041
imgRight,
4142
imgStart,
4243
imgEnd,
44+
imgBottom,
4345
header,
4446
headerHtml,
4547
footer,
@@ -55,12 +57,12 @@ export const BCard = /*#__PURE__*/ Vue.extend({
5557

5658
let $imgFirst = h()
5759
let $imgLast = h()
58-
if (props.imgSrc) {
60+
if (imgSrc) {
5961
const $img = h(BCardImg, {
6062
props: pluckProps(cardImgProps, props, unprefixPropName.bind(null, 'img'))
6163
})
6264

63-
if (props.imgBottom) {
65+
if (imgBottom) {
6466
$imgLast = $img
6567
} else {
6668
$imgFirst = $img
@@ -82,9 +84,18 @@ export const BCard = /*#__PURE__*/ Vue.extend({
8284

8385
let $content = normalizeSlot(SLOT_NAME_DEFAULT, slotScope, $scopedSlots, $slots)
8486

85-
// Wrap content in <card-body> when `noBody` prop set
87+
// Wrap content in `<card-body>` when `noBody` prop set
8688
if (!props.noBody) {
8789
$content = h(BCardBody, { props: pluckProps(bodyProps, props) }, $content)
90+
91+
// When the `overlap` prop is set we need to wrap the `<b-card-img>` and `<b-card-body>`
92+
// into a relative positioned wrapper to don't distract a potential header or footer
93+
if (props.overlay && imgSrc) {
94+
$content = h('div', { staticClass: 'position-relative' }, [$imgFirst, $content, $imgLast])
95+
// Reset image variables since they are already in the wrapper
96+
$imgFirst = h()
97+
$imgLast = h()
98+
}
8899
}
89100

90101
let $footer = h()

0 commit comments

Comments
 (0)