feat: rework dropdown-item
This commit is contained in:
parent
4cd0e90fea
commit
02deb0bedd
@ -1,46 +1,24 @@
|
|||||||
<template>
|
<template>
|
||||||
<component
|
<BaseButton class="dropdown-item">
|
||||||
:is="componentNodeName"
|
|
||||||
v-bind="elementBindings"
|
|
||||||
:to="to"
|
|
||||||
class="dropdown-item">
|
|
||||||
<span class="icon" v-if="icon">
|
<span class="icon" v-if="icon">
|
||||||
<icon :icon="icon"/>
|
<Icon :icon="icon"/>
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
<slot></slot>
|
<slot />
|
||||||
</span>
|
</span>
|
||||||
</component>
|
</BaseButton>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {ref, useAttrs, watchEffect} from 'vue'
|
import BaseButton, { type BaseButtonProps } from '@/components/base//BaseButton.vue'
|
||||||
|
import Icon from '@/components/misc/Icon'
|
||||||
|
import type { IconProp } from '@fortawesome/fontawesome-svg-core'
|
||||||
|
|
||||||
const props = defineProps<{
|
export interface DropDownItemProps extends BaseButtonProps {
|
||||||
to?: object,
|
icon?: IconProp,
|
||||||
icon?: string | string[],
|
}
|
||||||
}>()
|
|
||||||
|
|
||||||
const componentNodeName = ref<Node['nodeName']>('a')
|
defineProps<DropDownItemProps>()
|
||||||
const elementBindings = ref({})
|
|
||||||
|
|
||||||
const attrs = useAttrs()
|
|
||||||
watchEffect(() => {
|
|
||||||
let nodeName = 'a'
|
|
||||||
|
|
||||||
if (props.to) {
|
|
||||||
nodeName = 'router-link'
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('href' in attrs) {
|
|
||||||
nodeName = 'BaseButton'
|
|
||||||
}
|
|
||||||
|
|
||||||
componentNodeName.value = nodeName
|
|
||||||
elementBindings.value = {
|
|
||||||
...attrs,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@ -91,5 +69,4 @@ button.dropdown-item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
v-else-if="type === 'dropdown'"
|
v-else-if="type === 'dropdown'"
|
||||||
v-tooltip="tooltipText"
|
v-tooltip="tooltipText"
|
||||||
@click="changeSubscription"
|
@click="changeSubscription"
|
||||||
:class="{'is-disabled': disabled}"
|
:disabled="disabled"
|
||||||
:icon="iconName"
|
:icon="iconName"
|
||||||
>
|
>
|
||||||
{{ buttonText }}
|
{{ buttonText }}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user