bootstrap-vue
Version:
With more than 85 components, over 45 available plugins, several directives, and 1000+ icons, BootstrapVue provides one of the most comprehensive implementations of the Bootstrap v4 component and grid system available for Vue.js v2.6, complete with extens
62 lines (56 loc) • 1.7 kB
JavaScript
import Vue, { mergeData } from '../../vue'
import { NAME_CARD_BODY } from '../../constants/components'
import { copyProps, pluckProps, prefixPropName } from '../../utils/props'
import cardMixin from '../../mixins/card'
import { BCardTitle, props as titleProps } from './card-title'
import { BCardSubTitle, props as subTitleProps } from './card-sub-title'
export const props = {
// Import common card props and prefix them with `body-`
...copyProps(cardMixin.props, prefixPropName.bind(null, 'body')),
bodyClass: {
type: [String, Object, Array]
// default: null
},
...titleProps,
...subTitleProps,
overlay: {
type: Boolean,
default: false
}
}
// @vue/component
export const BCardBody = /*#__PURE__*/ Vue.extend({
name: NAME_CARD_BODY,
functional: true,
props,
render(h, { props, data, children }) {
let cardTitle = h()
let cardSubTitle = h()
const cardContent = children || [h()]
if (props.title) {
cardTitle = h(BCardTitle, { props: pluckProps(titleProps, props) })
}
if (props.subTitle) {
cardSubTitle = h(BCardSubTitle, {
props: pluckProps(subTitleProps, props),
class: ['mb-2']
})
}
return h(
props.bodyTag,
mergeData(data, {
staticClass: 'card-body',
class: [
{
'card-img-overlay': props.overlay,
[`bg-${props.bodyBgVariant}`]: props.bodyBgVariant,
[`border-${props.bodyBorderVariant}`]: props.bodyBorderVariant,
[`text-${props.bodyTextVariant}`]: props.bodyTextVariant
},
props.bodyClass || {}
]
}),
[cardTitle, cardSubTitle, ...cardContent]
)
}
})