-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
57 changed files
with
12,739 additions
and
4,613 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": ["next/core-web-vitals", "prettier"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[❮ Overview](../../README.md) | ||
|
||
<div align="center"> | ||
<h1> | ||
Next App | ||
</h1> | ||
</div> | ||
|
||
Next.js web app with integrated REST API. | ||
|
||
# 🧬 Structure | ||
|
||
## Code | ||
|
||
- `📁 pages/`: Contains [pages](https://nextjs.org/docs/basic-features/pages). | ||
- `📄 _app.tsx`: The root component for the whole [application](https://nextjs.org/docs/advanced-features/custom-app). It integrates [context providers](https://reactjs.org/docs/context.html#contextprovider). | ||
- `📄 _app.css`: Application wide [CSS styling](https://nextjs.org/docs/basic-features/built-in-css-support). | ||
- `📄 _document.tsx`: Customizations of the [HTML document](https://nextjs.org/docs/advanced-features/custom-document) that contains the app. | ||
- `📁 api/`: Contains [API routes](https://nextjs.org/docs/api-routes/introduction). | ||
- `📄 [...index].ts`: A catch all API router handler that forwards all request to the Express middleware from [`express-api`](libs/express-api/). | ||
- `📁 components/`: Components used by pages. Components use [Component-level CSS](https://nextjs.org/docs/basic-features/built-in-css-support#adding-component-level-css) for styling. | ||
- `📁 public/`: Contains [assets](https://nextjs.org/docs/basic-features/static-file-serving) (images, fonts, ...) | ||
- `📄 robots.txt`: Influences [search engine crawler behavior](https://developers.google.com/search/docs/advanced/robots/intro). | ||
- `📄 next.config.js`: Next.js build [config](https://nextjs.org/docs/api-reference/next.config.js/introduction). Adjusted to include source files from `libs/` into the build process. | ||
|
||
## Interactions | ||
|
||
- `$PUBLIC_URL/`: Serves the web application. | ||
- `$PUBLIC_URL/api/`: Provides the REST API used by the web application. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.container { | ||
flex: 0 0 auto; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
font-size: small; | ||
} | ||
|
||
.container > * { | ||
margin: 1rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import styles from "./footer.module.css"; | ||
|
||
interface Props {} | ||
|
||
/** | ||
* Contains horizontal bar at the bottom of each page | ||
*/ | ||
const Footer = ({}: Props) => { | ||
return <footer className={styles.container}></footer>; | ||
}; | ||
|
||
export default Footer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
.container { | ||
flex: 0 0 auto; | ||
color: #fff; | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
background-color: #1976d2; | ||
box-shadow: 0px 1px 3px #000; | ||
z-index: 1; | ||
} | ||
|
||
.container > nav { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
} | ||
|
||
.container > nav > * { | ||
margin: 1.2rem; | ||
cursor: pointer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import Image from "next/image"; | ||
import Link from "next/link"; | ||
import logoImage from "../public/logo.png"; | ||
import styles from "./header.module.css"; | ||
|
||
interface Props {} | ||
|
||
/** | ||
* Contains horizontal bar at the top | ||
*/ | ||
const Header = ({}: Props) => { | ||
return ( | ||
<header className={styles.container}> | ||
<nav> | ||
<Link href="/"> | ||
<a> | ||
<Image alt="" src={logoImage} width={32} height={32} /> | ||
</a> | ||
</Link> | ||
<Link href="/items"> | ||
<a>Items</a> | ||
</Link> | ||
</nav> | ||
<nav></nav> | ||
<nav></nav> | ||
</header> | ||
); | ||
}; | ||
|
||
export default Header; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.container { | ||
height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
position: relative; | ||
} | ||
|
||
.main { | ||
flex: 1 1 0; | ||
overflow-y: auto; | ||
display: flex; | ||
flex-direction: column; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Head from "next/head"; | ||
import Footer from "./footer"; | ||
import Header from "./header"; | ||
import styles from "./layout.module.css"; | ||
|
||
interface Props { | ||
children: React.ReactNode; | ||
} | ||
|
||
/** | ||
* Encapsulates layout decisions for pages. | ||
*/ | ||
const Layout = ({ children }: Props) => { | ||
return ( | ||
<div className={styles.container}> | ||
<Head> | ||
<link rel="icon" href="/logo.png" /> | ||
</Head> | ||
<Header /> | ||
<main className={styles.main}> | ||
{children} | ||
<Footer /> | ||
</main> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Layout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.container { | ||
display: flex; | ||
flex-direction: row; | ||
flex-wrap: wrap; | ||
overflow: hidden; | ||
} | ||
|
||
.container > * { | ||
margin: 0.5rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { CSSProperties } from "react"; | ||
import styles from "./row.module.css"; | ||
|
||
interface Props { | ||
children: React.ReactNode; | ||
style?: CSSProperties; | ||
} | ||
|
||
/** | ||
* Horizontal layout helper | ||
*/ | ||
const Row = ({ children, style }: Props) => { | ||
return ( | ||
<div className={styles.container} style={style}> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Row; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.container { | ||
flex: 1 0 0; | ||
padding: 1rem; | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: center; | ||
} | ||
|
||
.content { | ||
flex: 0 1 1280px; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.colored { | ||
background-color: #1976d2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { CSSProperties } from "react"; | ||
import styles from "./section.module.css"; | ||
|
||
interface Props { | ||
children?: React.ReactNode; | ||
style?: CSSProperties; | ||
colored?: boolean; | ||
} | ||
|
||
/** | ||
* Sections are vertical page parts that are visually separated (border, background color/image, ...) | ||
*/ | ||
const Section = ({ children, style, colored }: Props) => { | ||
return ( | ||
<section | ||
className={`${styles.container} ${colored ? styles.colored : ""}`} | ||
style={style} | ||
> | ||
<div className={styles.content}>{children}</div> | ||
</section> | ||
); | ||
}; | ||
|
||
export default Section; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/image-types/global" /> | ||
|
||
// NOTE: This file should not be edited | ||
// see https://nextjs.org/docs/basic-features/typescript for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// nextjs.org/docs/api-reference/next.config.js/introduction | ||
|
||
const path = require("path"); | ||
|
||
module.exports = { | ||
poweredByHeader: false, | ||
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => { | ||
// Include certain packages into build process (inspired by next-transpile-modules) | ||
config.module.rules.push({ | ||
test: /\.+(js|jsx|ts|tsx)$/, | ||
use: defaultLoaders.babel, | ||
include: [path.resolve(__dirname, "../../libs")], | ||
type: "javascript/auto", | ||
}); | ||
return config; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "@my-org/next-app", | ||
"version": "1.0.0", | ||
"private": true, | ||
"engines": { | ||
"node": ">=14.0.0" | ||
}, | ||
"dependencies": { | ||
"@my-org/express-api": "file:../../libs/express-api", | ||
"@my-org/react-api-client": "file:../../libs/react-api-client", | ||
"next": "^12.1.2", | ||
"react": "^17.0.0", | ||
"react-dom": "^17.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/express": "^4.17.13", | ||
"@types/node": "^17.0.23", | ||
"@types/react": "^17.0.43", | ||
"@types/react-dom": "^17.0.14", | ||
"browserslist": "^4.20.4", | ||
"eslint": "8.5.0", | ||
"eslint-config-next": "12.1.2", | ||
"eslint-config-prettier": "^8.5.0", | ||
"typescript": "^4.3.5" | ||
}, | ||
"scripts": { | ||
"dev": "next dev -p 3000", | ||
"build": "next build", | ||
"start": "next start", | ||
"lint": "next lint && prettier --check '**/*.{js,jsx,ts,tsx}'" | ||
}, | ||
"browserslist": [ | ||
"defaults" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Head from "next/head"; | ||
import Layout from "../components/layout"; | ||
import Section from "../components/section"; | ||
|
||
const ErrorPage = () => { | ||
return ( | ||
<Layout> | ||
<Head> | ||
<title>Error</title> | ||
</Head> | ||
<Section | ||
style={{ | ||
justifyContent: "center", | ||
}} | ||
> | ||
<h1 style={{ textAlign: "center" }}>Not Found</h1> | ||
</Section> | ||
</Layout> | ||
); | ||
}; | ||
|
||
export default ErrorPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
html, | ||
body { | ||
padding: 0; | ||
margin: 0; | ||
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, | ||
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; | ||
} | ||
|
||
html, | ||
body, | ||
#__next { | ||
min-height: 100%; | ||
height: 100%; | ||
overflow: hidden; | ||
} | ||
|
||
a { | ||
color: inherit; | ||
text-decoration: none; | ||
} | ||
|
||
* { | ||
box-sizing: border-box; | ||
} |
Oops, something went wrong.