aboutsummaryrefslogtreecommitdiff
path: root/src/components/Comment.svelte
blob: bc53f4d1b09b6a9f5fc138f8320eec2205c2d790 (plain)
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
<script lang="ts">
  import { creatorColor, formatTime } from '../lib/util';
  import type Comment from '../models/Thread';
  export let comment: Comment;
</script>


<div class="commentbox" id="{comment.id}">

  <span style="line-height: 2rem;">
    <span style="font-family: mono">{comment.id}</span>
    at {formatTime(comment.creationDate)} <br>
    ->  <span style="{creatorColor(comment.commentCreator)}; font-family: mono">
      {comment.commentCreator}
    </span> <br>
  </span>

  {#if comment.imageId!= null && comment.imageId != undefined}
    {#if comment.fileType == 'image'}
      <a href="{comment.imageId}" target="_blank" rel="noopener noreferrer">
        <img src="{comment.imageId}" alt="{comment.imageId}" height="300px" width="300px"> <br>
      </a>
    {:else if comment.fileType == 'video'}
      <video width="320" height="240" controls muted>
        <source src="{comment.imageId}">
      </video>
    {/if}
  {/if}

<p>{@html comment.commentText}</p>

</div>

<style>
  .commentbox {
    width: 500px;
    border: 5px solid green;
    padding: 10px;
    margin: 10px;
    background-color: white;
  }
  :target, .targeted {
    background-color: #ffa;
  }
</style>