├── src
├── image
│ ├── Cam.png
│ ├── Add.webp
│ ├── More.png
│ ├── AddImg.png
│ ├── attach.png
│ └── add_image.png
├── components
│ ├── Sidebar.jsx
│ ├── Navbar.jsx
│ ├── Chat.jsx
│ ├── Messages.jsx
│ ├── Message.jsx
│ ├── Chats.jsx
│ ├── Search.jsx
│ └── Input.jsx
├── pages
│ ├── Home.jsx
│ ├── Login.jsx
│ └── Register.jsx
├── index.js
├── firebase.js
├── context
│ ├── AuthContext.js
│ └── ChatContext.js
├── App.js
└── style.scss
├── .gitignore
├── .vscode
└── launch.json
├── public
├── manifest.json
└── index.html
├── package.json
└── README.md
/src/image/Cam.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NandhuNarayanan/Chat_App-mini_project-/HEAD/src/image/Cam.png
--------------------------------------------------------------------------------
/src/image/Add.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NandhuNarayanan/Chat_App-mini_project-/HEAD/src/image/Add.webp
--------------------------------------------------------------------------------
/src/image/More.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NandhuNarayanan/Chat_App-mini_project-/HEAD/src/image/More.png
--------------------------------------------------------------------------------
/src/image/AddImg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NandhuNarayanan/Chat_App-mini_project-/HEAD/src/image/AddImg.png
--------------------------------------------------------------------------------
/src/image/attach.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NandhuNarayanan/Chat_App-mini_project-/HEAD/src/image/attach.png
--------------------------------------------------------------------------------
/src/image/add_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NandhuNarayanan/Chat_App-mini_project-/HEAD/src/image/add_image.png
--------------------------------------------------------------------------------
/src/components/Sidebar.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import Navbar from './Navbar'
3 | import Search from './Search'
4 | import Chats from './Chats'
5 |
6 | function Sidebar() {
7 | return (
8 |
9 |
10 |
11 |
12 |
13 | )
14 | }
15 |
16 | export default Sidebar
--------------------------------------------------------------------------------
/src/pages/Home.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import Sidebar from '../components/Sidebar'
3 | import Chat from '../components/Chat'
4 |
5 | function Home() {
6 | return (
7 |
13 | )
14 | }
15 |
16 | export default Home
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom/client';
3 | import App from './App';
4 | import { AuthContextProvider } from './context/AuthContext';
5 | import { ChatContextProvider } from './context/ChatContext';
6 |
7 |
8 | const root = ReactDOM.createRoot(document.getElementById('root'));
9 | root.render(
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | );
18 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "chrome",
9 | "request": "launch",
10 | "name": "Launch Chrome against localhost",
11 | "url": "http://localhost:8080",
12 | "webRoot": "${workspaceFolder}"
13 | }
14 | ]
15 | }
--------------------------------------------------------------------------------
/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/src/components/Navbar.jsx:
--------------------------------------------------------------------------------
1 | import React, { useContext } from 'react'
2 | import { signOut } from "firebase/auth";
3 | import { auth } from '../firebase';
4 | import { AuthContext } from '../context/AuthContext';
5 |
6 | function Navbar() {
7 | const {currentUser} = useContext(AuthContext)
8 |
9 |
10 | return (
11 |
12 |
Engage App
13 |
14 |

15 |
{currentUser.displayName}
16 |
17 |
18 |
19 |
20 | )
21 | }
22 |
23 | export default Navbar
--------------------------------------------------------------------------------
/src/firebase.js:
--------------------------------------------------------------------------------
1 |
2 | import { initializeApp } from "firebase/app";
3 | import { getAuth } from "firebase/auth";
4 | import { getStorage } from "firebase/storage";
5 | import { getFirestore } from "firebase/firestore";
6 |
7 | const firebaseConfig = {
8 | apiKey: "AIzaSyDvMpHyRydsDHwJOZAQJ4mW3_j-kJ2sGqw",
9 | authDomain: "chatapp-b8e75.firebaseapp.com",
10 | projectId: "chatapp-b8e75",
11 | storageBucket: "chatapp-b8e75.appspot.com",
12 | messagingSenderId: "426524842545",
13 | appId: "1:426524842545:web:c4ef132fcf87bcff999310"
14 | };
15 |
16 | // Initialize Firebase
17 | export const app = initializeApp(firebaseConfig) ;
18 | export const auth = getAuth();
19 | export const storage = getStorage();
20 | export const db = getFirestore();
--------------------------------------------------------------------------------
/src/context/AuthContext.js:
--------------------------------------------------------------------------------
1 | import { onAuthStateChanged } from "firebase/auth";
2 | import { createContext, useEffect, useState } from "react";
3 | import { auth } from "../firebase";
4 |
5 |
6 | export const AuthContext = createContext()
7 |
8 |
9 | export const AuthContextProvider = ({children}) =>{
10 |
11 | const [currentUser,setCurrentUser] = useState({})
12 |
13 | useEffect(()=>{
14 | const unsub = onAuthStateChanged(auth, (user)=>{
15 | setCurrentUser(user);
16 | console.log(user);
17 | });
18 |
19 | return () => {
20 | unsub();
21 | }
22 | },[]);
23 |
24 | return(
25 |
26 | {children}
27 |
28 | );
29 |
30 | };
--------------------------------------------------------------------------------
/src/components/Chat.jsx:
--------------------------------------------------------------------------------
1 | import React, { useContext } from 'react'
2 | import Cam from '../image/Cam.png';
3 | import Add from '../image/Add.webp';
4 | import More from '../image/More.png';
5 | import Messages from './Messages';
6 | import Input from './Input'
7 | import { ChatContext } from '../context/ChatContext';
8 |
9 | function Chat() {
10 |
11 | const {data} = useContext(ChatContext);
12 |
13 | return (
14 |
15 |
16 |
17 |
{data.user?.displayName}
18 |
23 |
24 |
25 |
26 |
27 | )
28 | }
29 |
30 | export default Chat
--------------------------------------------------------------------------------
/src/components/Messages.jsx:
--------------------------------------------------------------------------------
1 | import { doc, onSnapshot } from 'firebase/firestore'
2 | import React, { useContext, useEffect, useState } from 'react'
3 | import { ChatContext } from '../context/ChatContext'
4 | import { db } from '../firebase'
5 | import Message from './Message'
6 |
7 | function Messages() {
8 | const [messages, setMessages] = useState([])
9 | const {data} = useContext(ChatContext)
10 |
11 |
12 | useEffect(()=>{
13 | const unsub = onSnapshot(doc(db, "chats", data.chatId), (doc)=>{
14 | doc.exists() && setMessages(doc.data().messages)
15 | })
16 |
17 | return () =>{
18 | unsub()
19 | }
20 | },[data.chatId])
21 |
22 |
23 | return (
24 |
25 | {messages.map((m)=>(
26 |
27 |
28 | ))}
29 |
30 |
31 |
32 | )
33 | }
34 |
35 | export default Messages
--------------------------------------------------------------------------------
/src/components/Message.jsx:
--------------------------------------------------------------------------------
1 | import React, { useContext, useEffect, useRef } from 'react'
2 | import { AuthContext } from '../context/AuthContext';
3 | import { ChatContext } from '../context/ChatContext';
4 |
5 | function Message({message}) {
6 |
7 | const {currentUser} = useContext(AuthContext);
8 | const {data} = useContext(ChatContext);
9 |
10 |
11 | const ref = useRef()
12 |
13 | useEffect(() =>{
14 | ref.current?.scrollIntoView({behavior:"smooth"})
15 | },[message])
16 |
17 |
18 |
19 | return (
20 |
21 |
23 |
24 |
25 |

26 |
27 |
just now
28 |
29 |
30 |
31 |
{message.text}
32 | {message.img &&

}
33 |
34 |
35 |
36 | )
37 | }
38 |
39 | export default Message
--------------------------------------------------------------------------------
/src/App.js:
--------------------------------------------------------------------------------
1 | import Home from './pages/Home';
2 | import Login from './pages/Login';
3 | import Register from './pages/Register'
4 | import "./style.scss"
5 | import { BrowserRouter, Routes, Route, Navigate } from "react-router-dom";
6 | import { useContext } from 'react';
7 | import { AuthContext } from './context/AuthContext';
8 |
9 |
10 | function App() {
11 |
12 | const { currentUser } = useContext(AuthContext)
13 |
14 | const ProtectedRoute = ({children}) => {
15 | if (!currentUser) {
16 | return
17 |
18 | }
19 |
20 | return children;
21 |
22 | }
23 |
24 |
25 |
26 | return (
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | } />
35 | } />
36 | } />
37 |
38 |
39 |
40 |
41 | );
42 | }
43 |
44 | export default App;
45 |
--------------------------------------------------------------------------------
/src/context/ChatContext.js:
--------------------------------------------------------------------------------
1 | import { onAuthStateChanged } from "firebase/auth";
2 | import { createContext, useContext, useEffect, useReducer, useState } from "react";
3 | import { auth } from "../firebase";
4 | import { AuthContext } from "./AuthContext";
5 |
6 |
7 | export const ChatContext = createContext();
8 |
9 |
10 |
11 | export const ChatContextProvider = ({children}) =>{
12 |
13 | const {currentUser} = useContext(AuthContext)
14 | const INITIAL_STATE = {
15 | chatId:"null",
16 | user:{}
17 | }
18 |
19 | const chatReducer = (state, action) => {
20 | switch (action.type) {
21 | case "CHANGE_USER":
22 | return{
23 | user:action.payload,
24 | chatId: currentUser.uid > action.payload.uid
25 | ? currentUser.uid + action.payload.uid
26 | : action.payload.uid + currentUser.uid
27 |
28 | };
29 | default:
30 | return state;
31 | }
32 | };
33 |
34 | const [state, dispatch] = useReducer(chatReducer, INITIAL_STATE);
35 |
36 |
37 | return(
38 |
39 | {children}
40 |
41 | );
42 |
43 | };
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "chat_app-project",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^5.16.5",
7 | "@testing-library/react": "^13.4.0",
8 | "@testing-library/user-event": "^13.5.0",
9 | "firebase": "^9.14.0",
10 | "react": "^18.2.0",
11 | "react-dom": "^18.2.0",
12 | "react-router-dom": "^6.4.4",
13 | "react-scripts": "5.0.1",
14 | "sass": "^1.56.1",
15 | "uuid": "^9.0.0",
16 | "web-vitals": "^2.1.4"
17 | },
18 | "scripts": {
19 | "start": "react-scripts start",
20 | "build": "react-scripts build",
21 | "test": "react-scripts test",
22 | "eject": "react-scripts eject"
23 | },
24 | "eslintConfig": {
25 | "extends": [
26 | "react-app",
27 | "react-app/jest"
28 | ]
29 | },
30 | "browserslist": {
31 | "production": [
32 | ">0.2%",
33 | "not dead",
34 | "not op_mini all"
35 | ],
36 | "development": [
37 | "last 1 chrome version",
38 | "last 1 firefox version",
39 | "last 1 safari version"
40 | ]
41 | },
42 | "description": "This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).",
43 | "main": "index.js",
44 | "author": "",
45 | "license": "ISC"
46 | }
47 |
--------------------------------------------------------------------------------
/src/components/Chats.jsx:
--------------------------------------------------------------------------------
1 | import { doc, onSnapshot } from 'firebase/firestore';
2 | import React, { useContext, useEffect, useState } from 'react'
3 | import { AuthContext } from '../context/AuthContext';
4 | import { ChatContext } from '../context/ChatContext';
5 | import { db } from '../firebase';
6 |
7 | function Chats() {
8 |
9 | const [chats , setChats] = useState([])
10 |
11 | const {currentUser} = useContext(AuthContext)
12 | const {dispatch} = useContext(ChatContext)
13 |
14 |
15 | useEffect(()=>{
16 | const getChats = () => {
17 | const unsub = onSnapshot(doc(db, "userChats", currentUser.uid), (doc) => {
18 | setChats(doc.data());
19 | });
20 |
21 | return () => {
22 | unsub();
23 | };
24 | };
25 |
26 | currentUser.uid && getChats()
27 | },[currentUser.uid]);
28 |
29 |
30 | const handleSelect = (u) => {
31 | dispatch({type:"CHANGE_USER", payload:u})
32 | }
33 | return (
34 |
35 | {Object.entries(chats)?.sort((a,b)=>b[1].data - a[1].data).map((chat)=>(
36 |
37 |
38 |

39 |
40 |
{chat[1].userInfo.displayName}
41 |
{chat[1].lastMessage?.text}
42 |
43 |
44 | ))}
45 |
46 | );
47 | };
48 |
49 | export default Chats
--------------------------------------------------------------------------------
/src/pages/Login.jsx:
--------------------------------------------------------------------------------
1 | import React, { useState } from 'react'
2 | import { Link, useNavigate } from 'react-router-dom'
3 | import Add from '../image/add_image.png'
4 | import { signInWithEmailAndPassword } from "firebase/auth";
5 | import { auth } from '../firebase';
6 |
7 |
8 | function Login() {
9 | const [err, setErr] = useState(false)
10 | const navigate = useNavigate()
11 |
12 |
13 |
14 | const handleSubmit = async (e) => {
15 | e.preventDefault();
16 | const email = e.target[0].value;
17 | const password = e.target[1].value;
18 |
19 | try {
20 | await signInWithEmailAndPassword(auth, email, password)
21 | navigate('/')
22 |
23 | } catch (error) {
24 | console.log('true', error)
25 | setErr(true)
26 | }
27 |
28 | }
29 |
30 |
31 |
32 | return (
33 |
34 |
35 |
Engage App
36 |
Login
37 |
38 |
45 |
You do have an account? Sign up
46 |
47 |
48 | )
49 | }
50 |
51 | export default Login
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
27 | React App
28 |
29 |
30 |
31 |
32 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/src/components/Search.jsx:
--------------------------------------------------------------------------------
1 | import React, { useContext, useState } from 'react'
2 | import { collection, query, where, getDocs, setDoc, updateDoc, serverTimestamp, getDoc, doc } from "firebase/firestore";
3 | import { db } from "../firebase"
4 | import { AuthContext } from "../context/AuthContext"
5 |
6 |
7 |
8 | function Search() {
9 | const [username, setUsername] = useState("")
10 | const [user, setUser] = useState(null)
11 | const [err, setErr] = useState(false)
12 |
13 | const { currentUser } = useContext(AuthContext)
14 |
15 |
16 | const handleSearch = async () => {
17 | const q = query(collection(db, "users"), where("displayName", "==", username));
18 |
19 | try {
20 | const querySnapshot = await getDocs(q);
21 | querySnapshot.forEach((doc) => {
22 | setUser(doc.data())
23 | });
24 |
25 | } catch (error) {
26 | setErr(true)
27 | }
28 |
29 | };
30 |
31 | const handleKey = (e) => {
32 | e.code === "Enter" && handleSearch();
33 | };
34 |
35 | const handleSelect = async() => {
36 | //check whether the group(chats in firestore) exists, if not create
37 | const combinedId =
38 | currentUser.uid > user.uid
39 | ? currentUser.uid + user.uid
40 | : user.uid + currentUser.uid
41 | try {
42 | const res = await getDoc(doc(db, "chats" ,combinedId));
43 |
44 | if (!res.exists()) {
45 | //create a chat in chats collection
46 | await setDoc(doc(db , "chats" , combinedId) , { messages: [] });
47 |
48 | //creat user chats
49 | await updateDoc(doc(db, "userChats", currentUser.uid),{
50 | [combinedId+".userInfo"]: {
51 | uid: user.uid,
52 | displayName: user.displayName,
53 | photoURL: user.photoURL
54 | },
55 | [combinedId+".date"]: serverTimestamp()
56 | })
57 |
58 | }
59 |
60 | } catch (error) {
61 |
62 | }
63 | setUser(null)
64 | setUsername("")
65 | };
66 |
67 |
68 | return (
69 |
70 |
71 | setUsername(e.target.value)} value={username} />
72 |
73 | {err &&
User not found!}
74 | {user &&
75 |

76 |
77 | {user.displayName}
78 |
79 |
80 |
}
81 |
82 |
83 | )
84 | }
85 |
86 | export default Search
--------------------------------------------------------------------------------
/src/components/Input.jsx:
--------------------------------------------------------------------------------
1 | import React, { useContext, useState } from 'react';
2 | import Attach from '../image/attach.png';
3 | import AddImg from '../image/AddImg.png';
4 | import { AuthContext } from '../context/AuthContext';
5 | import { ChatContext } from '../context/ChatContext';
6 | import { arrayUnion, doc, serverTimestamp, Timestamp, updateDoc } from 'firebase/firestore';
7 | import { db, storage } from '../firebase';
8 | import { v4 as uuid } from 'uuid';
9 | import { getDownloadURL, ref, uploadBytesResumable } from 'firebase/storage';
10 |
11 | function Input() {
12 |
13 | const [text , setText] = useState("")
14 | const [image , setImage] = useState(null)
15 |
16 | const {currentUser} = useContext(AuthContext)
17 | const {data} = useContext(ChatContext)
18 |
19 | const handleSend = async() =>{
20 |
21 | if (image) {
22 |
23 | const storageRef = ref(storage, uuid());
24 |
25 | const uploadTask = uploadBytesResumable(storageRef, image);
26 |
27 | uploadTask.on(
28 | (error) => {
29 | // setErr(true)
30 | },
31 | () => {
32 |
33 | getDownloadURL(uploadTask.snapshot.ref).then(async (downloadURL) => {
34 | await updateDoc(doc(db, "chats", data.chatId),{
35 | messages: arrayUnion({
36 | id:uuid(),
37 | text,
38 | senderId:currentUser.uid,
39 | date: Timestamp.now(),
40 | image: downloadURL,
41 | })
42 | })
43 |
44 | });
45 | }
46 | );
47 |
48 | }else{
49 | await updateDoc(doc(db, "chats", data.chatId),{
50 | messages: arrayUnion({
51 | id:uuid(),
52 | text,
53 | senderId:currentUser.uid,
54 | date: Timestamp.now(),
55 | })
56 | })
57 | }
58 |
59 | await updateDoc(doc(db, "userChats" , currentUser.uid),{
60 | [data.chatId + ".lastMessage"]:{
61 | text
62 | },
63 | [data.chatId+ ".date"]: serverTimestamp(),
64 | });
65 |
66 | await updateDoc(doc(db, "userChats" , data.user.uid),{
67 | [data.chatId + ".lastMessage"]:{
68 | text,
69 | },
70 | [data.chatId+ ".date"]: serverTimestamp(),
71 | });
72 |
73 |
74 | setText("")
75 | setImage(null)
76 | }
77 | return (
78 |
79 |
setText(e.target.value)}
80 | value={text} />
81 |
82 |

83 |
setImage(e.target.files[0])} />
84 |
89 |
90 |
91 |
92 | )
93 | }
94 |
95 | export default Input
--------------------------------------------------------------------------------
/src/pages/Register.jsx:
--------------------------------------------------------------------------------
1 | import React, { useState } from 'react'
2 | import Add from '../image/add_image.png'
3 | import { createUserWithEmailAndPassword, updateProfile } from "firebase/auth";
4 | import { auth, storage, db } from "../firebase";
5 | import { ref, uploadBytesResumable, getDownloadURL } from "firebase/storage";
6 | import { doc, setDoc } from "firebase/firestore";
7 | import { Link, useNavigate } from 'react-router-dom';
8 |
9 |
10 | function Register() {
11 | const [err, setErr] = useState(false)
12 | const navigate = useNavigate()
13 |
14 |
15 |
16 | const handleSubmit = async (e) => {
17 | e.preventDefault();
18 | const file = e.target[0].files[0];
19 | const displayName = e.target[1].value;
20 | const email = e.target[2].value;
21 | const password = e.target[3].value;
22 |
23 | try {
24 |
25 | const res = await createUserWithEmailAndPassword(auth, email, password);
26 | console.log(res.user.uid);
27 |
28 | const storageRef = ref(storage, displayName);
29 |
30 | const uploadTask = uploadBytesResumable(storageRef, file);
31 |
32 | // Register three observers:
33 | uploadTask.on(
34 | (error) => {
35 | console.log('ggggggggg', error);
36 | setErr(true)
37 | },
38 | () => {
39 |
40 | getDownloadURL(uploadTask.snapshot.ref).then(async (downloadURL) => {
41 | await updateProfile(res.user, {
42 | photoURL: downloadURL,
43 | displayName,
44 |
45 | });
46 |
47 | await setDoc(doc(db, "users", res.user.uid), {
48 | uid: res.user.uid,
49 | photoURL: downloadURL,
50 | displayName,
51 | email,
52 | });
53 |
54 | await setDoc(doc(db , "userChats" , res.user.uid),{})
55 | navigate('/')
56 |
57 | });
58 | }
59 | );
60 |
61 |
62 | } catch (error) {
63 | console.log('true', error)
64 | setErr(true)
65 | }
66 |
67 | };
68 |
69 | return (
70 |
71 |
72 |
Engage App
73 |
Register
74 |
75 |
88 |
You do have an account? Sign in
89 |
90 |
91 | )
92 | }
93 |
94 | export default Register
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Getting Started with Create React App
2 |
3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4 |
5 | ## Available Scripts
6 |
7 | In the project directory, you can run:
8 |
9 | ### `npm start`
10 |
11 | Runs the app in the development mode.\
12 | Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
13 |
14 | The page will reload when you make changes.\
15 | You may also see any lint errors in the console.
16 |
17 | ### `npm test`
18 |
19 | Launches the test runner in the interactive watch mode.\
20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21 |
22 | ### `npm run build`
23 |
24 | Builds the app for production to the `build` folder.\
25 | It correctly bundles React in production mode and optimizes the build for the best performance.
26 |
27 | The build is minified and the filenames include the hashes.\
28 | Your app is ready to be deployed!
29 |
30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31 |
32 | ### `npm run eject`
33 |
34 | **Note: this is a one-way operation. Once you `eject`, you can't go back!**
35 |
36 | 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.
37 |
38 | 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.
39 |
40 | 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.
41 |
42 | ## Learn More
43 |
44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45 |
46 | To learn React, check out the [React documentation](https://reactjs.org/).
47 |
48 | ### Code Splitting
49 |
50 | 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)
51 |
52 | ### Analyzing the Bundle Size
53 |
54 | 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)
55 |
56 | ### Making a Progressive Web App
57 |
58 | 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)
59 |
60 | ### Advanced Configuration
61 |
62 | 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)
63 |
64 | ### Deployment
65 |
66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67 |
68 | ### `npm run build` fails to minify
69 |
70 | 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)
71 |
--------------------------------------------------------------------------------
/src/style.scss:
--------------------------------------------------------------------------------
1 | @mixin mobile {
2 | @media screen and (max-width:480px) {
3 | @content
4 | }
5 | }
6 |
7 | @mixin tablet {
8 | @media screen and (max-width:768px) {
9 | @content
10 | }
11 | }
12 |
13 | @mixin laptop {
14 | @media screen and (max-width:1200px) {
15 | @content
16 | }
17 | }
18 |
19 |
20 |
21 | .formContainer{
22 | background-color: rgba(90, 35, 106, 0.924);
23 | height: 100vh;
24 | display: flex;
25 | align-items: center;
26 | justify-content: center;
27 |
28 | .formWrapper{
29 | background-color: rgb(255, 255, 255);
30 | padding: 20px 60px;
31 | display: flex;
32 | border-radius: 10px;
33 | flex-direction: column;
34 | align-items: center;
35 | gap: 10px;
36 |
37 |
38 |
39 | .logo{
40 | color: rgb(129, 51, 157);
41 | font-weight: bold;
42 | font-size: 25px;
43 |
44 | }
45 | .title{
46 | color: rgb(91, 95, 99);
47 | font-size: 19px;
48 | }
49 |
50 | form{
51 | display: flex;
52 | flex-direction: column;
53 | gap: 15px;
54 |
55 |
56 |
57 | input{
58 | padding: 25px;
59 | border: 0;
60 | border-bottom: 1px solid rgba(0, 0, 0, 0.66);
61 | &::placeholder{
62 | color: rgb(175, 175, 175);
63 | }
64 | }
65 | .img{
66 | width: 35px;
67 | height: 35px;
68 | }
69 |
70 |
71 | button{
72 | background-color: black;
73 | color: white;
74 | padding: 10px;
75 | font-weight: bold;
76 | border: none;
77 | cursor: pointer;
78 | }
79 | label{
80 | display: flex;
81 | align-items: center;
82 | }
83 | }
84 | p{
85 | color: #5d5b8d;
86 | font-size: 12px;
87 | margin-top: 10px;
88 | }
89 | }
90 | }
91 |
92 |
93 | .home{
94 |
95 | background-color: rgba(90, 35, 106, 0.924);
96 | height: 100vh;
97 | display: flex;
98 | align-items: center;
99 | justify-content: center;
100 |
101 | .container{
102 | border: 1px solid white;
103 | border-radius: 10px;
104 | width: 65%;
105 | height: 80%;
106 | display: flex ;
107 | overflow: hidden;
108 | @include tablet{
109 | width: 90%;
110 | }
111 |
112 | .sidebar{
113 | flex: 1;
114 | background-color: rgb(91, 95, 99);
115 | position: relative;
116 | .navbar{
117 | display: flex;
118 | align-items: center;
119 | background-color: rgb(25, 81, 127);
120 | height: 50px;
121 | padding: 10px;
122 | justify-content: space-between;
123 | color: #ddddf7;
124 |
125 | .logo{
126 | font-weight: bold;
127 | @include tablet{
128 | display: none;
129 | }
130 | }
131 | .user{
132 | display: flex;
133 | gap: 10px;
134 |
135 | img{
136 | background-color: #ddddf7;
137 | height: 24px;
138 | width: 24px;
139 | border-radius: 50%;
140 | object-fit: cover;
141 | }
142 | button{
143 | background-color: #5d5b8d;
144 | color: #ddddf7;
145 | font-size: 10px;
146 | border: none;
147 | cursor: pointer;
148 | @include tablet{
149 | position: absolute;
150 | bottom: 10px;
151 | }
152 | }
153 | }
154 |
155 | }
156 | .search{
157 | border-bottom: 1px solid gray;
158 |
159 | .searchForm{
160 | input{
161 | background-color: transparent;
162 | border: none;
163 | color: white;
164 | outline: none;
165 |
166 | &::placeholder{
167 | color: lightgray;
168 | }
169 | }
170 | }
171 | }
172 | .userChat{
173 | padding: 10px;
174 | display: flex;
175 | align-items: center;
176 | gap: 10px;
177 | color: white;
178 | cursor: pointer;
179 |
180 | &:hover{
181 | background-color: #2f2f2f;
182 | }
183 | img{
184 | width: 50px;
185 | height: 50px;
186 | border-radius: 50%;
187 | object-fit: cover;
188 | }
189 | .userChatInfo{
190 | span{
191 | font-size: 18px;
192 | font-weight: 500;
193 | }
194 | p{
195 | font-size: 14px;
196 | color: lightgray;
197 | }
198 | }
199 |
200 | }
201 | }
202 | .chat{
203 | flex: 2;
204 |
205 | .chatInfo{
206 | height: 50px;
207 | background-color: #5d5b8d;
208 | display: flex;
209 | align-items: center;
210 | justify-content: space-between;
211 | padding: 10px;
212 | color: lightgrey;
213 |
214 | }
215 | .chatIcons{
216 | display: flex;
217 | gap: 10px;
218 |
219 | img{
220 | height: 24px;
221 | cursor: pointer;
222 | }
223 | }
224 |
225 | .messages{
226 | background-color: #ddddf7;
227 | padding: 10px;
228 | height: calc(100% - 160px);
229 | overflow: scroll;
230 |
231 | .message{
232 | display: flex;
233 | gap: 20px;
234 |
235 | .messageInfo{
236 | display: flex;
237 | flex-direction: column;
238 | color: gray;
239 | font-weight: 300;
240 | img{
241 | width: 40px;
242 | height: 40px;
243 | background-repeat: 50%;
244 | object-fit: cover;
245 | }
246 |
247 | }
248 | .messageContent{
249 | max-width: 80%;
250 | display: flex;
251 | flex-direction: column;
252 | gap: 10px;
253 |
254 | p{
255 | background-color: white;
256 | padding: 10px 20px;
257 | border-radius: 0px 10px 10px 10px;
258 | max-width: max-content;
259 | }
260 | img{
261 | width: 50%;
262 | }
263 | }
264 | &.owner{
265 | flex-direction: row-reverse;
266 |
267 | .messageContent{
268 | align-items: flex-end;
269 |
270 | p{
271 | background-color: #5d5b8d;
272 | color: white;
273 | border-radius: 10px 0px 10px 10px;
274 |
275 |
276 |
277 | }
278 | }
279 | }
280 | }
281 |
282 | }
283 |
284 |
285 | .input{
286 | height: 50px;
287 | background-color: white;
288 | padding: 10px;
289 | display: flex;
290 | align-items: center;
291 | justify-content: space-between;
292 |
293 | input{
294 | width: 100%;
295 | border: none;
296 | outline: none;
297 | color: #2f2d52;
298 | font-size: 18px;
299 |
300 | &::placeholder{
301 | color: lightgrey;
302 | }
303 | }
304 | .send{
305 | display: flex;
306 | align-items: center;
307 | gap: 10px;
308 |
309 | img{
310 | height: 24px;
311 | cursor: pointer;
312 | }
313 | button{
314 | border: none;
315 | padding: 10px 15px;
316 | color: white;
317 | background-color: #2f2f2f;
318 | }
319 | }
320 | }
321 | }
322 |
323 | }
324 |
325 | }
326 |
--------------------------------------------------------------------------------