-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
LastCommit.svelte
71 lines (61 loc) · 1.66 KB
/
LastCommit.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
<script lang="ts">
import { formatDistanceToNow } from 'date-fns'
import Avatar from '$lib/Avatar.svelte'
import type { LastCommitFragment } from './LastCommit.gql'
export let lastCommit: LastCommitFragment
$: user = lastCommit.author.person
$: canonicalURL = lastCommit.canonicalURL
$: commitMessage = lastCommit.subject
$: commitDate = formatDistanceToNow(lastCommit.author.date, { addSuffix: true })
</script>
<div class="last-commit">
<div class="avatar">
<Avatar avatar={user} />
</div>
<div class="display-name">
<span class="label">{user.displayName || user.name}</span>
</div>
<div class="commit-message">
<a href={canonicalURL}>
{commitMessage}
</a>
</div>
<div class="commit-date">
{commitDate}
</div>
</div>
<style lang="scss">
.last-commit {
display: flex;
flex-flow: row nowrap;
align-items: center;
justify-content: space-between;
margin-right: 0.5rem;
white-space: nowrap;
max-width: 400px;
font-size: var(--font-size-small);
}
.avatar {
display: flex;
flex-flow: row nowrap;
align-items: center;
margin-right: 0.5rem;
--avatar-size: 1.5rem;
}
.display-name {
margin-right: 0.75rem;
color: var(--text-body);
}
.commit-message {
align-items: center;
color: var(--text-muted);
margin-right: 0.5rem;
max-width: 240px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.commit-date {
color: var(--text-muted);
}
</style>