This repository has been archived by the owner on Dec 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 84
/
Message.svelte
91 lines (75 loc) · 1.58 KB
/
Message.svelte
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
<script>
import { getContext } from 'svelte';
import { slide } from 'svelte/transition';
const { navigate } = getContext('REPL');
export let kind;
export let details = null;
export let filename = null;
export let truncate;
function message(details) {
let str = details.message || '[missing message]';
let loc = [];
if (details.filename && details.filename !== filename) {
loc.push(details.filename);
}
if (details.start) loc.push(details.start.line, details.start.column);
return str + (loc.length ? ` (${loc.join(':')})` : ``);
};
</script>
<style>
.message {
position: relative;
color: white;
padding: 12px 16px 12px 44px;
font: 400 12px/1.7 var(--font);
margin: 0;
border-top: 1px solid white;
}
.navigable {
cursor: pointer;
}
.message::before {
content: '!';
position: absolute;
left: 12px;
top: 10px;
text-align: center;
line-height: 1;
padding: 4px;
border-radius: 50%;
color: white;
border: 2px solid white;
box-sizing: content-box;
width: 10px;
height: 10px;
font-size: 11px;
font-weight: 700;
}
.truncate {
white-space: pre;
overflow-x: hidden;
text-overflow: ellipsis;
}
p {
margin: 0;
}
.error {
background-color: #da106e;
}
.warning {
background-color: #e47e0a;
}
.info {
background-color: var(--second);
}
</style>
<div in:slide={{delay: 150, duration: 100}} out:slide={{duration: 100}} class="message {kind}" class:truncate>
{#if details}
<p
class:navigable={details.filename}
on:click="{() => navigate(details)}"
>{message(details)}</p>
{:else}
<slot></slot>
{/if}
</div>