Skip to content

Commit e4d53ea

Browse files
committed
Sync FTV table's vote/seat share rows with the pov toggle
Reverses the earlier "always Republican" convention: repVoteShare/ repSeatShare become povVoteShare/povSeatShare, returning the Dem share directly when pov is dem, 1-share when rep. Row labels switch between "D"/"R" to match. The "Repub tilt"/"Dem tilt" verdict wording is unaffected — it names the actually-favored party regardless of pov, not a pov-relative framing, so nothing there needed to change.
1 parent 67782f0 commit e4d53ea

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

app/src/app/components/EvalPanel/PartisanSection.tsx

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,20 @@ export const PartisanSection: React.FC<PartisanSectionProps> = ({evaluation}) =>
145145
</HelpTip>
146146
);
147147

148-
// FTV table always shows the Republican share — independent of the pov
149-
// toggle above, since the "Repub tilt"/"Dem tilt" verdict wording already
150-
// names the party, leaving nothing for pov to flip.
151-
const repVoteShare = (key: string) => {
148+
// FTV table's vote/seat share rows follow the pov toggle above, same as the
149+
// Proportionality table. The "Repub tilt"/"Dem tilt" verdict wording stays
150+
// fixed either way — it names whichever party is actually favored, not a
151+
// POV-relative framing.
152+
const povVoteShare = (key: string) => {
152153
const dem = evaluation.vote_shares?.[key]?.dem;
153-
return dem !== undefined ? 1 - dem : null;
154+
if (dem === undefined) return null;
155+
return pov === 'dem' ? dem : 1 - dem;
154156
};
155-
const repSeatShare = (key: string) => {
157+
const povSeatShare = (key: string) => {
156158
const s = evaluation.seats?.[key];
157-
return s && s.total ? 1 - s.dem / s.total : null;
159+
if (!s || !s.total) return null;
160+
const demShare = s.dem / s.total;
161+
return pov === 'dem' ? demShare : 1 - demShare;
158162
};
159163
const ftvVerdict = (key: string): 'pass' | 'dem' | 'rep' | null => {
160164
const disprop = evaluation.disproportionality?.[key];
@@ -430,14 +434,14 @@ export const PartisanSection: React.FC<PartisanSectionProps> = ({evaluation}) =>
430434
<Table.Row>
431435
<Table.Cell>
432436
<Text size="2" weight="bold">
433-
R vote share
437+
{pov === 'dem' ? 'D' : 'R'} vote share
434438
</Text>
435439
</Table.Cell>
436440
{ftvElections.map(key => (
437441
<Table.Cell key={key} justify="center">
438442
<Text size="2">
439-
{repVoteShare(key) !== null
440-
? `${(repVoteShare(key)! * 100).toFixed(1)}%`
443+
{povVoteShare(key) !== null
444+
? `${(povVoteShare(key)! * 100).toFixed(1)}%`
441445
: '—'}
442446
</Text>
443447
</Table.Cell>
@@ -446,14 +450,14 @@ export const PartisanSection: React.FC<PartisanSectionProps> = ({evaluation}) =>
446450
<Table.Row>
447451
<Table.Cell>
448452
<Text size="2" weight="bold">
449-
R seat share
453+
{pov === 'dem' ? 'D' : 'R'} seat share
450454
</Text>
451455
</Table.Cell>
452456
{ftvElections.map(key => (
453457
<Table.Cell key={key} justify="center">
454458
<Text size="2">
455-
{repSeatShare(key) !== null
456-
? `${(repSeatShare(key)! * 100).toFixed(1)}%`
459+
{povSeatShare(key) !== null
460+
? `${(povSeatShare(key)! * 100).toFixed(1)}%`
457461
: '—'}
458462
</Text>
459463
</Table.Cell>

0 commit comments

Comments
 (0)