From c021d3a0bd80185cdd601c3cd5fe5012dc368b28 Mon Sep 17 00:00:00 2001 From: Annabelle Date: Fri, 24 May 2024 18:02:11 +0200 Subject: [PATCH 1/2] chore(app): Create vite app and add tailwind to style the app, create future folders. --- client/.eslintrc.cjs | 18 ++++++++++++++++++ client/.gitignore | 24 ++++++++++++++++++++++++ client/README.md | 30 ++++++++++++++++++++++++++++++ client/index.html | 13 +++++++++++++ client/package.json | 28 ++++++++++++++++++++++++++++ client/src/Pages/Home/index.tsx | 7 +++++++ client/src/main.tsx | 10 ++++++++++ client/src/styles/index.css | 3 +++ client/src/vite-env.d.ts | 1 + client/tsconfig.json | 25 +++++++++++++++++++++++++ client/tsconfig.node.json | 11 +++++++++++ client/vite.config.ts | 7 +++++++ package.json | 5 ++++- postcss.config.js | 6 ++++++ tailwind.config.js | 9 +++++++++ 15 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 client/.eslintrc.cjs create mode 100644 client/.gitignore create mode 100644 client/README.md create mode 100644 client/index.html create mode 100644 client/package.json create mode 100644 client/src/Pages/Home/index.tsx create mode 100644 client/src/main.tsx create mode 100644 client/src/styles/index.css create mode 100644 client/src/vite-env.d.ts create mode 100644 client/tsconfig.json create mode 100644 client/tsconfig.node.json create mode 100644 client/vite.config.ts create mode 100644 postcss.config.js create mode 100644 tailwind.config.js diff --git a/client/.eslintrc.cjs b/client/.eslintrc.cjs new file mode 100644 index 000000000..d6c953795 --- /dev/null +++ b/client/.eslintrc.cjs @@ -0,0 +1,18 @@ +module.exports = { + root: true, + env: { browser: true, es2020: true }, + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:react-hooks/recommended', + ], + ignorePatterns: ['dist', '.eslintrc.cjs'], + parser: '@typescript-eslint/parser', + plugins: ['react-refresh'], + rules: { + 'react-refresh/only-export-components': [ + 'warn', + { allowConstantExport: true }, + ], + }, +} diff --git a/client/.gitignore b/client/.gitignore new file mode 100644 index 000000000..a547bf36d --- /dev/null +++ b/client/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/client/README.md b/client/README.md new file mode 100644 index 000000000..0d6babedd --- /dev/null +++ b/client/README.md @@ -0,0 +1,30 @@ +# React + TypeScript + Vite + +This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. + +Currently, two official plugins are available: + +- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh +- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh + +## Expanding the ESLint configuration + +If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: + +- Configure the top-level `parserOptions` property like this: + +```js +export default { + // other rules... + parserOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + project: ['./tsconfig.json', './tsconfig.node.json'], + tsconfigRootDir: __dirname, + }, +} +``` + +- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` +- Optionally add `plugin:@typescript-eslint/stylistic-type-checked` +- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list diff --git a/client/index.html b/client/index.html new file mode 100644 index 000000000..e4b78eae1 --- /dev/null +++ b/client/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite + React + TS + + +
+ + + diff --git a/client/package.json b/client/package.json new file mode 100644 index 000000000..17fecdc76 --- /dev/null +++ b/client/package.json @@ -0,0 +1,28 @@ +{ + "name": "client", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc && vite build", + "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "preview": "vite preview" + }, + "dependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + }, + "devDependencies": { + "@types/react": "^18.2.66", + "@types/react-dom": "^18.2.22", + "@typescript-eslint/eslint-plugin": "^7.2.0", + "@typescript-eslint/parser": "^7.2.0", + "@vitejs/plugin-react": "^4.2.1", + "eslint": "^8.57.0", + "eslint-plugin-react-hooks": "^4.6.0", + "eslint-plugin-react-refresh": "^0.4.6", + "typescript": "^5.2.2", + "vite": "^5.2.0" + } +} diff --git a/client/src/Pages/Home/index.tsx b/client/src/Pages/Home/index.tsx new file mode 100644 index 000000000..dbe7ebbd6 --- /dev/null +++ b/client/src/Pages/Home/index.tsx @@ -0,0 +1,7 @@ +const Home = () => { + return ( +
ArgentBank
+ ) +} + +export default Home diff --git a/client/src/main.tsx b/client/src/main.tsx new file mode 100644 index 000000000..0c0c9a21d --- /dev/null +++ b/client/src/main.tsx @@ -0,0 +1,10 @@ +import React from 'react' +import ReactDOM from 'react-dom/client' +import Home from './Pages/Home' +import './styles/index.css' + +ReactDOM.createRoot(document.getElementById('root')!).render( + + + , +) diff --git a/client/src/styles/index.css b/client/src/styles/index.css new file mode 100644 index 000000000..bd6213e1d --- /dev/null +++ b/client/src/styles/index.css @@ -0,0 +1,3 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; \ No newline at end of file diff --git a/client/src/vite-env.d.ts b/client/src/vite-env.d.ts new file mode 100644 index 000000000..11f02fe2a --- /dev/null +++ b/client/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/client/tsconfig.json b/client/tsconfig.json new file mode 100644 index 000000000..a7fc6fbf2 --- /dev/null +++ b/client/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/client/tsconfig.node.json b/client/tsconfig.node.json new file mode 100644 index 000000000..97ede7ee6 --- /dev/null +++ b/client/tsconfig.node.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true, + "strict": true + }, + "include": ["vite.config.ts"] +} diff --git a/client/vite.config.ts b/client/vite.config.ts new file mode 100644 index 000000000..5a33944a9 --- /dev/null +++ b/client/vite.config.ts @@ -0,0 +1,7 @@ +import { defineConfig } from 'vite' +import react from '@vitejs/plugin-react' + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [react()], +}) diff --git a/package.json b/package.json index 632fb89a1..e03c88198 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,9 @@ "server": "node ./server/server.js" }, "devDependencies": { - "nodemon": "^2.0.4" + "autoprefixer": "^10.4.19", + "nodemon": "^2.0.4", + "postcss": "^8.4.38", + "tailwindcss": "^3.4.3" } } diff --git a/postcss.config.js b/postcss.config.js new file mode 100644 index 000000000..33ad091d2 --- /dev/null +++ b/postcss.config.js @@ -0,0 +1,6 @@ +module.exports = { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +} diff --git a/tailwind.config.js b/tailwind.config.js new file mode 100644 index 000000000..d947ab175 --- /dev/null +++ b/tailwind.config.js @@ -0,0 +1,9 @@ +/** @type {import('tailwindcss').Config} */ +module.exports = { + content: [], + theme: { + extend: {}, + }, + plugins: [], +} + From 2fc93da2bab42d42ff308c5f61f4028a12511119 Mon Sep 17 00:00:00 2001 From: Annabelle Date: Sat, 15 Jun 2024 18:04:24 +0200 Subject: [PATCH 2/2] feat(store): Add redux and create store and slice files. --- client/package.json | 12 +++++++++- client/src/main.tsx | 47 +++++++++++++++++++++++++++++++++++++--- client/src/store.ts | 15 +++++++++++++ client/src/userSlice.tsx | 23 ++++++++++++++++++++ package.json | 5 +---- 5 files changed, 94 insertions(+), 8 deletions(-) create mode 100644 client/src/store.ts create mode 100644 client/src/userSlice.tsx diff --git a/client/package.json b/client/package.json index 17fecdc76..638e54493 100644 --- a/client/package.json +++ b/client/package.json @@ -10,8 +10,15 @@ "preview": "vite preview" }, "dependencies": { + "@fortawesome/fontawesome-free": "^6.5.2", + "@fortawesome/fontawesome-svg-core": "^6.5.2", + "@fortawesome/free-solid-svg-icons": "^6.5.2", + "@fortawesome/react-fontawesome": "^0.2.0", + "@reduxjs/toolkit": "^2.2.5", "react": "^18.2.0", - "react-dom": "^18.2.0" + "react-dom": "^18.2.0", + "react-redux": "^9.1.2", + "react-router-dom": "^6.23.1" }, "devDependencies": { "@types/react": "^18.2.66", @@ -19,9 +26,12 @@ "@typescript-eslint/eslint-plugin": "^7.2.0", "@typescript-eslint/parser": "^7.2.0", "@vitejs/plugin-react": "^4.2.1", + "autoprefixer": "^10.4.19", "eslint": "^8.57.0", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-refresh": "^0.4.6", + "postcss": "^8.4.38", + "tailwindcss": "^3.4.3", "typescript": "^5.2.2", "vite": "^5.2.0" } diff --git a/client/src/main.tsx b/client/src/main.tsx index 0c0c9a21d..0c67ce74b 100644 --- a/client/src/main.tsx +++ b/client/src/main.tsx @@ -1,10 +1,51 @@ -import React from 'react' +import React from 'react'; import ReactDOM from 'react-dom/client' -import Home from './Pages/Home' +import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'; + +import { Provider } from 'react-redux'; +import { store } from './store'; + +import Home from './pages/Home'; +import SignIn from './pages/SignIn'; +import Dashboard from './pages/Dashboard'; +import NavBar from './components/NavBar'; +import Footer from './components/Footer'; + import './styles/index.css' +import { library } from '@fortawesome/fontawesome-svg-core'; +import { fas } from '@fortawesome/free-solid-svg-icons'; + +library.add(fas); ReactDOM.createRoot(document.getElementById('root')!).render( - + + + + + } /> + } /> + } /> + +