Moves routes inside an _app for the header and builds a print route
This commit is contained in:
64
src/components/documents/DocumentPrintRow.tsx
Normal file
64
src/components/documents/DocumentPrintRow.tsx
Normal file
@@ -0,0 +1,64 @@
|
||||
// DocumentRow.tsx
|
||||
// Generic row component for displaying any document type.
|
||||
import {
|
||||
isLocation,
|
||||
isMonster,
|
||||
isNpc,
|
||||
isScene,
|
||||
isSecret,
|
||||
isSession,
|
||||
isTreasure,
|
||||
type Document,
|
||||
} from "@/lib/types";
|
||||
import { LocationPrintRow } from "./location/LocationPrintRow";
|
||||
import { MonsterPrintRow } from "./monsters/MonsterPrintRow";
|
||||
import { TreasurePrintRow } from "./treasure/TreasurePrintRow";
|
||||
import { SecretPrintRow } from "./secret/SecretPrintRow";
|
||||
import { NpcPrintRow } from "./npc/NpcPrintRow";
|
||||
import { ScenePrintRow } from "./scene/ScenePrintRow";
|
||||
import { SessionPrintRow } from "./session/SessionPrintRow";
|
||||
|
||||
/**
|
||||
* Renders a row for any document type. Prioritizes Session, then Secret, then falls back to ID and creation time.
|
||||
* If rendering a SecretRow, uses the provided session prop if available.
|
||||
*/
|
||||
export const DocumentPrintRow = ({ document }: { document: Document }) => {
|
||||
if (isLocation(document)) {
|
||||
return <LocationPrintRow location={document} />;
|
||||
}
|
||||
|
||||
if (isMonster(document)) {
|
||||
return <MonsterPrintRow monster={document} />;
|
||||
}
|
||||
|
||||
if (isNpc(document)) {
|
||||
return <NpcPrintRow npc={document} />;
|
||||
}
|
||||
|
||||
if (isSession(document)) {
|
||||
return <SessionPrintRow session={document} />;
|
||||
}
|
||||
|
||||
if (isSecret(document)) {
|
||||
return <SecretPrintRow secret={document} />;
|
||||
}
|
||||
|
||||
if (isScene(document)) {
|
||||
return <ScenePrintRow scene={document} />;
|
||||
}
|
||||
|
||||
if (isTreasure(document)) {
|
||||
return <TreasurePrintRow treasure={document} />;
|
||||
}
|
||||
|
||||
// Fallback: show ID and creation time
|
||||
return (
|
||||
<div>
|
||||
<div className="font-semibold text-lg text-slate-300">
|
||||
Unrecognized Document
|
||||
</div>
|
||||
<div className="text-slate-400 text-sm">ID: {document.id}</div>
|
||||
<div className="text-slate-400 text-sm">Created: {document.created}</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
13
src/components/documents/location/LocationPrintRow.tsx
Normal file
13
src/components/documents/location/LocationPrintRow.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { Location } from "@/lib/types";
|
||||
|
||||
/**
|
||||
* Renders an print-friendly location row
|
||||
*/
|
||||
export const LocationPrintRow = ({ location }: { location: Location }) => {
|
||||
return (
|
||||
<li>
|
||||
<h4>{location.data.location.name}</h4>
|
||||
<p>{location.data.location.description}</p>
|
||||
</li>
|
||||
);
|
||||
};
|
||||
8
src/components/documents/monsters/MonsterPrintRow.tsx
Normal file
8
src/components/documents/monsters/MonsterPrintRow.tsx
Normal file
@@ -0,0 +1,8 @@
|
||||
import type { Monster } from "@/lib/types";
|
||||
|
||||
/**
|
||||
* Renders an editable monster row
|
||||
*/
|
||||
export const MonsterPrintRow = ({ monster }: { monster: Monster }) => {
|
||||
return <li>{monster.data.monster.name}</li>;
|
||||
};
|
||||
13
src/components/documents/npc/NpcPrintRow.tsx
Normal file
13
src/components/documents/npc/NpcPrintRow.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { Npc } from "@/lib/types";
|
||||
|
||||
/**
|
||||
* Renders an editable npc row
|
||||
*/
|
||||
export const NpcPrintRow = ({ npc }: { npc: Npc }) => {
|
||||
return (
|
||||
<li className="">
|
||||
<h4>{npc.data.npc.name}</h4>
|
||||
<p>{npc.data.npc.description}</p>
|
||||
</li>
|
||||
);
|
||||
};
|
||||
8
src/components/documents/scene/ScenePrintRow.tsx
Normal file
8
src/components/documents/scene/ScenePrintRow.tsx
Normal file
@@ -0,0 +1,8 @@
|
||||
import type { Scene } from "@/lib/types";
|
||||
|
||||
/**
|
||||
* Renders an editable scene row
|
||||
*/
|
||||
export const ScenePrintRow = ({ scene }: { scene: Scene }) => {
|
||||
return <li className="">{scene.data.scene.text}</li>;
|
||||
};
|
||||
24
src/components/documents/secret/SecretPrintRow.tsx
Normal file
24
src/components/documents/secret/SecretPrintRow.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
// SecretRow.tsx
|
||||
// Displays a single secret with discovered checkbox and text.
|
||||
import type { Secret } from "@/lib/types";
|
||||
|
||||
/**
|
||||
* Renders a secret row with a discovered checkbox and secret text.
|
||||
* Handles updating the discovered state and discoveredIn relationship.
|
||||
*/
|
||||
export const SecretPrintRow = ({ secret }: { secret: Secret }) => {
|
||||
return (
|
||||
<li className="flex items-center gap-3">
|
||||
<input
|
||||
type="checkbox"
|
||||
className="flex-none accent-emerald-500 w-5 h-5"
|
||||
aria-label="Discovered"
|
||||
/>
|
||||
<span>
|
||||
{(secret.data as any)?.secret?.text || (
|
||||
<span className="italic text-slate-400">(No secret text)</span>
|
||||
)}
|
||||
</span>
|
||||
</li>
|
||||
);
|
||||
};
|
||||
10
src/components/documents/session/SessionPrintRow.tsx
Normal file
10
src/components/documents/session/SessionPrintRow.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { Session } from "@/lib/types";
|
||||
|
||||
export const SessionPrintRow = ({ session }: { session: Session }) => {
|
||||
return (
|
||||
<div>
|
||||
<h3 className="text-lg font-bold text-slate-600">StrongStart</h3>
|
||||
<div className="">{session.data.session.strongStart}</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
24
src/components/documents/treasure/TreasurePrintRow.tsx
Normal file
24
src/components/documents/treasure/TreasurePrintRow.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
// TreasureRow.tsx
|
||||
// Displays a single treasure with discovered checkbox and text.
|
||||
import type { Treasure } from "@/lib/types";
|
||||
|
||||
/**
|
||||
* Renders a treasure row with a discovered checkbox and treasure text.
|
||||
* Handles updating the discovered state and discoveredIn relationship.
|
||||
*/
|
||||
export const TreasurePrintRow = ({ treasure }: { treasure: Treasure }) => {
|
||||
return (
|
||||
<li className="flex items-center gap-3">
|
||||
<input
|
||||
type="checkbox"
|
||||
className="flex-none accent-emerald-500 w-5 h-5"
|
||||
aria-label="Discovered"
|
||||
/>
|
||||
<span>
|
||||
{(treasure.data as any)?.treasure?.text || (
|
||||
<span className="italic text-slate-400">(No treasure text)</span>
|
||||
)}
|
||||
</span>
|
||||
</li>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user