Skip to content

Commit

Permalink
lint/pretty
Browse files Browse the repository at this point in the history
  • Loading branch information
asibs committed Feb 25, 2024
1 parent 8aa7fc7 commit 498dcbb
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 57 deletions.
27 changes: 15 additions & 12 deletions app/constituencies/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,15 @@ export default async function ConstituencyPage({
<Row>
<Col>
<h3
className={`${rubik.className} party ${partyCssClassFromSlug(constituencyData.recommendation.partySlug)}`}
className={`${
rubik.className
} party ${partyCssClassFromSlug(
constituencyData.recommendation.partySlug,
)}`}
>
{partyNameFromSlug(constituencyData.recommendation.partySlug)}
{partyNameFromSlug(
constituencyData.recommendation.partySlug,
)}
</h3>
</Col>
</Row>
Expand All @@ -113,17 +119,14 @@ export default async function ConstituencyPage({
<p>{JSON.stringify(constituencyData)}</p>
*/}
</>
)
}
)}

{
!constituencyData && (
<>
<h1>{params.slug}</h1>
<p>No data found for this constituency!</p>
</>
)
}
{!constituencyData && (
<>
<h1>{params.slug}</h1>
<p>No data found for this constituency!</p>
</>
)}
</>
);
}
3 changes: 2 additions & 1 deletion app/globals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ body {
font-size: 18px;
}

html, body {
html,
body {
background-color: var(--bs-gray-300);
}

Expand Down
12 changes: 5 additions & 7 deletions components/info_box/InfoBox.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
const InfoBox = ({ children }: {
children: React.ReactElement,
}) => {

const InfoBox = ({ children }: { children: React.ReactElement }) => {
return (
<div
className="rounded-4 p-3"
style={{
background: "linear-gradient(rgb(255, 243, 205), rgb(255, 230, 156))",
boxShadow: "0px 5px 10px 0px rgba(0, 0, 0, 0.075)"
}}>
boxShadow: "0px 5px 10px 0px rgba(0, 0, 0, 0.075)",
}}
>
{children}
</div >
</div>
);
};

Expand Down
11 changes: 8 additions & 3 deletions components/info_box/LocalTeamBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,21 @@ const LocalTeamBox = () => {
<InfoBox>
<>
<h3 className={`${rubik.className} fs-5`}>Your Constituency Team</h3>
<p>People in your local Movement Forward community are coming together to use their voting power.</p>
<p>
People in your local Movement Forward community are coming together to
use their voting power.
</p>
<p>
<Button variant="light" size="lg">
<FaUsers className="me-2" />
<span className={`${rubik.className} fw-bold`}>Join and get involved</span>
<span className={`${rubik.className} fw-bold`}>
Join and get involved
</span>
</Button>
</p>
</>
</InfoBox>
);
};

export default LocalTeamBox;
export default LocalTeamBox;
37 changes: 30 additions & 7 deletions components/info_box/PlanToVoteBox.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,51 @@
import InfoBox from "./InfoBox";
import { rubik } from "@/utils/Fonts";

import { FaPenClip, FaRegIdCard, FaEnvelopeOpenText, FaFileImage } from "react-icons/fa6";
import {
FaPenClip,
FaRegIdCard,
FaEnvelopeOpenText,
FaFileImage,
} from "react-icons/fa6";

const PlanToVoteBox = () => {
return (
<InfoBox>
<>
<h3 className={`${rubik.className} fs-5`}>Your Plan</h3>
<p>
<a href="https://www.gov.uk/register-to-vote" target="_blank" rel="noreferrer">
<a
href="https://www.gov.uk/register-to-vote"
target="_blank"
rel="noreferrer"
>
<FaPenClip className="me-2" style={{ color: "var(--bs-purple)" }} />
Register to vote, it takes 5 minutes
</a>
</p>
<p>
<a href="https://www.electoralcommission.org.uk/voting-and-elections/voter-id" target="_blank" rel="noreferrer">
<FaRegIdCard className="me-2" style={{ color: "var(--bs-green)" }} />
Don't forget your photo Voter ID
<a
href="https://www.electoralcommission.org.uk/voting-and-elections/voter-id"
target="_blank"
rel="noreferrer"
>
<FaRegIdCard
className="me-2"
style={{ color: "var(--bs-green)" }}
/>
Don&apos;t forget your photo Voter ID
</a>
</p>
<p>
<a href="https://www.gov.uk/apply-postal-vote" target="_blank" rel="noreferrer">
<FaEnvelopeOpenText className="me-2" style={{ color: "var(--bs-blue)" }} />
<a
href="https://www.gov.uk/apply-postal-vote"
target="_blank"
rel="noreferrer"
>
<FaEnvelopeOpenText
className="me-2"
style={{ color: "var(--bs-blue)" }}
/>
Vote in advance, privately, by post from home
</a>
</p>
Expand Down
65 changes: 46 additions & 19 deletions components/info_box/TacticalReasoningBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,42 @@ import InfoBox from "./InfoBox";
import { rubik } from "@/utils/Fonts";
import { partyCssClassFromSlug, partyNameFromSlug } from "@/utils/Party";

import { FaUser, FaChartSimple, FaChartLine, FaBullseye, FaTriangleExclamation } from "react-icons/fa6";
import {
FaUser,
FaChartSimple,
FaChartLine,
FaBullseye,
FaTriangleExclamation,
} from "react-icons/fa6";

const TacticalReasoningBox = ({ constituencyData }: { constituencyData: ConstituencyData }) => {
const TacticalReasoningBox = ({
constituencyData,
}: {
constituencyData: ConstituencyData;
}) => {
const recommendedParty = constituencyData.recommendation.partySlug;
const recommendedPartyName = partyNameFromSlug(recommendedParty);

const previousWinner = constituencyData.impliedPreviousResult.winningParty;
const previousBiggestProgressive = constituencyData.impliedPreviousResult.biggestProgressiveParty;
const previousBiggestProgressive =
constituencyData.impliedPreviousResult.biggestProgressiveParty;

const pollingWinner = constituencyData.pollingResults.winningParty;
const pollingBiggestProgressive = constituencyData.pollingResults.biggestProgressiveParty;
const pollingBiggestProgressive =
constituencyData.pollingResults.biggestProgressiveParty;

const recommendedPartyTargetSeat = constituencyData.otherVoteData.targetSeatData.some(
(target) => target.partySlug == recommendedParty && target.likelyTarget == "YES"
);
const recommendedPartyTargetSeat =
constituencyData.otherVoteData.targetSeatData.some(
(target) =>
target.partySlug == recommendedParty && target.likelyTarget == "YES",
);

const closeSeat = !constituencyData.otherVoteData.conservativeWinUnlikely;

const sortedPreviousResults = constituencyData.impliedPreviousResult.partyVoteResults.sort(
(a, b) => b.votePercent - a.votePercent
);
const sortedPreviousResults =
constituencyData.impliedPreviousResult.partyVoteResults.sort(
(a, b) => b.votePercent - a.votePercent,
);

return (
<InfoBox>
Expand All @@ -36,18 +51,27 @@ const TacticalReasoningBox = ({ constituencyData }: { constituencyData: Constitu
</p>

{/* Show previous biggest progressive if it matches our recommendation AND they weren't the winner */}
{recommendedParty == previousBiggestProgressive && recommendedParty != previousWinner && (
<p>
<FaChartSimple className="me-2" style={{ color: "var(--bs-green)" }} />
{recommendedPartyName} received the most progressive votes here in 2019
</p>
)}
{recommendedParty == previousBiggestProgressive &&
recommendedParty != previousWinner && (
<p>
<FaChartSimple
className="me-2"
style={{ color: "var(--bs-green)" }}
/>
{recommendedPartyName} received the most progressive votes here in
2019
</p>
)}

{/* Show polling biggest progressive if it matches our recommendation */}
{recommendedParty == pollingBiggestProgressive && (
<p>
<FaChartLine className="me-2" style={{ color: "var(--bs-green)" }} />
Polling indicates that {recommendedPartyName} have the best chance of beating the Tory party here at the next election
<FaChartLine
className="me-2"
style={{ color: "var(--bs-green)" }}
/>
Polling indicates that {recommendedPartyName} have the best chance
of beating the Tory party here at the next election
</p>
)}

Expand All @@ -62,7 +86,10 @@ const TacticalReasoningBox = ({ constituencyData }: { constituencyData: Constitu
{/* Check if this is a close seat */}
{closeSeat && (
<p>
<FaTriangleExclamation className="me-2" style={{ color: "var(--bs-red)" }} />
<FaTriangleExclamation
className="me-2"
style={{ color: "var(--bs-red)" }}
/>
This is a close seat, tactical voting can work very well here.
</p>
)}
Expand Down
4 changes: 2 additions & 2 deletions types/constituency_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ type PartyVoteResult = {
type OtherVoteData = {
targetSeatData: TargetSeat[];
conservativeWinUnlikely: boolean;
}
};

// Whether this is a target seat for the given party
type TargetSeat = {
partySlug: string;
likelyTarget: "YES" | "NO" | "UNKNOWN";
};
};
9 changes: 3 additions & 6 deletions utils/Party.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const partyNameFromSlug = (slug: string) => {
default:
"Other";
}
}
};

const partyCssClassFromSlug = (slug: string) => {
// TODO: Styles for SNP/Plaid (and Reform?)
Expand All @@ -39,9 +39,6 @@ const partyCssClassFromSlug = (slug: string) => {
default:
"";
}
}
};

export {
partyNameFromSlug,
partyCssClassFromSlug,
};
export { partyNameFromSlug, partyCssClassFromSlug };

0 comments on commit 498dcbb

Please sign in to comment.