MainTitleList.vue 2.46 KB
<template>
  <div class="text-blue-darken-2 text-h3 tw-text-center tw-mb-8">
    <span :class="titleCls">{{ title }}</span>
  </div>
  <v-divider class="border-opacity-30 tw-mb-[16px]" color="" v-if="titleDivider"></v-divider>
  <div class="text-body-1 tw-text-left tw-mb-8">
    <span>{{ 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-600 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
            :elevation="isHovering ? 16 : 2"
            :class="{ 'on-hover': isHovering }"
            class="mx-auto"
            height="350"
            width="260"
            v-bind="props"
          >
            <v-img :src="item.imageUrl" />
            <v-card-text class="text-center font-weight-medium text-subtitle-1">
              {{ item.name }}
            </v-card-text>
          </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
            :elevation="isHovering ? 16 : 2"
            :class="{ 'on-hover': isHovering }"
            class="mx-auto"
            height="350"
            v-bind="props"
          >
            <v-img :src="item.imageUrl" />
            <v-card-text class="text-center font-weight-medium text-subtitle-1">
              {{ item.name }}
            </v-card-text>
          </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 }[]
  cardNum?: number
  href?: string
  disabled?: boolean
  responsive?: boolean
  titleCls?: string
  titleDivider?: boolean
}>()

const lgCol = computed(() => (props.cardNum === 3 ? 4 : 3))
</script>