Skip to content

Commit

Permalink
switch to layout
Browse files Browse the repository at this point in the history
  • Loading branch information
dinoDanic committed Feb 29, 2024
1 parent 1bf9d36 commit 0e18c89
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 66 deletions.
20 changes: 20 additions & 0 deletions apps/bible/app/bible/components/bible-child.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"use client";

import { cn } from "@/lib/utils";
import { BibleContentChild } from "@/site/bible-contents";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { FC } from "react";

export const BibleChild: FC<BibleContentChild> = (child) => {
const segment = usePathname();
const isActive = segment?.includes(child.href);
return (
<Link
href={child.href}
className={cn("text-muted-foreground", isActive && "text-primary")}
>
{child.title}
</Link>
);
};
34 changes: 34 additions & 0 deletions apps/bible/app/bible/components/bible-side.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Stack } from "@/components/primitives/stack";
import { Text } from "@/components/typography/text";
import { BibleContent, bibleContents } from "@/site/bible-contents";
import { FC } from "react";
import { BibleChild } from "./bible-child";

export const BibleSide = () => {
return (
<Stack gap="2xl" className="p-4">
{bibleContents.map((bibleContent) => (
<BibleContent key={bibleContent.title} {...bibleContent} />
))}
</Stack>
);
};

const BibleContent: FC<BibleContent> = (content) => {
const bibleChilds = (
<Stack gap="xs" className="pl-xs border-l-2">
{content.children.map((bibleChild) => (
<BibleChild key={bibleChild.title} {...bibleChild} />
))}
</Stack>
);

const title = <Text>{content.title}</Text>;

return (
<Stack gap="xs">
{title}
{bibleChilds}
</Stack>
);
};
7 changes: 6 additions & 1 deletion apps/bible/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Inter } from "next/font/google";
import "./globals.css";
import { ThemeProvider } from "@/components/theme-provider";
import { cn } from "@/lib/utils";
import { Sidebar } from "@/components/primitives/sidebar";
import { BibleSide } from "./bible/components/bible-side";

const inter = Inter({ subsets: ["latin"] });

Expand All @@ -25,7 +27,10 @@ export default function RootLayout({
enableSystem
disableTransitionOnChange
>
{children}
<Sidebar>
<BibleSide />
{children}
</Sidebar>
</ThemeProvider>
</body>
</html>
Expand Down
62 changes: 1 addition & 61 deletions apps/bible/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,63 +1,3 @@
import { Stack } from "@/components/primitives/stack";
import { Text } from "@/components/typography/text";
import {
BibleContent,
BibleContentChild,
bibleContents,
} from "@/site/bible-contents";
import Link from "next/link";
import { FC } from "react";

export default function Home() {
return (
<Stack gap="2xl" className="p-4">
{bibleContents.map((bibleContent) => (
<BibleContent key={bibleContent.title} {...bibleContent} />
))}
</Stack>
);
return <div>home</div>;
}

const BibleContent: FC<BibleContent> = (content) => {
const bibleChilds = (
<Stack gap="xs" className="pl-xs border-l-2">
{content.children.map((bibleChild) => (
<BibleChild key={bibleChild.title} {...bibleChild} />
))}
</Stack>
);

const title = <Text tone="muted">{content.title}</Text>;

return (
<Stack gap="xs">
{title}
{bibleChilds}
</Stack>
);
};

const BibleChild: FC<BibleContentChild> = (child) => {
const title = child.href ? (
<Link href={child.href}> {child.title}</Link>
) : (
<Text>{child.title}</Text>
);

const notes = child.notes && (
<Stack className="border-l-2 py-xxs" gap="xs">
{child.notes.map((note) => (
<Text key={note} tone="muted" className="pl-xs">
{note}
</Text>
))}
</Stack>
);

return (
<Stack gap="xxs">
{title}
{notes}
</Stack>
);
};
5 changes: 1 addition & 4 deletions apps/bible/site/bible-contents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ export type BibleContent = {
};

export type BibleContentChild = Omit<BibleContent, "children"> & {
href: Route | null;
status: "done" | "todo" | "re-opened";
notes?: string[];
href: Route;
};

export const bibleContents: BibleContent[] = [
Expand All @@ -19,7 +17,6 @@ export const bibleContents: BibleContent[] = [
{
title: "Parrallel and Sequential data fetching",
href: routes.bible.dataFetching.parrallelAndSequential.index,
status: "todo",
},
],
},
Expand Down

0 comments on commit 0e18c89

Please sign in to comment.