Skip to content

Commit

Permalink
Frontend started
Browse files Browse the repository at this point in the history
Fixed loading error issue with react.
  • Loading branch information
MHN-Sathsara committed Jul 18, 2024
1 parent 5d9d6b3 commit f7ad96e
Show file tree
Hide file tree
Showing 10 changed files with 9,915 additions and 11,003 deletions.
20,797 changes: 9,827 additions & 10,970 deletions frontend/package-lock.json

Large diffs are not rendered by default.

10 changes: 2 additions & 8 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"@testing-library/user-event": "^13.5.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.24.1",
"react-scripts": "^3.0.1",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand All @@ -35,10 +34,5 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"description": "This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).",
"main": "index.js",
"keywords": [],
"author": "",
"license": "ISC"
}
}
38 changes: 38 additions & 0 deletions frontend/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.App {
text-align: center;
}

.App-logo {
height: 40vmin;
pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}

.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}

.App-link {
color: #61dafb;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
31 changes: 16 additions & 15 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import {BrowserRouter as Router, Route, Routes} from "react-router-dom";


//pages and com

import Home from "./pages/Home";
import logo from './logo.svg';
import './App.css';

function App() {
return (
<div className="App">
<BrowserRouter>
<div className="pages">
<Routes>
<Route path="/"
element={<Home/>} />
</Routes>
</div>

</BrowserRouter>
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/App.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { render, screen } from '@testing-library/react';
import App from './App';

test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
9 changes: 0 additions & 9 deletions frontend/src/Pages/Home.js

This file was deleted.

6 changes: 5 additions & 1 deletion frontend/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';

import reportWebVitals from './reportWebVitals';

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
Expand All @@ -11,3 +11,7 @@ root.render(
</React.StrictMode>
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
1 change: 1 addition & 0 deletions frontend/src/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions frontend/src/reportWebVitals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const reportWebVitals = onPerfEntry => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};

export default reportWebVitals;
5 changes: 5 additions & 0 deletions frontend/src/setupTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';

0 comments on commit f7ad96e

Please sign in to comment.