├── .env ├── _config.yml ├── public ├── robots.txt ├── favicon.ico ├── logo192.png ├── logo512.png ├── manifest.json └── index.html ├── .firebaserc ├── src ├── app │ └── store.js ├── setupTests.js ├── App.css ├── App.test.js ├── components │ ├── Body │ │ ├── Feed │ │ │ ├── InputOption.js │ │ │ ├── InputOption.css │ │ │ ├── Feed.css │ │ │ └── Feed.js │ │ ├── Post │ │ │ ├── Post.css │ │ │ └── Post.js │ │ ├── Widget │ │ │ ├── Widgets.js │ │ │ └── Widgets.css │ │ └── Sidebar │ │ │ ├── Sidebar.js │ │ │ └── Sidebar.css │ ├── Header │ │ ├── HeaderOption.css │ │ ├── HeaderOption.js │ │ ├── Header.css │ │ └── Header.js │ └── Login │ │ ├── Login.css │ │ └── Login.js ├── reportWebVitals.js ├── index.css ├── firebase.js ├── index.js ├── features │ └── userSlice.js ├── App.js ├── logo.svg └── serviceWorker.js ├── firebase.json ├── .gitignore ├── README.md ├── .github └── workflows │ ├── npm-publish.yml │ ├── node.js.yml │ ├── auto.yml │ ├── npm-publish-github-packages.yml │ ├── manual.yml │ └── google.yml ├── package.json ├── .firebase └── hosting.YnVpbGQ.cache └── .eslintcache /.env: -------------------------------------------------------------------------------- 1 | SKIP_PREFLIGHT_CHECK=true -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-slate -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | -------------------------------------------------------------------------------- /.firebaserc: -------------------------------------------------------------------------------- 1 | { 2 | "projects": { 3 | "default": "alanbinu-linkedin" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlanBinu007/Linkedin-Clone-React/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlanBinu007/Linkedin-Clone-React/HEAD/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlanBinu007/Linkedin-Clone-React/HEAD/public/logo512.png -------------------------------------------------------------------------------- /src/app/store.js: -------------------------------------------------------------------------------- 1 | import { configureStore } from '@reduxjs/toolkit'; 2 | import userReducer from '../features/userSlice'; 3 | 4 | export default configureStore({ 5 | reducer: { 6 | user: userReducer, 7 | }, 8 | }); 9 | -------------------------------------------------------------------------------- /src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /src/App.css: -------------------------------------------------------------------------------- 1 | .app { 2 | display: flex; 3 | flex-direction: column; 4 | align-items: center; 5 | background-color: #f3f2ef; 6 | } 7 | 8 | .app_body { 9 | display: flex; 10 | width: 90%; 11 | margin-top: 35px; 12 | margin-left: 20px; 13 | margin-right: 20px; 14 | } -------------------------------------------------------------------------------- /src/App.test.js: -------------------------------------------------------------------------------- 1 | import { render, screen } from '@testing-library/react'; 2 | import App from './App'; 3 | 4 | test('renders learn react link', () => { 5 | render(); 6 | const linkElement = screen.getByText(/learn react/i); 7 | expect(linkElement).toBeInTheDocument(); 8 | }); 9 | -------------------------------------------------------------------------------- /firebase.json: -------------------------------------------------------------------------------- 1 | { 2 | "hosting": { 3 | "public": "build", 4 | "ignore": [ 5 | "firebase.json", 6 | "**/.*", 7 | "**/node_modules/**" 8 | ], 9 | "rewrites": [ 10 | { 11 | "source": "**", 12 | "destination": "/index.html" 13 | } 14 | ] 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/components/Body/Feed/InputOption.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import './InputOption.css'; 3 | 4 | function InputOption({ Icon, title, color }) { 5 | return
6 | 7 |

{title}

8 |
; 9 | }; 10 | 11 | export default InputOption; 12 | -------------------------------------------------------------------------------- /src/components/Body/Feed/InputOption.css: -------------------------------------------------------------------------------- 1 | .inputOption { 2 | display: flex; 3 | align-items: center; 4 | margin-top: 15px; 5 | color: gray; 6 | padding: 10px; 7 | cursor: pointer; 8 | } 9 | 10 | .inputOption:hover { 11 | background-color: whitesmoke; 12 | border-radius: 10px; 13 | } 14 | 15 | .inputOption > h4 { 16 | margin-left: 5px; 17 | } -------------------------------------------------------------------------------- /.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/reportWebVitals.js: -------------------------------------------------------------------------------- 1 | const reportWebVitals = onPerfEntry => { 2 | if (onPerfEntry && onPerfEntry instanceof Function) { 3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 4 | getCLS(onPerfEntry); 5 | getFID(onPerfEntry); 6 | getFCP(onPerfEntry); 7 | getLCP(onPerfEntry); 8 | getTTFB(onPerfEntry); 9 | }); 10 | } 11 | }; 12 | 13 | export default reportWebVitals; 14 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | } 4 | 5 | body { 6 | margin: 0; 7 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 8 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 9 | sans-serif; 10 | -webkit-font-smoothing: antialiased; 11 | -moz-osx-font-smoothing: grayscale; 12 | } 13 | 14 | code { 15 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 16 | monospace; 17 | } 18 | -------------------------------------------------------------------------------- /src/components/Header/HeaderOption.css: -------------------------------------------------------------------------------- 1 | .headerOption { 2 | display: flex; 3 | flex-direction: column; 4 | align-items: center; 5 | margin-right: 20px; 6 | color: gray; 7 | cursor: pointer; 8 | } 9 | 10 | .headerOption_icon { 11 | object-fit: contain; 12 | height: 25px !important; 13 | width: 25px !important; 14 | } 15 | 16 | .headerOption_title { 17 | font-size: 12px; 18 | font-weight: 400; 19 | } 20 | 21 | .headerOption:hover { 22 | color: #000; 23 | } -------------------------------------------------------------------------------- /src/components/Body/Post/Post.css: -------------------------------------------------------------------------------- 1 | .post { 2 | background-color: white; 3 | padding: 15px; 4 | margin-bottom: 10px; 5 | border-radius: 10px; 6 | } 7 | 8 | .post_header { 9 | display: flex; 10 | margin-bottom: 10px; 11 | } 12 | 13 | .postInfo { 14 | margin-left: 10px; 15 | } 16 | 17 | .postInfo > p { 18 | font-size: 12px; 19 | color: gray; 20 | } 21 | 22 | .postInfo > h2 { 23 | font-size: 15px; 24 | } 25 | 26 | .post_buttons { 27 | display: flex; 28 | /* justify-content: space-evenly; */ 29 | } 30 | 31 | .post_body { 32 | overflow-wrap: anywhere; 33 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # LinkedIn -Clone using ReactJs 3 | 4 | **Project Link** - ***https://alanbinu-linkedin.web.app/*** 5 | 6 | ## Tech We Used 7 | 8 | - ReactJs 9 | - Firebase Hosting 10 | - Firebase Auth 11 | - Firebase Storage 12 | - React-Dom 13 | - React Redux 14 | 15 | ## Features 16 | 17 | - Login and Logout 18 | - Make post 19 | - Delete post 20 | - Neat and clean UI 21 | 22 | ## Steps to run in your machine 23 | 24 | #### Run the following commands 25 | ``` 26 | npm i 27 | npm run start 28 | ``` 29 | 30 | 31 | 32 | 33 | #### Hope you liked this project, dont forget to ⭐ the repo. 34 | -------------------------------------------------------------------------------- /src/firebase.js: -------------------------------------------------------------------------------- 1 | import firebase from 'firebase' 2 | 3 | const firebaseConfig = { 4 | apiKey: "AIzaSyDVs6C7mKimUog0gj8SezFF_xm_Ydzuw8U", 5 | authDomain: "linkedin-clone-e25d6.firebaseapp.com", 6 | projectId: "linkedin-clone-e25d6", 7 | storageBucket: "linkedin-clone-e25d6.appspot.com", 8 | messagingSenderId: "615063347346", 9 | appId: "1:615063347346:web:73e50767ea3869302d464b", 10 | measurementId: "G-5P10KF698M" 11 | }; 12 | 13 | const firebaseApp = firebase.initializeApp(firebaseConfig); 14 | const db = firebaseApp.firestore(); 15 | const auth = firebase.auth(); 16 | 17 | export { db, auth }; 18 | -------------------------------------------------------------------------------- /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/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import store from './app/store'; 6 | import { Provider } from 'react-redux'; 7 | import * as serviceWorker from './serviceWorker'; 8 | 9 | ReactDOM.render( 10 | 11 | 12 | 13 | 14 | , 15 | document.getElementById('root') 16 | ); 17 | 18 | // If you want your app to work offline and load faster, you can change 19 | // unregister() to register() below. Note this comes with some pitfalls. 20 | // Learn more about service workers: https://bit.ly/CRA-PWA 21 | serviceWorker.unregister(); 22 | -------------------------------------------------------------------------------- /src/components/Header/HeaderOption.js: -------------------------------------------------------------------------------- 1 | import { Avatar } from '@material-ui/core'; 2 | import React from 'react'; 3 | import { useSelector } from 'react-redux'; 4 | import { selectUser } from '../../features/userSlice'; 5 | import './HeaderOption.css'; 6 | // import { Avatar } from '@material-ui/core'; 7 | 8 | function HeaderOption({ avatar, Icon, title, onClick }) { 9 | const user = useSelector(selectUser); 10 | 11 | return ( 12 |
13 | {Icon && } 14 | {avatar && } 15 |

{title}

16 |
17 | ) 18 | } 19 | 20 | export default HeaderOption 21 | -------------------------------------------------------------------------------- /src/features/userSlice.js: -------------------------------------------------------------------------------- 1 | import { createSlice } from '@reduxjs/toolkit'; 2 | 3 | export const userSlice = createSlice({ 4 | name: 'user', 5 | initialState: { 6 | user: null, 7 | }, 8 | reducers: { 9 | login: (state, action) => { 10 | state.user = action.payload; 11 | }, 12 | logout: (state) => { 13 | state.user += null; 14 | }, 15 | }, 16 | }); 17 | 18 | export const { login, logout } = userSlice.actions; 19 | 20 | // The function below is called a selector and allows us to select a value from 21 | // the state. Selectors can also be defined inline where they're used instead of 22 | // in the slice file. For example: `useSelector((state) => state.counter.value)` 23 | export const selectUser = state => state.user.user; 24 | 25 | export default userSlice.reducer; 26 | -------------------------------------------------------------------------------- /src/components/Header/Header.css: -------------------------------------------------------------------------------- 1 | .header { 2 | position: sticky; 3 | top: 0; 4 | display: flex; 5 | background-color: #fff; 6 | justify-content: space-evenly; 7 | border-bottom: 0.1px solid lightgray; 8 | width: 100%; 9 | z-index: 500; 10 | padding: 5px; 11 | } 12 | 13 | .header__left { 14 | display: flex; 15 | } 16 | 17 | .header__left > img { 18 | object-fit: contain; 19 | height: 40px; 20 | margin-right: 10px; 21 | } 22 | 23 | .header__search { 24 | padding: 10px; 25 | display: flex; 26 | align-items: center; 27 | border-radius: 5px; 28 | height: 22px; 29 | color: gray; 30 | background-color: #eef3f8; 31 | } 32 | 33 | .header__search > input { 34 | outline: none; 35 | border: none; 36 | background: none; 37 | } 38 | 39 | .header__right { 40 | display: flex; 41 | } -------------------------------------------------------------------------------- /src/components/Body/Feed/Feed.css: -------------------------------------------------------------------------------- 1 | .feed { 2 | flex: 0.6; 3 | margin: 0 20px; 4 | } 5 | 6 | .feed_inputContainer { 7 | background-color: #fff; 8 | padding: 10px; 9 | padding-bottom: 20px; 10 | border-radius: 10px; 11 | margin-bottom: 20px; 12 | } 13 | 14 | .feed_input { 15 | border: 1px solid lightgray; 16 | border-radius: 25px; 17 | display: flex; 18 | padding: 10px; 19 | color: gray; 20 | padding-left: 15px; 21 | } 22 | 23 | .feed_input > form { 24 | display: flex; 25 | width: 100%; 26 | } 27 | 28 | .feed_input > form > input { 29 | border: none; 30 | flex: 1; 31 | margin-left: 10px; 32 | outline-width: 0; 33 | font-weight: 600; 34 | } 35 | 36 | .feed_input > form > button { 37 | display: none; 38 | } 39 | 40 | .feed_inputOption { 41 | display: flex; 42 | justify-content: space-evenly; 43 | } -------------------------------------------------------------------------------- /src/components/Login/Login.css: -------------------------------------------------------------------------------- 1 | .login { 2 | display: grid; 3 | place-items: center; 4 | margin-left: auto; 5 | margin-right: auto; 6 | padding-top: 100px; 7 | padding-bottom: 100px; 8 | } 9 | 10 | .login > img { 11 | object-fit: contain; 12 | height: 70px; 13 | margin-top: 20px; 14 | margin-bottom: 20px; 15 | } 16 | 17 | .login > form { 18 | display: flex; 19 | flex-direction: column; 20 | } 21 | 22 | .login > form > input { 23 | width: 350px; 24 | height: 50px; 25 | font-size: 20px; 26 | padding-right: 10px; 27 | margin-bottom: 10px; 28 | border-radius: 5px; 29 | } 30 | 31 | .login > form > button { 32 | width: 356px; 33 | height: 50px; 34 | font-size: large; 35 | color: #ffff; 36 | background-color: #0074b1; 37 | border-radius: 5px; 38 | border: none; 39 | } 40 | 41 | .login_register { 42 | color: #0177b7; 43 | cursor: pointer; 44 | } 45 | 46 | .login > p { 47 | margin-top: 20px; 48 | } 49 | 50 | 51 | -------------------------------------------------------------------------------- /.github/workflows/npm-publish.yml: -------------------------------------------------------------------------------- 1 | # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages 3 | 4 | name: Node.js Package 5 | 6 | on: 7 | release: 8 | types: [created] 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v2 15 | - uses: actions/setup-node@v2 16 | with: 17 | node-version: 16 18 | - run: npm ci 19 | - run: npm test 20 | 21 | publish-npm: 22 | needs: build 23 | runs-on: ubuntu-latest 24 | steps: 25 | - uses: actions/checkout@v2 26 | - uses: actions/setup-node@v2 27 | with: 28 | node-version: 16 29 | registry-url: https://registry.npmjs.org/ 30 | - run: npm ci 31 | - run: npm publish 32 | env: 33 | NODE_AUTH_TOKEN: ${{secrets.npm_token}} 34 | -------------------------------------------------------------------------------- /src/components/Body/Widget/Widgets.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import './Widgets.css'; 3 | import InfoIcon from '@material-ui/icons/Info'; 4 | import FiberManualRecordIcon from '@material-ui/icons/FiberManualRecord'; 5 | 6 | function Widgets() { 7 | const newsArticle = (heading, subtitle) => ( 8 |
9 |
10 | 11 |
12 | 13 |
14 |

{heading}

15 |

{subtitle}

16 |
17 |
18 | ); 19 | 20 | return ( 21 |
22 |
23 |

LinkedIn News

24 | 25 |
26 | 27 | {newsArticle("Coronavirus: Lagos updates", "Tops news - 324 readers")} 28 | {newsArticle("Bitcoin hits new high", "Tops news - 2,324 readers")} 29 |
30 | ) 31 | } 32 | 33 | export default Widgets 34 | -------------------------------------------------------------------------------- /.github/workflows/node.js.yml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions 3 | 4 | name: Node.js CI 5 | 6 | on: 7 | push: 8 | branches: [ master ] 9 | pull_request: 10 | branches: [ master ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | strategy: 18 | matrix: 19 | node-version: [12.x, 14.x, 16.x] 20 | # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ 21 | 22 | steps: 23 | - uses: actions/checkout@v2 24 | - name: Use Node.js ${{ matrix.node-version }} 25 | uses: actions/setup-node@v2 26 | with: 27 | node-version: ${{ matrix.node-version }} 28 | cache: 'npm' 29 | - run: npm ci 30 | - run: npm run build --if-present 31 | - run: npm test 32 | -------------------------------------------------------------------------------- /src/components/Body/Widget/Widgets.css: -------------------------------------------------------------------------------- 1 | .widgets { 2 | flex: 0.2; 3 | position: sticky; 4 | top: 80px; 5 | background-color: white; 6 | border-radius: 10px; 7 | border: 1px solid lightgray; 8 | height: fit-content; 9 | padding-bottom: 10px; 10 | } 11 | 12 | .widget_header { 13 | display: flex; 14 | align-items: center; 15 | justify-content: space-between; 16 | padding: 10px; 17 | } 18 | 19 | .widget_header > h2 { 20 | font-size: 16px; 21 | font-weight: 400; 22 | } 23 | 24 | .widget_article { 25 | display: flex; 26 | padding: 10px; 27 | cursor: pointer; 28 | } 29 | 30 | .widget_article:hover { 31 | background-color: whitesmoke; 32 | } 33 | 34 | .widgets_articleleft { 35 | color: #0177b7; 36 | margin-right: 5px; 37 | } 38 | 39 | .widgets_articleleft > .MuiSvgIcon-root { 40 | font-size: 15px; 41 | } 42 | 43 | .widgets_articleright { 44 | flex: 1; 45 | } 46 | 47 | .widgets_articleright > h4 { 48 | font-size: 14px; 49 | } 50 | 51 | .widgets_articleright > p { 52 | font-size: 12px; 53 | color: gray; 54 | } 55 | -------------------------------------------------------------------------------- /.github/workflows/auto.yml: -------------------------------------------------------------------------------- 1 | name: CI + CD 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | Staging: 8 | runs-on: ubuntu-latest 9 | environment: Staging 10 | steps: 11 | - uses: actions/checkout@v2 12 | - name: Run a script 13 | run: echo "Running in Staging" 14 | 15 | Quality_Assurance: 16 | runs-on: ubuntu-latest 17 | environment: Quality_Assurance 18 | needs: Staging 19 | steps: 20 | - uses: actions/checkout@v2 21 | - name: Run a script 22 | run: echo "Running in QA" 23 | 24 | Production: 25 | runs-on: ubuntu-latest 26 | environment: Development 27 | needs: Quality_Assurance 28 | steps: 29 | - uses: actions/checkout@v2 30 | - name: Run a script 31 | run: echo "Running in production" 32 | 33 | Development: 34 | runs-on: ubuntu-latest 35 | environment: Production 36 | needs: Production 37 | steps: 38 | - uses: actions/checkout@v2 39 | - name: Run a script 40 | run: echo "Deployed" 41 | -------------------------------------------------------------------------------- /.github/workflows/npm-publish-github-packages.yml: -------------------------------------------------------------------------------- 1 | # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages 3 | 4 | name: Node.js Package 5 | 6 | on: 7 | release: 8 | types: [created] 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v2 15 | - uses: actions/setup-node@v2 16 | with: 17 | node-version: 16 18 | - run: npm ci 19 | - run: npm test 20 | 21 | publish-gpr: 22 | needs: build 23 | runs-on: ubuntu-latest 24 | permissions: 25 | contents: read 26 | packages: write 27 | steps: 28 | - uses: actions/checkout@v2 29 | - uses: actions/setup-node@v2 30 | with: 31 | node-version: 16 32 | registry-url: https://npm.pkg.github.com/ 33 | - run: npm ci 34 | - run: npm publish 35 | env: 36 | NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} 37 | -------------------------------------------------------------------------------- /.github/workflows/manual.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow that is manually triggered 2 | 3 | name: Manual workflow 4 | 5 | # Controls when the action will run. Workflow runs when manually triggered using the UI 6 | # or API. 7 | on: 8 | workflow_dispatch: 9 | # Inputs the workflow accepts. 10 | inputs: 11 | name: 12 | # Friendly description to be shown in the UI instead of 'name' 13 | description: 'Person to greet' 14 | # Default value if no value is explicitly provided 15 | default: 'World' 16 | # Input has to be provided for the workflow to run 17 | required: true 18 | 19 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 20 | jobs: 21 | # This workflow contains a single job called "greet" 22 | greet: 23 | # The type of runner that the job will run on 24 | runs-on: ubuntu-latest 25 | 26 | # Steps represent a sequence of tasks that will be executed as part of the job 27 | steps: 28 | # Runs a single command using the runners shell 29 | - name: Send greeting 30 | run: echo "Hello ${{ github.event.inputs.name }}" 31 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "linkedin", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@material-ui/core": "^4.11.3", 7 | "@material-ui/icons": "^4.11.2", 8 | "@reduxjs/toolkit": "^1.5.1", 9 | "@testing-library/jest-dom": "^5.12.0", 10 | "@testing-library/react": "^11.2.6", 11 | "@testing-library/user-event": "^12.8.3", 12 | "firebase": "^8.4.2", 13 | "react": "^17.0.2", 14 | "react-dom": "^17.0.2", 15 | "react-flip-move": "^3.0.4", 16 | "react-redux": "^7.2.3", 17 | "react-scripts": "4.0.3", 18 | "web-vitals": "^1.1.1" 19 | }, 20 | "scripts": { 21 | "start": "react-scripts start", 22 | "build": "react-scripts build", 23 | "test": "react-scripts test", 24 | "eject": "react-scripts eject" 25 | }, 26 | "eslintConfig": { 27 | "extends": [ 28 | "react-app", 29 | "react-app/jest" 30 | ] 31 | }, 32 | "browserslist": { 33 | "production": [ 34 | ">0.2%", 35 | "not dead", 36 | "not op_mini all" 37 | ], 38 | "development": [ 39 | "last 1 chrome version", 40 | "last 1 firefox version", 41 | "last 1 safari version" 42 | ] 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/components/Body/Post/Post.js: -------------------------------------------------------------------------------- 1 | import { Avatar } from '@material-ui/core'; 2 | import React, { forwardRef } from 'react'; 3 | import InputOption from '../Feed/InputOption'; 4 | import './Post.css'; 5 | import ThumbUpAltOutlinedIcon from '@material-ui/icons/ThumbUpAltOutlined'; 6 | import ChatOutlinedIcon from '@material-ui/icons/ChatOutlined'; 7 | import ShareOutlinedIcon from '@material-ui/icons/ShareOutlined'; 8 | import SendOutlinedIcon from '@material-ui/icons/SendOutlined'; 9 | 10 | const Post = forwardRef(({ name, description, message, photoUrl }, ref) => { 11 | return ( 12 |
13 |
14 | 15 |
16 |

{name}

17 |

{description}

18 |
19 |
20 |
21 |

{message}

22 |
23 |
24 | 25 | 26 | 27 | 28 |
29 |
30 | ); 31 | }); 32 | 33 | export default Post; 34 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import React, { useEffect } from 'react'; 2 | import { useDispatch, useSelector } from 'react-redux'; 3 | import './App.css'; 4 | import Feed from './components/Body/Feed/Feed'; 5 | import Sidebar from './components/Body/Sidebar/Sidebar'; 6 | import Widgets from './components/Body/Widget/Widgets'; 7 | import Header from './components/Header/Header'; 8 | import Login from './components/Login/Login'; 9 | import { login, logout, selectUser } from './features/userSlice'; 10 | import { auth } from './firebase'; 11 | 12 | function App() { 13 | const user = useSelector(selectUser); 14 | const dispatch = useDispatch(); 15 | 16 | useEffect(() => { 17 | auth.onAuthStateChanged(userAuth => { 18 | if (userAuth) { 19 | // user is logged in 20 | dispatch(login({ 21 | email: userAuth.email, 22 | uid: userAuth.uid, 23 | displayName: userAuth.displayName, 24 | photoUrl: userAuth.photoURL, 25 | })) 26 | } else { 27 | // use is logged out 28 | dispatch(logout()); 29 | } 30 | }) 31 | }, [dispatch]); 32 | 33 | return ( 34 |
35 |
36 | 37 | {!user ? ( 38 | 39 | ) : ( 40 |
41 | 42 | 43 | 44 |
45 | )} 46 | 47 |
48 | ); 49 | } 50 | 51 | export default App; 52 | -------------------------------------------------------------------------------- /src/components/Body/Sidebar/Sidebar.js: -------------------------------------------------------------------------------- 1 | import { Avatar } from '@material-ui/core' 2 | import React from 'react'; 3 | import { useSelector } from 'react-redux'; 4 | import { selectUser } from '../../../features/userSlice'; 5 | // import { Avatar } from '@material-ui/core'; 6 | import './Sidebar.css'; 7 | 8 | function Sidebar() { 9 | const user = useSelector(selectUser); 10 | 11 | const recentItems = (topic) => ( 12 |
13 | # 14 |

{topic}

15 |
16 | ); 17 | 18 | return ( 19 |
20 |
21 | cover pics 25 | 26 | {user.email[0]} 27 | 28 |

{user.displayName}

29 |

{user.email}

30 |
31 |
32 |
33 |

Who viewed you

34 |

2,432

35 |
36 |
37 |

Views on post

38 |

1,232

39 |
40 |
41 | 42 |
43 |

Recent

44 | {recentItems("reactjs")} 45 | {recentItems('JavaScript')} 46 | {recentItems('Ruby')} 47 | {recentItems('Ruby on Rails')} 48 |
49 |
50 | ) 51 | } 52 | 53 | export default Sidebar 54 | -------------------------------------------------------------------------------- /src/components/Header/Header.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import './Header.css'; 3 | import SearchIcon from '@material-ui/icons/Search'; 4 | import HomeIcon from '@material-ui/icons/Home'; 5 | import SupervisorAccountIcon from '@material-ui/icons/SupervisorAccount'; 6 | import BusinessCenterIcon from '@material-ui/icons/BusinessCenter'; 7 | import ChatIcon from '@material-ui/icons/Chat'; 8 | import NotificationsIcon from '@material-ui/icons/Notifications'; 9 | import HeaderOption from './HeaderOption'; 10 | import { useDispatch } from 'react-redux'; 11 | import { auth } from '../../firebase'; 12 | import { logout } from '../../features/userSlice'; 13 | 14 | function Header() { 15 | const dispatch = useDispatch(); 16 | 17 | const logoutOfApp = () => { 18 | dispatch(logout()); 19 | auth.signOut(); 20 | } 21 | 22 | return ( 23 |
24 |
25 | logoss 26 |
27 | 28 | 29 |
30 |
31 |
32 | 33 | 34 | 35 | 36 | 37 | 42 |
43 |
44 | ) 45 | } 46 | 47 | export default Header 48 | -------------------------------------------------------------------------------- /.firebase/hosting.YnVpbGQ.cache: -------------------------------------------------------------------------------- 1 | 404.html,1619408754203,daa499dd96d8229e73235345702ba32f0793f0c8e5c0d30e40e37a5872be57aa 2 | asset-manifest.json,1619408214437,12899b912dda274871ec8639f37e77de9a9ace11a816f62dfcb06c8e965ca20a 3 | favicon.ico,1619272124014,87aecafb41d21ea93b7af81398237b980c43ee880676c78630ee2d1e9a6d711f 4 | logo192.png,1619272124015,ebf380e341383bbf65d6a762603f630a9f7610c97f32bd297bc097635bc37ee3 5 | index.html,1619408214437,c48531eb8ed377b827864bc7fbe0c8cce40a147c8ad1b6f881fd7f063f2ec7fa 6 | manifest.json,1619272124016,5c997de1364b8be939319fa9209abd77f2caf7f8844999a9e2e9173f844e7840 7 | robots.txt,1619272124016,53d2dcecb15666b4f7db4041361d3b6ea115483937dd38b66216deda98adaa4a 8 | logo512.png,1619272124015,c55d034d9cf7abfac7600919cbf4f4ce2f3ea3478df91d01177e8ff136f58918 9 | static/css/main.450991bb.chunk.css,1619408214441,fe7625d0ba23cf3101cc4e5c901516e7cbb6a0b33ea84297095d331e7cabc148 10 | static/css/main.450991bb.chunk.css.map,1619408214469,eb9b18c7df9811ed2e67f58562b28e411ad0df0c21ec22c01cfbcdfdb9ff005a 11 | static/js/2.66acf3e9.chunk.js.LICENSE.txt,1619408214469,2312bad32d362f6d6cf48f54219077fc34f54dcb7eeae10b1a74b95e3a2f5917 12 | static/js/main.c00e9f27.chunk.js,1619408214441,e07bd7ebe11c42941543ee76d5f4f3635200aee996778f1a5f18dcfc0ffe5081 13 | static/js/runtime-main.0ace9943.js,1619408214469,9d967a71697b74660d074e4cb69a7186c0e029c5b18dee84bfdd8138adc71b01 14 | static/js/runtime-main.0ace9943.js.map,1619408214469,e9976b7afe73cd3cb7c27509faea7f3b9f7392bb6a66d9d182a27a0f44c05189 15 | static/js/main.c00e9f27.chunk.js.map,1619408214469,462e2dc6508224c811d4399cbff176169bed48f1d447634d52119e8c4bbb8e9e 16 | static/js/2.66acf3e9.chunk.js,1619408214469,6568c25755fd7ebb64d9999e54126781d45c68fa998e3a4acafbd6ea1f05cae8 17 | static/js/2.66acf3e9.chunk.js.map,1619408214469,470443fc73cb54748fb23eb27ea1817da487d64e1e7f26677bdfc4fb253f2931 18 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | LinkedIn clone 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/components/Body/Sidebar/Sidebar.css: -------------------------------------------------------------------------------- 1 | .sidebar { 2 | position: sticky; 3 | top: 80px; 4 | flex: 0.2; 5 | border-radius: 10px; 6 | text-align: center; 7 | height: fit-content; 8 | } 9 | 10 | .sidebar_avatar { 11 | margin-bottom: 10px; 12 | } 13 | 14 | .sidebar_top { 15 | display: flex; 16 | flex-direction: column; 17 | align-items: center; 18 | border: 1px solid lightgray; 19 | border-bottom: 0; 20 | border-top-left-radius: 10px; 21 | border-top-right-radius: 10px; 22 | padding: 10px; 23 | background-color: white; 24 | } 25 | 26 | .sidebar_top > img { 27 | margin-bottom: -20px; 28 | height: 60px; 29 | width: 100%; 30 | border-top-left-radius: 10px; 31 | border-top-right-radius: 10px; 32 | object-fit: cover; 33 | } 34 | 35 | .sidebar_top > h4 { 36 | color: gray; 37 | font-size: 12px; 38 | } 39 | 40 | .sidebar_top > h2 { 41 | font-size: 18px; 42 | } 43 | 44 | .sidebar_stats { 45 | padding: 10px; 46 | margin-bottom: 10px; 47 | border: 1px solid lightgray; 48 | background-color: #fff; 49 | border-top-left-radius: 10px; 50 | border-top-right-radius: 10px; 51 | } 52 | 53 | .sidebar_stat { 54 | margin-top: 10px; 55 | display: flex; 56 | justify-content: space-between; 57 | } 58 | 59 | .sidebar_stat > p { 60 | color: gray; 61 | font-size: 12px; 62 | font-weight: 600; 63 | } 64 | 65 | .stat_number { 66 | font-weight: bold; 67 | color: #0a66c2 !important; 68 | } 69 | 70 | .sidebar_bottom { 71 | text-align: left; 72 | padding: 10px; 73 | border: 1px solid lightgray; 74 | background-color: #fff; 75 | border-radius: 10px; 76 | margin-top: 10px; 77 | } 78 | 79 | .sidebar_bottom > p { 80 | font-size: 13px; 81 | padding-bottom: 10px; 82 | } 83 | 84 | .recentItem { 85 | display: flex; 86 | font-size: 13px; 87 | color: gray; 88 | font-weight: bolder; 89 | cursor: pointer; 90 | margin-bottom: 5px; 91 | padding: 5px; 92 | } 93 | 94 | .recentItem:hover { 95 | background-color: whitesmoke; 96 | border-radius: 10px; 97 | cursor: pointer; 98 | color: #000; 99 | } 100 | 101 | .sidebar_hash { 102 | margin-right: 10px; 103 | margin-left: 10px; 104 | } 105 | -------------------------------------------------------------------------------- /src/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/Body/Feed/Feed.js: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useState } from 'react'; 2 | import './Feed.css'; 3 | import CreateIcon from '@material-ui/icons/Create'; 4 | import ImageIcon from '@material-ui/icons/Image'; 5 | import SubscriptionsIcon from '@material-ui/icons/Subscriptions'; 6 | import EventNoteIcon from '@material-ui/icons/EventNote'; 7 | import CalendarViewDayIcon from '@material-ui/icons/CalendarViewDay'; 8 | import InputOption from './InputOption'; 9 | import Post from '../Post/Post'; 10 | import { db } from '../../../firebase'; 11 | import firebase from 'firebase'; 12 | import { useSelector } from 'react-redux'; 13 | import { selectUser } from '../../../features/userSlice'; 14 | import FlipMove from 'react-flip-move'; 15 | 16 | function Feed() { 17 | const user = useSelector(selectUser); 18 | 19 | const [input, setInput] = useState(''); 20 | const [posts, setPosts] = useState([]); 21 | 22 | useEffect(() => { 23 | db.collection("posts").orderBy('timestamp', 'desc').onSnapshot(snapshot => ( 24 | setPosts(snapshot.docs.map(doc => ( 25 | { 26 | id: doc.id, 27 | data: doc.data(), 28 | } 29 | ))) 30 | )) 31 | }, []) 32 | 33 | const sendPost = e => { 34 | e.preventDefault(); 35 | 36 | db.collection("posts").add({ 37 | name: user.displayName, 38 | description: user.email, 39 | message: input, 40 | photoUrl: user.photoUrl || '', 41 | timestamp: firebase.firestore.FieldValue.serverTimestamp(), 42 | }); 43 | setInput(""); 44 | }; 45 | 46 | return ( 47 |
48 |
49 |
50 | 51 |
52 | setInput(e.target.value)} type="text" /> 53 | 54 |
55 |
56 |
57 | 58 | 59 | 60 | 61 |
62 |
63 | 64 | 65 | 66 | {posts.slice(0, 5).map(({ id, data: { name, description, message, photoUrl}}) => ( 67 | 74 | ))} 75 | 76 |
77 | ); 78 | }; 79 | 80 | export default Feed; 81 | -------------------------------------------------------------------------------- /src/components/Login/Login.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import { useDispatch } from 'react-redux'; 3 | import { login } from '../../features/userSlice'; 4 | import { auth } from '../../firebase'; 5 | import './Login.css'; 6 | 7 | function Login() { 8 | const [email, setEmail] = useState(''); 9 | const [password, setPassword] = useState(''); 10 | const [name, setName] = useState(''); 11 | const [profilePic, setProfilePic] = useState(''); 12 | 13 | const dispatch = useDispatch(); 14 | 15 | const loginToApp = e => { 16 | e.preventDefault(); 17 | auth.signInWithEmailAndPassword(email, password) 18 | .then(userAuth => { 19 | dispatch(login({ 20 | email: userAuth.user.email, 21 | uid: userAuth.user.uid, 22 | displayName: userAuth.user.displayName, 23 | profileUrl: userAuth.user.photoURL, 24 | })) 25 | }) 26 | .catch(error => alert(error)); 27 | }; 28 | 29 | const register = () => { 30 | if (!name) { 31 | return alert("Please enter a full name"); 32 | }; 33 | 34 | auth.createUserWithEmailAndPassword(email, password) 35 | .then(userAuth => { 36 | userAuth.user.updateProfile({ 37 | displayName: name, 38 | photoURL: profilePic, 39 | }) 40 | .then(() => { 41 | dispatch(login({ 42 | email: userAuth.user.email, 43 | uid: userAuth.user.uid, 44 | displayName: name, 45 | photoURL: profilePic, 46 | })) 47 | }) 48 | }).catch(error => alert(error)); 49 | }; 50 | 51 | return ( 52 |
53 | linkin logo 57 | 58 |
59 | setName(e.target.value)} 63 | placeholder="Full name (required if registering)" 64 | /> 65 | setProfilePic(e.target.value)} 69 | placeholder="Profile picture URL (optional)" 70 | /> 71 | setEmail(e.target.value)} 75 | placeholder="Email" 76 | /> 77 | setPassword(e.target.value)} 81 | placeholder="Password" 82 | /> 83 | 84 |
85 |

86 | Not a member? {" "} 87 | Register Now 88 |

89 |
90 | ); 91 | } 92 | 93 | export default Login 94 | -------------------------------------------------------------------------------- /.github/workflows/google.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a docker container, publish it to Google Container Registry, and deploy it to GKE when there is a push to the master branch. 2 | # 3 | # To configure this workflow: 4 | # 5 | # 1. Ensure that your repository contains the necessary configuration for your Google Kubernetes Engine cluster, including deployment.yml, kustomization.yml, service.yml, etc. 6 | # 7 | # 2. Set up secrets in your workspace: GKE_PROJECT with the name of the project and GKE_SA_KEY with the Base64 encoded JSON service account key (https://github.com/GoogleCloudPlatform/github-actions/tree/docs/service-account-key/setup-gcloud#inputs). 8 | # 9 | # 3. Change the values for the GKE_ZONE, GKE_CLUSTER, IMAGE, and DEPLOYMENT_NAME environment variables (below). 10 | # 11 | # For more support on how to run the workflow, please visit https://github.com/google-github-actions/setup-gcloud/tree/master/example-workflows/gke 12 | 13 | name: Build and Deploy to GKE 14 | 15 | on: 16 | push: 17 | branches: 18 | - master 19 | 20 | env: 21 | PROJECT_ID: ${{ secrets.GKE_PROJECT }} 22 | GKE_CLUSTER: cluster-1 # TODO: update to cluster name 23 | GKE_ZONE: us-central1-c # TODO: update to cluster zone 24 | DEPLOYMENT_NAME: gke-test # TODO: update to deployment name 25 | IMAGE: static-site 26 | 27 | jobs: 28 | setup-build-publish-deploy: 29 | name: Setup, Build, Publish, and Deploy 30 | runs-on: ubuntu-latest 31 | environment: production 32 | 33 | steps: 34 | - name: Checkout 35 | uses: actions/checkout@v2 36 | 37 | # Setup gcloud CLI 38 | - uses: google-github-actions/setup-gcloud@v0.2.0 39 | with: 40 | service_account_key: ${{ secrets.GKE_SA_KEY }} 41 | project_id: ${{ secrets.GKE_PROJECT }} 42 | 43 | # Configure Docker to use the gcloud command-line tool as a credential 44 | # helper for authentication 45 | - run: |- 46 | gcloud --quiet auth configure-docker 47 | 48 | # Get the GKE credentials so we can deploy to the cluster 49 | - uses: google-github-actions/get-gke-credentials@v0.2.1 50 | with: 51 | cluster_name: ${{ env.GKE_CLUSTER }} 52 | location: ${{ env.GKE_ZONE }} 53 | credentials: ${{ secrets.GKE_SA_KEY }} 54 | 55 | # Build the Docker image 56 | - name: Build 57 | run: |- 58 | docker build \ 59 | --tag "gcr.io/$PROJECT_ID/$IMAGE:$GITHUB_SHA" \ 60 | --build-arg GITHUB_SHA="$GITHUB_SHA" \ 61 | --build-arg GITHUB_REF="$GITHUB_REF" \ 62 | . 63 | 64 | # Push the Docker image to Google Container Registry 65 | - name: Publish 66 | run: |- 67 | docker push "gcr.io/$PROJECT_ID/$IMAGE:$GITHUB_SHA" 68 | 69 | # Set up kustomize 70 | - name: Set up Kustomize 71 | run: |- 72 | curl -sfLo kustomize https://github.com/kubernetes-sigs/kustomize/releases/download/v3.1.0/kustomize_3.1.0_linux_amd64 73 | chmod u+x ./kustomize 74 | 75 | # Deploy the Docker image to the GKE cluster 76 | - name: Deploy 77 | run: |- 78 | ./kustomize edit set image gcr.io/PROJECT_ID/IMAGE:TAG=gcr.io/$PROJECT_ID/$IMAGE:$GITHUB_SHA 79 | ./kustomize build . | kubectl apply -f - 80 | kubectl rollout status deployment/$DEPLOYMENT_NAME 81 | kubectl get services -o wide 82 | -------------------------------------------------------------------------------- /.eslintcache: -------------------------------------------------------------------------------- 1 | [{"/home/jsloyalty/Desktop/Redux/linkedin-clone/src/serviceWorker.js":"1","/home/jsloyalty/Desktop/Redux/linkedin-clone/src/App.js":"2","/home/jsloyalty/Desktop/Redux/linkedin-clone/src/components/Header/Header.js":"3","/home/jsloyalty/Desktop/Redux/linkedin-clone/src/components/Header/HeaderOption.js":"4","/home/jsloyalty/Desktop/Redux/linkedin-clone/src/app/store.js":"5","/home/jsloyalty/Desktop/Redux/linkedin-clone/src/components/Body/Sidebar/Sidebar.js":"6","/home/jsloyalty/Desktop/Redux/linkedin-clone/src/components/Body/Feed/Feed.js":"7","/home/jsloyalty/Desktop/Redux/linkedin-clone/src/components/Body/Feed/InputOption.js":"8","/home/jsloyalty/Desktop/Redux/linkedin-clone/src/index.js":"9","/home/jsloyalty/Desktop/Redux/linkedin-clone/src/components/Body/Post/Post.js":"10","/home/jsloyalty/Desktop/Redux/linkedin-clone/src/firebase.js":"11","/home/jsloyalty/Desktop/Redux/linkedin-clone/src/features/userSlice.js":"12","/home/jsloyalty/Desktop/Redux/linkedin-clone/src/components/Login/Login.js":"13","/home/jsloyalty/Desktop/Redux/linkedin-clone/src/components/Body/Widget/Widgets.js":"14"},{"size":5141,"mtime":1609512073771,"results":"15","hashOfConfig":"16"},{"size":1291,"mtime":1609608464040,"results":"17","hashOfConfig":"16"},{"size":1563,"mtime":1609605044295,"results":"18","hashOfConfig":"16"},{"size":646,"mtime":1609605246525,"results":"19","hashOfConfig":"16"},{"size":186,"mtime":1609593687908,"results":"20","hashOfConfig":"16"},{"size":1519,"mtime":1609620460776,"results":"21","hashOfConfig":"16"},{"size":2433,"mtime":1609607344300,"results":"22","hashOfConfig":"16"},{"size":242,"mtime":1609569396906,"results":"23","hashOfConfig":"16"},{"size":644,"mtime":1609512073771,"results":"24","hashOfConfig":"16"},{"size":1251,"mtime":1609620915932,"results":"25","hashOfConfig":"16"},{"size":530,"mtime":1609586978067,"results":"26","hashOfConfig":"16"},{"size":706,"mtime":1609593580785,"results":"27","hashOfConfig":"16"},{"size":2551,"mtime":1609602939630,"results":"28","hashOfConfig":"16"},{"size":836,"mtime":1609610247636,"results":"29","hashOfConfig":"16"},{"filePath":"30","messages":"31","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"32"},"15i2twh",{"filePath":"33","messages":"34","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"32"},{"filePath":"35","messages":"36","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"32"},{"filePath":"37","messages":"38","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"32"},{"filePath":"39","messages":"40","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"32"},{"filePath":"41","messages":"42","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"43","messages":"44","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"32"},{"filePath":"45","messages":"46","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"32"},{"filePath":"47","messages":"48","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"32"},{"filePath":"49","messages":"50","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"51","messages":"52","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"32"},{"filePath":"53","messages":"54","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"32"},{"filePath":"55","messages":"56","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"32"},{"filePath":"57","messages":"58","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/home/jsloyalty/Desktop/Redux/linkedin-clone/src/serviceWorker.js",[],["59","60"],"/home/jsloyalty/Desktop/Redux/linkedin-clone/src/App.js",[],"/home/jsloyalty/Desktop/Redux/linkedin-clone/src/components/Header/Header.js",[],"/home/jsloyalty/Desktop/Redux/linkedin-clone/src/components/Header/HeaderOption.js",[],"/home/jsloyalty/Desktop/Redux/linkedin-clone/src/app/store.js",[],"/home/jsloyalty/Desktop/Redux/linkedin-clone/src/components/Body/Sidebar/Sidebar.js",[],"/home/jsloyalty/Desktop/Redux/linkedin-clone/src/components/Body/Feed/Feed.js",[],"/home/jsloyalty/Desktop/Redux/linkedin-clone/src/components/Body/Feed/InputOption.js",[],"/home/jsloyalty/Desktop/Redux/linkedin-clone/src/index.js",[],"/home/jsloyalty/Desktop/Redux/linkedin-clone/src/components/Body/Post/Post.js",[],"/home/jsloyalty/Desktop/Redux/linkedin-clone/src/firebase.js",[],"/home/jsloyalty/Desktop/Redux/linkedin-clone/src/features/userSlice.js",[],"/home/jsloyalty/Desktop/Redux/linkedin-clone/src/components/Login/Login.js",[],"/home/jsloyalty/Desktop/Redux/linkedin-clone/src/components/Body/Widget/Widgets.js",[],{"ruleId":"61","replacedBy":"62"},{"ruleId":"63","replacedBy":"64"},"no-native-reassign",["65"],"no-negated-in-lhs",["66"],"no-global-assign","no-unsafe-negation"] -------------------------------------------------------------------------------- /src/serviceWorker.js: -------------------------------------------------------------------------------- 1 | // This optional code is used to register a service worker. 2 | // register() is not called by default. 3 | 4 | // This lets the app load faster on subsequent visits in production, and gives 5 | // it offline capabilities. However, it also means that developers (and users) 6 | // will only see deployed updates on subsequent visits to a page, after all the 7 | // existing tabs open on the page have been closed, since previously cached 8 | // resources are updated in the background. 9 | 10 | // To learn more about the benefits of this model and instructions on how to 11 | // opt-in, read https://bit.ly/CRA-PWA 12 | 13 | const isLocalhost = Boolean( 14 | window.location.hostname === 'localhost' || 15 | // [::1] is the IPv6 localhost address. 16 | window.location.hostname === '[::1]' || 17 | // 127.0.0.0/8 are considered localhost for IPv4. 18 | window.location.hostname.match( 19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ 20 | ) 21 | ); 22 | 23 | export function register(config) { 24 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { 25 | // The URL constructor is available in all browsers that support SW. 26 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href); 27 | if (publicUrl.origin !== window.location.origin) { 28 | // Our service worker won't work if PUBLIC_URL is on a different origin 29 | // from what our page is served on. This might happen if a CDN is used to 30 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374 31 | return; 32 | } 33 | 34 | window.addEventListener('load', () => { 35 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; 36 | 37 | if (isLocalhost) { 38 | // This is running on localhost. Let's check if a service worker still exists or not. 39 | checkValidServiceWorker(swUrl, config); 40 | 41 | // Add some additional logging to localhost, pointing developers to the 42 | // service worker/PWA documentation. 43 | navigator.serviceWorker.ready.then(() => { 44 | console.log( 45 | 'This web app is being served cache-first by a service ' + 46 | 'worker. To learn more, visit https://bit.ly/CRA-PWA' 47 | ); 48 | }); 49 | } else { 50 | // Is not localhost. Just register service worker 51 | registerValidSW(swUrl, config); 52 | } 53 | }); 54 | } 55 | } 56 | 57 | function registerValidSW(swUrl, config) { 58 | navigator.serviceWorker 59 | .register(swUrl) 60 | .then(registration => { 61 | registration.onupdatefound = () => { 62 | const installingWorker = registration.installing; 63 | if (installingWorker == null) { 64 | return; 65 | } 66 | installingWorker.onstatechange = () => { 67 | if (installingWorker.state === 'installed') { 68 | if (navigator.serviceWorker.controller) { 69 | // At this point, the updated precached content has been fetched, 70 | // but the previous service worker will still serve the older 71 | // content until all client tabs are closed. 72 | console.log( 73 | 'New content is available and will be used when all ' + 74 | 'tabs for this page are closed. See https://bit.ly/CRA-PWA.' 75 | ); 76 | 77 | // Execute callback 78 | if (config && config.onUpdate) { 79 | config.onUpdate(registration); 80 | } 81 | } else { 82 | // At this point, everything has been precached. 83 | // It's the perfect time to display a 84 | // "Content is cached for offline use." message. 85 | console.log('Content is cached for offline use.'); 86 | 87 | // Execute callback 88 | if (config && config.onSuccess) { 89 | config.onSuccess(registration); 90 | } 91 | } 92 | } 93 | }; 94 | }; 95 | }) 96 | .catch(error => { 97 | console.error('Error during service worker registration:', error); 98 | }); 99 | } 100 | 101 | function checkValidServiceWorker(swUrl, config) { 102 | // Check if the service worker can be found. If it can't reload the page. 103 | fetch(swUrl, { 104 | headers: { 'Service-Worker': 'script' }, 105 | }) 106 | .then(response => { 107 | // Ensure service worker exists, and that we really are getting a JS file. 108 | const contentType = response.headers.get('content-type'); 109 | if ( 110 | response.status === 404 || 111 | (contentType != null && contentType.indexOf('javascript') === -1) 112 | ) { 113 | // No service worker found. Probably a different app. Reload the page. 114 | navigator.serviceWorker.ready.then(registration => { 115 | registration.unregister().then(() => { 116 | window.location.reload(); 117 | }); 118 | }); 119 | } else { 120 | // Service worker found. Proceed as normal. 121 | registerValidSW(swUrl, config); 122 | } 123 | }) 124 | .catch(() => { 125 | console.log( 126 | 'No internet connection found. App is running in offline mode.' 127 | ); 128 | }); 129 | } 130 | 131 | export function unregister() { 132 | if ('serviceWorker' in navigator) { 133 | navigator.serviceWorker.ready.then(registration => { 134 | registration.unregister(); 135 | }); 136 | } 137 | } 138 | --------------------------------------------------------------------------------