UNPKG

bootstrap-vue

Version:

BootstrapVue, with more than 85 custom components, over 45 plugins, several custom directives, and over 300 icons, provides one of the most comprehensive implementations of Bootstrap v4 components and grid system for Vue.js. With extensive and automated W

38 lines (36 loc) 1.12 kB
import Vue from '../../utils/vue' import { mergeData } from 'vue-functional-data-merge' import { kebabCase, pascalCase, trim } from '../../utils/string' import { commonIconProps, BVIconBase } from './icon-base' /** * Icon component generator function * * @param {string} icon name (minus the leading `BIcon`) * @param {string} raw `innerHTML` for SVG * @return {VueComponent} */ export const makeIcon = (name, content) => { // For performance reason we pre-compute some values, so that // they are not computed on each render of the icon component const iconName = `BIcon${pascalCase(name)}` const iconNameClass = `bi-${kebabCase(name)}` const svgContent = trim(content || '') // Return the icon component definition return /*#__PURE__*/ Vue.extend({ name: iconName, functional: true, props: { ...commonIconProps, stacked: { type: Boolean, default: false } }, render(h, { data, props }) { return h( BVIconBase, mergeData(data, { staticClass: iconNameClass, props: { ...props, content: svgContent } }) ) } }) }