├── .editorconfig ├── .eslintignore ├── .eslintrc.json ├── .gitignore ├── babel.config.js ├── next-env.d.ts ├── next.config.js ├── package.json ├── prettier.config.js ├── src ├── assets │ └── rocketseat.svg ├── pages │ ├── _app.tsx │ ├── _document.tsx │ └── index.tsx ├── styles │ ├── global.ts │ ├── pages │ │ └── Home.ts │ ├── styles.d.ts │ └── theme.ts └── test.d.ts ├── tsconfig.json └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | charset = utf-8 7 | end_of_line = lf 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .next 3 | /*.js -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es2021": true, 5 | "node": true, 6 | "jest": true 7 | }, 8 | "extends": [ 9 | "plugin:react/recommended", 10 | "standard", 11 | "plugin:@typescript-eslint/recommended", 12 | "prettier/@typescript-eslint", 13 | "prettier/standard", 14 | "prettier/react" 15 | ], 16 | "parser": "@typescript-eslint/parser", 17 | "parserOptions": { 18 | "ecmaFeatures": { 19 | "jsx": true 20 | }, 21 | "ecmaVersion": 12, 22 | "sourceType": "module" 23 | }, 24 | "plugins": ["react", "@typescript-eslint", "prettier"], 25 | "rules": { 26 | "prettier/prettier": "error", 27 | "space-before-function-paren": "off", 28 | "react/prop-types": "off", 29 | "react/react-in-jsx-scope": "off" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | *.pem 21 | 22 | # debug 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | 27 | # local env files 28 | .env.local 29 | .env.development.local 30 | .env.test.local 31 | .env.production.local 32 | 33 | # vercel 34 | .vercel 35 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['next/babel'], 3 | plugins: [['styled-components', { ssr: true }], 'inline-react-svg'] 4 | } 5 | -------------------------------------------------------------------------------- /next-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | -------------------------------------------------------------------------------- /next.config.js: -------------------------------------------------------------------------------- 1 | const withImages = require('next-images') 2 | 3 | module.exports = withImages({ 4 | esModule: true 5 | }) 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-setup", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev", 7 | "build": "next build", 8 | "start": "next start" 9 | }, 10 | "dependencies": { 11 | "next": "9.5.3", 12 | "next-images": "^1.4.1", 13 | "react": "16.13.1", 14 | "react-dom": "16.13.1", 15 | "styled-components": "^5.2.0" 16 | }, 17 | "devDependencies": { 18 | "@types/node": "^14.10.1", 19 | "@types/react": "^16.9.49", 20 | "@types/styled-components": "^5.1.3", 21 | "@typescript-eslint/eslint-plugin": "^4.1.0", 22 | "@typescript-eslint/parser": "^4.1.0", 23 | "babel-plugin-inline-react-svg": "^1.1.1", 24 | "eslint": "^7.9.0", 25 | "eslint-config-prettier": "^6.11.0", 26 | "eslint-config-standard": "^14.1.1", 27 | "eslint-plugin-import": "^2.22.0", 28 | "eslint-plugin-node": "^11.1.0", 29 | "eslint-plugin-prettier": "^3.1.4", 30 | "eslint-plugin-promise": "^4.2.1", 31 | "eslint-plugin-react": "^7.20.6", 32 | "eslint-plugin-standard": "^4.0.1", 33 | "prettier": "^2.1.1", 34 | "typescript": "^4.0.2" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /prettier.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | semi: false, 3 | singleQuote: true, 4 | trailingComma: 'none', 5 | arrowParens: 'avoid', 6 | endOfLine: 'lf', 7 | } 8 | -------------------------------------------------------------------------------- /src/assets/rocketseat.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/pages/_app.tsx: -------------------------------------------------------------------------------- 1 | import { AppProps } from 'next/app' 2 | import { ThemeProvider } from 'styled-components' 3 | 4 | import GlobalStyle from '../styles/global' 5 | import theme from '../styles/theme' 6 | 7 | const MyApp: React.FC = ({ Component, pageProps }) => { 8 | return ( 9 | 10 | 11 | 12 | 13 | ) 14 | } 15 | 16 | export default MyApp 17 | -------------------------------------------------------------------------------- /src/pages/_document.tsx: -------------------------------------------------------------------------------- 1 | import Document, { 2 | DocumentContext, 3 | DocumentInitialProps, 4 | Html, 5 | Head, 6 | Main, 7 | NextScript 8 | } from 'next/document' 9 | import { ServerStyleSheet } from 'styled-components' 10 | 11 | export default class MyDocument extends Document { 12 | static async getInitialProps( 13 | ctx: DocumentContext 14 | ): Promise { 15 | const sheet = new ServerStyleSheet() 16 | const originalRenderPage = ctx.renderPage 17 | 18 | try { 19 | ctx.renderPage = () => 20 | originalRenderPage({ 21 | enhanceApp: App => props => sheet.collectStyles() 22 | }) 23 | 24 | const initialProps = await Document.getInitialProps(ctx) 25 | return { 26 | ...initialProps, 27 | styles: ( 28 | <> 29 | {initialProps.styles} 30 | {sheet.getStyleElement()} 31 | 32 | ) 33 | } 34 | } finally { 35 | sheet.seal() 36 | } 37 | } 38 | 39 | render(): JSX.Element { 40 | return ( 41 | 42 | 43 | 44 | 45 | 49 | 50 | 51 | 52 | 53 |
54 | 55 | 56 | 57 | ) 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/pages/index.tsx: -------------------------------------------------------------------------------- 1 | import Head from 'next/head' 2 | 3 | import RocketseatLogo from '../assets/rocketseat.svg' 4 | 5 | import { Container } from '../styles/pages/Home' 6 | 7 | const Home: React.FC = () => { 8 | return ( 9 | 10 | 11 | Homepage 12 | 13 | 14 | 15 |

ReactJS Structure

16 |

A ReactJS + Next.js structure made by Rocketseat

17 |
18 | ) 19 | } 20 | 21 | export default Home 22 | -------------------------------------------------------------------------------- /src/styles/global.ts: -------------------------------------------------------------------------------- 1 | import { createGlobalStyle } from 'styled-components' 2 | 3 | export default createGlobalStyle` 4 | * { 5 | margin: 0; 6 | padding: 0; 7 | box-sizing: border-box; 8 | } 9 | body { 10 | background: ${props => props.theme.colors.background}; 11 | color: ${props => props.theme.colors.text}; 12 | font: 400 16px Roboto, sans-serif; 13 | } 14 | ` 15 | -------------------------------------------------------------------------------- /src/styles/pages/Home.ts: -------------------------------------------------------------------------------- 1 | import styled from 'styled-components' 2 | 3 | export const Container = styled.div` 4 | width: 100vw; 5 | height: 100vh; 6 | 7 | display: flex; 8 | justify-content: center; 9 | align-items: center; 10 | flex-direction: column; 11 | 12 | h1 { 13 | font-size: 54px; 14 | color: ${props => props.theme.colors.primary}; 15 | margin-top: 40px; 16 | } 17 | 18 | p { 19 | margin-top: 24px; 20 | font-size: 24px; 21 | line-height: 32px; 22 | } 23 | ` 24 | -------------------------------------------------------------------------------- /src/styles/styles.d.ts: -------------------------------------------------------------------------------- 1 | import 'styled-components' 2 | 3 | import theme from './theme' 4 | 5 | export type Theme = typeof theme 6 | 7 | declare module 'styled-components' { 8 | // eslint-disable-next-line @typescript-eslint/no-empty-interface 9 | export interface DefaultTheme extends Theme {} 10 | } 11 | -------------------------------------------------------------------------------- /src/styles/theme.ts: -------------------------------------------------------------------------------- 1 | const theme = { 2 | colors: { 3 | background: '#121214', 4 | text: '#e1e1e6', 5 | primary: '#8257e6' 6 | } 7 | } 8 | 9 | export default theme 10 | -------------------------------------------------------------------------------- /src/test.d.ts: -------------------------------------------------------------------------------- 1 | interface TestProps { 2 | name: string 3 | } 4 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "strict": false, 12 | "forceConsistentCasingInFileNames": true, 13 | "noEmit": true, 14 | "esModuleInterop": true, 15 | "module": "esnext", 16 | "moduleResolution": "node", 17 | "resolveJsonModule": true, 18 | "isolatedModules": true, 19 | "jsx": "preserve" 20 | }, 21 | "include": [ 22 | "next-env.d.ts", 23 | "**/*.ts", 24 | "**/*.tsx" 25 | ], 26 | "exclude": [ 27 | "node_modules" 28 | ] 29 | } 30 | --------------------------------------------------------------------------------