Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | 104x 1752x 1752x 1752x 767x | import React from "react";
import { MyLink } from "chainr-frontend-shared";
import { ChevronLeft, Pencil } from "lucide-react";
import { Link, useLocation } from "react-router-dom";
import { usePageMeta } from "@/context/PageContext";
export interface SubPageInterface {
title: React.ReactNode;
title_icon?: React.ReactNode;
links?: React.ReactNode[];
description?: string;
children?: React.ReactNode;
editable?: boolean;
back?: string;
}
const SubPage: React.FC<SubPageInterface> = (props) => {
usePageMeta(props.title, true);
const location = useLocation();
return (
<div>
{props.back && (
<Link
to={props.back}
className="inline-flex items-center gap-1 text-xs text-gray-400 dark:text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 transition-colors mb-3"
>
<ChevronLeft className="size-3.5" />
Back
</Link>
)}
{!props.title_icon && (
<h1 className="text-xl font-bold drop-shadow-lg">{props.title}</h1>
)}
{props.title_icon && (
<div className="flex flex-row gap-4 items-center">
{props.title_icon}
<h1 className="text-xl font-bold drop-shadow-lg min-w-0 break-words">
{props.title}
</h1>
{props.editable && (
<MyLink
to={`${location.pathname}/edit`}
name={
<>
<Pencil className="pr-2" /> Edit
</>
}
classes="bg-slate-700 ml-auto"
/>
)}
</div>
)}
<br />
<hr />
<br />
{props.links && props.links.length > 0 && (
<>
{/* Wraps rather than running off a phone's screen: a page with
several actions is wider than 390px on one line. */}
<div className="flex flex-wrap justify-start items-start gap-x-4 gap-y-2">
{/* Keyed here rather than at the call site: `links` is an array
of elements, so React wants a key on each, and every page that
passed one got a console warning nobody read. The order is
fixed (it is a toolbar, not a data list), so the index is a
stable key. */}
{props.links.map((link, i) => (
<React.Fragment key={i}>{link}</React.Fragment>
))}
</div>
<br />
<hr />
<br />
</>
)}
{props.description && <p>{props.description}</p>}
{props.children}
</div>
);
};
export default SubPage;
|