Skip to content

Commit

Permalink
feat: initialise module page
Browse files Browse the repository at this point in the history
  • Loading branch information
ixahmedxi committed Sep 4, 2024
1 parent 8f91ca2 commit 9e48c2f
Show file tree
Hide file tree
Showing 8 changed files with 315 additions and 128 deletions.
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ words:
- Uploadthing
- Upstash
- healthcheck
- timeago
30 changes: 16 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@
}
},
"dependencies": {
"@clerk/nextjs": "^5.3.7",
"@clerk/themes": "^2.1.25",
"@clerk/nextjs": "^5.4.1",
"@clerk/themes": "^2.1.27",
"@hookform/resolvers": "^3.9.0",
"@neondatabase/serverless": "^0.9.4",
"@neondatabase/serverless": "^0.9.5",
"@paralleldrive/cuid2": "^2.2.2",
"@radix-ui/colors": "^3.0.0",
"@radix-ui/react-checkbox": "^1.1.1",
Expand All @@ -69,9 +69,10 @@
"@radix-ui/react-select": "^2.1.1",
"@radix-ui/react-separator": "^1.1.0",
"@radix-ui/react-slot": "^1.1.0",
"@react-email/components": "^0.0.24",
"@radix-ui/react-tabs": "^1.1.0",
"@react-email/components": "^0.0.25",
"@t3-oss/env-nextjs": "^0.11.1",
"@tanstack/react-query": "^5.53.1",
"@tanstack/react-query": "^5.54.1",
"@trpc/client": "next",
"@trpc/react-query": "next",
"@trpc/server": "next",
Expand All @@ -82,10 +83,10 @@
"clsx": "^2.1.1",
"drizzle-orm": "^0.33.0",
"drizzle-zod": "^0.5.1",
"framer-motion": "^11.3.31",
"framer-motion": "^11.4.0",
"geist": "^1.3.1",
"jiti": "^1.21.6",
"lucide-react": "^0.437.0",
"lucide-react": "^0.438.0",
"next": "14.2.7",
"next-mdx-remote": "^5.0.0",
"next-themes": "^0.3.0",
Expand All @@ -99,6 +100,7 @@
"sonner": "^1.5.0",
"superjson": "^2.2.1",
"tailwind-merge": "^2.5.2",
"timeago.js": "^4.0.2",
"use-resize-observer": "^9.1.0",
"zod": "^3.23.8"
},
Expand All @@ -111,17 +113,17 @@
"@eslint/compat": "^1.1.1",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.9.1",
"@happy-dom/global-registrator": "^15.7.2",
"@happy-dom/global-registrator": "^15.7.3",
"@ianvs/prettier-plugin-sort-imports": "^4.3.1",
"@next/eslint-plugin-next": "^14.2.7",
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/container-queries": "^0.1.1",
"@tailwindcss/typography": "^0.5.15",
"@total-typescript/ts-reset": "^0.6.0",
"@total-typescript/ts-reset": "^0.6.1",
"@types/bun": "^1.1.8",
"@types/eslint": "^9.6.1",
"@types/eslint-config-prettier": "^6.11.3",
"@types/node": "^22.5.2",
"@types/node": "^22.5.3",
"@types/react": "^18.3.5",
"@types/react-dom": "^18.3.0",
"commitizen": "^4.3.0",
Expand All @@ -131,24 +133,24 @@
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jsdoc": "^50.2.2",
"eslint-plugin-jsx-a11y": "^6.9.0",
"eslint-plugin-react": "^7.35.0",
"eslint-plugin-react": "^7.35.2",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-regexp": "^2.6.0",
"eslint-plugin-security": "^3.0.1",
"eslint-plugin-tailwindcss": "^3.17.4",
"globals": "^15.9.0",
"husky": "^9.1.5",
"lint-staged": "^15.2.9",
"lint-staged": "^15.2.10",
"markdownlint": "^0.35.0",
"markdownlint-cli": "^0.41.0",
"postcss": "^8.4.42",
"postcss": "^8.4.44",
"prettier": "^3.3.3",
"prettier-plugin-curly": "^0.2.2",
"prettier-plugin-packagejson": "^2.5.2",
"tailwindcss": "^3.4.10",
"tailwindcss-animate": "^1.0.7",
"typescript": "^5.5.4",
"typescript-eslint": "^8.3.0"
"typescript-eslint": "^8.4.0"
},
"trustedDependencies": [
"@clerk/shared",
Expand Down
113 changes: 113 additions & 0 deletions src/app/(dashboard)/app/_components/side-menu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import { api } from '@/lib/trpc/server';
import {
CircleHelpIcon,
DiamondIcon,
HomeIcon,
MessageSquareMore,
PenLineIcon,
} from 'lucide-react';
import Image from 'next/image';
import { ActiveButton } from './active-button';
import { CreateModulePopover } from './create-module-popover';
import type { IconNames } from '@/primitives/icon';
import { Icon } from '@/primitives/icon';
import { Button } from '@/primitives/button';

const iconSize = 15;

const sideMenuStaticLinks = [
{
icon: <HomeIcon size={iconSize} />,
label: 'Home',
href: '/app',
},
{
icon: <PenLineIcon size={iconSize} />,
label: 'Notebooks',
href: '/app/notes',
},
{
icon: <DiamondIcon size={iconSize} />,
label: 'Flashcards',
href: '/app/flashcards',
},
];

export async function SideMenu() {
const modules = await api.modules.getUserModules();

return (
<aside className="flex w-[200px] flex-col justify-between gap-8">
<div>
<div className="flex items-center gap-3 pl-3 pt-4">
<Image src="/logo.svg" width={35} height={35} alt="Noodle Logo" />
<span>Noodle</span>
</div>

<ul className="mt-8 flex flex-col">
{sideMenuStaticLinks.map(({ icon, label, href }) => (
<li key={label} className="flex flex-1 flex-col">
<ActiveButton icon={icon} label={label} href={href} />
</li>
))}
</ul>

<div className="mt-6 space-y-2">
<div className="flex items-center justify-between pl-4">
<h3 className="text-xs text-gray">Modules</h3>
<CreateModulePopover />
</div>
<ul className="flex flex-col">
{modules
.sort((a, b) => {
return (
new Date(a.createdAt).getTime() -
new Date(b.createdAt).getTime()
);
})
.map((module) => (
<li key={module.id} className="flex flex-1 flex-col">
<ActiveButton
href={`/app/module/${module.id}`}
icon={
<Icon
name={
module.icon === 'default'
? 'Folder'
: (module.icon as IconNames)
}
size={15}
strokeWidth={1.5}
/>
}
label={module.name}
/>
</li>
))}
</ul>
</div>
</div>

<div className="mb-6 flex flex-col">
<Button
variant="ghost"
className="justify-start gap-3 font-normal"
asChild
>
<a href="mailto:[email protected]">
<MessageSquareMore size={15} strokeWidth={1.5} /> Feedback
</a>
</Button>
<Button
variant="ghost"
className="justify-start gap-3 font-normal"
asChild
>
<a href="mailto:[email protected]">
<CircleHelpIcon size={15} strokeWidth={1.5} /> Help & Support
</a>
</Button>
</div>
</aside>
);
}
113 changes: 4 additions & 109 deletions src/app/(dashboard)/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,118 +1,13 @@
import {
CircleHelpIcon,
DiamondIcon,
HomeIcon,
MessageSquareMore,
PanelLeftCloseIcon,
PenLineIcon,
} from 'lucide-react';
import Image from 'next/image';
import { PanelLeftCloseIcon } from 'lucide-react';
import type { PropsWithChildren } from 'react';
import { ActiveButton } from './_components/active-button';
import { Button } from '@/primitives/button';
import { UserButton } from '@clerk/nextjs';
import { CreateModulePopover } from './_components/create-module-popover';
import { api } from '@/lib/trpc/server';
import type { IconNames } from '@/primitives/icon';
import { Icon } from '@/primitives/icon';

const iconSize = 15;

const sideMenuStaticLinks = [
{
icon: <HomeIcon size={iconSize} />,
label: 'Home',
href: '/app',
},
{
icon: <PenLineIcon size={iconSize} />,
label: 'Notebooks',
href: '/app/notes',
},
{
icon: <DiamondIcon size={iconSize} />,
label: 'Flashcards',
href: '/app/flashcards',
},
];

export default async function AppLayout({ children }: PropsWithChildren) {
const modules = await api.modules.getUserModules();
import { SideMenu } from './_components/side-menu';

export default function AppLayout({ children }: PropsWithChildren) {
return (
<main className="flex min-h-dvh gap-4 p-4">
<aside className="flex w-[200px] flex-col justify-between gap-8">
<div>
<div className="flex items-center gap-3 pl-3 pt-4">
<Image src="/logo.svg" width={35} height={35} alt="Noodle Logo" />
<span>Noodle</span>
</div>

<ul className="mt-8 flex flex-col">
{sideMenuStaticLinks.map(({ icon, label, href }) => (
<li key={label} className="flex flex-1 flex-col">
<ActiveButton icon={icon} label={label} href={href} />
</li>
))}
</ul>

<div className="mt-6 space-y-2">
<div className="flex items-center justify-between pl-4">
<h3 className="text-xs text-gray">Modules</h3>
<CreateModulePopover />
</div>
<ul className="flex flex-col">
{modules
.sort((a, b) => {
return (
new Date(a.createdAt).getTime() -
new Date(b.createdAt).getTime()
);
})
.map((module) => (
<li key={module.id} className="flex flex-1 flex-col">
<ActiveButton
href={`/modules/${module.id}`}
icon={
<Icon
name={
module.icon === 'default'
? 'Folder'
: (module.icon as IconNames)
}
size={15}
strokeWidth={1.5}
/>
}
label={module.name}
/>
</li>
))}
</ul>
</div>
</div>

<div className="mb-6 flex flex-col">
<Button
variant="ghost"
className="justify-start gap-3 font-normal"
asChild
>
<a href="mailto:[email protected]">
<MessageSquareMore size={15} strokeWidth={1.5} /> Feedback
</a>
</Button>
<Button
variant="ghost"
className="justify-start gap-3 font-normal"
asChild
>
<a href="mailto:[email protected]">
<CircleHelpIcon size={15} strokeWidth={1.5} /> Help & Support
</a>
</Button>
</div>
</aside>
<SideMenu />

<div className="flex flex-1 flex-col rounded-xl border px-6 pb-6 pt-4">
<nav className="mb-6 flex items-center justify-between">
Expand Down
Loading

0 comments on commit 9e48c2f

Please sign in to comment.