Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
asibs committed Mar 23, 2024
1 parent db74c0b commit e7bfa73
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 75 deletions.
11 changes: 7 additions & 4 deletions app/constituencies/at-risk-non-tory-seats/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export default async function ConstituencySummaryPage() {
<Col>
<h3>At Risk Non-Tory Seats</h3>
<p className="mb-2">
There are {constituencies.length} non-Tory
Constituencies* where we need to vote tactically to make sure
the Tories don&apos;t win!
There are {constituencies.length} non-Tory Constituencies*
where we need to vote tactically to make sure the Tories
don&apos;t win!
</p>
<p className="fst-italic">
* Based on converting 2019 voting patterns to new constituency
Expand All @@ -42,7 +42,10 @@ export default async function ConstituencySummaryPage() {
</Col>
</Row>

<NonToryConstituencyTable constituencies={constituencies} color={"RECOMMENDATION"} />
<NonToryConstituencyTable
constituencies={constituencies}
color={"RECOMMENDATION"}
/>
</Container>
</section>
</main>
Expand Down
44 changes: 21 additions & 23 deletions app/constituencies/constituencyTables.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { Col, Container, Row } from "react-bootstrap";
import Link from "next/link";
import { partyColorFromSlug, partyNameFromSlug } from "@/utils/Party";

const ToryConstituencyTable = ({ constituencies }: { constituencies: ConstituencyData[] }) => {
const ToryConstituencyTable = ({
constituencies,
}: {
constituencies: ConstituencyData[];
}) => {
return (
<Row className="pb-5">
<Col
xs={12}
lg={{ offset: 1, span: 10 }}
xl={{ offset: 2, span: 8 }}
>
<Col xs={12} lg={{ offset: 1, span: 10 }} xl={{ offset: 2, span: 8 }}>
<Container className="text-center">
<Row xs={2}>
<Col>
Expand All @@ -21,11 +21,7 @@ const ToryConstituencyTable = ({ constituencies }: { constituencies: Constituenc
</Row>

{constituencies.map((c) => (
<Row
xs={2}
className="pb-1"
key={c.constituencyIdentifiers.slug}
>
<Row xs={2} className="pb-1" key={c.constituencyIdentifiers.slug}>
<Col>
<Link
href={`/constituencies/${c.constituencyIdentifiers.slug}`}
Expand Down Expand Up @@ -64,22 +60,28 @@ const ToryConstituencyTable = ({ constituencies }: { constituencies: Constituenc
</Col>
</Row>
);
}
};

const NonToryConstituencyTable = ({ constituencies, color }: { constituencies: ConstituencyData[], color: "RECOMMENDATION" | "IMPLIED" }) => {
const NonToryConstituencyTable = ({
constituencies,
color,
}: {
constituencies: ConstituencyData[];
color: "RECOMMENDATION" | "IMPLIED";
}) => {
return (
<>
<Row xs={2} md={3} lg={4} xl={5} xxl={6} className="pb-5 g-1">
{constituencies.map((c) => (
<Col key={c.constituencyIdentifiers.slug}>
<Link
href={`/constituencies/${c.constituencyIdentifiers.slug}`}
>
<Link href={`/constituencies/${c.constituencyIdentifiers.slug}`}>
<span
className="badge rounded-pill w-100 h-100 text-wrap align-middle"
style={{
backgroundColor: partyColorFromSlug(
color === "RECOMMENDATION" ? c.recommendation.partySlug : c.impliedPreviousResult.winningParty,
color === "RECOMMENDATION"
? c.recommendation.partySlug
: c.impliedPreviousResult.winningParty,
),
}}
>
Expand All @@ -91,10 +93,6 @@ const NonToryConstituencyTable = ({ constituencies, color }: { constituencies: C
</Row>
</>
);
}
};


export {
NonToryConstituencyTable,
ToryConstituencyTable,
}
export { NonToryConstituencyTable, ToryConstituencyTable };
70 changes: 51 additions & 19 deletions app/constituencies/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ export default async function ConstituencySummaryPage() {
await getConstituenciesData()
).filter((c: ConstituencyData) => c.recommendation.partySlug !== "None");

const torySeatsProgressiveAheadCount = torySeatsProgressiveAhead(constituenciesData).length;
const torySeatsProgressiveBehindCount = torySeatsProgressiveBehind(constituenciesData).length;
const torySeatsNoRecommendationCount = torySeatsNoRecommendation(constituenciesData).length;
const torySeatsProgressiveAheadCount =
torySeatsProgressiveAhead(constituenciesData).length;
const torySeatsProgressiveBehindCount =
torySeatsProgressiveBehind(constituenciesData).length;
const torySeatsNoRecommendationCount =
torySeatsNoRecommendation(constituenciesData).length;
const nonTorySeatsUnsafeCount = nonTorySeatsUnsafe(constituenciesData).length;
const nonTorySeatsTorySafeCount = nonTorySeatsSafe(constituenciesData).length;

Expand All @@ -37,63 +40,92 @@ export default async function ConstituencySummaryPage() {
<Container>
<Row className="pb-3">
<Col>
<h3><Link href="/constituencies/target-tory-seats">Target Tory Seats</Link></h3>
<h3>
<Link href="/constituencies/target-tory-seats">
Target Tory Seats
</Link>
</h3>
<p className="mb-2">
There are {torySeatsProgressiveAheadCount} Tory
Constituencies* that we have a great chance of taking back!
<br />
<Link href="/constituencies/target-tory-seats">See them all here.</Link>
<Link href="/constituencies/target-tory-seats">
See them all here.
</Link>
</p>
</Col>
</Row>

<Row className="pb-3">
<Col>
<h3><Link href="/constituencies/tough-tory-seats">Tough Tory Seats</Link></h3>
<h3>
<Link href="/constituencies/tough-tory-seats">
Tough Tory Seats
</Link>
</h3>
<p className="mb-2">
There are {torySeatsProgressiveBehindCount} Tory
Constituencies* that we need to work even harder to take back!
<br />
<Link href="/constituencies/tough-tory-seats">See them all here.</Link>
<Link href="/constituencies/tough-tory-seats">
See them all here.
</Link>
</p>
</Col>
</Row>

<Row className="pb-3">
<Col>
<h3><Link href="/constituencies/tory-seats-still-calculating">Tory Seats we&apos;re still working on</Link></h3>
<h3>
<Link href="/constituencies/tory-seats-still-calculating">
Tory Seats we&apos;re still working on
</Link>
</h3>
<p className="mb-2">
There are {torySeatsNoRecommendationCount} Tory
Constituencies* where we&apos;re still working out the
tactical vote...
<br />
<Link href="/constituencies/tory-seats-still-calculating">See them all here.</Link>
<Link href="/constituencies/tory-seats-still-calculating">
See them all here.
</Link>
</p>
</Col>
</Row>

<Row className="pb-3">
<Col>
<h3><Link href="/constituencies/at-risk-non-tory-seats">At Risk Non-Tory Seats</Link></h3>
<h3>
<Link href="/constituencies/at-risk-non-tory-seats">
At Risk Non-Tory Seats
</Link>
</h3>
<p className="mb-2">
There are {nonTorySeatsUnsafeCount} non-Tory
Constituencies* where we need to vote tactically to make sure
the Tories don&apos;t win!
There are {nonTorySeatsUnsafeCount} non-Tory Constituencies*
where we need to vote tactically to make sure the Tories
don&apos;t win!
<br />
<Link href="/constituencies/at-risk-non-tory-seats">See them all here.</Link>
<Link href="/constituencies/at-risk-non-tory-seats">
See them all here.
</Link>
</p>
</Col>
</Row>


<Row className="pb-3">
<Col>
<h3><Link href="/constituencies/safe-non-tory-seats">Safe Non-Tory Seats</Link></h3>
<h3>
<Link href="/constituencies/safe-non-tory-seats">
Safe Non-Tory Seats
</Link>
</h3>
<p className="mb-2">
There are {nonTorySeatsTorySafeCount} non-Tory
Constituencies* where you can safely vote with your heart.
There are {nonTorySeatsTorySafeCount} non-Tory Constituencies*
where you can safely vote with your heart.
<br />
<Link href="/constituencies/safe-non-tory-seats">See them all here.</Link>
<Link href="/constituencies/safe-non-tory-seats">
See them all here.
</Link>
</p>
</Col>
</Row>
Expand Down
9 changes: 6 additions & 3 deletions app/constituencies/safe-non-tory-seats/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export default async function ConstituencySummaryPage() {
<Col>
<h3>Safe Non-Tory Seats</h3>
<p className="mb-2">
There are {constituencies.length} non-Tory
Constituencies* where you can safely vote with your heart
There are {constituencies.length} non-Tory Constituencies*
where you can safely vote with your heart
</p>
<p className="fst-italic">
* Based on converting 2019 voting patterns to new constituency
Expand All @@ -41,7 +41,10 @@ export default async function ConstituencySummaryPage() {
</Col>
</Row>

<NonToryConstituencyTable constituencies={constituencies} color={"IMPLIED"} />
<NonToryConstituencyTable
constituencies={constituencies}
color={"IMPLIED"}
/>
</Container>
</section>
</main>
Expand Down
8 changes: 5 additions & 3 deletions app/constituencies/target-tory-seats/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export default async function ConstituencySummaryPage() {
await getConstituenciesData()
).filter((c: ConstituencyData) => c.recommendation.partySlug !== "None");

const constituencies = sortByMajority(torySeatsProgressiveAhead(constituenciesData));
const constituencies = sortByMajority(
torySeatsProgressiveAhead(constituenciesData),
);

return (
<>
Expand All @@ -31,8 +33,8 @@ export default async function ConstituencySummaryPage() {
<Col>
<h3>Target Tory Seats</h3>
<p className="mb-2">
There are {constituencies.length} Tory
Constituencies* that we have a great chance of taking back!
There are {constituencies.length} Tory Constituencies* that we
have a great chance of taking back!
</p>
<p className="fst-italic">
* Based on converting 2019 voting patterns to new constituency
Expand Down
9 changes: 5 additions & 4 deletions app/constituencies/tory-seats-still-calculating/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export default async function ConstituencySummaryPage() {
await getConstituenciesData()
).filter((c: ConstituencyData) => c.recommendation.partySlug !== "None");

const constituencies = sortByMajority(torySeatsNoRecommendation(constituenciesData));
const constituencies = sortByMajority(
torySeatsNoRecommendation(constituenciesData),
);

return (
<>
Expand All @@ -31,9 +33,8 @@ export default async function ConstituencySummaryPage() {
<Col>
<h3>Tory Seats we&apos;re still working on</h3>
<p className="mb-2">
There are {constituencies.length} Tory
Constituencies* where we&apos;re still working out the
tactical vote...
There are {constituencies.length} Tory Constituencies* where
we&apos;re still working out the tactical vote...
</p>
<p className="fst-italic">
* Based on converting 2019 voting patterns to new constituency
Expand Down
10 changes: 6 additions & 4 deletions app/constituencies/tough-tory-seats/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export default async function ConstituencySummaryPage() {
await getConstituenciesData()
).filter((c: ConstituencyData) => c.recommendation.partySlug !== "None");

const constituencies = sortByMajority(torySeatsProgressiveBehind(constituenciesData));
const constituencies = sortByMajority(
torySeatsProgressiveBehind(constituenciesData),
);
return (
<>
<Header backgroundImage="FESTIVAL_CROWD">
Expand All @@ -30,8 +32,8 @@ export default async function ConstituencySummaryPage() {
<Col>
<h3>Tough Tory Seats</h3>
<p className="mb-2">
There are {constituencies.length} Tory
Constituencies* that we need to work even harder to take back!
There are {constituencies.length} Tory Constituencies* that we
need to work even harder to take back!
</p>
<p className="fst-italic">
* Based on converting 2019 voting patterns to new constituency
Expand All @@ -43,7 +45,7 @@ export default async function ConstituencySummaryPage() {
<ToryConstituencyTable constituencies={constituencies} />
</Container>
</section>
</main >
</main>
</>
);
}
Loading

0 comments on commit e7bfa73

Please sign in to comment.