Repository: hiteshchoudhary/chai-aur-react
Branch: main
Commit: 651285bff5ba
Files: 223
Total size: 195.0 KB
Directory structure:
gitextract_ev68w7bd/
├── .gitignore
├── .vscode/
│ └── settings.json
├── 01basicreact/
│ ├── .gitignore
│ ├── README.md
│ ├── package.json
│ ├── public/
│ │ ├── index.html
│ │ ├── manifest.json
│ │ └── robots.txt
│ └── src/
│ ├── App.js
│ ├── Chai.jsx
│ └── index.js
├── 01vitereact/
│ ├── .eslintrc.cjs
│ ├── .gitignore
│ ├── README.md
│ ├── index.html
│ ├── package.json
│ ├── src/
│ │ ├── App.jsx
│ │ ├── chai.jsx
│ │ └── main.jsx
│ └── vite.config.js
├── 02counter/
│ ├── .eslintrc.cjs
│ ├── .gitignore
│ ├── README.md
│ ├── index.html
│ ├── package.json
│ ├── src/
│ │ ├── App.css
│ │ ├── App.jsx
│ │ ├── index.css
│ │ └── main.jsx
│ └── vite.config.js
├── 03tailwindprops/
│ ├── .eslintrc.cjs
│ ├── .gitignore
│ ├── README.md
│ ├── index.html
│ ├── package.json
│ ├── postcss.config.js
│ ├── src/
│ │ ├── App.css
│ │ ├── App.jsx
│ │ ├── components/
│ │ │ └── Card.jsx
│ │ ├── index.css
│ │ └── main.jsx
│ ├── tailwind.config.js
│ └── vite.config.js
├── 04bgChanger/
│ ├── .eslintrc.cjs
│ ├── .gitignore
│ ├── README.md
│ ├── bun.lockb
│ ├── index.html
│ ├── package.json
│ ├── postcss.config.js
│ ├── src/
│ │ ├── App.css
│ │ ├── App.jsx
│ │ ├── index.css
│ │ └── main.jsx
│ ├── tailwind.config.js
│ └── vite.config.js
├── 05passwordGenerator/
│ ├── .eslintrc.cjs
│ ├── .gitignore
│ ├── README.md
│ ├── index.html
│ ├── package.json
│ ├── postcss.config.js
│ ├── src/
│ │ ├── App.css
│ │ ├── App.jsx
│ │ ├── index.css
│ │ └── main.jsx
│ ├── tailwind.config.js
│ └── vite.config.js
├── 06currencyConvertor/
│ ├── .eslintrc.cjs
│ ├── .gitignore
│ ├── README.md
│ ├── index.html
│ ├── package.json
│ ├── postcss.config.js
│ ├── src/
│ │ ├── App.css
│ │ ├── App.jsx
│ │ ├── components/
│ │ │ ├── InputBox.jsx
│ │ │ └── index.js
│ │ ├── hooks/
│ │ │ └── useCurrencyInfo.js
│ │ ├── index.css
│ │ └── main.jsx
│ ├── tailwind.config.js
│ └── vite.config.js
├── 07reactRouter/
│ ├── .eslintrc.cjs
│ ├── .gitignore
│ ├── README.md
│ ├── index.html
│ ├── package.json
│ ├── postcss.config.js
│ ├── src/
│ │ ├── App.css
│ │ ├── App.jsx
│ │ ├── Layout.jsx
│ │ ├── components/
│ │ │ ├── About/
│ │ │ │ └── About.jsx
│ │ │ ├── Contact/
│ │ │ │ └── Contact.jsx
│ │ │ ├── Footer/
│ │ │ │ └── Footer.jsx
│ │ │ ├── Github/
│ │ │ │ └── Github.jsx
│ │ │ ├── Header/
│ │ │ │ └── Header.jsx
│ │ │ ├── Home/
│ │ │ │ └── Home.jsx
│ │ │ └── User/
│ │ │ └── User.jsx
│ │ ├── index.css
│ │ └── main.jsx
│ ├── tailwind.config.js
│ └── vite.config.js
├── 08miniContext/
│ ├── .eslintrc.cjs
│ ├── .gitignore
│ ├── README.md
│ ├── index.html
│ ├── package.json
│ ├── src/
│ │ ├── App.css
│ │ ├── App.jsx
│ │ ├── components/
│ │ │ ├── Login.jsx
│ │ │ └── Profile.jsx
│ │ ├── context/
│ │ │ ├── UserContext.js
│ │ │ └── UserContextProvider.jsx
│ │ ├── index.css
│ │ └── main.jsx
│ └── vite.config.js
├── 09themeswitcher/
│ ├── .eslintrc.cjs
│ ├── .gitignore
│ ├── README.md
│ ├── index.html
│ ├── package.json
│ ├── postcss.config.js
│ ├── src/
│ │ ├── App.css
│ │ ├── App.jsx
│ │ ├── components/
│ │ │ ├── Card.jsx
│ │ │ └── ThemeBtn.jsx
│ │ ├── contexts/
│ │ │ └── theme.js
│ │ ├── index.css
│ │ └── main.jsx
│ ├── tailwind.config.js
│ └── vite.config.js
├── 10todocontextLocal/
│ ├── .eslintrc.cjs
│ ├── .gitignore
│ ├── README.md
│ ├── index.html
│ ├── package.json
│ ├── postcss.config.js
│ ├── src/
│ │ ├── App.css
│ │ ├── App.jsx
│ │ ├── components/
│ │ │ ├── TodoForm.jsx
│ │ │ ├── TodoItem.jsx
│ │ │ └── index.js
│ │ ├── contexts/
│ │ │ ├── TodoContext.js
│ │ │ └── index.js
│ │ ├── index.css
│ │ └── main.jsx
│ ├── tailwind.config.js
│ └── vite.config.js
├── 12MegaBlog/
│ ├── .eslintrc.cjs
│ ├── .gitignore
│ ├── README.md
│ ├── bun.lockb
│ ├── index.html
│ ├── package.json
│ ├── postcss.config.js
│ ├── src/
│ │ ├── App.css
│ │ ├── App.jsx
│ │ ├── appwrite/
│ │ │ ├── auth.js
│ │ │ └── config.js
│ │ ├── components/
│ │ │ ├── AuthLayout.jsx
│ │ │ ├── Button.jsx
│ │ │ ├── Footer/
│ │ │ │ └── Footer.jsx
│ │ │ ├── Header/
│ │ │ │ ├── Header.jsx
│ │ │ │ └── LogoutBtn.jsx
│ │ │ ├── Input.jsx
│ │ │ ├── Login.jsx
│ │ │ ├── Logo.jsx
│ │ │ ├── PostCard.jsx
│ │ │ ├── RTE.jsx
│ │ │ ├── Select.jsx
│ │ │ ├── Signup.jsx
│ │ │ ├── container/
│ │ │ │ └── Container.jsx
│ │ │ ├── index.js
│ │ │ └── post-form/
│ │ │ └── PostForm.jsx
│ │ ├── conf/
│ │ │ └── conf.js
│ │ ├── index.css
│ │ ├── main.jsx
│ │ ├── pages/
│ │ │ ├── AddPost.jsx
│ │ │ ├── AllPosts.jsx
│ │ │ ├── EditPost.jsx
│ │ │ ├── Home.jsx
│ │ │ ├── Login.jsx
│ │ │ ├── Post.jsx
│ │ │ └── Signup.jsx
│ │ └── store/
│ │ ├── authSlice.js
│ │ └── store.js
│ ├── tailwind.config.js
│ └── vite.config.js
├── contextNotes.md
├── currency.md
├── customReact/
│ ├── customreact.js
│ └── index.html
├── interview-discussion/
│ ├── .eslintrc.cjs
│ ├── .gitignore
│ ├── README.md
│ ├── index.html
│ ├── package.json
│ ├── src/
│ │ ├── App.css
│ │ ├── App.jsx
│ │ ├── index.css
│ │ └── main.jsx
│ └── vite.config.js
├── reactRouterNotes.md
├── readme.md
├── reduxToolkitTodo/
│ ├── .eslintrc.cjs
│ ├── .gitignore
│ ├── README.md
│ ├── bun.lockb
│ ├── index.html
│ ├── package.json
│ ├── postcss.config.js
│ ├── src/
│ │ ├── App.css
│ │ ├── App.jsx
│ │ ├── app/
│ │ │ └── store.js
│ │ ├── components/
│ │ │ ├── AddTodo.jsx
│ │ │ └── Todos.jsx
│ │ ├── features/
│ │ │ └── todo/
│ │ │ └── todoSlice.js
│ │ ├── index.css
│ │ └── main.jsx
│ ├── tailwind.config.js
│ └── vite.config.js
└── todoContextapiNotes.md
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
.DS_Store
12MegaBlog/.env
================================================
FILE: .vscode/settings.json
================================================
{
"editor.acceptSuggestionOnEnter": "on",
"liveServer.settings.port": 5501
}
================================================
FILE: 01basicreact/.gitignore
================================================
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
================================================
FILE: 01basicreact/README.md
================================================
# Getting Started with Create React App
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
The page will reload when you make changes.\
You may also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
### Analyzing the Bundle Size
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
### Making a Progressive Web App
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
### Advanced Configuration
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
### Deployment
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
### `npm run build` fails to minify
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
================================================
FILE: 01basicreact/package.json
================================================
{
"name": "01basicreact",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
================================================
FILE: 01basicreact/public/index.html
================================================
React App
You need to enable JavaScript to run this app.
================================================
FILE: 01basicreact/public/manifest.json
================================================
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
================================================
FILE: 01basicreact/public/robots.txt
================================================
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
================================================
FILE: 01basicreact/src/App.js
================================================
import Chai from "./Chai";
function App() {
return (
<>
>
);
}
export default App;
================================================
FILE: 01basicreact/src/Chai.jsx
================================================
function Chai(){
return(
chai in react
)
}
export default Chai
================================================
FILE: 01basicreact/src/index.js
================================================
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
);
================================================
FILE: 01vitereact/.eslintrc.cjs
================================================
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
================================================
FILE: 01vitereact/.gitignore
================================================
# 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?
================================================
FILE: 01vitereact/README.md
================================================
# React + 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
================================================
FILE: 01vitereact/index.html
================================================
Vite + React
================================================
FILE: 01vitereact/package.json
================================================
{
"name": "01vitereact",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint . --ext js,jsx --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.15",
"@types/react-dom": "^18.2.7",
"@vitejs/plugin-react": "^4.0.3",
"eslint": "^8.45.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"vite": "^4.4.5"
}
}
================================================
FILE: 01vitereact/src/App.jsx
================================================
import Chai from "./chai"
function App() {
const username = "chai aur code"
return (
<>
chai aur react {username}
test para
>
)
}
export default App
================================================
FILE: 01vitereact/src/chai.jsx
================================================
function Chai(){
return(
chai is ready
)
}
export default Chai
================================================
FILE: 01vitereact/src/main.jsx
================================================
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
function MyApp(){
return (
Custom App | chai
)
}
// const ReactElement = {
// type: 'a',
// props: {
// href: 'https://google.com',
// target: '_blank'
// },
// children: 'Click me to visit google'
// }
const anotherElement = (
Visit google
)
const anotherUser = "chai aur react"
const reactElement = React.createElement(
'a',
{href: 'https://google.com',target: '_blank' },
'click me to visit google',
anotherElement
)
ReactDOM.createRoot(document.getElementById('root')).render(
reactElement
)
================================================
FILE: 01vitereact/vite.config.js
================================================
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})
================================================
FILE: 02counter/.eslintrc.cjs
================================================
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
================================================
FILE: 02counter/.gitignore
================================================
# 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?
================================================
FILE: 02counter/README.md
================================================
# React + 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
================================================
FILE: 02counter/index.html
================================================
Vite + React
================================================
FILE: 02counter/package.json
================================================
{
"name": "02counter",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint . --ext js,jsx --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.15",
"@types/react-dom": "^18.2.7",
"@vitejs/plugin-react": "^4.0.3",
"eslint": "^8.45.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"vite": "^4.4.5"
}
}
================================================
FILE: 02counter/src/App.css
================================================
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}
@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
}
.card {
padding: 2em;
}
.read-the-docs {
color: #888;
}
================================================
FILE: 02counter/src/App.jsx
================================================
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'
function App() {
const [counter, setCounter] = useState(15)
//let counter = 15
const addValue = () => {
//counter = counter + 1
setCounter(prevCounter => prevCounter + 1)
setCounter(prevCounter => prevCounter + 1 )
setCounter(prevCounter => prevCounter + 1)
setCounter(prevCounter => prevCounter + 1)
}
const removeValue = () => {
setCounter(counter - 1)
}
return (
<>
Chai aur react
Counter value: {counter}
Add value {counter}
remove value {counter}
footer: {counter}
>
)
}
export default App
================================================
FILE: 02counter/src/index.css
================================================
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;
color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
}
a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}
body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}
h1 {
font-size: 3.2em;
line-height: 1.1;
}
button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}
@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}
================================================
FILE: 02counter/src/main.jsx
================================================
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'
ReactDOM.createRoot(document.getElementById('root')).render(
,
)
================================================
FILE: 02counter/vite.config.js
================================================
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})
================================================
FILE: 03tailwindprops/.eslintrc.cjs
================================================
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
================================================
FILE: 03tailwindprops/.gitignore
================================================
# 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?
================================================
FILE: 03tailwindprops/README.md
================================================
# React + 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
================================================
FILE: 03tailwindprops/index.html
================================================
Vite + React
================================================
FILE: 03tailwindprops/package.json
================================================
{
"name": "03tailwindprops",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint . --ext js,jsx --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.15",
"@types/react-dom": "^18.2.7",
"@vitejs/plugin-react": "^4.0.3",
"autoprefixer": "^10.4.15",
"eslint": "^8.45.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"postcss": "^8.4.28",
"tailwindcss": "^3.3.3",
"vite": "^4.4.5"
}
}
================================================
FILE: 03tailwindprops/postcss.config.js
================================================
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
================================================
FILE: 03tailwindprops/src/App.css
================================================
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}
@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
}
.card {
padding: 2em;
}
.read-the-docs {
color: #888;
}
================================================
FILE: 03tailwindprops/src/App.jsx
================================================
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'
import Card from './components/Card'
function App() {
const [count, setCount] = useState(0)
let myObj = {
username: "hitesh",
age: 21
}
let newArr = [1, 2, 3]
return (
<>
Tailwind test
>
)
}
export default App
================================================
FILE: 03tailwindprops/src/components/Card.jsx
================================================
import React from 'react'
function Card({username, btnText="visit me"}) {
console.log(username);
return (
{username}
Lorem ipsum dolor sit amet consectetur adipisicing elit. Excepturi,
debitis?
{btnText } →
)
}
export default Card
================================================
FILE: 03tailwindprops/src/index.css
================================================
@tailwind base;
@tailwind components;
@tailwind utilities;
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;
color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
}
a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}
body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}
h1 {
font-size: 3.2em;
line-height: 1.1;
}
button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}
@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}
================================================
FILE: 03tailwindprops/src/main.jsx
================================================
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'
ReactDOM.createRoot(document.getElementById('root')).render(
,
)
================================================
FILE: 03tailwindprops/tailwind.config.js
================================================
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
================================================
FILE: 03tailwindprops/vite.config.js
================================================
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})
================================================
FILE: 04bgChanger/.eslintrc.cjs
================================================
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
================================================
FILE: 04bgChanger/.gitignore
================================================
# 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?
================================================
FILE: 04bgChanger/README.md
================================================
# React + 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
================================================
FILE: 04bgChanger/index.html
================================================
Vite + React
================================================
FILE: 04bgChanger/package.json
================================================
{
"name": "04bgchanger",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint . --ext js,jsx --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.15",
"@types/react-dom": "^18.2.7",
"@vitejs/plugin-react": "^4.0.3",
"autoprefixer": "^10.4.15",
"eslint": "^8.45.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"postcss": "^8.4.28",
"tailwindcss": "^3.3.3",
"vite": "^4.4.5"
}
}
================================================
FILE: 04bgChanger/postcss.config.js
================================================
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
================================================
FILE: 04bgChanger/src/App.css
================================================
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}
@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
}
.card {
padding: 2em;
}
.read-the-docs {
color: #888;
}
================================================
FILE: 04bgChanger/src/App.jsx
================================================
import { useState } from "react"
function App() {
const [color, setColor] = useState("olive")
return (
setColor("red")}
className="outline-none px-4 py-1 rounded-full text-white shadow-lg"
style={{backgroundColor: "red"}}
>Red
setColor("green")}
className="outline-none px-4 py-1 rounded-full text-white shadow-lg"
style={{backgroundColor: "green"}}
>Green
setColor("blue")}
className="outline-none px-4 py-1 rounded-full text-white shadow-lg"
style={{backgroundColor: "blue"}}
>Blue
)
}
export default App
================================================
FILE: 04bgChanger/src/index.css
================================================
@tailwind base;
@tailwind components;
@tailwind utilities;
================================================
FILE: 04bgChanger/src/main.jsx
================================================
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'
ReactDOM.createRoot(document.getElementById('root')).render(
,
)
================================================
FILE: 04bgChanger/tailwind.config.js
================================================
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
================================================
FILE: 04bgChanger/vite.config.js
================================================
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})
================================================
FILE: 05passwordGenerator/.eslintrc.cjs
================================================
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
================================================
FILE: 05passwordGenerator/.gitignore
================================================
# 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?
================================================
FILE: 05passwordGenerator/README.md
================================================
# React + 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
================================================
FILE: 05passwordGenerator/index.html
================================================
Vite + React
================================================
FILE: 05passwordGenerator/package.json
================================================
{
"name": "05passwordgenerator",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint . --ext js,jsx --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.15",
"@types/react-dom": "^18.2.7",
"@vitejs/plugin-react": "^4.0.3",
"autoprefixer": "^10.4.15",
"eslint": "^8.45.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"postcss": "^8.4.28",
"tailwindcss": "^3.3.3",
"vite": "^4.4.5"
}
}
================================================
FILE: 05passwordGenerator/postcss.config.js
================================================
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
================================================
FILE: 05passwordGenerator/src/App.css
================================================
================================================
FILE: 05passwordGenerator/src/App.jsx
================================================
import { useState, useCallback, useEffect, useRef } from 'react'
function App() {
const [length, setLength] = useState(8)
const [numberAllowed, setNumberAllowed] = useState(false);
const [charAllowed, setCharAllowed] = useState(false)
const [password, setPassword] = useState("")
//useRef hook
const passwordRef = useRef(null)
const passwordGenerator = useCallback(() => {
let pass = ""
let str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
if (numberAllowed) str += "0123456789"
if (charAllowed) str += "!@#$%^&*-_+=[]{}~`"
for (let i = 1; i <= length; i++) {
let char = Math.floor(Math.random() * str.length + 1)
pass += str.charAt(char)
}
setPassword(pass)
}, [length, numberAllowed, charAllowed, setPassword])
const copyPasswordToClipboard = useCallback(() => {
passwordRef.current?.select();
passwordRef.current?.setSelectionRange(0, 999);
window.navigator.clipboard.writeText(password)
}, [password])
useEffect(() => {
passwordGenerator()
}, [length, numberAllowed, charAllowed, passwordGenerator])
return (
)
}
export default App
================================================
FILE: 05passwordGenerator/src/index.css
================================================
@tailwind base;
@tailwind components;
@tailwind utilities;
================================================
FILE: 05passwordGenerator/src/main.jsx
================================================
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'
ReactDOM.createRoot(document.getElementById('root')).render(
,
)
================================================
FILE: 05passwordGenerator/tailwind.config.js
================================================
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
================================================
FILE: 05passwordGenerator/vite.config.js
================================================
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})
================================================
FILE: 06currencyConvertor/.eslintrc.cjs
================================================
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
================================================
FILE: 06currencyConvertor/.gitignore
================================================
# 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?
================================================
FILE: 06currencyConvertor/README.md
================================================
# React + 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
================================================
FILE: 06currencyConvertor/index.html
================================================
Vite + React
================================================
FILE: 06currencyConvertor/package.json
================================================
{
"name": "06currencyconvertor",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint . --ext js,jsx --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.15",
"@types/react-dom": "^18.2.7",
"@vitejs/plugin-react": "^4.0.3",
"autoprefixer": "^10.4.15",
"eslint": "^8.45.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"postcss": "^8.4.29",
"tailwindcss": "^3.3.3",
"vite": "^4.4.5"
}
}
================================================
FILE: 06currencyConvertor/postcss.config.js
================================================
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
================================================
FILE: 06currencyConvertor/src/App.css
================================================
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}
@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
}
.card {
padding: 2em;
}
.read-the-docs {
color: #888;
}
================================================
FILE: 06currencyConvertor/src/App.jsx
================================================
import { useState } from 'react'
import {InputBox} from './components'
import useCurrencyInfo from './hooks/useCurrencyInfo'
function App() {
const [amount, setAmount] = useState(0)
const [from, setFrom] = useState("usd")
const [to, setTo] = useState("inr")
const [convertedAmount, setConvertedAmount] = useState(0)
const currencyInfo = useCurrencyInfo(from)
const options = Object.keys(currencyInfo)
const swap = () => {
setFrom(to)
setTo(from)
setConvertedAmount(amount)
setAmount(convertedAmount)
}
const convert = () => {
setConvertedAmount(amount * currencyInfo[to])
}
return (
);
}
export default App
================================================
FILE: 06currencyConvertor/src/components/InputBox.jsx
================================================
import React, {useId} from 'react'
function InputBox({
label,
amount,
onAmountChange,
onCurrencyChange,
currencyOptions = [],
selectCurrency = "usd",
amountDisable = false,
currencyDisable = false,
className = "",
}) {
const amountInputId = useId()
return (
);
}
export default InputBox;
================================================
FILE: 06currencyConvertor/src/components/index.js
================================================
import InputBox from './InputBox'
export {InputBox}
================================================
FILE: 06currencyConvertor/src/hooks/useCurrencyInfo.js
================================================
import {useEffect, useState} from "react"
function useCurrencyInfo(currency){
const [data, setData] = useState({})
useEffect(() => {
fetch(`https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/${currency}.json`)
.then((res) => res.json())
.then((res) => setData(res[currency]))
console.log(data);
}, [currency])
console.log(data);
return data
}
export default useCurrencyInfo;
================================================
FILE: 06currencyConvertor/src/index.css
================================================
@tailwind base;
@tailwind components;
@tailwind utilities;
================================================
FILE: 06currencyConvertor/src/main.jsx
================================================
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'
ReactDOM.createRoot(document.getElementById('root')).render(
,
)
================================================
FILE: 06currencyConvertor/tailwind.config.js
================================================
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
================================================
FILE: 06currencyConvertor/vite.config.js
================================================
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})
================================================
FILE: 07reactRouter/.eslintrc.cjs
================================================
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
================================================
FILE: 07reactRouter/.gitignore
================================================
# 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?
================================================
FILE: 07reactRouter/README.md
================================================
# React + 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
================================================
FILE: 07reactRouter/index.html
================================================
Vite + React
================================================
FILE: 07reactRouter/package.json
================================================
{
"name": "07reactrouter",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.15.0"
},
"devDependencies": {
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@vitejs/plugin-react": "^4.0.3",
"autoprefixer": "^10.4.15",
"eslint": "^8.45.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"postcss": "^8.4.29",
"tailwindcss": "^3.3.3",
"vite": "^4.4.5"
}
}
================================================
FILE: 07reactRouter/postcss.config.js
================================================
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
================================================
FILE: 07reactRouter/src/App.css
================================================
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}
@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
}
.card {
padding: 2em;
}
.read-the-docs {
color: #888;
}
================================================
FILE: 07reactRouter/src/App.jsx
================================================
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'
import Header from './components/Header/Header'
import Footer from './components/Footer/Footer'
import Home from './components/Home/Home'
function App() {
const [count, setCount] = useState(0)
return (
<>
>
)
}
export default App
================================================
FILE: 07reactRouter/src/Layout.jsx
================================================
import React from 'react'
import Header from './components/Header/Header'
import Footer from './components/Footer/Footer'
import { Outlet } from 'react-router-dom'
function Layout() {
return (
<>
>
)
}
export default Layout
================================================
FILE: 07reactRouter/src/components/About/About.jsx
================================================
import React from 'react'
export default function About() {
return (
React development is carried out by passionate developers
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Eum omnis voluptatem
accusantium nemo perspiciatis delectus atque autem! Voluptatum tenetur beatae unde
aperiam, repellat expedita consequatur! Officiis id consequatur atque doloremque!
Nobis minus voluptatibus pariatur dignissimos libero quaerat iure expedita at?
Asperiores nemo possimus nesciunt dicta veniam aspernatur quam mollitia.
);
}
================================================
FILE: 07reactRouter/src/components/Contact/Contact.jsx
================================================
import React from 'react'
export default function Contact() {
return (
Get in touch:
Fill in the form to start a conversation
Acme Inc, Street, State, Postal Code
);
}
================================================
FILE: 07reactRouter/src/components/Footer/Footer.jsx
================================================
import React from 'react'
import { Link } from 'react-router-dom';
export default function Footer() {
return (
Legal
Privacy Policy
Terms & Conditions
© 2023
hiteshchoudhary
. All Rights Reserved.
Facebook page
Discord community
Twitter page
GitHub account
Dribbble account
);
}
================================================
FILE: 07reactRouter/src/components/Github/Github.jsx
================================================
import React, { useEffect, useState } from 'react'
import { useLoaderData } from 'react-router-dom'
function Github() {
const data = useLoaderData()
// const [data, setData] = useState([])
// useEffect(() => {
// fetch('https://api.github.com/users/hiteshchoudhary')
// .then(response => response.json())
// .then(data => {
// console.log(data);
// setData(data)
// })
// }, [])
return (
Github followers: {data.followers}
)
}
export default Github
export const githubInfoLoader = async () => {
const response = await fetch('https://api.github.com/users/hiteshchoudhary')
return response.json()
}
================================================
FILE: 07reactRouter/src/components/Header/Header.jsx
================================================
import React from 'react'
import {Link, NavLink} from 'react-router-dom'
export default function Header() {
return (
Log in
Get started
);
}
================================================
FILE: 07reactRouter/src/components/Home/Home.jsx
================================================
import React from 'react'
import { Link } from 'react-router-dom';
export default function Home() {
return (
Download Now
Lorem Ipsum
Download now
Lorem Ipsum Yojo
);
}
================================================
FILE: 07reactRouter/src/components/User/User.jsx
================================================
import React from 'react'
import { useParams } from 'react-router-dom'
function User() {
const {userid} = useParams()
return (
User: {userid}
)
}
export default User
================================================
FILE: 07reactRouter/src/index.css
================================================
@tailwind base;
@tailwind components;
@tailwind utilities;
================================================
FILE: 07reactRouter/src/main.jsx
================================================
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'
import { Route, RouterProvider, createBrowserRouter, createRoutesFromElements } from 'react-router-dom'
import Layout from './Layout.jsx'
import Home from './components/Home/Home.jsx'
import About from './components/About/About.jsx'
import Contact from './components/Contact/Contact.jsx'
import User from './components/User/User.jsx'
import Github, { githubInfoLoader } from './components/Github/Github.jsx'
// const router = createBrowserRouter([
// {
// path: '/',
// element: ,
// children: [
// {
// path: "",
// element:
// },
// {
// path: "about",
// element:
// },
// {
// path: "contact",
// element:
// }
// ]
// }
// ])
const router = createBrowserRouter(
createRoutesFromElements(
}>
} />
} />
} />
} />
}
/>
)
)
ReactDOM.createRoot(document.getElementById('root')).render(
,
)
================================================
FILE: 07reactRouter/tailwind.config.js
================================================
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
================================================
FILE: 07reactRouter/vite.config.js
================================================
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})
================================================
FILE: 08miniContext/.eslintrc.cjs
================================================
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
================================================
FILE: 08miniContext/.gitignore
================================================
# 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?
================================================
FILE: 08miniContext/README.md
================================================
# React + 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
================================================
FILE: 08miniContext/index.html
================================================
Vite + React
================================================
FILE: 08miniContext/package.json
================================================
{
"name": "08minicontext",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint . --ext js,jsx --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.15",
"@types/react-dom": "^18.2.7",
"@vitejs/plugin-react": "^4.0.3",
"eslint": "^8.45.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"vite": "^4.4.5"
}
}
================================================
FILE: 08miniContext/src/App.css
================================================
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}
@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
}
.card {
padding: 2em;
}
.read-the-docs {
color: #888;
}
================================================
FILE: 08miniContext/src/App.jsx
================================================
import './App.css'
import Login from './components/Login'
import Profile from './components/Profile'
import UserContextProvider from './context/UserContextProvider'
function App() {
return (
React with Chai and share is important
)
}
export default App
================================================
FILE: 08miniContext/src/components/Login.jsx
================================================
import React, {useState, useContext} from 'react'
import UserContext from '../context/UserContext'
function Login() {
const [username, setUsername] = useState('')
const [password, setPassword] = useState('')
const {setUser} = useContext(UserContext)
const handleSubmit = (e) => {
e.preventDefault()
setUser({username, password})
}
return (
Login
setUsername(e.target.value) }
placeholder='username' />
{" "}
setPassword(e.target.value) }
placeholder='password' />
Submit
)
}
export default Login
================================================
FILE: 08miniContext/src/components/Profile.jsx
================================================
import React, {useContext} from 'react'
import UserContext from '../context/UserContext'
function Profile() {
const {user} = useContext(UserContext)
if (!user) return please login
return Welcome {user.username}
}
export default Profile
================================================
FILE: 08miniContext/src/context/UserContext.js
================================================
import React from 'react'
const UserContext = React.createContext()
export default UserContext;
================================================
FILE: 08miniContext/src/context/UserContextProvider.jsx
================================================
import React from "react";
import UserContext from "./UserContext";
const UserContextProvider = ({children}) => {
const [user, setUser] = React.useState(null)
return(
{children}
)
}
export default UserContextProvider
================================================
FILE: 08miniContext/src/index.css
================================================
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;
color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
}
a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}
body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}
h1 {
font-size: 3.2em;
line-height: 1.1;
}
button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}
@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}
================================================
FILE: 08miniContext/src/main.jsx
================================================
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'
ReactDOM.createRoot(document.getElementById('root')).render(
,
)
================================================
FILE: 08miniContext/vite.config.js
================================================
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})
================================================
FILE: 09themeswitcher/.eslintrc.cjs
================================================
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
================================================
FILE: 09themeswitcher/.gitignore
================================================
# 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?
================================================
FILE: 09themeswitcher/README.md
================================================
# React + 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
================================================
FILE: 09themeswitcher/index.html
================================================
Vite + React
================================================
FILE: 09themeswitcher/package.json
================================================
{
"name": "09themeswitcher",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint . --ext js,jsx --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.15",
"@types/react-dom": "^18.2.7",
"@vitejs/plugin-react": "^4.0.3",
"autoprefixer": "^10.4.15",
"eslint": "^8.45.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"postcss": "^8.4.29",
"tailwindcss": "^3.3.3",
"vite": "^4.4.5"
}
}
================================================
FILE: 09themeswitcher/postcss.config.js
================================================
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
================================================
FILE: 09themeswitcher/src/App.css
================================================
================================================
FILE: 09themeswitcher/src/App.jsx
================================================
import { useEffect, useState } from 'react'
import './App.css'
import { ThemeProvider } from './contexts/theme'
import ThemeBtn from './components/ThemeBtn'
import Card from './components/Card'
function App() {
const [themeMode, setThemeMode] = useState("light")
const lightTheme = () => {
setThemeMode("light")
}
const darkTheme = () => {
setThemeMode("dark")
}
// actual change in theme
useEffect(() => {
document.querySelector('html').classList.remove("light", "dark")
document.querySelector('html').classList.add(themeMode)
}, [themeMode])
return (
)
}
export default App
================================================
FILE: 09themeswitcher/src/components/Card.jsx
================================================
import React from 'react'
export default function Card() {
return (
);
}
================================================
FILE: 09themeswitcher/src/components/ThemeBtn.jsx
================================================
import React from 'react'
import useTheme from '../contexts/theme';
export default function ThemeBtn() {
const {themeMode, lightTheme, darkTheme} = useTheme()
const onChangeBtn = (e) => {
const darkModeStatus = e.currentTarget.checked
if (darkModeStatus) {
darkTheme()
} else {
lightTheme()
}
}
return (
Toggle Theme
);
}
================================================
FILE: 09themeswitcher/src/contexts/theme.js
================================================
import { createContext, useContext } from "react";
export const ThemeContext = createContext({
themeMode: "light",
darkTheme: () => {},
lightTheme: () => {},
})
export const ThemeProvider = ThemeContext.Provider
export default function useTheme(){
return useContext(ThemeContext)
}
================================================
FILE: 09themeswitcher/src/index.css
================================================
@tailwind base;
@tailwind components;
@tailwind utilities;
================================================
FILE: 09themeswitcher/src/main.jsx
================================================
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'
ReactDOM.createRoot(document.getElementById('root')).render(
,
)
================================================
FILE: 09themeswitcher/tailwind.config.js
================================================
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
darkMode: "class",
theme: {
extend: {},
},
plugins: [],
}
================================================
FILE: 09themeswitcher/vite.config.js
================================================
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})
================================================
FILE: 10todocontextLocal/.eslintrc.cjs
================================================
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
================================================
FILE: 10todocontextLocal/.gitignore
================================================
# 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?
================================================
FILE: 10todocontextLocal/README.md
================================================
# React + 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
================================================
FILE: 10todocontextLocal/index.html
================================================
Vite + React
================================================
FILE: 10todocontextLocal/package.json
================================================
{
"name": "10todocontextlocal",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint . --ext js,jsx --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.15",
"@types/react-dom": "^18.2.7",
"@vitejs/plugin-react": "^4.0.3",
"autoprefixer": "^10.4.15",
"eslint": "^8.45.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"postcss": "^8.4.29",
"tailwindcss": "^3.3.3",
"vite": "^4.4.5"
}
}
================================================
FILE: 10todocontextLocal/postcss.config.js
================================================
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
================================================
FILE: 10todocontextLocal/src/App.css
================================================
================================================
FILE: 10todocontextLocal/src/App.jsx
================================================
import { useState, useEffect } from 'react'
import {TodoProvider} from './contexts'
import './App.css'
import TodoForm from './components/TodoForm'
import TodoItem from './components/TodoItem'
function App() {
const [todos, setTodos] = useState([])
const addTodo = (todo) => {
setTodos((prev) => [{id: Date.now(), ...todo}, ...prev] )
}
const updateTodo = (id, todo) => {
setTodos((prev) => prev.map((prevTodo) => (prevTodo.id === id ? todo : prevTodo )))
}
const deleteTodo = (id) => {
setTodos((prev) => prev.filter((todo) => todo.id !== id))
}
const toggleComplete = (id) => {
//console.log(id);
setTodos((prev) =>
prev.map((prevTodo) =>
prevTodo.id === id ? { ...prevTodo,
completed: !prevTodo.completed } : prevTodo))
}
useEffect(() => {
const todos = JSON.parse(localStorage.getItem("todos"))
if (todos && todos.length > 0) {
setTodos(todos)
}
}, [])
useEffect(() => {
localStorage.setItem("todos", JSON.stringify(todos))
}, [todos])
return (
Manage Your Todos
{/* Todo form goes here */}
{/*Loop and Add TodoItem here */}
{todos.map((todo) => (
))}
)
}
export default App
================================================
FILE: 10todocontextLocal/src/components/TodoForm.jsx
================================================
import React, { useState } from 'react'
import { useTodo } from '../contexts/TodoContext';
function TodoForm() {
const [todo, setTodo] = useState("")
const {addTodo} = useTodo()
const add = (e) => {
e.preventDefault()
if (!todo) return
addTodo({ todo, completed: false})
setTodo("")
}
return (
);
}
export default TodoForm;
================================================
FILE: 10todocontextLocal/src/components/TodoItem.jsx
================================================
import React, { useState } from 'react'
import { useTodo } from '../contexts/TodoContext';
function TodoItem({ todo }) {
const [isTodoEditable, setIsTodoEditable] = useState(false)
const [todoMsg, setTodoMsg] = useState(todo.todo)
const {updateTodo, deleteTodo, toggleComplete} = useTodo()
const editTodo = () => {
updateTodo(todo.id, {...todo, todo: todoMsg})
setIsTodoEditable(false)
}
const toggleCompleted = () => {
//console.log(todo.id);
toggleComplete(todo.id)
}
return (
setTodoMsg(e.target.value)}
readOnly={!isTodoEditable}
/>
{/* Edit, Save Button */}
{
if (todo.completed) return;
if (isTodoEditable) {
editTodo();
} else setIsTodoEditable((prev) => !prev);
}}
disabled={todo.completed}
>
{isTodoEditable ? "📁" : "✏️"}
{/* Delete Todo Button */}
deleteTodo(todo.id)}
>
❌
);
}
export default TodoItem;
================================================
FILE: 10todocontextLocal/src/components/index.js
================================================
import TodoForm from "./TodoForm";
import TodoItem from "./TodoItem";
export {TodoForm, TodoItem}
================================================
FILE: 10todocontextLocal/src/contexts/TodoContext.js
================================================
import {createContext, useContext} from "react"
export const TodoContext = createContext({
todos: [
{
id: 1,
todo: " Todo msg",
completed: false,
}
],
addTodo: (todo) => {},
updateTodo: (id, todo) => {},
deleteTodo: (id) => {},
toggleComplete: (id) => {}
})
export const useTodo = () => {
return useContext(TodoContext)
}
export const TodoProvider = TodoContext.Provider
================================================
FILE: 10todocontextLocal/src/contexts/index.js
================================================
export {TodoContext, TodoProvider, useTodo} from "./TodoContext"
================================================
FILE: 10todocontextLocal/src/index.css
================================================
@tailwind base;
@tailwind components;
@tailwind utilities;
================================================
FILE: 10todocontextLocal/src/main.jsx
================================================
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'
ReactDOM.createRoot(document.getElementById('root')).render(
,
)
================================================
FILE: 10todocontextLocal/tailwind.config.js
================================================
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
================================================
FILE: 10todocontextLocal/vite.config.js
================================================
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})
================================================
FILE: 12MegaBlog/.eslintrc.cjs
================================================
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
================================================
FILE: 12MegaBlog/.gitignore
================================================
# 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?
================================================
FILE: 12MegaBlog/README.md
================================================
# React + 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
================================================
FILE: 12MegaBlog/index.html
================================================
Vite + React
================================================
FILE: 12MegaBlog/package.json
================================================
{
"name": "12megablog",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"@reduxjs/toolkit": "^1.9.5",
"@tinymce/tinymce-react": "^4.3.0",
"appwrite": "^13.0.0",
"html-react-parser": "^4.2.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.46.1",
"react-redux": "^8.1.2",
"react-router-dom": "^6.16.0"
},
"devDependencies": {
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@vitejs/plugin-react": "^4.0.3",
"autoprefixer": "^10.4.15",
"eslint": "^8.45.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"postcss": "^8.4.30",
"tailwindcss": "^3.3.3",
"vite": "^4.4.5"
}
}
================================================
FILE: 12MegaBlog/postcss.config.js
================================================
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
================================================
FILE: 12MegaBlog/src/App.css
================================================
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}
@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
}
.card {
padding: 2em;
}
.read-the-docs {
color: #888;
}
================================================
FILE: 12MegaBlog/src/App.jsx
================================================
import React, { useState, useEffect } from 'react'
import { useDispatch } from 'react-redux'
import './App.css'
import authService from "./appwrite/auth"
import {login, logout} from "./store/authSlice"
import { Footer, Header } from './components'
import { Outlet } from 'react-router-dom'
function App() {
const [loading, setLoading] = useState(true)
const dispatch = useDispatch()
useEffect(() => {
authService.getCurrentUser()
.then((userData) => {
if (userData) {
dispatch(login({userData}))
} else {
dispatch(logout())
}
})
.finally(() => setLoading(false))
}, [])
return !loading ? (
) : null
}
export default App
================================================
FILE: 12MegaBlog/src/appwrite/auth.js
================================================
import conf from '../conf/conf.js';
import { Client, Account, ID } from "appwrite";
export class AuthService {
client = new Client();
account;
constructor() {
this.client
.setEndpoint(conf.appwriteUrl)
.setProject(conf.appwriteProjectId);
this.account = new Account(this.client);
}
async createAccount({email, password, name}) {
try {
const userAccount = await this.account.create(ID.unique(), email, password, name);
if (userAccount) {
// call another method
return this.login({email, password});
} else {
return userAccount;
}
} catch (error) {
throw error;
}
}
async login({email, password}) {
try {
return await this.account.createEmailSession(email, password);
} catch (error) {
throw error;
}
}
async getCurrentUser() {
try {
return await this.account.get();
} catch (error) {
console.log("Appwrite serive :: getCurrentUser :: error", error);
}
return null;
}
async logout() {
try {
await this.account.deleteSessions();
} catch (error) {
console.log("Appwrite serive :: logout :: error", error);
}
}
}
const authService = new AuthService();
export default authService
================================================
FILE: 12MegaBlog/src/appwrite/config.js
================================================
import conf from '../conf/conf.js';
import { Client, ID, Databases, Storage, Query } from "appwrite";
export class Service{
client = new Client();
databases;
bucket;
constructor(){
this.client
.setEndpoint(conf.appwriteUrl)
.setProject(conf.appwriteProjectId);
this.databases = new Databases(this.client);
this.bucket = new Storage(this.client);
}
async createPost({title, slug, content, featuredImage, status, userId}){
try {
return await this.databases.createDocument(
conf.appwriteDatabaseId,
conf.appwriteCollectionId,
slug,
{
title,
content,
featuredImage,
status,
userId,
}
)
} catch (error) {
console.log("Appwrite serive :: createPost :: error", error);
}
}
async updatePost(slug, {title, content, featuredImage, status}){
try {
return await this.databases.updateDocument(
conf.appwriteDatabaseId,
conf.appwriteCollectionId,
slug,
{
title,
content,
featuredImage,
status,
}
)
} catch (error) {
console.log("Appwrite serive :: updatePost :: error", error);
}
}
async deletePost(slug){
try {
await this.databases.deleteDocument(
conf.appwriteDatabaseId,
conf.appwriteCollectionId,
slug
)
return true
} catch (error) {
console.log("Appwrite serive :: deletePost :: error", error);
return false
}
}
async getPost(slug){
try {
return await this.databases.getDocument(
conf.appwriteDatabaseId,
conf.appwriteCollectionId,
slug
)
} catch (error) {
console.log("Appwrite serive :: getPost :: error", error);
return false
}
}
async getPosts(queries = [Query.equal("status", "active")]){
try {
return await this.databases.listDocuments(
conf.appwriteDatabaseId,
conf.appwriteCollectionId,
queries,
)
} catch (error) {
console.log("Appwrite serive :: getPosts :: error", error);
return false
}
}
// file upload service
async uploadFile(file){
try {
return await this.bucket.createFile(
conf.appwriteBucketId,
ID.unique(),
file
)
} catch (error) {
console.log("Appwrite serive :: uploadFile :: error", error);
return false
}
}
async deleteFile(fileId){
try {
await this.bucket.deleteFile(
conf.appwriteBucketId,
fileId
)
return true
} catch (error) {
console.log("Appwrite serive :: deleteFile :: error", error);
return false
}
}
getFilePreview(fileId){
return this.bucket.getFilePreview(
conf.appwriteBucketId,
fileId
)
}
}
const service = new Service()
export default service
================================================
FILE: 12MegaBlog/src/components/AuthLayout.jsx
================================================
import React, {useEffect, useState} from 'react'
import {useSelector} from 'react-redux'
import {useNavigate} from 'react-router-dom'
export default function Protected({children, authentication = true}) {
const navigate = useNavigate()
const [loader, setLoader] = useState(true)
const authStatus = useSelector(state => state.auth.status)
useEffect(() => {
//TODO: make it more easy to understand
// if (authStatus ===true){
// navigate("/")
// } else if (authStatus === false) {
// navigate("/login")
// }
//let authValue = authStatus === true ? true : false
if(authentication && authStatus !== authentication){
navigate("/login")
} else if(!authentication && authStatus !== authentication){
navigate("/")
}
setLoader(false)
}, [authStatus, navigate, authentication])
return loader ? Loading... : <>{children}>
}
================================================
FILE: 12MegaBlog/src/components/Button.jsx
================================================
import React from "react";
export default function Button({
children,
type = "button",
bgColor = "bg-blue-600",
textColor = "text-white",
className = "",
...props
}) {
return (
{children}
);
}
================================================
FILE: 12MegaBlog/src/components/Footer/Footer.jsx
================================================
import React from 'react'
import { Link } from 'react-router-dom'
import Logo from '../Logo'
function Footer() {
return (
© Copyright 2023. All Rights Reserved by DevUI.
Company
Features
Pricing
Affiliate Program
Press Kit
Support
Account
Help
Contact Us
Customer Support
Legals
Terms & Conditions
Privacy Policy
Licensing
)
}
export default Footer
================================================
FILE: 12MegaBlog/src/components/Header/Header.jsx
================================================
import React from 'react'
import {Container, Logo, LogoutBtn} from '../index'
import { Link } from 'react-router-dom'
import {useSelector} from 'react-redux'
import { useNavigate } from 'react-router-dom'
function Header() {
const authStatus = useSelector((state) => state.auth.status)
const navigate = useNavigate()
const navItems = [
{
name: 'Home',
slug: "/",
active: true
},
{
name: "Login",
slug: "/login",
active: !authStatus,
},
{
name: "Signup",
slug: "/signup",
active: !authStatus,
},
{
name: "All Posts",
slug: "/all-posts",
active: authStatus,
},
{
name: "Add Post",
slug: "/add-post",
active: authStatus,
},
]
return (
{navItems.map((item) =>
item.active ? (
navigate(item.slug)}
className='inline-bock px-6 py-2 duration-200 hover:bg-blue-100 rounded-full'
>{item.name}
) : null
)}
{authStatus && (
)}
)
}
export default Header
================================================
FILE: 12MegaBlog/src/components/Header/LogoutBtn.jsx
================================================
import React from 'react'
import {useDispatch} from 'react-redux'
import authService from '../../appwrite/auth'
import {logout} from '../../store/authSlice'
function LogoutBtn() {
const dispatch = useDispatch()
const logoutHandler = () => {
authService.logout().then(() => {
dispatch(logout())
})
}
return (
Logout
)
}
export default LogoutBtn
================================================
FILE: 12MegaBlog/src/components/Input.jsx
================================================
import React, {useId} from 'react'
const Input = React.forwardRef( function Input({
label,
type = "text",
className = "",
...props
}, ref){
const id = useId()
return (
{label &&
{label}
}
)
})
export default Input
================================================
FILE: 12MegaBlog/src/components/Login.jsx
================================================
import React, {useState} from 'react'
import {Link, useNavigate} from 'react-router-dom'
import { login as authLogin } from '../store/authSlice'
import {Button, Input, Logo} from "./index"
import {useDispatch} from "react-redux"
import authService from "../appwrite/auth"
import {useForm} from "react-hook-form"
function Login() {
const navigate = useNavigate()
const dispatch = useDispatch()
const {register, handleSubmit} = useForm()
const [error, setError] = useState("")
const login = async(data) => {
setError("")
try {
const session = await authService.login(data)
if (session) {
const userData = await authService.getCurrentUser()
if(userData) dispatch(authLogin(userData));
navigate("/")
}
} catch (error) {
setError(error.message)
}
}
return (
Sign in to your account
Don't have any account?
Sign Up
{error &&
{error}
}
)
}
export default Login
================================================
FILE: 12MegaBlog/src/components/Logo.jsx
================================================
import React from 'react'
function Logo({width = '100px'}) {
return (
Logo
)
}
export default Logo
================================================
FILE: 12MegaBlog/src/components/PostCard.jsx
================================================
import React from 'react'
import appwriteService from "../appwrite/config"
import {Link} from 'react-router-dom'
function PostCard({$id, title, featuredImage}) {
return (
)
}
export default PostCard
================================================
FILE: 12MegaBlog/src/components/RTE.jsx
================================================
import React from 'react'
import {Editor } from '@tinymce/tinymce-react';
import {Controller } from 'react-hook-form';
export default function RTE({name, control, label, defaultValue =""}) {
return (
{label && {label} }
(
)}
/>
)
}
================================================
FILE: 12MegaBlog/src/components/Select.jsx
================================================
import React, {useId} from 'react'
function Select({
options,
label,
className,
...props
}, ref) {
const id = useId()
return (
{label && }
{options?.map((option) => (
{option}
))}
)
}
export default React.forwardRef(Select)
================================================
FILE: 12MegaBlog/src/components/Signup.jsx
================================================
import React, {useState} from 'react'
import authService from '../appwrite/auth'
import {Link ,useNavigate} from 'react-router-dom'
import {login} from '../store/authSlice'
import {Button, Input, Logo} from './index.js'
import {useDispatch} from 'react-redux'
import {useForm} from 'react-hook-form'
function Signup() {
const navigate = useNavigate()
const [error, setError] = useState("")
const dispatch = useDispatch()
const {register, handleSubmit} = useForm()
const create = async(data) => {
setError("")
try {
const userData = await authService.createAccount(data)
if (userData) {
const userData = await authService.getCurrentUser()
if(userData) dispatch(login(userData));
navigate("/")
}
} catch (error) {
setError(error.message)
}
}
return (
Sign up to create account
Already have an account?
Sign In
{error &&
{error}
}
)
}
export default Signup
================================================
FILE: 12MegaBlog/src/components/container/Container.jsx
================================================
import React from 'react'
function Container({children}) {
return {children}
;
}
export default Container
================================================
FILE: 12MegaBlog/src/components/index.js
================================================
import Select from "./Select";
import Header from "./Header/Header";
import Footer from "./Footer/Footer";
import Container from "./container/Container";
import Logo from "./Logo";
import LogoutBtn from "./Header/LogoutBtn";
import RTE from "./RTE";
import Signup from "./Signup";
import Login from "./Login";
import Button from "./Button";
import PostForm from "./post-form/PostForm";
import PostCard from "./PostCard";
import AuthLayout from "./AuthLayout";
import Input from "./Input";
export {
Header,
Footer,
Container,
Logo,
LogoutBtn,
RTE,
Signup,
Login,
Button,
PostForm,
PostCard,
AuthLayout,
Input,
Select,
}
================================================
FILE: 12MegaBlog/src/components/post-form/PostForm.jsx
================================================
import React, { useCallback } from "react";
import { useForm } from "react-hook-form";
import { Button, Input, RTE, Select } from "..";
import appwriteService from "../../appwrite/config";
import { useNavigate } from "react-router-dom";
import { useSelector } from "react-redux";
export default function PostForm({ post }) {
const { register, handleSubmit, watch, setValue, control, getValues } = useForm({
defaultValues: {
title: post?.title || "",
slug: post?.$id || "",
content: post?.content || "",
status: post?.status || "active",
},
});
const navigate = useNavigate();
const userData = useSelector((state) => state.auth.userData);
const submit = async (data) => {
if (post) {
const file = data.image[0] ? await appwriteService.uploadFile(data.image[0]) : null;
if (file) {
appwriteService.deleteFile(post.featuredImage);
}
const dbPost = await appwriteService.updatePost(post.$id, {
...data,
featuredImage: file ? file.$id : undefined,
});
if (dbPost) {
navigate(`/post/${dbPost.$id}`);
}
} else {
const file = await appwriteService.uploadFile(data.image[0]);
if (file) {
const fileId = file.$id;
data.featuredImage = fileId;
const dbPost = await appwriteService.createPost({ ...data, userId: userData.$id });
if (dbPost) {
navigate(`/post/${dbPost.$id}`);
}
}
}
};
const slugTransform = useCallback((value) => {
if (value && typeof value === "string")
return value
.trim()
.toLowerCase()
.replace(/[^a-zA-Z\d\s]+/g, "-")
.replace(/\s/g, "-");
return "";
}, []);
React.useEffect(() => {
const subscription = watch((value, { name }) => {
if (name === "title") {
setValue("slug", slugTransform(value.title), { shouldValidate: true });
}
});
return () => subscription.unsubscribe();
}, [watch, slugTransform, setValue]);
return (
);
}
================================================
FILE: 12MegaBlog/src/conf/conf.js
================================================
const conf = {
appwriteUrl: String(import.meta.env.VITE_APPWRITE_URL),
appwriteProjectId: String(import.meta.env.VITE_APPWRITE_PROJECT_ID),
appwriteDatabaseId: String(import.meta.env.VITE_APPWRITE_DATABASE_ID),
appwriteCollectionId: String(import.meta.env.VITE_APPWRITE_COLLECTION_ID),
appwriteBucketId: String(import.meta.env.VITE_APPWRITE_BUCKET_ID),
}
// there was a name issue with the import.meta.env.VITE_APPWRITE_URL, it was later fixed in debugging video
export default conf
================================================
FILE: 12MegaBlog/src/index.css
================================================
@tailwind base;
@tailwind components;
@tailwind utilities;
================================================
FILE: 12MegaBlog/src/main.jsx
================================================
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'
import { Provider } from 'react-redux'
import store from './store/store.js'
import { RouterProvider, createBrowserRouter } from 'react-router-dom'
import Home from './pages/Home.jsx'
import { AuthLayout, Login } from './components/index.js'
import AddPost from "./pages/AddPost";
import Signup from './pages/Signup'
import EditPost from "./pages/EditPost";
import Post from "./pages/Post";
import AllPosts from "./pages/AllPosts";
const router = createBrowserRouter([
{
path: "/",
element: ,
children: [
{
path: "/",
element: ,
},
{
path: "/login",
element: (
),
},
{
path: "/signup",
element: (
),
},
{
path: "/all-posts",
element: (
{" "}
),
},
{
path: "/add-post",
element: (
{" "}
),
},
{
path: "/edit-post/:slug",
element: (
{" "}
),
},
{
path: "/post/:slug",
element: ,
},
],
},
])
ReactDOM.createRoot(document.getElementById('root')).render(
,
)
================================================
FILE: 12MegaBlog/src/pages/AddPost.jsx
================================================
import React from 'react'
import { Container, PostForm } from '../components'
function AddPost() {
return (
)
}
export default AddPost
================================================
FILE: 12MegaBlog/src/pages/AllPosts.jsx
================================================
import React, {useState, useEffect} from 'react'
import { Container, PostCard } from '../components'
import appwriteService from "../appwrite/config";
function AllPosts() {
const [posts, setPosts] = useState([])
useEffect(() => {}, [])
appwriteService.getPosts([]).then((posts) => {
if (posts) {
setPosts(posts.documents)
}
})
return (
{posts.map((post) => (
))}
)
}
export default AllPosts
================================================
FILE: 12MegaBlog/src/pages/EditPost.jsx
================================================
import React, {useEffect, useState} from 'react'
import {Container, PostForm} from '../components'
import appwriteService from "../appwrite/config";
import { useNavigate, useParams } from 'react-router-dom';
function EditPost() {
const [post, setPosts] = useState(null)
const {slug} = useParams()
const navigate = useNavigate()
useEffect(() => {
if (slug) {
appwriteService.getPost(slug).then((post) => {
if (post) {
setPosts(post)
}
})
} else {
navigate('/')
}
}, [slug, navigate])
return post ? (
) : null
}
export default EditPost
================================================
FILE: 12MegaBlog/src/pages/Home.jsx
================================================
import React, {useEffect, useState} from 'react'
import appwriteService from "../appwrite/config";
import {Container, PostCard} from '../components'
function Home() {
const [posts, setPosts] = useState([])
useEffect(() => {
appwriteService.getPosts().then((posts) => {
if (posts) {
setPosts(posts.documents)
}
})
}, [])
if (posts.length === 0) {
return (
)
}
return (
{posts.map((post) => (
))}
)
}
export default Home
================================================
FILE: 12MegaBlog/src/pages/Login.jsx
================================================
import React from 'react'
import { Login as loginComponent } from '../components'
function Login() {
return (
)
}
export default Login
================================================
FILE: 12MegaBlog/src/pages/Post.jsx
================================================
import React, { useEffect, useState } from "react";
import { Link, useNavigate, useParams } from "react-router-dom";
import appwriteService from "../appwrite/config";
import { Button, Container } from "../components";
import parse from "html-react-parser";
import { useSelector } from "react-redux";
export default function Post() {
const [post, setPost] = useState(null);
const { slug } = useParams();
const navigate = useNavigate();
const userData = useSelector((state) => state.auth.userData);
const isAuthor = post && userData ? post.userId === userData.$id : false;
useEffect(() => {
if (slug) {
appwriteService.getPost(slug).then((post) => {
if (post) setPost(post);
else navigate("/");
});
} else navigate("/");
}, [slug, navigate]);
const deletePost = () => {
appwriteService.deletePost(post.$id).then((status) => {
if (status) {
appwriteService.deleteFile(post.featuredImage);
navigate("/");
}
});
};
return post ? (
{isAuthor && (
Edit
Delete
)}
{post.title}
{parse(post.content)}
) : null;
}
================================================
FILE: 12MegaBlog/src/pages/Signup.jsx
================================================
import React from 'react'
import { Signup as SignupComponent } from '../components'
function Signup() {
return (
)
}
export default Signup
================================================
FILE: 12MegaBlog/src/store/authSlice.js
================================================
import { createSlice } from "@reduxjs/toolkit";
const initialState = {
status : false,
userData: null
}
const authSlice = createSlice({
name: "auth",
initialState,
reducers: {
login: (state, action) => {
state.status = true;
state.userData = action.payload.userData;
},
logout: (state) => {
state.status = false;
state.userData = null;
}
}
})
export const {login, logout} = authSlice.actions;
export default authSlice.reducer;
================================================
FILE: 12MegaBlog/src/store/store.js
================================================
import {configureStore} from '@reduxjs/toolkit';
import authSlice from './authSlice';
const store = configureStore({
reducer: {
auth : authSlice,
//TODO: add more slices here for posts
}
});
export default store;
================================================
FILE: 12MegaBlog/tailwind.config.js
================================================
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
================================================
FILE: 12MegaBlog/vite.config.js
================================================
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})
================================================
FILE: contextNotes.md
================================================
# Notes for context api
## ThemeBtn UI
```javascript
export default function ThemeBtn() {
return (
Toggle Theme
);
}
```
## Card UI
```javascript
export default function Card() {
return (
);
}
```
## App UI
```javascript
```
## remember to change config in tailwind
```javascript
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
darkMode: "class",
theme: {
extend: {},
},
plugins: [],
}
```
================================================
FILE: currency.md
================================================
# notes for currency converter app
## api link
```javascript
let url = `https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/${currency}.json`
```
## input box
```javascript
function InputBox({
label,
className = "",
}) {
return (
);
}
export default InputBox;
```
## app js
```javascript
function App() {
return (
);
```
================================================
FILE: customReact/customreact.js
================================================
function customRender(reactElement, container){
/*
const domElement = document.createElement(reactElement.type)
domElement.innerHTML = reactElement.children
domElement.setAttribute('href', reactElement.props.href)
domElement.setAttribute('target', reactElement.props.target)
container.appendChild(domElement)
*/
const domElement = document.createElement(reactElement.type)
domElement.innerHTML = reactElement.children
for (const prop in reactElement.props) {
if (prop === 'children') continue;
domElement.setAttribute(prop, reactElement.props[prop])
}
container.appendChild(domElement)
}
const reactElement = {
type: 'a',
props: {
href: 'https://google.com',
target: '_blank'
},
children: 'Click me to visit google'
}
const mainContainer = document.querySelector('#root')
customRender(reactElement, mainContainer)
================================================
FILE: customReact/index.html
================================================
Custom React App
================================================
FILE: interview-discussion/.eslintrc.cjs
================================================
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
================================================
FILE: interview-discussion/.gitignore
================================================
# 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?
================================================
FILE: interview-discussion/README.md
================================================
# React + 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
================================================
FILE: interview-discussion/index.html
================================================
Vite + React
================================================
FILE: interview-discussion/package.json
================================================
{
"name": "interview-discussion",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint . --ext js,jsx --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.15",
"@types/react-dom": "^18.2.7",
"@vitejs/plugin-react": "^4.0.3",
"eslint": "^8.45.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"vite": "^4.4.5"
}
}
================================================
FILE: interview-discussion/src/App.css
================================================
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}
@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
}
.card {
padding: 2em;
}
.read-the-docs {
color: #888;
}
================================================
FILE: interview-discussion/src/App.jsx
================================================
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'
import { useEffect } from 'react'
function App() {
console.log("App rendered", Math.random());
const [value, setValue] = useState({
value: 0,
})
//const [multipliedValue, setMultipliedValue] = useState(1)
//let multipliedValue = value * 5
// const multiplybyfive = () => {
// //setMultipliedValue(value * 5)
// setValue(value + 1)
// }
const clickMe = () => {
setValue({
value: 0,
})
}
return (
<>
Main value: {value.value}
Click to multiply by 5
{/* Multiplied value: {multipliedValue} */}
>
)
}
export default App
================================================
FILE: interview-discussion/src/index.css
================================================
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;
color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
}
a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}
body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}
h1 {
font-size: 3.2em;
line-height: 1.1;
}
button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}
@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}
================================================
FILE: interview-discussion/src/main.jsx
================================================
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'
ReactDOM.createRoot(document.getElementById('root')).render(
,
)
================================================
FILE: interview-discussion/vite.config.js
================================================
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})
================================================
FILE: reactRouterNotes.md
================================================
# all raw html css file for react router video
## header component
```javascript
export default function Header() {
return (
Log in
Get started
);
}
```
## Footer component
```javascript
export default function Footer() {
return (
Legal
Privacy Policy
Terms & Conditions
© 2023
hiteshchoudhary
. All Rights Reserved.
Facebook page
Discord community
Twitter page
GitHub account
Dribbble account
);
}
```
## Home component
```javascript
export default function Home() {
return (
Download Now
Lorem Ipsum
Download now
Lorem Ipsum Yojo
);
}
```
## About us component
```javascript
export default function About() {
return (
React development is carried out by passionate developers
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Eum omnis voluptatem
accusantium nemo perspiciatis delectus atque autem! Voluptatum tenetur beatae unde
aperiam, repellat expedita consequatur! Officiis id consequatur atque doloremque!
Nobis minus voluptatibus pariatur dignissimos libero quaerat iure expedita at?
Asperiores nemo possimus nesciunt dicta veniam aspernatur quam mollitia.
);
}
```
## Contact us Component
```javascript
export default function Contact() {
return (
Get in touch:
Fill in the form to start a conversation
Acme Inc, Street, State, Postal Code
);
}
```
================================================
FILE: readme.md
================================================
# ReactJS In-Depth Tutorial Series
Welcome to the comprehensive repository dedicated to teaching ReactJS in depth. This series covers not just the basics but dives deep into the intricacies of ReactJS to ensure that you emerge with a solid foundation and deep understanding of the most popular frontend library in the world.
## 🌟 Features
- **In-Depth Explanations**: Each concept is broken down for easier understanding and comprehensive learning.
- **Project-Based Learning**: Multiple projects to ensure that your theoretical knowledge is supplemented with practical experience.
- **Free Video Series**: All lessons are available in video format on our YouTube channel "chai aur code".
## 🚀 Getting Started
1. Clone this repository:
```bash
git clone https://github.com/hiteshchoudhary/chai-aur-react.git
```
2. Navigate to each project folder and follow the instructions in the respective README to set up and run the project.
3. Parallelly, watch the video lessons on the ["chai aur code" YouTube channel](https://www.youtube.com/channel/UCNQ6FEtztATuaVhZKCY28Yw) for a detailed walk-through.
## 📚 Modules & Projects
1. **React JS RoadMap**:
- [Watch Lesson](https://www.youtube.com/watch?v=vz1RlUyrc3w&list=PLu71SKxNbfoDqgPchmvIsL4hTnJIrtige)
2. **Create react projects**:
- [Watch Lesson](https://www.youtube.com/watch?v=k3KqQvywToE&list=PLu71SKxNbfoDqgPchmvIsL4hTnJIrtige&index=2)
3. **Understand the react flow and structure**:
- [Watch Lesson](https://www.youtube.com/watch?v=yNbnA5pryMg&list=PLu71SKxNbfoDqgPchmvIsL4hTnJIrtige&index=3)
4. **Create your own react library and JSX**:
- [Watch Lesson](https://www.youtube.com/watch?v=kAOuj6o7Kxs&list=PLu71SKxNbfoDqgPchmvIsL4hTnJIrtige&index=4)
... _(on going series)_
## 📖 Additional Resources
- [Official React Documentation](https://reactjs.org/docs/getting-started.html)
- [React Community Support on Discord](https://hitesh.ai/discord)
## 💼 Contribution
Contributions are always welcomed. Feel free to raise issues or send in pull requests. Please do not update the existing code as users when they watch videos, they expect same code in repo.
## 📺 "chai aur code" on YouTube
Don't forget to subscribe to ["chai aur code"](https://www.youtube.com/channel/UCNQ6FEtztATuaVhZKCY28Yw) on YouTube for the entire video series and much more!
## 🙏 Acknowledgements
A big thank you to the React community, Open Source contributors, and all the students and professionals who've provided their feedback and support to make this series better!
---
**Happy Learning!** ✨
---
_Made with ☕️ by HiteshChoudhary_
================================================
FILE: reduxToolkitTodo/.eslintrc.cjs
================================================
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
================================================
FILE: reduxToolkitTodo/.gitignore
================================================
# 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?
================================================
FILE: reduxToolkitTodo/README.md
================================================
# React + 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
================================================
FILE: reduxToolkitTodo/index.html
================================================
Vite + React
================================================
FILE: reduxToolkitTodo/package.json
================================================
{
"name": "reduxtoolkittodo",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"@reduxjs/toolkit": "^1.9.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-redux": "^8.1.2"
},
"devDependencies": {
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@vitejs/plugin-react": "^4.0.3",
"autoprefixer": "^10.4.15",
"eslint": "^8.45.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"postcss": "^8.4.29",
"tailwindcss": "^3.3.3",
"vite": "^4.4.5"
}
}
================================================
FILE: reduxToolkitTodo/postcss.config.js
================================================
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
================================================
FILE: reduxToolkitTodo/src/App.css
================================================
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}
@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
}
.card {
padding: 2em;
}
.read-the-docs {
color: #888;
}
================================================
FILE: reduxToolkitTodo/src/App.jsx
================================================
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'
import AddTodo from './components/AddTodo'
import Todos from './components/Todos'
function App() {
return (
<>
Learn about redux toolkit
>
)
}
export default App
================================================
FILE: reduxToolkitTodo/src/app/store.js
================================================
import {configureStore} from '@reduxjs/toolkit';
import todoReducer from '../features/todo/todoSlice';
export const store = configureStore({
reducer: todoReducer
})
================================================
FILE: reduxToolkitTodo/src/components/AddTodo.jsx
================================================
import React, {useState} from 'react'
import {useDispatch} from 'react-redux'
import {addTodo} from '../features/todo/todoSlice'
function AddTodo() {
const [input, setInput] = useState('')
const dispatch = useDispatch()
const addTodoHandler = (e) => {
e.preventDefault()
dispatch(addTodo(input))
setInput('')
}
return (
)
}
export default AddTodo
================================================
FILE: reduxToolkitTodo/src/components/Todos.jsx
================================================
import React from 'react'
import { useSelector, useDispatch } from 'react-redux'
import {removeTodo} from '../features/todo/todoSlice'
function Todos() {
const todos = useSelector(state => state.todos)
const dispatch = useDispatch()
return (
<>
Todos
{todos.map((todo) => (
{todo.text}
dispatch(removeTodo(todo.id))}
className="text-white bg-red-500 border-0 py-1 px-4 focus:outline-none hover:bg-red-600 rounded text-md"
>
))}
>
)
}
export default Todos
================================================
FILE: reduxToolkitTodo/src/features/todo/todoSlice.js
================================================
import {createSlice, nanoid } from '@reduxjs/toolkit';
const initialState = {
todos: [{id: 1, text: "Hello world"}]
}
export const todoSlice = createSlice({
name: 'todo',
initialState,
reducers: {
addTodo: (state, action) => {
const todo = {
id: nanoid(),
text: action.payload
}
state.todos.push(todo)
},
removeTodo: (state, action) => {
state.todos = state.todos.filter((todo) => todo.id !== action.payload )
},
}
})
export const {addTodo, removeTodo} = todoSlice.actions
export default todoSlice.reducer
================================================
FILE: reduxToolkitTodo/src/index.css
================================================
@tailwind base;
@tailwind components;
@tailwind utilities;
================================================
FILE: reduxToolkitTodo/src/main.jsx
================================================
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'
import { Provider } from 'react-redux'
import {store} from './app/store'
ReactDOM.createRoot(document.getElementById('root')).render(
,
)
================================================
FILE: reduxToolkitTodo/tailwind.config.js
================================================
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
================================================
FILE: reduxToolkitTodo/vite.config.js
================================================
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})
================================================
FILE: todoContextapiNotes.md
================================================
# todo context api notes
## Todo Form UI
```javascript
function TodoForm() {
return (
);
}
export default TodoForm;
```
## Todo Item UI
```javascript
function TodoItem({ todo }) {
return (
setTodoMsg(e.target.value)}
readOnly={!isTodoEditable}
/>
{/* Edit, Save Button */}
{
if (todo.completed) return;
if (isTodoEditable) {
editTodo();
} else setIsTodoEditable((prev) => !prev);
}}
disabled={todo.completed}
>
{isTodoEditable ? "📁" : "✏️"}
{/* Delete Todo Button */}
deleteTodo(todo.id)}
>
❌
);
}
export default TodoItem;
```
## App js UI
```javascript
Manage Your Todos
{/* Todo form goes here */}
{/*Loop and Add TodoItem here */}
```