Skip to content

Commit

Permalink
fix(plugin-icon): fix color prop not working
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Jan 16, 2025
1 parent b66125e commit 1da0e31
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions plugins/features/plugin-icon/src/client/components/VPIcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,43 +21,35 @@ export const VPIcon = defineComponent({
/**
* Icon prefix
*/
prefix: {
type: String,
default: '',
},
prefix: String,

/**
* Icon class
*
* 图标类名
*/
icon: { type: String, default: '' },
icon: String,

/**
* Icon color
*
* 图标颜色
*/
color: { type: String, default: '' },
color: String,

/**
* Icon size
*
* 图标大小
*/
size: {
type: [String, Number],
default: '',
},
size: [String, Number],

/**
* Icon vertical align
*
* 图标垂直对齐方式
*/
verticalAlign: {
type: String,
default: '',
},
verticalAlign: String,

/**
* Icon sizing
Expand All @@ -74,18 +66,21 @@ export const VPIcon = defineComponent({

setup(props) {
const imageLink = computed(() =>
isLinkHttp(props.icon)
? props.icon
: isLinkAbsolute(props.icon)
? withBase(props.icon)
: null,
props.icon
? isLinkHttp(props.icon)
? props.icon
: isLinkAbsolute(props.icon)
? withBase(props.icon)
: null
: null,
)

const attrs = computed(() => {
const attrsObject: Record<string, unknown> = {}
const styleObject: CSSProperties = {}
const { type, verticalAlign, size, sizing } = props

if (props.color) styleObject.color = props.color
if (size)
styleObject['--icon-size'] = Number.isNaN(Number(size))
? (size as string)
Expand All @@ -107,7 +102,7 @@ export const VPIcon = defineComponent({
icon.includes('fa-') || /^fa.$/.test(icon) ? icon : `fa-${icon}`

return (): VNode | null => {
const { type, icon, prefix, sizing } = props
const { type, icon, prefix = '', sizing } = props

if (!icon) return null

Expand Down

0 comments on commit 1da0e31

Please sign in to comment.