|
1 | 1 | <script lang="ts">
|
2 |
| - import Since from '$lib/time/since.svelte'; |
3 |
| - import { onMount } from 'svelte'; |
| 2 | + import RefreshIcon from '$lib/icons/refresh-icon.svelte'; |
| 3 | + import FormattedDate from '$lib/time/formatted-date.svelte'; |
| 4 | + import { Card } from '@gleich/ui'; |
4 | 5 |
|
5 |
| - const loadingFrames = [ |
6 |
| - '[ ]', // 0% |
7 |
| - '[⋅ ]', // 6.25% |
8 |
| - '[⋅⋅ ]', // 12.5% |
9 |
| - '[⋅⋅⋅ ]', // 18.75% |
10 |
| - '[ ⋅⋅⋅]', // 25% |
11 |
| - '[ ⋅⋅]', // 31.25% |
12 |
| - '[ ⋅]', // 37.5% |
13 |
| - '[ ]', // 43.75% |
14 |
| - '[ ⋅]', // 50% |
15 |
| - '[ ⋅⋅]', // 56.25% |
16 |
| - '[ ⋅⋅⋅]', // 62.5% |
17 |
| - '[⋅⋅⋅⋅]', // 68.75% |
18 |
| - '[⋅⋅⋅ ]', // 75% |
19 |
| - '[⋅⋅ ]', // 81.25% |
20 |
| - '[⋅ ]', // 87.5% |
21 |
| - '[ ]', // 93.75% |
22 |
| - '[ ]' // 100% |
23 |
| - ]; |
24 |
| - let frameIndex = $state(0); |
25 |
| - let frame = $derived(loadingFrames[frameIndex]); |
26 |
| -
|
27 |
| - onMount(() => { |
28 |
| - const interval = setInterval(() => { |
29 |
| - frameIndex = (frameIndex + 1) % loadingFrames.length; |
30 |
| - }, 30); |
31 |
| - return () => clearInterval(interval); |
32 |
| - }); |
33 |
| -
|
34 |
| - const { name, updated }: { name: string; updated?: Date } = $props(); |
| 6 | + const { |
| 7 | + name, |
| 8 | + updated, |
| 9 | + updateFrequency |
| 10 | + }: { name: string; updated?: Date; updateFrequency: string } = $props(); |
35 | 11 | </script>
|
36 | 12 |
|
37 |
| -<div class="container"> |
38 |
| - <p class="frame">{frame}</p> |
39 |
| - <p class="online">ONLINE</p> |
40 |
| - <p class="name">{name} <span class="cache-text"> cache</span></p> |
41 |
| - <p class="updated"><Since time={updated ?? new Date()} /></p> |
42 |
| -</div> |
| 13 | +<Card padding="0"> |
| 14 | + <div class="container"> |
| 15 | + <div class="header"> |
| 16 | + <p class="cache-name">{name} Cache</p> |
| 17 | + {#if updated} |
| 18 | + <p class="online">ONLINE</p> |
| 19 | + {:else} |
| 20 | + <p class="offline">OFFLINE</p> |
| 21 | + {/if} |
| 22 | + </div> |
| 23 | + </div> |
| 24 | + <div class="refresh"> |
| 25 | + <div class="refresh-icon"> |
| 26 | + <RefreshIcon /> |
| 27 | + </div> |
| 28 | + <p>{updateFrequency}</p> |
| 29 | + </div> |
| 30 | + <div class="updated"> |
| 31 | + {#if updated} |
| 32 | + Updated <FormattedDate lowercase time={updated} /> |
| 33 | + {:else} |
| 34 | + Cache is currently offline |
| 35 | + {/if} |
| 36 | + </div> |
| 37 | +</Card> |
43 | 38 |
|
44 | 39 | <style>
|
45 |
| - .container { |
46 |
| - display: flex; |
47 |
| - gap: 5px; |
| 40 | + .cache-name { |
| 41 | + font-size: 19px; |
| 42 | + padding-left: 10px; |
| 43 | + padding-top: 6px; |
| 44 | + font-family: 'Inter'; |
| 45 | + font-weight: 700; |
| 46 | + background-color: #343537; |
| 47 | + box-shadow: inset 0px 0px 6px var(--box-shadow-color); |
| 48 | + border: 1px solid var(--border); |
| 49 | + border-top: 0; |
| 50 | + border-left: 0; |
| 51 | + border-bottom-right-radius: var(--border-radius); |
| 52 | + padding-bottom: 5px; |
| 53 | + padding-right: 10px; |
48 | 54 | }
|
49 | 55 |
|
50 |
| - .frame { |
51 |
| - white-space: pre; |
52 |
| - display: inline-block; |
53 |
| - font-family: 'IBM Plex Mono'; |
| 56 | + .header { |
| 57 | + display: flex; |
| 58 | + justify-content: space-between; |
54 | 59 | }
|
55 | 60 |
|
56 |
| - .name { |
57 |
| - width: 120px; |
| 61 | + .online, |
| 62 | + .offline { |
| 63 | + font-family: 'IBM Plex Mono'; |
| 64 | + display: flex; |
| 65 | + align-items: center; |
| 66 | + padding: 4px 10px; |
| 67 | + border-top: 0 !important; |
| 68 | + border-right: 0 !important; |
| 69 | + font-size: 14px; |
| 70 | + border-bottom-left-radius: var(--border-radius); |
58 | 71 | }
|
59 | 72 |
|
60 | 73 | .online {
|
61 | 74 | color: var(--green-foreground);
|
62 | 75 | background-color: var(--green-background);
|
63 |
| - padding: 0 5px; |
64 |
| - margin: 0 5px; |
65 |
| - border-radius: 2px; |
| 76 | + border: 1px solid var(--green-border); |
| 77 | + } |
| 78 | +
|
| 79 | + .offline { |
| 80 | + color: var(--red-foreground); |
| 81 | + background-color: var(--red-background); |
| 82 | + border: 1px solid var(--red-border); |
| 83 | + } |
| 84 | +
|
| 85 | + .refresh { |
| 86 | + padding: 20px 10px; |
| 87 | + display: flex; |
| 88 | + gap: 10px; |
| 89 | + align-items: center; |
| 90 | + justify-content: center; |
| 91 | + } |
| 92 | +
|
| 93 | + .refresh-icon :global(svg) { |
| 94 | + position: relative; |
| 95 | + top: 1px; |
| 96 | + width: 14px; |
| 97 | + height: 14px; |
| 98 | + animation: spin 3s linear infinite; |
| 99 | + transform-origin: center; |
66 | 100 | }
|
67 | 101 |
|
68 | 102 | .updated {
|
69 |
| - margin-left: 5px; |
70 | 103 | color: grey;
|
| 104 | + border-top: 1px solid var(--border); |
| 105 | + padding: 5px; |
| 106 | + display: flex; |
| 107 | + align-items: center; |
| 108 | + justify-content: center; |
| 109 | + font-size: 14px; |
71 | 110 | }
|
72 | 111 |
|
73 |
| - @media (max-width: 450px) { |
74 |
| - .cache-text { |
75 |
| - display: none; |
| 112 | + @keyframes spin { |
| 113 | + to { |
| 114 | + transform: rotate(360deg); |
76 | 115 | }
|
| 116 | + } |
77 | 117 |
|
78 |
| - .name { |
79 |
| - width: 80px; |
| 118 | + @media (max-width: 500px) { |
| 119 | + .cache-name { |
| 120 | + font-size: 15px; |
80 | 121 | }
|
81 | 122 | }
|
82 | 123 | </style>
|
0 commit comments