Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ibukun-okunfolami committed Aug 4, 2022
0 parents commit fbe2442
Show file tree
Hide file tree
Showing 45 changed files with 10,435 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# These are some examples of commonly ignored file patterns.
# You should customize this list as applicable to your project.
# Learn more about .gitignore:
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore

# Node artifact files
node_modules/
dist/

# Compiled Java class files
*.class

# Compiled Python bytecode
*.py[cod]

# Log files
*.log

# Package files
*.jar

# Maven
target/
dist/

# JetBrains IDE
.idea/

# Unit test reports
TEST*.xml

# Generated by MacOS
.DS_Store

# Generated by Windows
Thumbs.db

# Applications
*.app
*.exe
*.war

# Large media files
*.mp4
*.tiff
*.avi
*.flv
*.mov
*.wmv

.vercel

README.md
54 changes: 54 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "gcreacttest",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"dependencies": {
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^28.1.6",
"@types/node": "^18.0.6",
"@types/react": "^18.0.15",
"@types/react-dom": "^18.0.6",
"axios": "^0.27.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router": "5.3.3",
"react-router-dom": "5.3.3",
"react-scripts": "5.0.1",
"sass": "^1.53.0",
"typescript": "^4.7.4",
"web-vitals": "^2.1.4"
},
"devDependencies": {
"@types/react-router-dom": "^5.3.3",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.7.1"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest",
"plugin:prettier/recommended"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file added public/Images/huma.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/favicon.ico
Binary file not shown.
43 changes: 43 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Gain Changer</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
Binary file added public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"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"
}
3 changes: 3 additions & 0 deletions public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
8 changes: 8 additions & 0 deletions src/App.test.tsx
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();
});
84 changes: 84 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import Navbar from 'components/Navbar'
import ScrollToTop from 'components/ScrollToTop'
import Sidebar from 'components/Sidebar'
import ErrorHandler from 'ErrorHandler'
import Countries from 'pages/Countries/Countries'
import Dashboard from 'pages/Dashboard/Dashboard'
import React, { useEffect, useRef, useState } from 'react'
import {
BrowserRouter as Router,
Route,
Switch,
Redirect,
useLocation,
} from 'react-router-dom'

const App = () => {
return (
<Router>
<ErrorHandler>
<Root />
</ErrorHandler>
</Router>
)
}

const Root = () => {
let location = useLocation()
const [showSidebar, setShowSidebar] = useState<boolean>(false)
const sidebarRef = useRef<HTMLDivElement>(null)

window.addEventListener('mousedown', hideSidebar)

function hideSidebar(event: MouseEvent) {
const target = event.target as HTMLElement
if (sidebarRef.current && sidebarRef.current.contains(target)) {
return ''
}
setShowSidebar(false)
}

useEffect(() => {
if (showSidebar) {
setShowSidebar(false)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [location.pathname])

useEffect(() => {
return () => {
window.removeEventListener('mousedown', hideSidebar)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

function toggleSidebar(): void {
setShowSidebar(!showSidebar)
}
return (
<div className="app">
<div className="app-container">
<div
className={`left-col ${showSidebar ? 'show-left' : 'hide-left'}`}
ref={sidebarRef}
>
<Sidebar />
</div>

<div className="right-col">
<Navbar toggleSidebar={toggleSidebar} />
<div className="route-container">
<ScrollToTop />
<Switch>
<Route exact path="/" component={Dashboard} />
<Route exact path="/countries" component={Countries} />
<Redirect to="/" />
</Switch>
</div>
</div>
</div>
</div>
)
}

export default App
23 changes: 23 additions & 0 deletions src/ErrorHandler.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as React from 'react'

type Props = {
children: React.ReactNode
}

type State = {
error?: Error
}

export default class ErrorHandler extends React.Component<Props, State> {
state = {
error: undefined,
}

componentDidCatch(error: Error) {
this.setState({ error })
}

render() {
return this.state.error ? <div>Error?</div> : this.props.children
}
}
Binary file added src/assests/fonts/BR-Firma-Bold.woff
Binary file not shown.
Binary file added src/assests/fonts/BR-Firma-Light.woff
Binary file not shown.
Binary file added src/assests/fonts/BR-Firma-Regular.woff
Binary file not shown.
Binary file added src/assests/fonts/BR-Firma-Thin.woff
Binary file not shown.
28 changes: 28 additions & 0 deletions src/components/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react'
import '../styles/components/navbar.scss'

type Props = {
toggleSidebar: () => void
}

const Navbar = ({ toggleSidebar }: Props) => {
return (
<div className="navbar">
<div className="nav">
<div role="button" className="nav-toggle" onClick={toggleSidebar}>
<div className="bar"></div>
<div className="bar"></div>
<div className="bar"></div>
</div>
<h3>Gain Temp</h3>
</div>
<div className="user-profile">
<div className="border">
<img src={'Images/huma.png'} alt="profile" />
</div>
</div>
</div>
)
}

export default Navbar
14 changes: 14 additions & 0 deletions src/components/ScrollToTop.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { useEffect } from 'react'
import { useLocation } from 'react-router-dom'

const ScrollToTop = () => {
const { pathname } = useLocation()

useEffect(() => {
window.scrollTo(0, 0)
}, [pathname])

return null
}

export default ScrollToTop
35 changes: 35 additions & 0 deletions src/components/Select.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react'
import '../styles/components/select.scss'

type Props = {
name: string
value: string
onChange: (event: React.ChangeEvent<HTMLSelectElement>) => void
options: Array<{ name: string; value: number | string }>
disabled?: boolean
width?: string
}

const Select = ({ name, value, disabled, onChange, options, width }: Props) => {
return (
<div className="select-wrapper">
<select
name={name}
className="select__input"
value={value}
disabled={disabled}
onChange={onChange}
style={{ width: width || '' }}
>
{options.length > 0 &&
options.map((opt, i) => (
<option key={i} value={opt.value}>
{opt.name}
</option>
))}
</select>
</div>
)
}

export default Select
Loading

0 comments on commit fbe2442

Please sign in to comment.