You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.3 KiB
50 lines
1.3 KiB
<script type="text/jsx">
|
|
import {isExternal} from '@/utils/validate'
|
|
|
|
export default {
|
|
name: 'SvgIcon',
|
|
|
|
functional: true,
|
|
|
|
props: {
|
|
icon: String,
|
|
className: String
|
|
},
|
|
|
|
render(h, context) {
|
|
const {listeners} = context
|
|
const {icon, className} = context.props
|
|
const c = 'svg-icon ' + (className || '')
|
|
if (isExternal(icon)) {
|
|
const style = {
|
|
mask: `url(${this.icon}) no-repeat 50% 50%`,
|
|
'-webkit-mask': `url(${this.icon}) no-repeat 50% 50%`
|
|
}
|
|
return <div {...{on: listeners}} class={'svg-external-icon ' + c} style={style}/>
|
|
}
|
|
else {
|
|
const iconName = `#icon-${icon}`
|
|
return (
|
|
<svg {...{on: listeners}} class={c} aria-hidden="true">
|
|
<use href={iconName}/>
|
|
</svg>
|
|
)
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
.svg-icon {
|
|
width: 1em;
|
|
height: 1em;
|
|
fill: currentColor;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.svg-external-icon {
|
|
background-color: currentColor;
|
|
mask-size: cover !important;
|
|
display: inline-block;
|
|
}
|
|
</style>
|
|
|