MainTitleList.vue
2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<template>
<div class="text-blue-darken-1 text-h3 tw-text-center tw-mb-[16px] font-weight-bold">
<div :class="titleCls">{{ title }}</div>
</div>
<div class="text-body-1 tw-max-w-[600px] tw-m-auto tw-mb-8">
<span class="">{{ desc }}</span>
<router-link :to="href" v-if="href">
<span
class="font-weight-bold text-decoration-underline tw-inline-block tw-underline tw-text-sky-500 hover:tw-text-sky-800"
>detail
<v-icon class="tw-mt-[-4px]" size="18" icon="mdi-arrow-right"></v-icon>
</span>
</router-link>
</div>
<v-item-group multiple v-if="!responsive">
<v-row>
<v-col v-for="(item, index) in list" :key="index" cols="12" :lg="lgCol" md="4" sm="6">
<v-hover v-slot="{ isHovering, props }" open-delay="200" :disabled="disabled">
<v-card
color="blue-darken-1"
variant="outlined"
:elevation="isHovering ? 16 : 2"
:class="{ 'on-hover': isHovering }"
class="mx-auto"
height="295"
width="260"
v-bind="props"
:href="item.href ? item.href : undefined"
>
<v-img :src="item.imageUrl" />
<div
class="text-center bg-blue-darken-1 tw-absolute tw-bottom-0 tw-text-center tw-w-full tw-h-9 tw-leading-9"
>
{{ item.name }}
</div>
</v-card>
</v-hover>
</v-col>
</v-row>
</v-item-group>
<v-item-group multiple v-if="responsive">
<v-row>
<v-col v-for="(item, index) in list" :key="index">
<v-hover v-slot="{ isHovering, props }" open-delay="200" :disabled="disabled">
<v-card
color="blue-darken-1"
variant="outlined"
:elevation="isHovering ? 16 : 2"
:class="{ 'on-hover': isHovering }"
class="pt-5 mx-auto"
height="350"
v-bind="props"
:href="item.href ? item.href : undefined"
>
<v-img :src="item.imageUrl" width="250" class="text-center ma-auto" />
<div
class="text-center bg-blue-darken-1 tw-absolute tw-bottom-0 tw-text-center tw-w-full tw-h-9 tw-leading-9"
>
{{ item.name }}
</div>
</v-card>
</v-hover>
</v-col>
</v-row>
</v-item-group>
<!-- <li class="tw-flex-1 tw-flex-row item tw-mb-8"></li> -->
</template>
<script setup lang="ts">
import type { Category } from '@/type'
import { computed, ref } from 'vue'
const props = defineProps<{
title: string
desc?: string
list: Category[] | { name: string; imageUrl?: string; href: string }[]
cardNum?: number
href?: string
disabled?: boolean
responsive?: boolean
titleCls?: string
titleDivider?: boolean
}>()
const lgCol = computed(() => (props.cardNum === 3 ? 4 : 3))
</script>