All files / src/components UnifiedContentCard.vue

66.66% Statements 4/6
60% Branches 3/5
0% Functions 0/1
66.66% Lines 4/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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  44x                         4x                             38x                                     38x                                                                
<template>
  <div
    class="card unified-content-card h-100 position-relative"
    :class="[extraClasses, { 'card-clickable': clickable, 'border-primary': active }]"
    @click="handleCardClick"
  >
    <div
      v-if="$slots.actions"
      class="card-actions"
      :class="{ 'd-none d-md-flex': hideActionsOnMobile }"
    >
      <slot name="actions" />
    </div>
 
    <div class="card-body">
      <slot />
    </div>
 
    <div v-if="$slots.footer" class="card-footer border-top">
      <slot name="footer" />
    </div>
  </div>
</template>
 
<script setup lang="ts">
import type { PropType } from 'vue'
 
type CardClass = string | string[] | Record<string, boolean>
 
const props = defineProps({
  clickable: {
    type: Boolean,
    default: false
  },
  active: {
    type: Boolean,
    default: false
  },
  hideActionsOnMobile: {
    type: Boolean,
    default: true
  },
  extraClasses: {
    type: [String, Array, Object] as PropType<CardClass>,
    default: ''
  }
})
 
const emit = defineEmits<{
  click: []
}>()
 
function handleCardClick() {
  if (props.clickable) {
    emit('click')
  }
}
</script>
 
<style scoped>
.card-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  display: flex;
  gap: 4px;
}
 
.card-actions :deep(.action-icon) {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  border-radius: 4px;
  opacity: 0.92;
}
 
.card-actions :deep(.action-icon:hover) {
  opacity: 1;
}
</style>