File size: 2,383 Bytes
7428b13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
120
121
122
123
124
<script lang="ts">
  import type { PicletInstance } from '$lib/db/schema';
  
  export let piclet: PicletInstance;
  export let hpPercentage: number;
  export let isPlayer: boolean;
  
  $: hpColor = hpPercentage > 0.5 ? '#4caf50' : hpPercentage > 0.25 ? '#ffc107' : '#f44336';
  $: displayHp = Math.max(0, Math.round(piclet.currentHp * hpPercentage));
</script>

<div class="piclet-info {isPlayer ? 'player-info' : 'enemy-info'}">
  <div class="info-header">
    <span class="piclet-name">{piclet.nickname}</span>
    <span class="piclet-level">Lv.{piclet.level}</span>
  </div>
  
  <div class="hp-container">
    <div class="hp-label">HP</div>
    <div class="hp-bar-wrapper">
      <div class="hp-bar-bg">
        <div 
          class="hp-bar-fill" 
          style="width: {hpPercentage * 100}%; background-color: {hpColor}"
        ></div>
      </div>
    </div>
  </div>
  
  {#if isPlayer}
    <div class="hp-text">
      {displayHp} / {piclet.maxHp}
    </div>
  {/if}
</div>

<style>
  .piclet-info {
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #333;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    min-width: 200px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  }
  
  .player-info {
    order: 2;
  }
  
  .enemy-info {
    order: 1;
  }
  
  .info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
  }
  
  .piclet-name {
    font-weight: 600;
    font-size: 1rem;
    color: #1a1a1a;
  }
  
  .piclet-level {
    font-size: 0.875rem;
    color: #666;
  }
  
  .hp-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
  
  .hp-label {
    font-weight: 600;
    font-size: 0.75rem;
    color: #666;
  }
  
  .hp-bar-wrapper {
    flex: 1;
  }
  
  .hp-bar-bg {
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
  }
  
  .hp-bar-fill {
    height: 100%;
    transition: width 0.5s ease, background-color 0.3s ease;
    border-radius: 4px;
  }
  
  .hp-text {
    text-align: right;
    font-size: 0.75rem;
    color: #666;
    margin-top: 0.25rem;
  }
  
  @media (max-width: 768px) {
    .piclet-info {
      min-width: 150px;
      padding: 0.5rem 0.75rem;
    }
    
    .piclet-name {
      font-size: 0.875rem;
    }
    
    .piclet-level {
      font-size: 0.75rem;
    }
  }
</style>