Skip to content
Myr

side-column.tsx

This file

Path

apps/web/src/features/shared/shell/side-column.tsx

40 lines · 1.1 KiB · TypeScript

Last changed by

Merge redesign into mainoscabrielbefore adoptioncaedd21

History of this file

Take it

Merge redesign into mainoscabrielbefore adoptioncaedd21

lines 1–40why, one step back
1import { useMatches } from "@tanstack/react-router";
2import { createElement } from "react";3import type { ComponentType, ReactNode } from "react";45declare module "@tanstack/react-router" {6 interface StaticDataRouteOption {7 /** A project page's side column: the file tree beside code, or a finish's files. */8 readonly column?: ComponentType;9 }10}1112/** Its own scroll, so a long tree never moves the page beside it. */13export const SideColumn = ({14 children,15 label = "Files",16}: {17 readonly children: ReactNode;18 readonly label?: string;19}) => (20 <section21 aria-label={label}22 className="flex min-h-0 flex-1 flex-col overflow-hidden"23 data-column="tree"24 >25 {children}26 </section>27);2829export const useSideColumn = (): ComponentType | undefined =>30 useMatches({31 select: (matches) =>32 matches.findLast(({ staticData }) => staticData.column !== undefined)33 ?.staticData.column,34 });3536export const SideColumnOutlet = (): ReactNode => {37 const Content = useSideColumn();3839 return Content === undefined ? null : createElement(Content);40};