2024-09-07 07:38:18 +00:00
|
|
|
<script setup lang="ts">
|
2022-12-26 08:50:11 +00:00
|
|
|
const props = defineProps<{
|
|
|
|
text?: string
|
2023-01-02 20:19:36 +00:00
|
|
|
content?: string
|
2022-12-29 20:01:31 +00:00
|
|
|
description?: string
|
2022-12-26 08:50:11 +00:00
|
|
|
icon?: string
|
2023-01-02 20:19:36 +00:00
|
|
|
to?: string | Record<string, string>
|
2022-12-26 08:50:11 +00:00
|
|
|
command?: boolean
|
2023-01-05 08:47:58 +00:00
|
|
|
disabled?: boolean
|
2023-01-04 14:43:17 +00:00
|
|
|
external?: true
|
2023-01-05 08:59:49 +00:00
|
|
|
large?: true
|
2023-01-22 19:53:04 +00:00
|
|
|
match?: boolean
|
2024-04-03 13:59:42 +00:00
|
|
|
target?: string
|
2022-12-26 08:50:11 +00:00
|
|
|
}>()
|
|
|
|
|
|
|
|
const router = useRouter()
|
2024-04-03 13:59:42 +00:00
|
|
|
const scrollOnClick = computed(() => props.to && !(props.target === '_blank' || props.external))
|
2022-12-26 08:50:11 +00:00
|
|
|
|
2022-12-29 19:31:29 +00:00
|
|
|
useCommand({
|
|
|
|
scope: 'Settings',
|
2022-12-26 08:50:11 +00:00
|
|
|
|
2023-01-02 20:19:36 +00:00
|
|
|
name: () => props.text
|
2024-03-05 14:48:58 +00:00
|
|
|
?? (props.to
|
|
|
|
? typeof props.to === 'string'
|
|
|
|
? props.to
|
|
|
|
: props.to.name
|
|
|
|
: ''
|
|
|
|
),
|
2022-12-29 20:01:31 +00:00
|
|
|
description: () => props.description,
|
2022-12-29 19:31:29 +00:00
|
|
|
icon: () => props.icon || '',
|
2023-01-02 20:19:36 +00:00
|
|
|
visible: () => props.command && props.to,
|
2022-12-26 08:50:11 +00:00
|
|
|
|
2022-12-29 19:31:29 +00:00
|
|
|
onActivate() {
|
2023-01-02 20:19:36 +00:00
|
|
|
router.push(props.to!)
|
2022-12-29 19:31:29 +00:00
|
|
|
},
|
|
|
|
})
|
2022-12-26 08:50:11 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<NuxtLink
|
2023-01-05 08:47:58 +00:00
|
|
|
:disabled="disabled"
|
2022-12-26 08:50:11 +00:00
|
|
|
:to="to"
|
2023-01-04 14:43:17 +00:00
|
|
|
:external="external"
|
2024-04-03 13:59:42 +00:00
|
|
|
:target="target"
|
2022-12-26 08:50:11 +00:00
|
|
|
exact-active-class="text-primary"
|
2023-01-22 19:53:04 +00:00
|
|
|
:class="disabled ? 'op25 pointer-events-none ' : match ? 'text-primary' : ''"
|
2022-12-26 08:50:11 +00:00
|
|
|
block w-full group focus:outline-none
|
2023-01-05 08:47:58 +00:00
|
|
|
:tabindex="disabled ? -1 : null"
|
2024-04-03 13:59:42 +00:00
|
|
|
@click="scrollOnClick ? $scrollToTop() : undefined"
|
2022-12-26 08:50:11 +00:00
|
|
|
>
|
|
|
|
<div
|
2024-02-24 16:46:14 +00:00
|
|
|
w-full flex px5 py3 md:gap2 gap4 items-center
|
2022-12-26 08:50:11 +00:00
|
|
|
transition-250 group-hover:bg-active
|
|
|
|
group-focus-visible:ring="2 current"
|
|
|
|
>
|
|
|
|
<div flex-1 flex items-center md:gap2 gap4>
|
|
|
|
<div
|
2023-01-02 20:19:36 +00:00
|
|
|
v-if="$slots.icon || icon"
|
2022-12-27 06:07:29 +00:00
|
|
|
flex items-center justify-center flex-shrink-0
|
2022-12-26 08:50:11 +00:00
|
|
|
:class="$slots.description ? 'w-12 h-12' : ''"
|
|
|
|
>
|
|
|
|
<slot name="icon">
|
2023-01-05 08:59:49 +00:00
|
|
|
<div
|
|
|
|
v-if="icon"
|
|
|
|
:class="[icon, large ? 'text-xl mr-1' : 'text-xl md:text-size-inherit']"
|
|
|
|
/>
|
2022-12-26 08:50:11 +00:00
|
|
|
</slot>
|
|
|
|
</div>
|
2023-01-11 22:24:00 +00:00
|
|
|
<div flex="~ col gap-0.5">
|
2022-12-26 08:50:11 +00:00
|
|
|
<p>
|
|
|
|
<slot>
|
|
|
|
<span>{{ text }}</span>
|
|
|
|
</slot>
|
|
|
|
</p>
|
2023-01-02 20:19:36 +00:00
|
|
|
<p v-if="$slots.description || description" text-sm text-secondary>
|
2022-12-29 20:01:31 +00:00
|
|
|
<slot name="description">
|
|
|
|
{{ description }}
|
|
|
|
</slot>
|
2022-12-26 08:50:11 +00:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-01-02 20:19:36 +00:00
|
|
|
<p v-if="$slots.content || content" text-sm text-secondary>
|
|
|
|
<slot name="content">
|
|
|
|
{{ content }}
|
|
|
|
</slot>
|
|
|
|
</p>
|
2023-01-04 14:43:17 +00:00
|
|
|
<div v-if="to" :class="!external ? 'i-ri:arrow-right-s-line' : 'i-ri:external-link-line'" text-xl text-secondary-light class="rtl-flip" />
|
2022-12-26 08:50:11 +00:00
|
|
|
</div>
|
|
|
|
</NuxtLink>
|
|
|
|
</template>
|