<script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { cn } from "~/lib/utils"

const props = defineProps<{
  class?: HTMLAttributes["class"]
  link?: string
  hasClick?: boolean
}>()

const emit = defineEmits(["on-click"])
</script>

<template>
  <div
    :class="
      cn('rounded-lg border bg-card text-card-foreground shadow-xs transition-all isolate', props.class, {
        'relative hover:-translate-y-[.2rem]':
          props.link || props.hasClick
      })
    "
  >
    <NuxtLink
      v-if="props.link"
      :to="props.link"
      class="rounded-lg focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 absolute inset-0 z-10 cursor-pointer"
    />
    <button
      v-if="props.hasClick"
      class="rounded-lg focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 absolute inset-0 z-10 cursor-pointer"
      @click="emit('on-click')"
    />

    <slot />
  </div>
</template>
