Skip to content

Commit

Permalink
Update headline for same state + battleground
Browse files Browse the repository at this point in the history
  • Loading branch information
davepeck committed Mar 13, 2024
1 parent c2ac89b commit 71b3a5b
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/components/More.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { useCallback, useEffect, useState } from "react";
import { type RegistrationHandler } from "../utils/analytics";
import { assertNever } from "../utils/asserts";

import { stateSelection, type StateSelection } from "../election/powerRankings";
import {
isBattleground,
stateSelection,
type StateSelection,
} from "../election/powerRankings";
import {
CANDIDATES_2020,
ELECTION_2020,
Expand Down Expand Up @@ -298,12 +302,21 @@ const SelectionHeadline: React.FC<{ result: StateSelectionResult }> = ({
break;

case "same":
headline = (
<>
Your home and school states are both{" "}
<span className="text-point">{selectedStateName(result)}</span>.
</>
);
if (isBattleground(result.homeState)) {
headline = (
<>
<span className="text-point">{homeStateName(result)}</span> votes
count more.
</>
);
} else {
headline = (
<>
Your home and school states are both{" "}
<span className="text-point">{selectedStateName(result)}</span>.
</>
);
}
break;

default:
Expand Down Expand Up @@ -411,7 +424,7 @@ const DescribeSelection: React.FC<{
<RegisterToVoteButton
state={homeState}
handler={handler}
chosen={selection !== "toss-up" && selection !== "same"}
chosen={selection !== "toss-up"}
/>
)}
{selection !== "home" &&
Expand Down

0 comments on commit 71b3a5b

Please sign in to comment.