starfleet-ui
Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.
Dernier runRéussi#6 · main · 2 min 01 s
0Étoiles
0Forks
0Issues
| 1 | <script lang="ts"> |
| 2 | import type { LogEntry } from '$lib/types'; |
| 3 | |
| 4 | interface Props { |
| 5 | entries: LogEntry[]; |
| 6 | unread: number; |
| 7 | open: boolean; |
| 8 | onToggle: () => void; |
| 9 | } |
| 10 | |
| 11 | let { entries, unread, open, onToggle }: Props = $props(); |
| 12 | |
| 13 | const time = (at: string) => new Date(at).toLocaleTimeString('en-GB', { hour12: false }); |
| 14 | const kindLabel = (k: string) => k.replace(/^[a-z]+\./, '').replaceAll('_', ' '); |
| 15 | const TONE: Record<string, string> = { |
| 16 | ship: 'text-cyan-400', |
| 17 | system: 'text-violet-300', |
| 18 | trade: 'text-amber-300', |
| 19 | contract: 'text-emerald-300' |
| 20 | }; |
| 21 | </script> |
| 22 | |
| 23 | <section class="hud-panel pointer-events-auto flex min-h-0 flex-col overflow-hidden"> |
| 24 | <button |
| 25 | onclick={onToggle} |
| 26 | aria-expanded={open} |
| 27 | class="flex items-center justify-between gap-2 px-3 py-2 text-left hover:bg-slate-800/40" |
| 28 | > |
| 29 | <span class="hud-label flex items-center gap-2"> |
| 30 | <span class="relative flex h-2 w-2"> |
| 31 | <span class="absolute inline-flex h-full w-full animate-ping rounded-full bg-cyan-400 opacity-50"></span> |
| 32 | <span class="relative inline-flex h-2 w-2 rounded-full bg-cyan-400"></span> |
| 33 | </span> |
| 34 | Captain's log |
| 35 | </span> |
| 36 | {#if unread && !open} |
| 37 | <span class="rounded-full bg-cyan-500 px-1.5 text-[10px] font-bold text-slate-950">{unread}</span> |
| 38 | {:else} |
| 39 | <span class="text-xs text-slate-500" aria-hidden="true">{open ? '▾' : '▴'}</span> |
| 40 | {/if} |
| 41 | </button> |
| 42 | {#if open} |
| 43 | <ol class="max-h-64 space-y-1.5 overflow-y-auto px-3 pb-3" aria-live="polite"> |
| 44 | {#each entries as e (e.number)} |
| 45 | <li class="animate-rise text-xs leading-snug"> |
| 46 | <span class="font-mono text-[10px] text-slate-500 tabular-nums">{time(e.at)}</span> |
| 47 | <span class="ml-1 text-[10px] font-bold tracking-wider uppercase {TONE[e.kind.split('.')[0]] ?? 'text-slate-400'}"> |
| 48 | {kindLabel(e.kind)} |
| 49 | </span> |
| 50 | <p class="text-slate-300">{e.text}</p> |
| 51 | </li> |
| 52 | {:else} |
| 53 | <li class="text-xs text-slate-500 italic">Quiet so far.</li> |
| 54 | {/each} |
| 55 | </ol> |
| 56 | {/if} |
| 57 | </section> |