matthartman commited on
Commit
6150b06
·
verified ·
1 Parent(s): 150e09e

Upload src/App.svelte with huggingface_hub

Browse files
Files changed (1) hide show
  1. src/App.svelte +134 -41
src/App.svelte CHANGED
@@ -1,47 +1,140 @@
 
1
  <script lang="ts">
2
- import svelteLogo from './assets/svelte.svg'
3
- import viteLogo from '/vite.svg'
4
- import Counter from './lib/Counter.svelte'
5
- </script>
6
 
7
- <main>
8
- <div>
9
- <a href="https://vite.dev" target="_blank" rel="noreferrer">
10
- <img src={viteLogo} class="logo" alt="Vite Logo" />
11
- </a>
12
- <a href="https://svelte.dev" target="_blank" rel="noreferrer">
13
- <img src={svelteLogo} class="logo svelte" alt="Svelte Logo" />
14
- </a>
15
- </div>
16
- <h1>Vite + Svelte</h1>
17
-
18
- <div class="card">
19
- <Counter />
20
- </div>
21
-
22
- <p>
23
- Check out <a href="https://github.com/sveltejs/kit#readme" target="_blank" rel="noreferrer">SvelteKit</a>, the official Svelte app framework powered by Vite!
24
- </p>
25
-
26
- <p class="read-the-docs">
27
- Click on the Vite and Svelte logos to learn more
28
- </p>
29
- </main>
30
-
31
- <style>
32
- .logo {
33
- height: 6em;
34
- padding: 1.5em;
35
- will-change: filter;
36
- transition: filter 300ms;
37
  }
38
- .logo:hover {
39
- filter: drop-shadow(0 0 2em #646cffaa);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  }
41
- .logo.svelte:hover {
42
- filter: drop-shadow(0 0 2em #ff3e00aa);
 
 
 
43
  }
44
- .read-the-docs {
45
- color: #888;
 
 
 
46
  }
47
- </style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!-- src/App.svelte -->
2
  <script lang="ts">
3
+ import { onMount } from 'svelte';
4
+ import EmailCard from './lib/EmailCard.svelte';
5
+ import LoadingSpinner from './lib/LoadingSpinner.svelte';
6
+ import ErrorMessage from './lib/ErrorMessage.svelte';
7
 
8
+ interface Email {
9
+ id: string;
10
+ from: string;
11
+ subject: string;
12
+ body: string;
13
+ date: string;
14
+ snippet: string;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  }
16
+
17
+ let emails: Email[] = [];
18
+ let currentIndex = 0;
19
+ let loading = true;
20
+ let error: string | null = null;
21
+
22
+ async function fetchEmails() {
23
+ try {
24
+ loading = true;
25
+ error = null;
26
+
27
+ // Simulated Gmail API response
28
+ // In a real app, you would use Google's Gmail API
29
+ const mockEmails: Email[] = [
30
+ {
31
+ id: '1',
32
+ from: 'GitHub <[email protected]>',
33
+ subject: 'New pull request created',
34
+ body: 'A new pull request has been created in the repository. Please review the changes and provide feedback.',
35
+ date: '2024-01-15 10:30 AM',
36
+ snippet: 'A new pull request has been created...'
37
+ },
38
+ {
39
+ id: '2',
40
+ from: 'Netflix <[email protected]>',
41
+ subject: 'New releases this week',
42
+ body: 'Discover the latest movies and TV shows added to Netflix this week. Don\'t miss out on the trending titles!',
43
+ date: '2024-01-15 9:15 AM',
44
+ snippet: 'Discover the latest movies and TV shows...'
45
+ },
46
+ {
47
+ id: '3',
48
+ from: 'Amazon <[email protected]>',
49
+ subject: 'Your order has been shipped',
50
+ body: 'Your package is on the way! Track your order #12345-ABCD-67890 and see the estimated delivery date.',
51
+ date: '2024-01-15 8:45 AM',
52
+ snippet: 'Your package is on the way! Track your order...'
53
+ },
54
+ {
55
+ id: '4',
56
+ from: 'LinkedIn <[email protected]>',
57
+ subject: 'You have 3 new connection requests',
58
+ body: 'Expand your professional network by connecting with these 3 people who have requested to connect with you.',
59
+ date: '2024-01-14 6:20 PM',
60
+ snippet: 'Expand your professional network...'
61
+ }
62
+ ];
63
+
64
+ await new Promise(resolve => setTimeout(resolve, 1000));
65
+ emails = mockEmails;
66
+
67
+ } catch (err) {
68
+ error = 'Failed to load emails. Please check your connection and try again.';
69
+ } finally {
70
+ loading = false;
71
+ }
72
  }
73
+
74
+ function nextEmail() {
75
+ if (currentIndex < emails.length - 1) {
76
+ currentIndex++;
77
+ }
78
  }
79
+
80
+ function previousEmail() {
81
+ if (currentIndex > 0) {
82
+ currentIndex--;
83
+ }
84
  }
85
+
86
+ onMount(() => {
87
+ fetchEmails();
88
+ });
89
+ </script>
90
+
91
+ <main>
92
+ <header>
93
+ <h1>Gmail Reader</h1>
94
+ <button
95
+ class="refresh-btn"
96
+ on:click={fetchEmails}
97
+ disabled={loading}
98
+ aria-label="Refresh emails"
99
+ >
100
+ ↻ Refresh
101
+ </button>
102
+ </header>
103
+
104
+ {#if loading}
105
+ <LoadingSpinner />
106
+ {:else if error}
107
+ <ErrorMessage {error} onRetry={fetchEmails} />
108
+ {:else if emails.length === 0}
109
+ <div class="empty-state">
110
+ <h2>No emails found</h2>
111
+ <p>Your inbox is empty. Check back later!</p>
112
+ </div>
113
+ {:else}
114
+ <div class="email-container">
115
+ <EmailCard email={emails[currentIndex]} />
116
+
117
+ <div class="navigation">
118
+ <button
119
+ on:click={previousEmail}
120
+ disabled={currentIndex === 0}
121
+ aria-label="Previous email"
122
+ >
123
+ ← Previous
124
+ </button>
125
+
126
+ <span class="counter">
127
+ {currentIndex + 1} of {emails.length}
128
+ </span>
129
+
130
+ <button
131
+ on:click={nextEmail}
132
+ disabled={currentIndex === emails.length - 1}
133
+ aria-label="Next email"
134
+ >
135
+ Next →
136
+ </button>
137
+ </div>
138
+ </div>
139
+ {/if}
140
+ </main>