Skip to content

Commit

Permalink
Linted program
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasonnyang committed Aug 7, 2023
1 parent 957ff30 commit 1a6565b
Show file tree
Hide file tree
Showing 18 changed files with 1,343 additions and 513 deletions.
960 changes: 857 additions & 103 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"lint": "eslint . --ext .tsx"
},
"eslintConfig": {
"extends": [
Expand All @@ -50,10 +51,11 @@
]
},
"devDependencies": {
"@shopify/eslint-plugin": "^42.1.0",
"@types/geojson": "^7946.0.10",
"@types/leaflet": "^1.9.3",
"@typescript-eslint/parser": "^5.0.1",
"eslint": "^8.7.0",
"eslint": "^8.46.0",
"prettier": "^2.5.1",
"react-router-dom": "^6.8.1",
"ts-loader": "^9.4.2",
Expand Down
9 changes: 6 additions & 3 deletions src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { render, screen } from '@testing-library/react';
import App from './App';
// Not using jsx
/* eslint-disable react/react-in-jsx-scope */
import { render, screen } from "@testing-library/react";

test('renders learn react link', () => {
import App from "./App";

test("renders learn react link", () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
Expand Down
48 changes: 23 additions & 25 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
import * as React from 'react';
import * as ReactDom from "react-dom";
import 'leaflet/dist/leaflet.css';
import './App.css';
import {createBrowserRouter,
RouterProvider,
} from "react-router-dom";

import Home from "./pages/HomePage"
import Visualization from "./pages/Visualization"
import Profile from "./pages/Profile"
import AboutUs from './pages/AboutUs';
import * as React from "react";
import "leaflet/dist/leaflet.css";
import "./App.css";
import { createBrowserRouter, RouterProvider } from "react-router-dom";

import Home from "./pages/HomePage";
import Visualization from "./pages/Visualization";
import Profile from "./pages/Profile";
import AboutUs from "./pages/AboutUs";

const router = createBrowserRouter([
{
path: "/",
element: <Home />,
},
{
path: "/AboutUs" ,
element: <AboutUs />
},
path: "/AboutUs",
element: <AboutUs />,
},
{
path: "/Visualization" ,
element: <Visualization />
path: "/Visualization",
element: <Visualization />,
},
{
path: "/Profile" ,
element: <Profile />
}
])
path: "/Services",
element: <AboutUs />,
},
{
path: "/Profile",
element: <Profile />,
},
]);
export default function App() {
return (
<RouterProvider router={router} />
);
}
return <RouterProvider router={router} />;
}
79 changes: 44 additions & 35 deletions src/components/Dropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,46 +1,55 @@
import React, { useState, useEffect } from 'react';
// Don't need keyboard alternatives for mouse click events
/* eslint-disable jsx-a11y/click-events-have-key-events */
import React, { useState, useEffect } from "react";
import "../assets/css/dropdown.css";

interface DropdownProps {
options: String[],
selected: String,
setSelected: (value: String)=>void
};
options: string[];
selected: string;
setSelected: (value: string) => void;
}

export default function Dropdown(props: DropdownProps) {
const [open, setOpen] = useState<boolean>(false)
const [open, setOpen] = useState<boolean>(false);

// i don't know what type event should be
const handleOpen = (e: { stopPropagation: () => void; }) => {
e.stopPropagation();
setOpen(() => !open)
}
// i don't know what type event should be
const handleOpen = (event: { stopPropagation: () => void }) => {
event.stopPropagation();
setOpen(() => !open);
};

const handleSelectOption = (value: String) => {
props.setSelected(value);
setOpen(false);
}
const handleSelectOption = (value: string) => {
props.setSelected(value);
setOpen(false);
};

// close the menu whenever we click outside
useEffect(() => {
const handler = () => setOpen(false);
window.addEventListener("click", handler);
// close the menu whenever we click outside
useEffect(() => {
const handler = () => setOpen(false);
window.addEventListener("click", handler);

return () => {
window.removeEventListener("click", handler);
}
})
return () => {
window.removeEventListener("click", handler);
};
});

return (
<div className='dropdown'>
<div className='dropdown-button' onClick={handleOpen}>{props.selected}</div>
{open && <div className='dropdown-options'>
{React.Children.map(props.options, (option) => (
<div className='dropdown-option' onClick={() => handleSelectOption(option)}>
{option}
</div>
))}
</div>}
return (
<div className="dropdown">
<div className="dropdown-button" onClick={handleOpen}>
{props.selected}
</div>
{open && (
<div className="dropdown-options">
{React.Children.map(props.options, (option) => (
<div
className="dropdown-option"
onClick={() => handleSelectOption(option)}
>
{option}
</div>
))}
</div>
)
}
)}
</div>
);
}
89 changes: 41 additions & 48 deletions src/components/LeafletMap.tsx
Original file line number Diff line number Diff line change
@@ -1,59 +1,52 @@
import {
MapContainer,
TileLayer,
LayersControl,
useMap,
Polygon,
GeoJSON,
} from 'react-leaflet';
import { GeoJsonObject } from 'geojson'
import mapData from "./Classify.json"
import React from 'react';
const center = [40.63463151377654, -97.89969605983609];
import { MapContainer, TileLayer, LayersControl, GeoJSON } from "react-leaflet";
import { GeoJsonObject } from "geojson";
import React from "react";

import mapData from "./Classify.json";

const { BaseLayer } = LayersControl;
export default function LeafletMap() {
return (
<div>
<MapContainer
center={[18.173094, -77.318759]}
zoom={10}
style={{ width: '50vw', height: '60vh', marginLeft:'25vw'}}
className="map"
>
<GeoJSON
data={{
type: "FeatureCollection",
features: mapData.features
} as GeoJsonObject }
/>
<LayersControl>
<BaseLayer checked name="OpenStreetMap">
return (
<>
<MapContainer
center={[18.173094, -77.318759]}
zoom={10}
style={{ width: "50vw", height: "60vh", marginLeft: "25vw" }}
className="map"
>
<GeoJSON
data={
{
type: "FeatureCollection",
features: mapData.features,
} as GeoJsonObject
}
/>
<LayersControl>
<BaseLayer checked name="OpenStreetMap">
<TileLayer
attribution='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
/>
</BaseLayer>
<BaseLayer name="Topography">
</BaseLayer>
<BaseLayer name="Topography">
<TileLayer
attribution='Map data: &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, <a href="http://viewfinderpanoramas.org">SRTM</a> | Map style: &copy; <a href="https://opentopomap.org">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA</a>)'
url='https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png'
url="https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png"
/>
</BaseLayer>
<BaseLayer name="Background Imagery">
</BaseLayer>
<BaseLayer name="Background Imagery">
<TileLayer
attribution='Tiles &copy; Esri &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'
url='https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}'
attribution="Tiles &copy; Esri &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community"
url="https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
/>
</BaseLayer>
</LayersControl>
{/*
<Marker position={[51.505, -0.09]}>
<Popup>
A pretty CSS3 popup. <br /> Easily customizable.
</Popup>
</Marker> */}
</MapContainer>
<button style={{marginLeft:"67vw", fontSize:"1.5vw"}}>Download</button>
</div>
)
}
</BaseLayer>
</LayersControl>
</MapContainer>
{/* eslint-disable-next-line @shopify/jsx-no-hardcoded-content*/}
<button type="submit" style={{ marginLeft: "67vw", fontSize: "1.5vw" }}>
Download
</button>
</>
);
}
84 changes: 46 additions & 38 deletions src/components/MenuBar.tsx
Original file line number Diff line number Diff line change
@@ -1,44 +1,52 @@
import React, { useState } from "react";
import '../assets/css/MenuBar.css';
/* eslint-disable @shopify/jsx-no-hardcoded-content */
import React from "react";
import "../assets/css/MenuBar.css";
import { useAuth0 } from "@auth0/auth0-react";

import { LogoutButton } from "./logout-button";
import { LoginButton } from "./login-button";

export const MenuBar = () => {
const { isAuthenticated } = useAuth0();

return (
<div className="nav">
<div className="container">
<div className="logo">
<a href="/">Mangrove Monitoring</a>
</div>
<div id="mainListDiv" className="main_list">
<ul className="navlinks">
<li><a href="/AboutUs">About Us</a></li>
<li><a href="/Visualization">Visualization</a></li>
<li><a href="#">Services</a></li>
<li><a href="/Profile">Profile</a></li>
{!isAuthenticated && (
<>
<LoginButton />
</>
)}
{isAuthenticated && (
<>
<LogoutButton />
</>
)}
export const MenuBar = () => {
const { isAuthenticated } = useAuth0();

</ul>
</div>
<span className="navTrigger">
<i></i>
<i></i>
<i></i>
</span>
</div>
return (
<div className="nav">
<div className="container">
<div className="logo">
<a href="/">Mangrove Monitoring</a>
</div>
);

}
<div id="mainListDiv" className="main_list">
<ul className="navlinks">
<li>
<a href="/AboutUs">About Us</a>
</li>
<li>
<a href="/Visualization">Visualization</a>
</li>
<li>
<a href="Services">Services</a>
</li>
<li>
<a href="/Profile">Profile</a>
</li>
{!isAuthenticated && (
<>
<LoginButton />
</>
)}
{isAuthenticated && (
<>
<LogoutButton />
</>
)}
</ul>
</div>
<span className="navTrigger">
<i />
<i />
<i />
</span>
</div>
</div>
);
};
Loading

0 comments on commit 1a6565b

Please sign in to comment.