Skip to content

Commit

Permalink
feat: initial routing
Browse files Browse the repository at this point in the history
  • Loading branch information
mfaux committed Oct 9, 2024
1 parent ebd7f0b commit 50b94ef
Show file tree
Hide file tree
Showing 30 changed files with 439 additions and 94 deletions.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions apps/web/app/inbox/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Inbox() {
return <div>Inbox</div>;
}
24 changes: 15 additions & 9 deletions apps/web/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
import type { Metadata } from "next";
"use client";

import { useRouter } from "next/navigation";
import localFont from "next/font/local";
import "./globals.css";
import "@repo/ui/styles.css";
import { Shell } from "@repo/ui/shell/shell";
import { ActionBar } from "@repo/ui/shell/action-bar";
import { HeaderBar } from "@repo/ui/shell/header-bar";
import { Main } from "@repo/ui/shell/main";

const geistSans = localFont({
src: "./fonts/GeistVF.woff",
src: "./_fonts/GeistVF.woff",
variable: "--font-geist-sans",
});
const geistMono = localFont({
src: "./fonts/GeistMonoVF.woff",
src: "./_fonts/GeistMonoVF.woff",
variable: "--font-geist-mono",
});

export const metadata: Metadata = {
title: "Create Next App",
description: "Generated by create next app",
};

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
const router = useRouter();
return (
<html lang="en">
<body className={`${geistSans.variable} ${geistMono.variable}`}>
{children}
<Shell>
<HeaderBar>Header</HeaderBar>
<ActionBar onNavigate={(path) => router.push(path)}></ActionBar>
<Main>{children}</Main>
</Shell>
</body>
</html>
);
Expand Down
12 changes: 1 addition & 11 deletions apps/web/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
import { ActionBar } from "@repo/ui/shell/action-bar";
import { HeaderBar } from "@repo/ui/shell/header-bar";
import { Main } from "@repo/ui/shell/main";

export default function Home() {
return (
<div>
<ActionBar></ActionBar>
<HeaderBar></HeaderBar>
<Main>Swolo</Main>
</div>
);
return <div>Home</div>;
}
3 changes: 3 additions & 0 deletions apps/web/app/pages/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Pages() {
return <div>Pages</div>;
}
3 changes: 3 additions & 0 deletions apps/web/app/projects/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Projects() {
return <div>Projects</div>;
}
3 changes: 3 additions & 0 deletions apps/web/app/settings/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Settings() {
return <div>Settings</div>;
}
3 changes: 3 additions & 0 deletions apps/web/app/tasks/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Tasks() {
return <div>Tasks</div>;
}
1 change: 1 addition & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"@repo/core": "workspace:*",
"@repo/ui": "workspace:*",
"clsx": "^2.1.1",
"next": "14.2.6",
Expand Down
2 changes: 1 addition & 1 deletion apps/web/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Config } from "tailwindcss";
import sharedConfig from "@repo/tailwind-config";

const config: Pick<Config, "content" | "presets"> = {
content: ["./app/**/*.tsx", "../../packages/ui/**/*{.js,.ts,.jsx,.tsx}"],
content: ["./app/**/*.tsx", "../../packages/ui/src/**/*{.js,.ts,.jsx,.tsx}"],
presets: [sharedConfig],
};

Expand Down
28 changes: 28 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "@repo/core",
"version": "0.0.0",
"private": true,
"exports": {
"./routes": {
"types": "./src/routes.ts",
"default": "./dist/routes.js"
}
},
"scripts": {
"dev": "tsc --watch",
"build": "tsc",
"lint": "eslint . --max-warnings 0",
"type-check": "tsc --noEmit"
},
"devDependencies": {
"@repo/eslint-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"@types/eslint": "^8.56.5",
"@types/node": "^20.11.24",
"eslint": "^8.57.0",
"typescript": "^5.6.2"
},
"dependencies": {
"lucide-react": "^0.451.0"
}
}
8 changes: 8 additions & 0 deletions packages/core/src/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export type Route =
| "/"
| "/inbox"
| "/projects"
| "/project:id"
| "/tasks"
| "/pages"
| "/settings";
9 changes: 9 additions & 0 deletions packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "@repo/typescript-config/base.json",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src"
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
1 change: 1 addition & 0 deletions packages/tailwind-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"devDependencies": {
"@repo/typescript-config": "workspace:*",
"@types/node": "^22.7.5",
"tailwindcss": "^3.4.1"
}
}
1 change: 0 additions & 1 deletion packages/tailwind-config/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const config: Omit<Config, "content"> = {
},
},
},
plugins: [],
},
};

Expand Down
9 changes: 6 additions & 3 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
"private": true,
"exports": {
"./styles.css": "./dist/index.css",
"./shell/shell": "./src/shell/shell.tsx",
"./shell/action-bar": "./src/shell/action-bar.tsx",
"./shell/header-bar": "./src/shell/header-bar.tsx",
"./shell/main": "./src/shell/main.tsx",
"./button": "./src/button.tsx",
"./card": "./src/card.tsx",
"./code": "./src/code.tsx"
"./button": "./src/button.tsx"
},
"scripts": {
"build": "tailwindcss -i ./src/styles.css -o ./dist/index.css",
Expand All @@ -35,7 +34,11 @@
"typescript-plugin-css-modules": "^5.1.0"
},
"dependencies": {
"@radix-ui/react-slot": "^1.1.0",
"@repo/core": "workspace:*",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"lucide-react": "^0.451.0",
"react": "^18.2.0",
"tailwind-merge": "^2.5.3"
}
Expand Down
70 changes: 55 additions & 15 deletions packages/ui/src/button.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,60 @@
"use client";

import type { ReactNode } from "react";
// https://github.com/shadcn-ui/ui/blob/main/apps/www/registry/default/ui/button.tsx

interface ButtonProps {
children: ReactNode;
className?: string;
appName: string;
import * as React from "react";
import { Slot } from "@radix-ui/react-slot";
import { cva, type VariantProps } from "class-variance-authority";

import { cn } from "@repo/ui/lib/utils";

const buttonVariants = cva(
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
{
variants: {
variant: {
default: "bg-primary text-primary-foreground hover:bg-primary/90",
destructive:
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
outline:
"border border-input bg-background hover:bg-accent hover:text-accent-foreground",
secondary:
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
ghost: "hover:bg-accent hover:text-accent-foreground",
link: "text-primary underline-offset-4 hover:underline",
},
size: {
default: "h-10 px-4 py-2",
sm: "h-9 rounded-md px-3",
lg: "h-11 rounded-md px-8",
icon: "h-10 w-10",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
}
);

export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
asChild?: boolean;
}

export const Button = ({ children, className, appName }: ButtonProps) => {
return (
<button
className={className}
onClick={() => alert(`Hello from your ${appName} app!`)}
>
{children}
</button>
);
};
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : "button";
return (
<Comp
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
/>
);
}
);
Button.displayName = "Button";

export { Button, buttonVariants };
25 changes: 0 additions & 25 deletions packages/ui/src/card.tsx

This file was deleted.

9 changes: 0 additions & 9 deletions packages/ui/src/code.tsx

This file was deleted.

File renamed without changes.
3 changes: 0 additions & 3 deletions packages/ui/src/shell/action-bar.module.css

This file was deleted.

Loading

0 comments on commit 50b94ef

Please sign in to comment.