-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
281 additions
and
291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { BaseCard } from "@components/card"; | ||
import PageTitle from "@components/page-title"; | ||
import { ExclamationCircleIcon } from "@heroicons/react/24/solid"; | ||
|
||
export const metadata = { | ||
title: "404 | Sidan hittades inte | Partiguiden", | ||
}; | ||
|
||
export default function Error404() { | ||
return ( | ||
<main> | ||
<PageTitle Icon={ExclamationCircleIcon}> | ||
404 - Sidan hittades inte | ||
</PageTitle> | ||
<div className="container mt-4"> | ||
<BaseCard> | ||
<p className="text-center text-lg"> | ||
Sidan du letade har kanske blivit borttagen, eller skrev du in en | ||
felaktig URL. | ||
</p> | ||
</BaseCard> | ||
</div> | ||
</main> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { notFound } from "next/navigation"; | ||
import type { Party } from "@partiguiden/party-data/types"; | ||
import { | ||
getStandpointsForSubject, | ||
getSubject, | ||
} from "@partiguiden/party-data/reader"; | ||
import { ERROR_404_TITLE } from "@lib/constants"; | ||
import PageTitle from "@components/page-title"; | ||
import PartyStandpoints from "./party-standpoints"; | ||
|
||
interface PageProps { | ||
params: { | ||
id: string; | ||
}; | ||
} | ||
|
||
export async function generateMetadata({ params: { id } }: PageProps) { | ||
const subject = getSubject(id); | ||
|
||
if (!subject) { | ||
return { | ||
title: ERROR_404_TITLE, | ||
}; | ||
} | ||
|
||
return { | ||
title: `${subject.name} | Ämne | Partiguiden`, | ||
description: `Vad tar Sveriges partier för ståndpunkter inom sakområdet ${subject.name}? Här hittar du informationen du behöver för att kunna jämföra och hitta det parti du sympatiserar med mest!`, | ||
}; | ||
} | ||
|
||
export default function Standpoints({ params: { id } }: PageProps) { | ||
const subject = getSubject(id); | ||
if (!subject) { | ||
return notFound(); | ||
} | ||
|
||
const standpoints = getStandpointsForSubject(subject.id); | ||
|
||
return ( | ||
<main> | ||
<PageTitle>{subject.name}</PageTitle> | ||
<div className="container"> | ||
{Object.entries(standpoints).map(([party, standpoints]) => ( | ||
<PartyStandpoints | ||
key={party} | ||
party={party as Party} | ||
standpoints={standpoints} | ||
/> | ||
))} | ||
</div> | ||
</main> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"use client"; | ||
|
||
import type { Party, Standpoint } from "@partiguiden/party-data/types"; | ||
import { getPartyName } from "@partiguiden/party-data/utils"; | ||
import { useState } from "react"; | ||
|
||
interface PartyStandpointsProps { | ||
party: Party; | ||
standpoints: Standpoint[]; | ||
} | ||
|
||
export default function PartyStandpoints({ | ||
party, | ||
standpoints, | ||
}: PartyStandpointsProps) { | ||
const [visible, setVisible] = useState(false); | ||
|
||
function handleClick() { | ||
setVisible((prevState) => !prevState); | ||
} | ||
|
||
return <div>{getPartyName(party)}</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import PageTitle from "@components/page-title"; | ||
import { getSubjects } from "@partiguiden/party-data/reader"; | ||
import { PencilSquareIcon } from "@heroicons/react/24/solid"; | ||
import Link from "next/link"; | ||
import { routes } from "@lib/navigation"; | ||
|
||
export const metadata = { | ||
title: "Partiernas ståndpunkter | Partiguiden", | ||
description: | ||
"Vad tar Sveriges partier för ståndpunkter i olika ämnen och sakfrågor? Jämför Sveriges partier politik och hitta det parti du sympatiserar mest med nu!", | ||
}; | ||
|
||
const shiftColors = [ | ||
"[&:nth-child(3n)]:bg-gray-100", | ||
"[&:nth-child(3n+1)]:bg-gray-200", | ||
"[&:nth-child(3n+2)]:bg-gray-200/60", | ||
"dark:[&:nth-child(3n)]:bg-background-elevated-dark", | ||
"dark:[&:nth-child(3n+1)]:bg-background-elevated-dark", | ||
"dark:[&:nth-child(3n+2)]:bg-background-elevated-dark", | ||
].join(" "); | ||
|
||
export default function Subjects() { | ||
const subjects = getSubjects().sort((a, b) => { | ||
if (a.name < b.name) { | ||
return -1; | ||
} | ||
if (a.name > b.name) { | ||
return 1; | ||
} | ||
return 0; | ||
}); | ||
|
||
return ( | ||
<main> | ||
<PageTitle Icon={PencilSquareIcon}>Partiernas Ståndpunkter</PageTitle> | ||
<div className="mb-8 sm:container"> | ||
<div className="border-l-primary grid grid-cols-1 border-l-2 border-t-2 border-t-slate-300 dark:border-t-slate-700 md:grid-cols-2"> | ||
{subjects.map((subject) => ( | ||
<Link | ||
key={subject.id} | ||
href={routes.standpoint(subject.id)} | ||
className={`${shiftColors} group`} | ||
> | ||
<span className="to-primary group:hover:transition-all inline-block bg-gradient-to-l from-transparent from-50% to-50% bg-[length:200%_100%] bg-right px-3 py-4 duration-300 group-hover:bg-left group-hover:text-white"> | ||
{subject.name} | ||
</span> | ||
</Link> | ||
))} | ||
</div> | ||
</div> | ||
</main> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
type PageTitleProps = React.PropsWithChildren<{ | ||
Icon?: React.ElementType; | ||
}>; | ||
|
||
export default function PageTitle({ children, Icon }: PageTitleProps) { | ||
return ( | ||
<div className="bg-primary dark:bg-background-elevated-dark py-4 text-center text-white"> | ||
{Icon && <Icon className="mx-auto mb-4 h-10 w-10" />} | ||
<h1 className="text-3xl">{children}</h1> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const ERROR_404_TITLE = "404 | Sidan hittades inte | Partiguiden"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.