Skip to content

Commit

Permalink
feat: add other stories
Browse files Browse the repository at this point in the history
  • Loading branch information
KeziahMoselle committed May 5, 2023
1 parent 6ce517a commit f734cf6
Show file tree
Hide file tree
Showing 12 changed files with 643 additions and 31 deletions.
8 changes: 5 additions & 3 deletions src/components/Layout/StoriesLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ const ITEMS = [
},
{
label: "Characters",
href: "/database/stories/character",
href: "/database/stories/characters",
},
{
label: "EX characters",
href: "/database/stories/ex-character",
href: "/database/stories/ex-characters",
},
{
label: "Recollections of Dusk",
href: "/database/stories/rod-character",
href: "/database/stories/rod-characters",
},
{
label: "Events",
Expand All @@ -30,6 +30,7 @@ const ITEMS = [
{
label: "Hidden stories",
href: "/database/stories/hidden-stories",
disabled: true,
},
{
label: "Lost archives",
Expand Down Expand Up @@ -65,6 +66,7 @@ export default function StoriesLayout({ children }): JSX.Element {
href={item.href}
className={classNames(
"flex items-center justify-center text-center p-4 transition-colors ease-out-cubic relative bordered",
item.disabled ? "pointer-events-none opacity-40" : "",
router.asPath.includes(item.href)
? "active bg-beige active"
: "bg-grey-lighter"
Expand Down
102 changes: 102 additions & 0 deletions src/pages/database/stories/anecdotes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import Layout from "@components/Layout";
import Meta from "@components/Meta";
import Link from "next/link";
import SVG from "react-inlinesvg";
import prisma from "@libs/prisma";
import { card_story } from "@prisma/client";
import { CDN_URL } from "@config/constants";
import { useState } from "react";
import { FormControl, InputLabel, MenuItem, Select } from "@mui/material";
import Squares from "@components/decorations/Squares";
import StoriesLayout from "@components/Layout/StoriesLayout";

interface Props {
anecdotes: card_story[];
}

export default function DatabaseStories({ anecdotes }: Props): JSX.Element {
const [anecdoteIndex, setAnecdoteIndex] = useState(anecdotes[0].id);

return (
<Layout>
<Meta
title="Anecdotes stories - Database"
description="Anecdotes stories"
cover="https://nierrein.guide/cover-stories.jpg"
/>

<nav className="mb-16">
<Link href="/database" passHref={true} className="btn">
<SVG src="/decorations/arrow-left.svg" className="h-6" />
<span>Return to Database</span>
</Link>
</nav>

<StoriesLayout>
<div className="relative">
<div className="flex items-center gap-y-4 gap-x-4 bg-grey-dark border border-beige border-opacity-50 p-4 mb-8">
<FormControl className="flex-1">
<InputLabel id="season-index">Anecdote</InputLabel>
<Select
labelId="season-index"
value={anecdoteIndex}
label="Type"
onChange={(e) => {
setAnecdoteIndex(e.target.value);
}}
>
{anecdotes.map((anecdote) => (
<MenuItem
className="flex items-center justify-between"
key={anecdote.id}
value={anecdote.id}
>
<span>{anecdote.name}</span>
</MenuItem>
))}
</Select>
</FormControl>
</div>

<article className="relative bordered bg-grey-dark p-4 rounded-lg">
<Squares />
{anecdotes
.filter((anecdote) => anecdote.id === anecdoteIndex)
.map((anecdote) => (
<div key={anecdote.id}>
{anecdote.stories.map(({ story, image_path }, index) => (
<div key={index} className="my-4">
<img
className="mb-4"
src={`${CDN_URL}${image_path}`}
alt={`Story ${index + 1} image`}
loading="lazy"
/>
<p
className="whitespace-pre-wrap mb-4 pl-4"
dangerouslySetInnerHTML={{
__html: story,
}}
></p>
</div>
))}
</div>
))}
</article>
</div>
</StoriesLayout>
</Layout>
);
}

export async function getStaticProps() {
const anecdotes = await prisma.dump.card_story.findMany();

return {
props: JSON.parse(
JSON.stringify({
anecdotes,
})
),
};
}
107 changes: 107 additions & 0 deletions src/pages/database/stories/characters.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import Layout from "@components/Layout";
import Meta from "@components/Meta";
import Link from "next/link";
import SVG from "react-inlinesvg";
import prisma from "@libs/prisma";
import { character } from "@prisma/client";
import { CDN_URL } from "@config/constants";
import { useState } from "react";
import { FormControl, InputLabel, MenuItem, Select } from "@mui/material";
import Squares from "@components/decorations/Squares";
import StoriesLayout from "@components/Layout/StoriesLayout";

interface Props {
characters: character[];
}

export default function DatabaseStories({ characters }: Props): JSX.Element {
const [characterIndex, setCharacterIndex] = useState(
characters[0].character_id
);

return (
<Layout>
<Meta
title="Characters stories - Database"
description="Characters stories"
cover="https://nierrein.guide/cover-stories.jpg"
/>

<nav className="mb-16">
<Link href="/database" passHref={true} className="btn">
<SVG src="/decorations/arrow-left.svg" className="h-6" />
<span>Return to Database</span>
</Link>
</nav>

<StoriesLayout>
<div className="relative">
<div className="flex items-center gap-y-4 gap-x-4 bg-grey-dark border border-beige border-opacity-50 p-4 mb-8">
<FormControl className="flex-1">
<InputLabel id="season-index">Character</InputLabel>
<Select
labelId="season-index"
value={characterIndex}
label="Type"
onChange={(e) => {
setCharacterIndex(e.target.value);
}}
>
{characters.map((character) => (
<MenuItem
key={character.character_id}
value={character.character_id}
>
{character.name}
</MenuItem>
))}
</Select>
</FormControl>
</div>

<article className="relative bordered bg-grey-dark p-4 rounded-lg">
<Squares />
{characters
.filter((character) => character.character_id === characterIndex)
.map((character) => (
<div key={character.character_id}>
{character.character_stories.map(
({ story, image_path }, index) => (
<div key={index} className="my-4">
<img
className="mb-4"
src={`${CDN_URL}${image_path}`}
alt={`Story ${index + 1} image`}
loading="lazy"
/>
<p
className="whitespace-pre-wrap mb-4 pl-4"
dangerouslySetInnerHTML={{
__html: story,
}}
></p>
</div>
)
)}
</div>
))}
</article>
</div>
</StoriesLayout>
</Layout>
);
}

export async function getStaticProps() {
const characters = await prisma.dump.character.findMany();

return {
props: JSON.parse(
JSON.stringify({
characters: characters.filter(
(character) => character.character_stories.length > 0
),
})
),
};
}
9 changes: 3 additions & 6 deletions src/pages/database/stories/companions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Box } from "@mui/system";
import { StoriesNavbar } from "./index";
import { useSettingsStore } from "@store/settings";
import CompanionThumbnail from "@components/CompanionThumbnail";
import StoriesLayout from "@components/Layout/StoriesLayout";

interface DatabaseStoriesCompanionsProps {
companions: companion[];
Expand Down Expand Up @@ -56,11 +57,7 @@ export default function DatabaseStoriesCompanions({
cover="https://nierrein.guide/cover-stories.jpg"
/>

<section>
<h2 className="overlap">Companions stories</h2>

<StoriesNavbar />

<StoriesLayout>
<div className="flex flex-col items-center md:flex-row gap-y-4 gap-x-4 bg-grey-dark border border-beige border-opacity-50 p-4 mb-8">
<Autocomplete
onChange={(e, companion: companion) => {
Expand Down Expand Up @@ -127,7 +124,7 @@ export default function DatabaseStoriesCompanions({
</div>
))}
</div>
</section>
</StoriesLayout>
</Layout>
);
}
Expand Down
10 changes: 3 additions & 7 deletions src/pages/database/stories/costumes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { NextPageContext } from "next";
import { Box } from "@mui/system";
import { StoriesNavbar } from "./index";
import { useSettingsStore } from "@store/settings";
import StoriesLayout from "@components/Layout/StoriesLayout";

interface DatabaseStoriesCostumesProps {
costumes: costume[];
Expand Down Expand Up @@ -96,11 +97,7 @@ export default function DatabaseStoriesCostumes({
cover="https://nierrein.guide/cover-stories.jpg"
/>

<section>
<h2 className="overlap">Costumes stories</h2>

<StoriesNavbar />

<StoriesLayout>
<div className="flex flex-col items-center md:flex-row gap-y-4 gap-x-4 bg-grey-dark border border-beige border-opacity-50 p-4 mb-8">
<Autocomplete
onChange={(e, character) => {
Expand Down Expand Up @@ -164,7 +161,6 @@ export default function DatabaseStoriesCostumes({
/>
</LocalizationProvider>
</div>

<div>
{costumes
.filter((costume) => {
Expand Down Expand Up @@ -215,7 +211,7 @@ export default function DatabaseStoriesCostumes({
</div>
)}
</div>
</section>
</StoriesLayout>
</Layout>
);
}
Expand Down
Loading

0 comments on commit f734cf6

Please sign in to comment.