Skip to content

Commit

Permalink
refactor: ♻️ Refactor code and improvements.
Browse files Browse the repository at this point in the history
- Refactor code structure and dependencies.

Update project structure.
  • Loading branch information
RicardoGEsteves committed Dec 19, 2023
1 parent 3bfd566 commit de619ba
Show file tree
Hide file tree
Showing 14 changed files with 1,979 additions and 50 deletions.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# SpreadIt

`create-next-app`
SpreadIt is a dynamic social news aggregation platform powered by robust backend technologies and a user-friendly interface. It employs modern web development frameworks and scalable architecture to enable seamless content submission, sharing, and voting across various formats (articles, images, videos).

`TypeScript, React, Next.js`

## Getting Started

Expand All @@ -15,3 +17,19 @@ pnpm dev
# or
bun dev
```

## .env

```bash
DATABASE_URL=
NEXTAUTH_SECRET=

GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=

UPLOADTHING_SECRET=
UPLOADTHING_APP_ID=

REDIS_URL=
REDIS_SECRET=
```
9 changes: 9 additions & 0 deletions app/(main)/(home)/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//import { } from ' ';

type HomePageProps = {};

const HomePage = ({}: HomePageProps) => {
return <div> HomePage </div>;
};

export default HomePage;
16 changes: 16 additions & 0 deletions app/(main)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Navbar from "@/components/navigation/navbar";

type MainLayoutProps = {
children: React.ReactNode;
};

const MainLayout = ({ children }: MainLayoutProps) => {
return (
<>
<Navbar />
<div className="container max-w-7xl mx-auto h-full pt-12">{children}</div>
</>
);
};

export default MainLayout;
12 changes: 9 additions & 3 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "./globals.css";

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

import "@/styles/globals.css";

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

Expand All @@ -16,8 +19,11 @@ export default function RootLayout({
children: React.ReactNode;
}) {
return (
<html lang="en">
<body className={inter.className}>{children}</body>
<html
lang="en"
className={cn("dark antialiased", inter.className)}
>
<body className="min-h-screen pt-12 antialiased">{children}</body>
</html>
);
}
3 changes: 0 additions & 3 deletions app/page.tsx

This file was deleted.

43 changes: 43 additions & 0 deletions components/icons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { LucideProps, MessageSquare, User } from "lucide-react";
import Image from "next/image";
import SpreadIt from "./spreadit.svg";

export const Icons = {
user: User,
logo: () => (
<Image
src={SpreadIt}
alt="SpreadIt Logo"
width={200}
height={200}
/>
),
google: (props: LucideProps) => (
<svg
{...props}
viewBox="0 0 24 24"
>
<path
d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"
fill="#4285F4"
/>
<path
d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"
fill="#34A853"
/>
<path
d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"
fill="#FBBC05"
/>
<path
d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"
fill="#EA4335"
/>
<path
d="M1 1h22v22H1z"
fill="none"
/>
</svg>
),
commentReply: MessageSquare,
};
44 changes: 44 additions & 0 deletions components/navigation/navbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// import { authOptions } from "@/lib/auth";
// import { getServerSession } from "next-auth";
import Link from "next/link";
// import { Icons } from "./Icons";
import { buttonVariants } from "../ui/button";
// import { UserAccountNav } from "./UserAccountNav";
// import SearchBar from "./SearchBar";

const Navbar = async () => {
// const session = await getServerSession(authOptions);
return (
<div className="fixed top-0 inset-x-0 h-fit bg-neutral-100 border-b border-neutral-300 z-[10] py-2">
<div className="container max-w-7xl h-full mx-auto flex items-center justify-between gap-2">
{/* logo */}
<Link
href="/"
className="flex gap-2 items-center"
>
{/* <Icons.logo className="h-8 w-8 sm:h-6 sm:w-6" /> */}
<p className="hidden text-neutral-700 text-sm font-medium md:block">
SpreadIt
</p>
</Link>

{/* search bar */}
{/* <SearchBar /> */}

{/* actions */}
{/* {session?.user ? (
<UserAccountNav user={session.user} />
) : (
<Link
href="/sign-in"
className={buttonVariants()}
>
Sign In
</Link>
)} */}
</div>
</div>
);
};

export default Navbar;
73 changes: 73 additions & 0 deletions components/ui/button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import * as React from "react";
import { Slot } from "@radix-ui/react-slot";
import { cva, type VariantProps } from "class-variance-authority";
import { Loader2 } from "lucide-react";

import { cn } from "@/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;
isLoading?: boolean;
}

const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
(
{
className,
children,
variant,
isLoading,
size,
asChild = false,
...props
},
ref
) => {
const Comp = asChild ? Slot : "button";
return (
<Comp
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
disabled={isLoading}
{...props}
>
{isLoading ? <Loader2 className="mr-2 h-4 w-4 animate-spin" /> : null}
{children}
</Comp>
);
}
);
Button.displayName = "Button";

export { Button, buttonVariants };
Loading

0 comments on commit de619ba

Please sign in to comment.