-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListView.svelte
More file actions
146 lines (131 loc) · 3.83 KB
/
Copy pathListView.svelte
File metadata and controls
146 lines (131 loc) · 3.83 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<script>
import { emails, currSelected } from './../fallback/stores.js'
import { _, locale } from 'svelte-i18n'
/** @type {{rightMode: any, searchTerm: any}} */
// eslint-disable-next-line no-useless-assignment
let { rightMode = $bindable(), searchTerm = $bindable() } = $props()
let sorted = $derived(
$emails &&
$emails.length > 0 &&
$emails.sort(
(a, b) =>
new Date(b.date).getTime() - new Date(a.date).getTime()
)
)
let sortedFiltered = $derived(
searchTerm
? sorted.filter(
(email) =>
email.raw
.toLowerCase()
.indexOf(searchTerm.toLowerCase()) > 0
)
: sorted
)
</script>
{#if sortedFiltered.length > 0}
<div class="email-list">
{#each sortedFiltered as email (email.id)}
<button
class="email-item"
class:selected={$currSelected === email.id}
onclick={(e) => {
e.preventDefault()
currSelected.set(email.id)
rightMode = 'MailView'
}}
type="button"
>
<span class="email-subject">{email.subject}</span>
<span class="email-sender">
{#if email.from.name}
{email.from.name}
{:else}
{email.from.address}
{/if}
</span>
<span class="email-date">
{new Date(email.date).toLocaleString($locale ?? undefined)}
</span>
</button>
{/each}
</div>
{:else}
<div class="empty-state">
<h4>{$_('fallback.list.nothing')}</h4>
<p>{$_('fallback.list.nothing2')}</p>
</div>
{/if}
<style lang="scss">
.email-list {
width: 100%;
display: flex;
flex-direction: column;
}
.email-item {
all: unset;
cursor: pointer;
display: flex;
flex-direction: column;
gap: 0.15rem;
padding: 0.75rem 1rem;
border-bottom: 1px solid var(--pg-input-normal);
text-align: left;
transition:
background 0.15s ease,
color 0.15s ease;
&:hover {
background: var(--pg-soft-background);
}
&.selected {
background: var(--pg-primary);
color: white;
.email-sender,
.email-date {
color: rgba(255, 255, 255, 0.85);
}
}
&:focus-visible {
outline: 2px solid var(--pg-primary);
outline-offset: -2px;
border-radius: var(--pg-border-radius-sm);
}
}
.email-subject {
font-weight: var(--pg-font-weight-bold);
font-size: var(--pg-font-size-sm);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.email-sender {
font-size: var(--pg-font-size-sm);
color: var(--pg-text-secondary);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.email-date {
font-size: var(--pg-font-size-xs);
color: var(--pg-text-secondary);
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 2rem 1.5rem;
text-align: center;
flex: 1;
h4 {
margin: 0 0 0.5rem;
font-size: var(--pg-font-size-md);
font-weight: var(--pg-font-weight-bold);
}
p {
margin: 0;
font-size: var(--pg-font-size-sm);
color: var(--pg-text-secondary);
}
}
</style>