Skip to content

Commit 2872d9b

Browse files
committed
Improve readability for chained utterances
Alternate boxes left and right to make the exchanges clearer force paginations at ~100 items
1 parent 83b7b97 commit 2872d9b

5 files changed

Lines changed: 18 additions & 8 deletions

File tree

‎src/components/reader/UtteranceCard.tsx‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import type { UtteranceWithPerson } from '@/types/database';
66
interface UtteranceCardProps {
77
utterance: UtteranceWithPerson;
88
highlighted?: boolean;
9+
index?: number;
910
}
1011

11-
export function UtteranceCard({ utterance, highlighted }: UtteranceCardProps) {
12+
export function UtteranceCard({ utterance, highlighted, index = 0 }: UtteranceCardProps) {
1213
const partyColor = getPartyColor(utterance.person_party);
1314
const textColor = getContrastTextColor(partyColor);
1415

@@ -33,7 +34,11 @@ export function UtteranceCard({ utterance, highlighted }: UtteranceCardProps) {
3334
className={`border-l-4 bg-white rounded-lg shadow-sm p-6 mb-4 ${
3435
highlighted ? 'border-blue-500 bg-blue-50' : ''
3536
}`}
36-
style={!highlighted ? { borderLeftColor: partyColor } : {}}
37+
style={{
38+
...(!highlighted ? { borderLeftColor: partyColor } : {}),
39+
marginLeft: index % 2 === 1 ? '10rem' : '0',
40+
marginRight: index % 2 === 0 ? '10rem' : '0',
41+
}}
3742
>
3843
{/* Metadata */}
3944
<div className="flex flex-wrap items-center gap-4 mb-4 text-sm">
@@ -93,7 +98,7 @@ export function UtteranceCard({ utterance, highlighted }: UtteranceCardProps) {
9398
)}
9499

95100
{/* Content */}
96-
<div className="text-gray-700 leading-relaxed prose max-w-none">
101+
<div className="text-gray-700 leading-relaxed prose max-w-none whitespace-pre-wrap max-h-64 overflow-y-auto">
97102
{utterance.content}
98103
</div>
99104
</div>

‎src/lib/database/DatabaseManager.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ export class DatabaseManager {
166166
// Initialize database
167167
const db = new this.SQL.Database(data);
168168

169+
// Break prev/next links every ~100 utterances to create page boundaries
170+
db.run(`UPDATE utterance SET next = NULL WHERE rowid % 100 = 0`);
171+
db.run(`UPDATE utterance SET prev = NULL WHERE rowid % 100 = 1 AND rowid > 1`);
172+
169173
// Store in memory cache
170174
this.memoryCache.set(year, db);
171175
this.updateLRU(year);

‎src/lib/utils/config.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const config = {
99
// Database URLs
1010
databaseBaseUrl: (import.meta.env.DEV && import.meta.env.VITE_USE_REMOTE_DB !== 'true')
1111
? '/dbs'
12-
: 'https://raw.githubusercontent.com/DigitalHistory-Lund/ToK-Preparer/main',
12+
: 'https://raw.githubusercontent.com/DigitalHistory-Lund/ToK-Preparer/run',
1313

1414
// Database filename pattern
1515
databaseFilename: (year: number) =>
@@ -25,7 +25,7 @@ export const config = {
2525
},
2626

2727
// Cache settings
28-
cacheVersion: '1.0.0',
28+
cacheVersion: '1.2.0',
2929
maxCachedDatabases: 3, // Max databases in memory
3030
cacheDbName: 'tok-reader-cache',
3131
cacheStoreName: 'databases',

‎src/pages/ReaderPage.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ export function ReaderPage() {
449449

450450
{/* Utterances */}
451451
<div className="space-y-4">
452-
{utterances.map((utterance) => (
452+
{utterances.map((utterance, index) => (
453453
<div
454454
key={utterance.id}
455455
ref={(el) => {
@@ -465,6 +465,7 @@ export function ReaderPage() {
465465
<UtteranceCard
466466
utterance={utterance}
467467
highlighted={utterance.id === utteranceId}
468+
index={index}
468469
/>
469470
</div>
470471
))}

‎vite.config.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import react from '@vitejs/plugin-react'
33
import path from 'path'
44

55
// https://vitejs.dev/config/
6-
export default defineConfig(({ command }) => ({
6+
export default defineConfig(({ command, mode }) => ({
77
plugins: [react()],
8-
base: command === 'serve' ? '/' : '/ToK-Reader/',
8+
base: command === 'serve' && mode !== 'production' ? '/' : '/ToK-Reader/',
99
resolve: {
1010
alias: {
1111
'@': path.resolve(__dirname, './src'),

0 commit comments

Comments
 (0)