All files / components/organisms/PostCard PostCard.vue

95% Statements 19/20
100% Branches 0/0
100% Functions 0/0
95% Lines 19/20

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 621x   1x 1x   1x     1x   1x 1x   1x       1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x                                                                    
<script setup lang="ts">
import type { Post } from "@/types/api";
import { useDark } from "@vueuse/core";
import { ref, watch } from "vue";
 
const props = defineProps<{
  post: Post;
}>();
const link: string = `/post/${props.post.id}`;
 
const isDark = ref(useDark().value);
watch(useDark(), () => {
  isDark.value = useDark().value;
});
</script>
 
<template>
  <div :class="$style.card">
    <a
      :class="[$style.post_link, { [$style.dark]: isDark }]"
      class="post_link"
      :href="link"
      >{{ post.title }}</a
    >
    <p :class="[$style.post_body, { [$style.dark]: isDark }]">
      {{ post.body }}
    </p>
  </div>
</template>
 
<style module>
.card {
  cursor: pointer;
  border: solid 1px #e1e1e1;
  box-sizing: border-box;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.16);
  overflow: hidden;
  height: 160px;
 
  .dark {
    color: #bfcbd9;
  }
}
 
.post_link {
  display: block;
  padding: 1em;
  height: calc(100% - 2em);
  color: #111827;
  font-size: 32px;
  font-weight: 700;
}
 
.post_body {
  margin-top: -70px;
  padding: 0 3em;
  color: #111827;
  font-size: 18px;
  line-height: 125%;
}
</style>