Skip to content

Commit

Permalink
feat: #17 - Adopt next.js app route
Browse files Browse the repository at this point in the history
  • Loading branch information
andriyfm committed Mar 10, 2024
1 parent d4f900b commit 3ce9e43
Show file tree
Hide file tree
Showing 22 changed files with 2,617 additions and 1,841 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"dependencies": {
"autoprefixer": "^10.4.11",
"next": "^12.3.0",
"next": "^14.1.3",
"next-pwa": "^5.6.0",
"postcss": "^8.4.16",
"react": "^18.2.0",
Expand All @@ -47,25 +47,25 @@
"@types/react": "^18.0.20",
"@types/testing-library__jest-dom": "^5.14.5",
"@types/testing-library__react": "^10.2.0",
"@typescript-eslint/eslint-plugin": "^5.37.0",
"@typescript-eslint/parser": "^5.3.0",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
"commitizen": "^4.2.5",
"cypress": "^10.8.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "<8.0.0",
"eslint": "^8.57.0",
"eslint-config-google": "^0.14.0",
"eslint-config-next": "12.0.3",
"eslint-config-next": "^14.1.3",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jest-dom": "^4.0.2",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.26.1",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-react-hooks": "^4.6.0",
"husky": "^8.0.1",
"jest": "^29.0.3",
"jest-environment-jsdom": "^29.0.3",
"lint-staged": "^13.0.3",
"msw": "^0.47.3",
"next-router-mock": "^0.7.4",
"next-router-mock": "^0.9.12",
"prettier": "^2.7.1",
"start-server-and-test": "^1.14.0",
"ts-node": "^10.9.1",
Expand Down
35 changes: 35 additions & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* eslint-disable new-cap */
import { Metadata } from "next";
import { Inter } from "next/font/google";
import "../styles/globals.css";

// If loading a variable font, you don't need to specify the font weight
const inter = Inter({
subsets: ["latin"],
display: "swap",
});

if (process.env.NEXT_PUBLIC_API_MOCKING === "enabled") {
import("../mocks").then(({ setupMocks }) => {
setupMocks();
});
}

export const metadata: Metadata = {
title: "Home",
description: "Welcome to Next.js",
};

export default function RootLayout({
// Layouts must accept a children prop.
// This will be populated with nested layouts or pages
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en" className={inter.className}>
<body>{children}</body>
</html>
);
}
File renamed without changes.
36 changes: 12 additions & 24 deletions src/pages/index.tsx → src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,29 @@
import type { NextPage } from "next";
import Head from "next/head";
import { Metadata } from "next";
import Image from "next/image";
import * as React from "react";
import styles from "styles/Home.module.css";
import styles from "./page.module.css";

const Home: NextPage = () => {
React.useEffect(() => {
fetch("/api/hello")
.then((res) => res.json())
.then((res) => console.log(res))
.catch((err) => console.log(err));
}, []);
export const metadata: Metadata = {
title: "My Page Title",
description: "My Page Description",
};

export default function HomePage() {
return (
<div className={styles.container}>
<Head>
<title>Next Boilerplate</title>
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</Head>

<main className={styles.main}>
<h1 className="font-black text-7xl">
Next{" "}
<h1 className="tw-font-black tw-text-7xl">
Next.js{" "}
<a
href="https://github.com/andriyfm/next-boilerplate"
className="text-blue-500 transition-colors hover:text-blue-600"
className="tw-text-blue-500 tw-transition-colors hover:tw-text-red-500"
>
Boilerplate
</a>
</h1>

<a
href="https://github.com/andriyfm"
className="text-xs text-center text-gray-400 hover:underline"
className="tw-text-xs tw-text-center tw-text-gray-400 hover:tw-underline"
>
by andriyfm
</a>
Expand Down Expand Up @@ -88,6 +78,4 @@ const Home: NextPage = () => {
</footer>
</div>
);
};

export default Home;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Button from ".";
import Button from "./Button";
import { fireEvent, render, screen } from "@testing-library/react";

describe("Button", () => {
Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions src/components/atoms/index.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// Place all atom components in this folder and import it here.
export {};
export { Button } from "./Button/Button";
2 changes: 0 additions & 2 deletions src/configs/index.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions src/contexts/index.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions src/data/index.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions src/hooks/index.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions src/layouts/index.tsx

This file was deleted.

13 changes: 0 additions & 13 deletions src/pages/_app.tsx

This file was deleted.

21 changes: 0 additions & 21 deletions src/pages/_document.tsx

This file was deleted.

33 changes: 0 additions & 33 deletions src/pages/_offline.tsx

This file was deleted.

13 changes: 0 additions & 13 deletions src/pages/api/hello.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src/pages/api/user.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/styles/globals.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

@import "typography.css";
1 change: 0 additions & 1 deletion src/styles/typography.css

This file was deleted.

1 change: 1 addition & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const colors = require("tailwindcss/colors");

/** @type {import('tailwindcss').Config} */
module.exports = {
prefix: "tw-",
content: ["./src/**/*.{js,ts,jsx,tsx}"],
theme: {
extend: {
Expand Down
10 changes: 7 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
"noImplicitReturns": true,
"pretty": true,
"sourceMap": true,
"baseUrl": "./src",
"baseUrl": ".",
"paths": {
"*": ["src/*"],
"@/contexts/*": ["contexts/*"],
"@/pages/*": ["pages/*"],
"@/data/*": ["data/*"],
Expand All @@ -44,8 +43,13 @@
"node",
"@types/testing-library__jest-dom",
"@testing-library/jest-dom"
],
"plugins": [
{
"name": "next"
}
]
},
"include": ["next-env.d.ts", "src/**/*"],
"include": ["next-env.d.ts", "src/**/*", ".next/types/**/*.ts"],
"exclude": ["node_modules", "cypress"]
}
Loading

0 comments on commit 3ce9e43

Please sign in to comment.