|
@@ -1,5 +1,5 @@
|
|
|
<script lang="ts">
|
|
<script lang="ts">
|
|
|
-import { h, PropType } from 'vue';
|
|
|
|
|
|
|
+import { computed, h, inject, PropType } from 'vue';
|
|
|
import { createComponent } from '@/packages/utils/create';
|
|
import { createComponent } from '@/packages/utils/create';
|
|
|
const { componentName, create } = createComponent('icon');
|
|
const { componentName, create } = createComponent('icon');
|
|
|
import { pxCheck } from '@/packages/utils/pxCheck';
|
|
import { pxCheck } from '@/packages/utils/pxCheck';
|
|
@@ -8,14 +8,15 @@ export default create({
|
|
|
props: {
|
|
props: {
|
|
|
name: { type: String, default: '' },
|
|
name: { type: String, default: '' },
|
|
|
size: { type: [String, Number], default: '' },
|
|
size: { type: [String, Number], default: '' },
|
|
|
- classPrefix: { type: String, default: 'nut-icon' },
|
|
|
|
|
- fontClassName: { type: String, default: 'nutui-iconfont' },
|
|
|
|
|
|
|
+ classPrefix: { type: String, default: '' },
|
|
|
|
|
+ fontClassName: { type: String, default: '' },
|
|
|
color: { type: String, default: '' },
|
|
color: { type: String, default: '' },
|
|
|
tag: { type: String as PropType<keyof HTMLElementTagNameMap>, default: 'i' }
|
|
tag: { type: String as PropType<keyof HTMLElementTagNameMap>, default: 'i' }
|
|
|
},
|
|
},
|
|
|
emits: ['click'],
|
|
emits: ['click'],
|
|
|
|
|
|
|
|
setup(props, { emit, slots }) {
|
|
setup(props, { emit, slots }) {
|
|
|
|
|
+ const config: any = inject('nut-config-provider', null);
|
|
|
const handleClick = (event: Event) => {
|
|
const handleClick = (event: Event) => {
|
|
|
emit('click', event);
|
|
emit('click', event);
|
|
|
};
|
|
};
|
|
@@ -23,6 +24,8 @@ export default create({
|
|
|
const isImage = () => {
|
|
const isImage = () => {
|
|
|
return props.name ? props.name.indexOf('/') !== -1 : false;
|
|
return props.name ? props.name.indexOf('/') !== -1 : false;
|
|
|
};
|
|
};
|
|
|
|
|
+ const classPrefix = computed(() => props.classPrefix || config?.classPrefix || 'nut-icon');
|
|
|
|
|
+ const fontClassName = computed(() => props.fontClassName || config?.fontClassName || 'nutui-iconfont');
|
|
|
|
|
|
|
|
return () => {
|
|
return () => {
|
|
|
const _isImage = isImage();
|
|
const _isImage = isImage();
|
|
@@ -31,7 +34,7 @@ export default create({
|
|
|
{
|
|
{
|
|
|
class: _isImage
|
|
class: _isImage
|
|
|
? `${componentName}__img`
|
|
? `${componentName}__img`
|
|
|
- : `${props.fontClassName} ${componentName} ${props.classPrefix}-${props.name}`,
|
|
|
|
|
|
|
+ : `${fontClassName.value} ${componentName} ${classPrefix.value}-${props.name}`,
|
|
|
style: {
|
|
style: {
|
|
|
color: props.color,
|
|
color: props.color,
|
|
|
fontSize: pxCheck(props.size),
|
|
fontSize: pxCheck(props.size),
|