Initial commit

This commit is contained in:
Filipe Medeiros 2021-11-21 12:24:18 +00:00
commit 87a64a2f59
25 changed files with 5377 additions and 0 deletions

3
.eslintrc.json Normal file
View file

@ -0,0 +1,3 @@
{
"extends": ["next/core-web-vitals", "prettier"]
}

34
.gitignore vendored Normal file
View file

@ -0,0 +1,34 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# 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
.env.development.local
.env.test.local
.env.production.local
# vercel
.vercel

4
.husky/pre-commit Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
yarn lint && yarn lint:staged

4
.lintstagedrc.json Normal file
View file

@ -0,0 +1,4 @@
{
"*": "yarn format",
"**/*.css": ["yarn lint:css"]
}

3
.prettierignore Normal file
View file

@ -0,0 +1,3 @@
.husky
.prettierignore
.gitignore

9
.prettierrc Normal file
View file

@ -0,0 +1,9 @@
{
"arrowParens": "avoid",
"semi": false,
"singleQuote": true,
"importOrder": ["<THIRD_PARTY_MODULES>", "^[./]"],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true
}

71
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,71 @@
{
"editor.fontSize": 15,
"terminal.integrated.fontSize": 15,
"workbench.panel.defaultLocation": "right",
"editor.suggestSelection": "first",
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[svelte]": {
"editor.defaultFormatter": "svelte.svelte-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.detectIndentation": false,
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"files.associations": {
"*.ts.dev.ffencrypted": "typescript",
"*.ts.prd.we1.ffencrypted": "typescript",
".env.*": "env",
".*rc": "json"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"workbench.editor.wrapTabs": true,
"workbench.editor.decorations.colors": true,
"workbench.editor.decorations.badges": true,
"git.autofetch": true,
"git.autofetchPeriod": 300,
"diffEditor.ignoreTrimWhitespace": false,
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"terminal.integrated.automationShell.linux": "",
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.inlineSuggest.enabled": true,
"javascript.format.placeOpenBraceOnNewLineForControlBlocks": true,
"javascript.format.placeOpenBraceOnNewLineForFunctions": true,
"typescript.format.placeOpenBraceOnNewLineForControlBlocks": true,
"typescript.format.placeOpenBraceOnNewLineForFunctions": true,
"typescript.updateImportsOnFileMove.enabled": "always",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"svelte.enable-ts-plugin": true,
"workbench.colorTheme": "GitHub Dark Default",
"window.zoomLevel": 2,
"redhat.telemetry.enabled": true,
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"eslint.format.enable": true,
"eslint.packageManager": "yarn",
"eslint.alwaysShowStatus": true,
"editor.foldingImportsByDefault": true,
"javascript.preferences.importModuleSpecifier": "project-relative",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
]
}

29
README.md Normal file
View file

@ -0,0 +1,29 @@
# Next.js + Tailwind CSS Example
This example shows how to use [Tailwind CSS](https://tailwindcss.com/) [(v2.2)](https://blog.tailwindcss.com/tailwindcss-2-2) with Next.js. It follows the steps outlined in the official [Tailwind docs](https://tailwindcss.com/docs/guides/nextjs).
It uses the new [`Just-in-Time Mode`](https://tailwindcss.com/docs/just-in-time-mode) for Tailwind CSS.
## Preview
Preview the example live on [StackBlitz](http://stackblitz.com/):
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/with-tailwindcss)
## Deploy your own
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-tailwindcss&project-name=with-tailwindcss&repository-name=with-tailwindcss)
## How to use
Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example:
```bash
npx create-next-app --example with-tailwindcss with-tailwindcss-app
# or
yarn create next-app --example with-tailwindcss with-tailwindcss-app
```
Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).

View file

@ -0,0 +1,24 @@
---
to: pages/api/<%= name %>.ts
---
import type { NextApiHandler } from 'next'
import checkToken from '@lib/middlewares/checkToken'
// remove if not needed
export type ResponseBody = any // change to correct type
const handler: NextApiHandler<ResponseBody> = (req, res) => {
try {
checkToken(req, res)
// handle request
} catch {
res.redirect('/login')
}
}
export default handler

View file

@ -0,0 +1,15 @@
---
to: components/<%= name %>.tsx
---
import type { FC } from 'react'
// delete if not needed
export interface Props {
// your props here
}
const <%= componentName %>: FC<Props> = ({ children }) => {
return <>{children}</>
}
export default <%= componentName %>

View file

@ -0,0 +1,10 @@
module.exports = {
params: ({ args }) => {
const nameSplit = args.name.split('/')
let componentName = nameSplit[nameSplit.length - 1]
componentName = `${componentName[0].toLocaleUpperCase()}${componentName.slice(
1
)}`
return { ...args, componentName }
},
}

View file

@ -0,0 +1,13 @@
---
to: lib/hooks/<%= name %>.ts
---
import { use } from 'react'
const <%= name %> = () => {
}
export default <%= name %>

View file

@ -0,0 +1,10 @@
module.exports = {
params: ({ args }) => {
const nameSplit = args.name.split('/')
let componentName = nameSplit[nameSplit.length - 1]
componentName = `${componentName[0].toLocaleUpperCase()}${componentName.slice(
1
)}`
return { ...args, componentName }
},
}

View file

@ -0,0 +1,10 @@
---
to: pages/<%= name %>.tsx
---
import type { NextPage } from 'next'
const <%= componentName %>: NextPage = () => {
return <></>
}
export default <%= componentName %>

6
next-env.d.ts vendored Normal file
View file

@ -0,0 +1,6 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.

58
package.json Normal file
View file

@ -0,0 +1,58 @@
{
"license": "MIT",
"private": false,
"engines": {
"node": ">12"
},
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"test": "echo TODO",
"lint": "next lint",
"lint:staged": "lint-staged",
"lint:css": "stylelint **/*.css --fix .",
"format": "prettier --write .",
"gen:component": "hygen component new",
"gen:apiHandler": "hygen apiHandler new",
"gen:page": "hygen page new",
"gen:hook": "hygen hook new"
},
"dependencies": {
"next": "latest",
"prettier": "^2.4.1",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"@trivago/prettier-plugin-sort-imports": "^3.1.1",
"@types/node": "^16.11.7",
"@types/react": "^17.0.34",
"@types/react-dom": "^17.0.11",
"@typescript-eslint/parser": "^5.4.0",
"autoprefixer": "^10.2.6",
"eslint": "<8.0.0",
"eslint-config-next": "^12.0.4",
"eslint-config-prettier": "^8.3.0",
"husky": "^7.0.4",
"hygen": "^6.1.0",
"lint-staged": "^12.0.2",
"postcss": "^8.3.5",
"prettier-eslint": "^13.0.0",
"stylelint": "^14.1.0",
"tailwindcss": "^2.2.4",
"typescript": "^4.4.4"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

10
pages/_app.tsx Normal file
View file

@ -0,0 +1,10 @@
import type { AppProps } from 'next/app'
import { FC, useEffect } from 'react'
import 'tailwindcss/tailwind.css'
const MyApp: FC<AppProps> = ({ Component, pageProps }) => {
useEffect(() => {}, [useEffect])
return <Component {...pageProps} />
}
export default MyApp

5
pages/api/hello.js Normal file
View file

@ -0,0 +1,5 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
export default function helloAPI(req, res) {
res.status(200).json({ name: 'John Doe' })
}

82
pages/index.tsx Normal file
View file

@ -0,0 +1,82 @@
import Head from 'next/head'
export default function Home() {
return (
<div className="flex flex-col items-center justify-center min-h-screen py-2">
<Head>
<title>Create Next App</title>
<link rel="icon" href="/favicon.ico" />
</Head>
<main className="flex flex-col items-center justify-center w-full flex-1 px-20 text-center">
<h1 className="text-6xl font-bold">
Welcome to{' '}
<a className="text-blue-600" href="https://nextjs.org">
Next.js!
</a>
</h1>
<p className="mt-3 text-2xl">
Get started by editing{' '}
<code className="p-3 font-mono text-lg bg-gray-100 rounded-md">
pages/index.js
</code>
</p>
<div className="flex flex-wrap items-center justify-around max-w-4xl mt-6 sm:w-full">
<a
href="https://nextjs.org/docs"
className="p-6 mt-6 text-left border w-96 rounded-xl hover:text-blue-600 focus:text-blue-600"
>
<h3 className="text-2xl font-bold">Documentation &rarr;</h3>
<p className="mt-4 text-xl">
Find in-depth information about Next.js features and API.
</p>
</a>
<a
href="https://nextjs.org/learn"
className="p-6 mt-6 text-left border w-96 rounded-xl hover:text-blue-600 focus:text-blue-600"
>
<h3 className="text-2xl font-bold">Learn &rarr;</h3>
<p className="mt-4 text-xl">
Learn about Next.js in an interactive course with quizzes!
</p>
</a>
<a
href="https://github.com/vercel/next.js/tree/master/examples"
className="p-6 mt-6 text-left border w-96 rounded-xl hover:text-blue-600 focus:text-blue-600"
>
<h3 className="text-2xl font-bold">Examples &rarr;</h3>
<p className="mt-4 text-xl">
Discover and deploy boilerplate example Next.js projects.
</p>
</a>
<a
href="https://vercel.com/import?filter=next.js&utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
className="p-6 mt-6 text-left border w-96 rounded-xl hover:text-blue-600 focus:text-blue-600"
>
<h3 className="text-2xl font-bold">Deploy &rarr;</h3>
<p className="mt-4 text-xl">
Instantly deploy your Next.js site to a public URL with Vercel.
</p>
</a>
</div>
</main>
<footer className="flex items-center justify-center w-full h-24 border-t">
<a
className="flex items-center justify-center"
href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
Powered by{' '}
<img src="/vercel.svg" alt="Vercel Logo" className="h-4 ml-2" />
</a>
</footer>
</div>
)
}

8
postcss.config.js Normal file
View file

@ -0,0 +1,8 @@
// If you want to use other PostCSS plugins, see the following:
// https://tailwindcss.com/docs/using-with-preprocessors
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

4
public/vercel.svg Normal file
View file

@ -0,0 +1,4 @@
<svg width="283" height="64" viewBox="0 0 283 64" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path d="M141.04 16c-11.04 0-19 7.2-19 18s8.96 18 20 18c6.67 0 12.55-2.64 16.19-7.09l-7.65-4.42c-2.02 2.21-5.09 3.5-8.54 3.5-4.79 0-8.86-2.5-10.37-6.5h28.02c.22-1.12.35-2.28.35-3.5 0-10.79-7.96-17.99-19-17.99zm-9.46 14.5c1.25-3.99 4.67-6.5 9.45-6.5 4.79 0 8.21 2.51 9.45 6.5h-18.9zM248.72 16c-11.04 0-19 7.2-19 18s8.96 18 20 18c6.67 0 12.55-2.64 16.19-7.09l-7.65-4.42c-2.02 2.21-5.09 3.5-8.54 3.5-4.79 0-8.86-2.5-10.37-6.5h28.02c.22-1.12.35-2.28.35-3.5 0-10.79-7.96-17.99-19-17.99zm-9.45 14.5c1.25-3.99 4.67-6.5 9.45-6.5 4.79 0 8.21 2.51 9.45 6.5h-18.9zM200.24 34c0 6 3.92 10 10 10 4.12 0 7.21-1.87 8.8-4.92l7.68 4.43c-3.18 5.3-9.14 8.49-16.48 8.49-11.05 0-19-7.2-19-18s7.96-18 19-18c7.34 0 13.29 3.19 16.48 8.49l-7.68 4.43c-1.59-3.05-4.68-4.92-8.8-4.92-6.07 0-10 4-10 10zm82.48-29v46h-9V5h9zM36.95 0L73.9 64H0L36.95 0zm92.38 5l-27.71 48L73.91 5H84.3l17.32 30 17.32-30h10.39zm58.91 12v9.69c-1-.29-2.06-.49-3.2-.49-5.81 0-10 4-10 10V51h-9V17h9v9.2c0-5.08 5.91-9.2 13.2-9.2z" fill="#000"/>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

12
tailwind.config.js Normal file
View file

@ -0,0 +1,12 @@
module.exports = {
mode: 'jit',
purge: ['./pages/**/*.{js,ts,jsx,tsx}', './components/**/*.{js,ts,jsx,tsx}'],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {},
},
variants: {
extend: {},
},
plugins: [],
}

20
tsconfig.json Normal file
View file

@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"incremental": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}

4933
yarn.lock Normal file

File diff suppressed because it is too large Load diff