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