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