2022-12-26 08:50:11 +00:00
|
|
|
<script lang="ts" setup>
|
|
|
|
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
|
2022-12-26 08:50:11 +00:00
|
|
|
}>()
|
|
|
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
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
|
|
|
|
?? (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"
|
2022-12-26 08:50:11 +00:00
|
|
|
exact-active-class="text-primary"
|
2023-01-05 08:47:58 +00:00
|
|
|
:class="disabled ? 'op25 pointer-events-none ' : ''"
|
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"
|
2023-01-02 20:19:36 +00:00
|
|
|
@click="to ? $scrollToTop() : undefined"
|
2022-12-26 08:50:11 +00:00
|
|
|
>
|
|
|
|
<div
|
|
|
|
w-full flex w-fit px5 py3 md:gap2 gap4 items-center
|
|
|
|
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>
|
|
|
|
<div space-y-1>
|
|
|
|
<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>
|