feat(plugin-iconify): 新增更多的 icon props
This commit is contained in:
parent
85b6d2c7d7
commit
90e6b81fb7
@ -1,15 +1,23 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { Icon as OfflineIcon } from '@iconify/vue/offline'
|
import { Icon as OfflineIcon } from '@iconify/vue/offline'
|
||||||
import { ClientOnly } from '@vuepress/client'
|
import { ClientOnly } from '@vuepress/client'
|
||||||
import type { CSSProperties } from 'vue'
|
import type { IconifyRenderMode } from '@iconify/vue'
|
||||||
|
import type { StyleValue } from 'vue'
|
||||||
import { computed, toRefs } from 'vue'
|
import { computed, toRefs } from 'vue'
|
||||||
import { useIconify } from '../composables/iconify.js'
|
import { useIconify } from '../composables/iconify.js'
|
||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
name?: string
|
name?: string
|
||||||
size?: string
|
size?: string | number
|
||||||
color?: string
|
color?: string
|
||||||
|
mode?: IconifyRenderMode
|
||||||
|
style?: StyleValue
|
||||||
|
flip?: string
|
||||||
|
vFlip?: boolean
|
||||||
|
hFlip?: boolean
|
||||||
|
inline?: boolean
|
||||||
|
rotate?: number
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
name: '',
|
name: '',
|
||||||
@ -29,14 +37,21 @@ const size = computed(() => {
|
|||||||
|
|
||||||
return size
|
return size
|
||||||
})
|
})
|
||||||
const iconStyle = computed(() => {
|
const color = computed(() => props.color || __VUEPRESS_PLUGIN_ICONIFY_DEFAULT_COLOR__)
|
||||||
const style: CSSProperties = {
|
|
||||||
color: props.color || __VUEPRESS_PLUGIN_ICONIFY_DEFAULT_COLOR__,
|
const bind = computed<any>(() => ({
|
||||||
width: size.value,
|
icon: icon.value,
|
||||||
height: size.value,
|
mode: props.mode,
|
||||||
}
|
inline: props.inline,
|
||||||
return style
|
rotate: props.rotate,
|
||||||
})
|
flip: props.flip,
|
||||||
|
vFlip: props.vFlip,
|
||||||
|
hFlip: props.hFlip,
|
||||||
|
color: props.color,
|
||||||
|
width: size.value,
|
||||||
|
height: size.value,
|
||||||
|
style: props.style,
|
||||||
|
}))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
@ -46,12 +61,11 @@ declare const __VUEPRESS_PLUGIN_ICONIFY_DEFAULT_COLOR__: string
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<ClientOnly>
|
<ClientOnly>
|
||||||
<span v-if="!loaded" class="vp-iconify" :style="iconStyle" />
|
<span v-if="!loaded" class="vp-iconify" :style="{ color, width: size, height: size }" />
|
||||||
<OfflineIcon
|
<OfflineIcon
|
||||||
v-else-if="icon"
|
v-else-if="icon"
|
||||||
:icon="icon"
|
|
||||||
class="vp-iconify"
|
class="vp-iconify"
|
||||||
:style="iconStyle"
|
v-bind="bind"
|
||||||
/>
|
/>
|
||||||
</ClientOnly>
|
</ClientOnly>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user