All files / src/components CardPicture.vue

100% Statements 4/4
100% Branches 4/4
100% Functions 0/0
100% Lines 4/4

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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119    148x                       8x           8x                                 148x                                                                                                                                                                  
<template>
  <ImageField
    v-if="picture"
    :model-value="picture"
    :field="{ name: 'picture', type: 'image', fieldId: 'picture' }"
    :is-editing="false"
    :entity-id="entityId"
    :item-id="entityId"
    object-fit="cover"
    no-thumbnail
    :clickable="false"
    no-wrapper
  />
  <div v-else class="default-picture">
    <div class="default-picture-inner">
      <div class="default-picture-art">
        <span class="default-picture-sun" />
        <span class="default-picture-mountain default-picture-mountain-back" />
        <span class="default-picture-mountain default-picture-mountain-front" />
      </div>
      <span class="default-picture-label">{{ t('common.noImage') }}</span>
    </div>
  </div>
</template>
 
<script setup lang="ts">
// The picture at the top of a card (an entity's, a pack's), or a drawing
// saying there is none. The card sizes its container.
import ImageField from '@/components/ImageField.vue'
import { useUILanguage } from '@/composables/useUILanguage'
 
defineProps<{
  picture?: string | null
  // The entity the picture is an entity's own, for reading it
  entityId?: string
}>()
 
const { t } = useUILanguage()
</script>
 
<style scoped>
.default-picture {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.08), transparent 45%),
    radial-gradient(circle at 70% 80%, rgba(255, 255, 255, 0.06), transparent 50%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.03), rgba(0, 0, 0, 0.08));
  color: rgba(255, 255, 255, 0.35);
}
 
.default-picture-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
 
.default-picture-art {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.08));
  overflow: hidden;
}
 
.default-picture-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.7rem;
  opacity: 0.85;
  letter-spacing: 0.03em;
  line-height: 1;
  white-space: nowrap;
  color: rgba(230, 236, 245, 0.95);
  background: rgba(15, 20, 30, 0.48);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 0.28rem 0.6rem;
  backdrop-filter: blur(2px);
}
 
.default-picture-sun {
  position: absolute;
  top: 18%;
  left: 20%;
  width: 1rem;
  height: 1rem;
  border-radius: 999px;
  background: rgba(20, 28, 40, 0.45);
}
 
.default-picture-mountain {
  position: absolute;
  bottom: -2px;
  width: 56%;
  height: 54%;
  background: rgba(20, 28, 40, 0.62);
  clip-path: polygon(0% 100%, 34% 48%, 56% 70%, 72% 38%, 100% 100%);
}
 
.default-picture-mountain-back {
  left: -2%;
  opacity: 0.75;
}
 
.default-picture-mountain-front {
  right: -2%;
}
</style>