bootstrap-vue
Version:
Quickly integrate Bootstrap 4 components with Vue.js
46 lines (40 loc) • 1.17 kB
JavaScript
import { mergeData, pluckProps } from "../../utils";
import { assign } from "../../utils/object";
import Link, { propsFactory as linkPropsFactory } from "../link/link";
let linkProps = linkPropsFactory();
delete linkProps.href.default;
delete linkProps.to.default;
export const props = assign(linkProps, {
tag: {
type: String,
default: "span"
},
variant: {
type: String,
default: "secondary"
},
pill: {
type: Boolean,
default: false
}
});
export default {
functional: true,
props,
render(h, { props, data, children }) {
const tag = !props.href && !props.to ? props.tag : Link;
const componentData = {
staticClass: "badge",
class: [
!props.variant ? "badge-secondary" : `badge-${props.variant}`,
{
"badge-pill": Boolean(props.pill),
active: props.active,
disabled: props.disabled
}
],
props: pluckProps(linkProps, props)
};
return h(tag, mergeData(data, componentData), children);
}
};