rafmacalaba commited on
Commit
46de1a2
·
1 Parent(s): 36b41a7

feat: format dropdown names and add light/dark theme toggle

Browse files
app/api/documents/route.js CHANGED
@@ -151,6 +151,7 @@ export async function GET(request) {
151
  corpus: corpus.id,
152
  corpus_name: corpus.name,
153
  index: link.index,
 
154
  pdf_url: pdfUrl,
155
  landing_page: link.landing_page_url,
156
  annotatable_pages: allPages,
 
151
  corpus: corpus.id,
152
  corpus_name: corpus.name,
153
  index: link.index,
154
+ original_name: link.original_name,
155
  pdf_url: pdfUrl,
156
  landing_page: link.landing_page_url,
157
  annotatable_pages: allPages,
app/components/DocumentSelector.js CHANGED
@@ -22,11 +22,16 @@ export default function DocumentSelector({
22
  onDocChange(corpus, parseInt(idx, 10));
23
  }}
24
  >
25
- {documents.map(doc => (
26
- <option key={`${doc.corpus}:${doc.index}`} value={`${doc.corpus}:${doc.index}`}>
27
- [{doc.corpus_name}] Doc {doc.index} ({doc.annotatable_pages.length} pages)
28
- </option>
29
- ))}
 
 
 
 
 
30
  </select>
31
  </div>
32
  </div>
 
22
  onDocChange(corpus, parseInt(idx, 10));
23
  }}
24
  >
25
+ {documents.map(doc => {
26
+ const title = doc.original_name || `Doc ${doc.index}`;
27
+ const limit = 40;
28
+ const truncated = title.length > limit ? title.substring(0, limit) + '...' : title;
29
+ return (
30
+ <option key={`${doc.corpus}:${doc.index}`} value={`${doc.corpus}:${doc.index}`}>
31
+ [{doc.corpus_name}] {truncated} ({doc.annotatable_pages.length} pages)
32
+ </option>
33
+ );
34
+ })}
35
  </select>
36
  </div>
37
  </div>
app/components/MarkdownAnnotator.js CHANGED
@@ -368,7 +368,7 @@ export default function MarkdownAnnotator({ selectedDocIndex, selectedPage, curr
368
 
369
  <div className="markdown-content">
370
  <div className="markdown-content-header">
371
- <h3>Doc {selectedDocIndex}, Page {selectedPage !== null ? selectedPage + 1 : ''}</h3>
372
  {datasets.length > 0 && (
373
  <span className="dataset-count">
374
  {datasets.length} data mention{datasets.length !== 1 ? 's' : ''} detected
 
368
 
369
  <div className="markdown-content">
370
  <div className="markdown-content-header">
371
+ <h3>Page {selectedPage !== null ? selectedPage + 1 : ''}</h3>
372
  {datasets.length > 0 && (
373
  <span className="dataset-count">
374
  {datasets.length} data mention{datasets.length !== 1 ? 's' : ''} detected
app/globals.css CHANGED
@@ -1,7 +1,9 @@
1
  :root {
2
  --bg-color: #0f172a;
3
  --text-color: #f1f5f9;
 
4
  --pane-bg: #1e293b;
 
5
  --accent: #3b82f6;
6
  --accent-hover: #2563eb;
7
  --border-color: #334155;
@@ -11,6 +13,39 @@
11
  --nav-height: 56px;
12
  }
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  * {
15
  box-sizing: border-box;
16
  }
@@ -30,7 +65,7 @@ h2,
30
  h3,
31
  h4 {
32
  margin-top: 0;
33
- color: #f8fafc;
34
  }
35
 
36
  /* ── Layout ─────────────────────────────────────── */
@@ -397,7 +432,7 @@ h4 {
397
 
398
  .left-pane {
399
  border-right: 1px solid var(--border-color);
400
- background-color: #020617;
401
  }
402
 
403
  .right-pane {
@@ -516,7 +551,7 @@ h4 {
516
  left: 0;
517
  right: 0;
518
  height: var(--nav-height);
519
- background-color: #020617;
520
  border-top: 1px solid var(--border-color);
521
  display: flex;
522
  align-items: center;
@@ -683,7 +718,7 @@ h4 {
683
  color: #94a3b8;
684
  padding: 4px 10px;
685
  border-radius: 6px;
686
- background-color: #1e293b;
687
  border: 1px solid;
688
  }
689
 
@@ -707,14 +742,14 @@ h4 {
707
  }
708
 
709
  .markdown-preview {
710
- color: #cbd5e1;
711
  }
712
 
713
  .markdown-preview h1,
714
  .markdown-preview h2,
715
  .markdown-preview h3,
716
  .markdown-preview h4 {
717
- color: #e2e8f0;
718
  margin-top: 1.2em;
719
  margin-bottom: 0.4em;
720
  }
@@ -735,12 +770,12 @@ h4 {
735
 
736
  .markdown-preview strong,
737
  .markdown-preview b {
738
- color: #e2e8f0;
739
  font-weight: 600;
740
  }
741
 
742
  .markdown-preview pre {
743
- background-color: #0f172a;
744
  padding: 12px;
745
  border-radius: 6px;
746
  overflow-x: auto;
@@ -749,11 +784,11 @@ h4 {
749
 
750
  .markdown-preview code {
751
  font-family: monospace;
752
- background-color: #1e293b;
753
  padding: 2px 4px;
754
  border-radius: 4px;
755
  font-size: 0.9em;
756
- color: #cbd5e1;
757
  }
758
 
759
  .markdown-preview table {
@@ -770,8 +805,8 @@ h4 {
770
  }
771
 
772
  .markdown-preview th {
773
- background-color: #334155;
774
- color: #e2e8f0;
775
  }
776
 
777
  .markdown-content hr {
@@ -1240,7 +1275,7 @@ h4 {
1240
  }
1241
 
1242
  .help-modal-body h2 {
1243
- color: #e2e8f0;
1244
  font-size: 1.1rem;
1245
  margin-top: 1.2em;
1246
  }
@@ -1260,8 +1295,8 @@ h4 {
1260
  }
1261
 
1262
  .help-modal-body th {
1263
- background-color: #334155;
1264
- color: #e2e8f0;
1265
  }
1266
 
1267
  .help-modal-body hr {
@@ -1277,7 +1312,7 @@ h4 {
1277
  }
1278
 
1279
  .help-modal-body strong {
1280
- color: #e2e8f0;
1281
  }
1282
 
1283
  .modal-header {
 
1
  :root {
2
  --bg-color: #0f172a;
3
  --text-color: #f1f5f9;
4
+ --text-muted: #94a3b8;
5
  --pane-bg: #1e293b;
6
+ --left-pane-bg: #020617;
7
  --accent: #3b82f6;
8
  --accent-hover: #2563eb;
9
  --border-color: #334155;
 
13
  --nav-height: 56px;
14
  }
15
 
16
+ [data-theme="light"] {
17
+ --bg-color: #f8fafc;
18
+ --text-color: #0f172a;
19
+ --text-muted: #64748b;
20
+ --pane-bg: #ffffff;
21
+ --left-pane-bg: #f1f5f9;
22
+ --accent: #2563eb;
23
+ --accent-hover: #1d4ed8;
24
+ --border-color: #cbd5e1;
25
+ --success: #059669;
26
+ --error: #d32f2f;
27
+ --surface: #e2e8f0;
28
+ }
29
+
30
+ .btn-theme-toggle {
31
+ background: none;
32
+ border: 1px solid var(--border-color);
33
+ color: var(--text-color);
34
+ padding: 3px 10px;
35
+ border-radius: 6px;
36
+ font-size: 0.72rem;
37
+ cursor: pointer;
38
+ transition: all 0.2s;
39
+ display: inline-flex;
40
+ align-items: center;
41
+ gap: 4px;
42
+ }
43
+
44
+ .btn-theme-toggle:hover {
45
+ background: var(--surface);
46
+ border-color: var(--accent);
47
+ }
48
+
49
  * {
50
  box-sizing: border-box;
51
  }
 
65
  h3,
66
  h4 {
67
  margin-top: 0;
68
+ color: var(--text-color);
69
  }
70
 
71
  /* ── Layout ─────────────────────────────────────── */
 
432
 
433
  .left-pane {
434
  border-right: 1px solid var(--border-color);
435
+ background-color: var(--left-pane-bg);
436
  }
437
 
438
  .right-pane {
 
551
  left: 0;
552
  right: 0;
553
  height: var(--nav-height);
554
+ background-color: var(--left-pane-bg);
555
  border-top: 1px solid var(--border-color);
556
  display: flex;
557
  align-items: center;
 
718
  color: #94a3b8;
719
  padding: 4px 10px;
720
  border-radius: 6px;
721
+ background-color: var(--pane-bg);
722
  border: 1px solid;
723
  }
724
 
 
742
  }
743
 
744
  .markdown-preview {
745
+ color: var(--text-color);
746
  }
747
 
748
  .markdown-preview h1,
749
  .markdown-preview h2,
750
  .markdown-preview h3,
751
  .markdown-preview h4 {
752
+ color: var(--text-color);
753
  margin-top: 1.2em;
754
  margin-bottom: 0.4em;
755
  }
 
770
 
771
  .markdown-preview strong,
772
  .markdown-preview b {
773
+ color: var(--text-color);
774
  font-weight: 600;
775
  }
776
 
777
  .markdown-preview pre {
778
+ background-color: var(--bg-color);
779
  padding: 12px;
780
  border-radius: 6px;
781
  overflow-x: auto;
 
784
 
785
  .markdown-preview code {
786
  font-family: monospace;
787
+ background-color: var(--surface);
788
  padding: 2px 4px;
789
  border-radius: 4px;
790
  font-size: 0.9em;
791
+ color: var(--text-color);
792
  }
793
 
794
  .markdown-preview table {
 
805
  }
806
 
807
  .markdown-preview th {
808
+ background-color: var(--surface);
809
+ color: var(--text-color);
810
  }
811
 
812
  .markdown-content hr {
 
1275
  }
1276
 
1277
  .help-modal-body h2 {
1278
+ color: var(--text-color);
1279
  font-size: 1.1rem;
1280
  margin-top: 1.2em;
1281
  }
 
1295
  }
1296
 
1297
  .help-modal-body th {
1298
+ background-color: var(--surface);
1299
+ color: var(--text-color);
1300
  }
1301
 
1302
  .help-modal-body hr {
 
1312
  }
1313
 
1314
  .help-modal-body strong {
1315
+ color: var(--text-color);
1316
  }
1317
 
1318
  .modal-header {
app/layout.js CHANGED
@@ -8,6 +8,25 @@ export const metadata = {
8
  export default function RootLayout({ children }) {
9
  return (
10
  <html lang="en">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  <body>{children}</body>
12
  </html>
13
  );
 
8
  export default function RootLayout({ children }) {
9
  return (
10
  <html lang="en">
11
+ <head>
12
+ <script
13
+ dangerouslySetInnerHTML={{
14
+ __html: `
15
+ (function() {
16
+ try {
17
+ const theme = localStorage.getItem('theme');
18
+ if (theme) {
19
+ document.documentElement.setAttribute('data-theme', theme);
20
+ } else {
21
+ const systemDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
22
+ document.documentElement.setAttribute('data-theme', systemDark ? 'dark' : 'light');
23
+ }
24
+ } catch (e) {}
25
+ })();
26
+ `,
27
+ }}
28
+ />
29
+ </head>
30
  <body>{children}</body>
31
  </html>
32
  );
app/page.js CHANGED
@@ -37,6 +37,20 @@ export default function Home() {
37
  }
38
  }, []);
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  // Modal state
41
  const [modalOpen, setModalOpen] = useState(false);
42
  const [selectedText, setSelectedText] = useState('');
@@ -565,6 +579,13 @@ export default function Home() {
565
  annotatorName={annotatorName}
566
  />
567
  <div className="top-bar-user">
 
 
 
 
 
 
 
568
  <button
569
  className="btn-leaderboard"
570
  onClick={() => setLeaderboardOpen(true)}
 
37
  }
38
  }, []);
39
 
40
+ const [theme, setTheme] = useState('dark');
41
+
42
+ useEffect(() => {
43
+ const currentTheme = document.documentElement.getAttribute('data-theme') || 'dark';
44
+ setTheme(currentTheme);
45
+ }, []);
46
+
47
+ const toggleTheme = () => {
48
+ const nextTheme = theme === 'dark' ? 'light' : 'dark';
49
+ setTheme(nextTheme);
50
+ document.documentElement.setAttribute('data-theme', nextTheme);
51
+ localStorage.setItem('theme', nextTheme);
52
+ };
53
+
54
  // Modal state
55
  const [modalOpen, setModalOpen] = useState(false);
56
  const [selectedText, setSelectedText] = useState('');
 
579
  annotatorName={annotatorName}
580
  />
581
  <div className="top-bar-user">
582
+ <button
583
+ className="btn-theme-toggle"
584
+ onClick={toggleTheme}
585
+ title={theme === 'dark' ? 'Switch to Light Mode' : 'Switch to Dark Mode'}
586
+ >
587
+ {theme === 'dark' ? '☀️ Light' : '🌙 Dark'}
588
+ </button>
589
  <button
590
  className="btn-leaderboard"
591
  onClick={() => setLeaderboardOpen(true)}