item icon supports custom class
This commit is contained in:
@@ -1,19 +1,19 @@
|
|||||||
<template>
|
<template>
|
||||||
<i class="item-icon" :class="icon" :style="style" v-if="!hiddenStatus">
|
<i class="item-icon" :class="classes" :style="style" v-if="!hiddenStatus">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</i>
|
</i>
|
||||||
<v-badge class="right-bottom-icon" color="secondary"
|
<v-badge class="right-bottom-icon" color="secondary"
|
||||||
location="bottom right" offset-y="2" :icon="icons.hide"
|
location="bottom right" offset-y="2" :icon="icons.hide"
|
||||||
v-if="hiddenStatus">
|
v-if="hiddenStatus">
|
||||||
<i class="item-icon" :class="icon" :style="style">
|
<i class="item-icon" :class="classes" :style="style">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</i>
|
</i>
|
||||||
</v-badge>
|
</v-badge>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import iconConstatns from '@/consts/icon.js';
|
import iconConstants from '@/consts/icon.js';
|
||||||
import colorConstatns from '@/consts/color.js';
|
import colorConstants from '@/consts/color.js';
|
||||||
import { isNumber } from '@/lib/common.js';
|
import { isNumber } from '@/lib/common.js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -22,6 +22,7 @@ import {
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: [
|
props: [
|
||||||
|
'class',
|
||||||
'iconType',
|
'iconType',
|
||||||
'iconId',
|
'iconId',
|
||||||
'color',
|
'color',
|
||||||
@@ -38,16 +39,18 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
icon() {
|
classes() {
|
||||||
|
let allClasses = this.class ? (this.class + ' ') : '';
|
||||||
|
|
||||||
if (this.iconType === 'account') {
|
if (this.iconType === 'account') {
|
||||||
return this.getAccountIcon(this.iconId);
|
allClasses += this.getAccountIcon(this.iconId);
|
||||||
} else if (this.iconType === 'category') {
|
} else if (this.iconType === 'category') {
|
||||||
return this.getCategoryIcon(this.iconId);
|
allClasses += this.getCategoryIcon(this.iconId);
|
||||||
} else if (this.iconType === 'fixed') {
|
} else if (this.iconType === 'fixed') {
|
||||||
return this.iconId;
|
allClasses += this.iconId;
|
||||||
} else {
|
|
||||||
return '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return allClasses;
|
||||||
},
|
},
|
||||||
style() {
|
style() {
|
||||||
let defaultColor = 'var(--default-icon-color)';
|
let defaultColor = 'var(--default-icon-color)';
|
||||||
@@ -71,25 +74,25 @@ export default {
|
|||||||
iconId = iconId.toString();
|
iconId = iconId.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!iconConstatns.allAccountIcons[iconId]) {
|
if (!iconConstants.allAccountIcons[iconId]) {
|
||||||
return iconConstatns.defaultAccountIcon.icon;
|
return iconConstants.defaultAccountIcon.icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
return iconConstatns.allAccountIcons[iconId].icon;
|
return iconConstants.allAccountIcons[iconId].icon;
|
||||||
},
|
},
|
||||||
getCategoryIcon(iconId) {
|
getCategoryIcon(iconId) {
|
||||||
if (isNumber(iconId)) {
|
if (isNumber(iconId)) {
|
||||||
iconId = iconId.toString();
|
iconId = iconId.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!iconConstatns.allCategoryIcons[iconId]) {
|
if (!iconConstants.allCategoryIcons[iconId]) {
|
||||||
return iconConstatns.defaultCategoryIcon.icon;
|
return iconConstants.defaultCategoryIcon.icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
return iconConstatns.allCategoryIcons[iconId].icon;
|
return iconConstants.allCategoryIcons[iconId].icon;
|
||||||
},
|
},
|
||||||
getAccountIconStyle(color, defaultColor, additionalColorAttr) {
|
getAccountIconStyle(color, defaultColor, additionalColorAttr) {
|
||||||
if (color && color !== colorConstatns.defaultAccountColor) {
|
if (color && color !== colorConstants.defaultAccountColor) {
|
||||||
color = '#' + color;
|
color = '#' + color;
|
||||||
} else {
|
} else {
|
||||||
color = defaultColor;
|
color = defaultColor;
|
||||||
@@ -110,7 +113,7 @@ export default {
|
|||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
getCategoryIconStyle(color, defaultColor, additionalColorAttr) {
|
getCategoryIconStyle(color, defaultColor, additionalColorAttr) {
|
||||||
if (color && color !== colorConstatns.defaultCategoryColor) {
|
if (color && color !== colorConstants.defaultCategoryColor) {
|
||||||
color = '#' + color;
|
color = '#' + color;
|
||||||
} else {
|
} else {
|
||||||
color = defaultColor;
|
color = defaultColor;
|
||||||
@@ -131,7 +134,7 @@ export default {
|
|||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
getDefaultIconStyle(color, defaultColor, additionalColorAttr) {
|
getDefaultIconStyle(color, defaultColor, additionalColorAttr) {
|
||||||
if (color && color !== colorConstatns.defaultColor) {
|
if (color && color !== colorConstants.defaultColor) {
|
||||||
color = '#' + color;
|
color = '#' + color;
|
||||||
} else {
|
} else {
|
||||||
color = defaultColor;
|
color = defaultColor;
|
||||||
|
|||||||
Reference in New Issue
Block a user