Skip to content

Commit 70e4a4e

Browse files
authored
Create Banner.svelte
1 parent 7564b61 commit 70e4a4e

1 file changed

Lines changed: 97 additions & 0 deletions

File tree

app/src/components/Banner.svelte

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<script lang="ts">
2+
import {
3+
ArrowRight,
4+
Check,
5+
CloudAlert,
6+
ServerOff,
7+
Wrench,
8+
} from "@lucide/svelte";
9+
10+
const {
11+
type = "fail",
12+
message,
13+
href,
14+
since = 1,
15+
till,
16+
}: StatusMessage = $props();
17+
18+
const messages = {
19+
issues: "We're having issues - some features may be unavailable",
20+
outage: "We're experiencing a major outage - working on it",
21+
annoucement: "",
22+
resolved: "Issues have been resolved!",
23+
fail: "Unable to fetch status info. Please click here to view our status page.",
24+
};
25+
</script>
26+
27+
{#snippet icon(type: StatusMessage["type"])}
28+
{#if type == "issues"}
29+
<Wrench size="1rem" />
30+
{:else if type == "outage"}
31+
<ServerOff size="1rem" />
32+
{:else if type == "resolved"}
33+
<Check size="1rem" />
34+
{:else if type == "fail"}
35+
<CloudAlert size="1rem" />
36+
{/if}
37+
{/snippet}
38+
39+
{#if !href && type != "fail"}
40+
<div id="banner" class={type} class:annoucement={!type && message}>
41+
{@render icon(type)}
42+
{#if !message && type in messages}
43+
{messages[type]}
44+
{:else}
45+
{message}
46+
{/if}
47+
</div>
48+
{:else}
49+
<a
50+
id="banner"
51+
href={href ? href : "https://status.unii.dev/"}
52+
target="_blank"
53+
class="link {type}"
54+
class:annoucement={!type && message}
55+
>
56+
{@render icon(type)}
57+
{#if !message && type in messages}
58+
{messages[type]}
59+
{:else}
60+
{message}
61+
{/if}
62+
<ArrowRight size="1rem" />
63+
</a>
64+
{/if}
65+
66+
<style lang="scss">
67+
#banner {
68+
--background: #141414;
69+
70+
display: flex;
71+
justify-content: center;
72+
align-items: center;
73+
padding: 0.25rem 0.5rem;
74+
gap: 0.5rem;
75+
background: var(--background);
76+
77+
&.outage {
78+
--background: #cb1d1d;
79+
}
80+
81+
&.issues {
82+
--background: #e48e24;
83+
}
84+
85+
&.annoucement {
86+
--background: #33596d;
87+
}
88+
89+
&.resolved {
90+
--background: #336d44;
91+
}
92+
}
93+
94+
a:hover {
95+
cursor: pointer;
96+
}
97+
</style>

0 commit comments

Comments
 (0)