Skip to content

Commit

Permalink
Learned about layouts in nextjs
Browse files Browse the repository at this point in the history
  • Loading branch information
unstoppableayush committed Mar 8, 2024
1 parent b7a248b commit 30db991
Show file tree
Hide file tree
Showing 23 changed files with 5,258 additions and 0 deletions.
3 changes: 3 additions & 0 deletions NextJS/129_layouts_in_next.js/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
36 changes: 36 additions & 0 deletions NextJS/129_layouts_in_next.js/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
36 changes: 36 additions & 0 deletions NextJS/129_layouts_in_next.js/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.js`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react'

const Comment = () => {
return (
<div>Comments</div>
)
}

export default Comment
20 changes: 20 additions & 0 deletions NextJS/129_layouts_in_next.js/app/(admin)/adminlogin/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react'

const page = () => {
return (

<div>
Admin Login
<p>Feel free to login as an Admin</p>
</div>
)
}

export default page

// Dynamic metadata
export async function generateMetadata({ params }) {
return {
title: 'Admin Login',
}
}
19 changes: 19 additions & 0 deletions NextJS/129_layouts_in_next.js/app/(admin)/adminlogout/layout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Inter } from "next/font/google";

import Navbar from "@/components/Navbar";
import Footer from "@/components/Footer";
const inter = Inter({ subsets: ["latin"] });

export const metadata = {
title: "Admin Facebook - Connect With World",
description: "Admin Page Facebook - connect with friends and world around you",
};

export default function AdminLayout({ children }) {
return (
<>
<span>Logout Navbar</span>
{children}
</>
);
}
9 changes: 9 additions & 0 deletions NextJS/129_layouts_in_next.js/app/(admin)/adminlogout/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react'

const Logout = () => {
return (
<div>Logout</div>
)
}

export default Logout
19 changes: 19 additions & 0 deletions NextJS/129_layouts_in_next.js/app/(admin)/layout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Inter } from "next/font/google";

import Navbar from "@/components/Navbar";
import Footer from "@/components/Footer";
const inter = Inter({ subsets: ["latin"] });

export const metadata = {
title: "Admin Facebook - Connect With World",
description: "Admin Page Facebook - connect with friends and world around you",
};

export default function AdminLayout({ children }) {
return (
<>
<span>Admin Navbar</span>
{children}
</>
);
}
9 changes: 9 additions & 0 deletions NextJS/129_layouts_in_next.js/app/about/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react'

const page = () => {
return (
<div>Facebook is Lorem ipsum dolor, sit amet consectetur adipisicing elit. Labore maxime aut quod soluta!</div>
)
}

export default page
Binary file added NextJS/129_layouts_in_next.js/app/favicon.ico
Binary file not shown.
33 changes: 33 additions & 0 deletions NextJS/129_layouts_in_next.js/app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-end-rgb: 255, 255, 255;
}

@media (prefers-color-scheme: dark) {
:root {
--foreground-rgb: 255, 255, 255;
--background-start-rgb: 0, 0, 0;
--background-end-rgb: 0, 0, 0;
}
}

body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(
to bottom,
transparent,
rgb(var(--background-end-rgb))
)
rgb(var(--background-start-rgb));
}

@layer utilities {
.text-balance {
text-wrap: balance;
}
}
22 changes: 22 additions & 0 deletions NextJS/129_layouts_in_next.js/app/layout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Inter } from "next/font/google";
import "./globals.css";
import Navbar from "@/components/Navbar";
import Footer from "@/components/Footer";
const inter = Inter({ subsets: ["latin"] });

export const metadata = {
title: "Facebook - Connect With World",
description: "Facebook - connect with friends and world around you",
};

export default function RootLayout({ children }) {
return (
<html lang="en">
<body className={inter.className}>
<Navbar/>
{children}
<Footer/>
</body>
</html>
);
}
9 changes: 9 additions & 0 deletions NextJS/129_layouts_in_next.js/app/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Image from "next/image";

export default function Home() {
return (
<div className="homepage">
I am Homepage
</div>
);
}
117 changes: 117 additions & 0 deletions NextJS/129_layouts_in_next.js/components/Footer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import React from 'react'

const Footer = () => {
return (
<div>
<footer class="text-gray-600 body-font">
<div class="container px-5 py-24 mx-auto">
<div class="flex flex-wrap md:text-left text-center order-first">
<div class="lg:w-1/4 md:w-1/2 w-full px-4">
<h2 class="title-font font-medium text-gray-900 tracking-widest text-sm mb-3">CATEGORIES</h2>
<nav class="list-none mb-10">
<li>
<a class="text-gray-600 hover:text-gray-800">First Link</a>
</li>
<li>
<a class="text-gray-600 hover:text-gray-800">Second Link</a>
</li>
<li>
<a class="text-gray-600 hover:text-gray-800">Third Link</a>
</li>
<li>
<a class="text-gray-600 hover:text-gray-800">Fourth Link</a>
</li>
</nav>
</div>
<div class="lg:w-1/4 md:w-1/2 w-full px-4">
<h2 class="title-font font-medium text-gray-900 tracking-widest text-sm mb-3">CATEGORIES</h2>
<nav class="list-none mb-10">
<li>
<a class="text-gray-600 hover:text-gray-800">First Link</a>
</li>
<li>
<a class="text-gray-600 hover:text-gray-800">Second Link</a>
</li>
<li>
<a class="text-gray-600 hover:text-gray-800">Third Link</a>
</li>
<li>
<a class="text-gray-600 hover:text-gray-800">Fourth Link</a>
</li>
</nav>
</div>
<div class="lg:w-1/4 md:w-1/2 w-full px-4">
<h2 class="title-font font-medium text-gray-900 tracking-widest text-sm mb-3">CATEGORIES</h2>
<nav class="list-none mb-10">
<li>
<a class="text-gray-600 hover:text-gray-800">First Link</a>
</li>
<li>
<a class="text-gray-600 hover:text-gray-800">Second Link</a>
</li>
<li>
<a class="text-gray-600 hover:text-gray-800">Third Link</a>
</li>
<li>
<a class="text-gray-600 hover:text-gray-800">Fourth Link</a>
</li>
</nav>
</div>
<div class="lg:w-1/4 md:w-1/2 w-full px-4">
<h2 class="title-font font-medium text-gray-900 tracking-widest text-sm mb-3">SUBSCRIBE</h2>
<div class="flex xl:flex-nowrap md:flex-nowrap lg:flex-wrap flex-wrap justify-center items-end md:justify-start">
<div class="relative w-40 sm:w-auto xl:mr-4 lg:mr-0 sm:mr-4 mr-2">
<label for="footer-field" class="leading-7 text-sm text-gray-600">Placeholder</label>
<input type="text" id="footer-field" name="footer-field" class="w-full bg-gray-100 bg-opacity-50 rounded border border-gray-300 focus:bg-transparent focus:ring-2 focus:ring-indigo-200 focus:border-indigo-500 text-base outline-none text-gray-700 py-1 px-3 leading-8 transition-colors duration-200 ease-in-out"/>
</div>
<button class="lg:mt-2 xl:mt-0 flex-shrink-0 inline-flex text-white bg-indigo-500 border-0 py-2 px-6 focus:outline-none hover:bg-indigo-600 rounded">Button</button>
</div>
<p class="text-gray-500 text-sm mt-2 md:text-left text-center">Bitters chicharrones fanny pack

</p>
</div>
</div>
</div>
<div class="bg-gray-100">
<div class="container px-5 py-6 mx-auto flex items-center sm:flex-row flex-col">
<a class="flex title-font font-medium items-center md:justify-start justify-center text-gray-900">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" class="w-10 h-10 text-white p-2 bg-indigo-500 rounded-full" viewBox="0 0 24 24">
<path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"></path>
</svg>
<span class="ml-3 text-xl">Tailblocks</span>
</a>
<p class="text-sm text-gray-500 sm:ml-6 sm:mt-0 mt-4">© 2020 Tailblocks —
<a href="https://twitter.com/knyttneve" rel="noopener noreferrer" class="text-gray-600 ml-1" target="_blank">@knyttneve</a>
</p>
<span class="inline-flex sm:ml-auto sm:mt-0 mt-4 justify-center sm:justify-start">
<a class="text-gray-500">
<svg fill="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" class="w-5 h-5" viewBox="0 0 24 24">
<path d="M18 2h-3a5 5 0 00-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 011-1h3z"></path>
</svg>
</a>
<a class="ml-3 text-gray-500">
<svg fill="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" class="w-5 h-5" viewBox="0 0 24 24">
<path d="M23 3a10.9 10.9 0 01-3.14 1.53 4.48 4.48 0 00-7.86 3v1A10.66 10.66 0 013 4s-4 9 5 13a11.64 11.64 0 01-7 2c9 5 20 0 20-11.5a4.5 4.5 0 00-.08-.83A7.72 7.72 0 0023 3z"></path>
</svg>
</a>
<a class="ml-3 text-gray-500">
<svg fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" class="w-5 h-5" viewBox="0 0 24 24">
<rect width="20" height="20" x="2" y="2" rx="5" ry="5"></rect>
<path d="M16 11.37A4 4 0 1112.63 8 4 4 0 0116 11.37zm1.5-4.87h.01"></path>
</svg>
</a>
<a class="ml-3 text-gray-500">
<svg fill="currentColor" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="0" class="w-5 h-5" viewBox="0 0 24 24">
<path stroke="none" d="M16 8a6 6 0 016 6v7h-4v-7a2 2 0 00-2-2 2 2 0 00-2 2v7h-4v-7a6 6 0 016-6zM2 9h4v12H2z"></path>
<circle cx="4" cy="4" r="2" stroke="none"></circle>
</svg>
</a>
</span>
</div>
</div>
</footer>
</div>
)
}

export default Footer
31 changes: 31 additions & 0 deletions NextJS/129_layouts_in_next.js/components/Navbar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react'

const Navbar = () => {
return (
<div>
<header class="text-gray-600 body-font">
<div class="container mx-auto flex flex-wrap p-5 flex-col md:flex-row items-center">
<a class="flex title-font font-medium items-center text-gray-900 mb-4 md:mb-0">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" class="w-10 h-10 text-white p-2 bg-indigo-500 rounded-full" viewBox="0 0 24 24">
<path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"></path>
</svg>
<span class="ml-3 text-xl">Tailblocks</span>
</a>
<nav class="md:mr-auto md:ml-4 md:py-1 md:pl-4 md:border-l md:border-gray-400 flex flex-wrap items-center text-base justify-center">
<a class="mr-5 hover:text-gray-900">First Link</a>
<a class="mr-5 hover:text-gray-900">Second Link</a>
<a class="mr-5 hover:text-gray-900">Third Link</a>
<a class="mr-5 hover:text-gray-900">Fourth Link</a>
</nav>
<button class="inline-flex items-center bg-gray-100 border-0 py-1 px-3 focus:outline-none hover:bg-gray-200 rounded text-base mt-4 md:mt-0">Button
<svg fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" class="w-4 h-4 ml-1" viewBox="0 0 24 24">
<path d="M5 12h14M12 5l7 7-7 7"></path>
</svg>
</button>
</div>
</header>
</div>
)
}

export default Navbar
7 changes: 7 additions & 0 deletions NextJS/129_layouts_in_next.js/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"compilerOptions": {
"paths": {
"@/*": ["./*"]
}
}
}
Loading

0 comments on commit 30db991

Please sign in to comment.