Skip to content

Commit 09318f8

Browse files
committed
Prettify, add navigation
1 parent c0c9ba9 commit 09318f8

9 files changed

Lines changed: 795 additions & 55 deletions

File tree

‎.gitignore‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ dbs/
1515
.vite/
1616
.turbo/
1717

18-
1918
# Environment variables
2019
.env
2120
.env.local

‎src/components/reader/UtteranceCard.tsx‎

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { formatDate, normalizePartyName } from '@/lib/utils/urlHelpers';
1+
import { Link } from 'react-router-dom';
2+
import { formatDate } from '@/lib/utils/urlHelpers';
3+
import { getPartyColor, getContrastTextColor } from '@/lib/utils/partyColors';
24
import type { UtteranceWithPerson } from '@/types/database';
35

46
interface UtteranceCardProps {
@@ -7,31 +9,56 @@ interface UtteranceCardProps {
79
}
810

911
export function UtteranceCard({ utterance, highlighted }: UtteranceCardProps) {
10-
const partyColor = normalizePartyName(utterance.person_party);
12+
const partyColor = getPartyColor(utterance.person_party);
13+
const textColor = getContrastTextColor(partyColor);
14+
15+
const getGenderSymbol = (gender: string | null): string => {
16+
if (!gender) return '';
17+
const lower = gender.toLowerCase();
18+
if (lower === 'man' || lower === 'män') return '♂';
19+
if (lower === 'woman' || lower === 'kvinna') return '♀';
20+
return gender;
21+
};
22+
23+
const getGenderStyle = (gender: string | null): string => {
24+
if (!gender) return 'text-gray-600';
25+
const lower = gender.toLowerCase();
26+
if (lower === 'man' || lower === 'män') return 'text-blue-600 font-bold text-lg';
27+
if (lower === 'woman' || lower === 'kvinna') return 'text-red-600 font-bold text-lg';
28+
return 'text-gray-600';
29+
};
1130

1231
return (
1332
<div
1433
className={`border-l-4 bg-white rounded-lg shadow-sm p-6 mb-4 ${
15-
highlighted
16-
? 'border-blue-500 bg-blue-50'
17-
: `border-party-${partyColor} border-gray-300`
34+
highlighted ? 'border-blue-500 bg-blue-50' : ''
1835
}`}
36+
style={!highlighted ? { borderLeftColor: partyColor } : {}}
1937
>
2038
{/* Metadata */}
2139
<div className="flex flex-wrap items-center gap-4 mb-4 text-sm">
22-
<div className="font-semibold text-gray-800">
40+
<Link
41+
to={`/search?year=${utterance.year}&speaker=${utterance.person_id}`}
42+
target="_blank"
43+
rel="noopener noreferrer"
44+
className="font-semibold text-blue-600 hover:text-blue-800 hover:underline cursor-pointer"
45+
title={`View all utterances by ${utterance.person_name}`}
46+
>
2347
{utterance.person_name}
24-
</div>
48+
</Link>
2549

2650
{utterance.person_party && (
27-
<span className={`px-3 py-1 rounded-full text-white bg-party-${partyColor} bg-gray-600 text-xs font-semibold`}>
51+
<span
52+
className="px-3 py-1 rounded-full text-xs font-semibold"
53+
style={{ backgroundColor: partyColor, color: textColor }}
54+
>
2855
{utterance.person_party}
2956
</span>
3057
)}
3158

3259
{utterance.person_gender && (
33-
<span className="text-gray-600">
34-
{utterance.person_gender}
60+
<span className={getGenderStyle(utterance.person_gender)} title={utterance.person_gender}>
61+
{getGenderSymbol(utterance.person_gender)}
3562
</span>
3663
)}
3764

‎src/config/partyColors.json‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"parties": {
3+
"Socialdemokraterna": { "color": "#E02020" },
4+
"Bondeförbundet": { "color": "#166534" },
5+
"Liberala": { "color": "#3B82F6" },
6+
"Höger": { "color": "#4338CA" },
7+
"Vänsterpartiet": { "color": "#7C2D12" },
8+
"Nationella": { "color": "#6366F1" }
9+
},
10+
"default": { "color": "#6B7280" }
11+
}

0 commit comments

Comments
 (0)