4cd4fd28
郭伟龙
feat: 初始化项目
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
import { extend, mergeData } from '../../vue'
import { omit } from '../../utils/object'
import { kebabCase, pascalCase, trim } from '../../utils/string'
import { BVIconBase, props as BVIconBaseProps } from './icon-base'
const iconProps = omit(BVIconBaseProps, ['content'])
/**
* 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 kebabName = kebabCase(name)
const iconName = `BIcon${pascalCase(name)}`
const iconNameClass = `bi-${kebabName}`
const iconTitle = kebabName.replace(/-/g, ' ')
const svgContent = trim(content || '')
return /*#__PURE__*/ extend({
name: iconName,
functional: true,
props: iconProps,
render(h, { data, props }) {
return h(
BVIconBase,
mergeData(
// Defaults
{
props: { title: iconTitle },
attrs: { 'aria-label': iconTitle }
},
// User data
data,
// Required data
{
staticClass: iconNameClass,
props: { ...props, content: svgContent }
}
)
)
}
})
}
|