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 | 2x 5x 5x 5x 5x 5x 5x 5x | import { useWorkspace } from "@/context/WorkspaceContext";
import { linkActive } from "@/routes/workspace";
import { Link, useLocation } from "react-router-dom";
// import { useTheme } from "../../../context/ThemeContext";
export interface SectionLinkProps {
href: string;
children: React.ReactNode | string;
indentLevel?: number;
}
const SectionLink: React.FC<SectionLinkProps> = (props) => {
const currLocation = useLocation();
const workspace = useWorkspace();
// const { theme } = useTheme();
// Matched where the link goes in this workspace — `Link` moves it there —
// not against the Personal route it is written as.
const selected = linkActive(workspace, props.href, currLocation.pathname);
const indent = props.indentLevel ? props.indentLevel * 16 : 0; // px
const selectedClass =
// theme === "dark"
// ? "border-l-4 border-blue-500 bg-blue-950 text-blue-700 font-medium"
"border-l-4 border-blue-500 text-blue-700 font-medium selected";
Iif (props.indentLevel ?? 0 > 0) {
return (
<div style={{ paddingLeft: indent }}>
<Link
to={props.href}
className={`hover:pl-5 block w-full pl-4 py-2 border-l transition-all duration-200
${selected ? selectedClass : "hover:pl-5 block pl-4 py-2 border-l transition-all duration-200"}`}
>
{props.children}
</Link>
</div>
);
}
return (
<Link
to={props.href}
className={`hover:pl-5 block w-full pl-4 py-2 border-l transition-all duration-200
${selected ? selectedClass : "hover:pl-5 block pl-4 py-2 border-l transition-all duration-200"}`}
>
{props.children}
</Link>
);
};
export default SectionLink;
|