Skip to content

Commit

Permalink
added back prettier (#461)
Browse files Browse the repository at this point in the history
  • Loading branch information
GhostOf0days authored Feb 24, 2024
1 parent 04939b8 commit 24d5406
Show file tree
Hide file tree
Showing 26 changed files with 1,340 additions and 1,232 deletions.
27 changes: 27 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"bracketSpacing": true,
"printWidth": 80,
"proseWrap": "preserve",
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"tabWidth": 4,
"useTabs": true,
"arrowParens": "always",
"endOfLine": "lf",
"overrides": [
{
"files": "*.json",
"options": {
"singleQuote": false
}
},
{
"files": ".*rc",
"options": {
"singleQuote": false,
"parser": "json"
}
}
]
}
116 changes: 58 additions & 58 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,100 +1,100 @@
:root {
--navbar-height: 70px;
--navbar-height: calc(56px + max(env(safe-area-inset-bottom), 14px));
--navbar-height: 70px;
--navbar-height: calc(56px + max(env(safe-area-inset-bottom), 14px));
}

html,
body,
#root,
.App {
height: 100%;
height: 100%;
}

html,
body {
background-color: #2c2f33;
margin: 0;
padding: 0;
font-size: 14px;
font-family:
"Inter",
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
"Roboto",
"Oxygen",
"Ubuntu",
"Cantarell",
"Fira Sans",
"Droid Sans",
"Helvetica Neue",
sans-serif;
text-rendering: optimizeLegibility;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
-webkit-text-size-adjust: 100%;
background-color: #2c2f33;
margin: 0;
padding: 0;
font-size: 14px;
font-family:
'Inter',
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
'Roboto',
'Oxygen',
'Ubuntu',
'Cantarell',
'Fira Sans',
'Droid Sans',
'Helvetica Neue',
sans-serif;
text-rendering: optimizeLegibility;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
-webkit-text-size-adjust: 100%;
}

.App {
text-align: left;
background-color: #2c2f33;
display: flex;
flex-direction: column;
text-align: left;
background-color: #2c2f33;
display: flex;
flex-direction: column;
}

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

.MainContent {
overflow: auto;
flex: 1;
overflow: auto;
flex: 1;
}

@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
.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;
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;
color: #61dafb;
}

.Container {
padding: 1.5rem 3rem 0;
flex-grow: 1;
padding: 1.5rem 3rem 0;
flex-grow: 1;
}

.footer {
margin-top: 80px;
background-color: #23272a;
padding: 40px;
min-height: 130px;
margin-top: 80px;
background-color: #23272a;
padding: 40px;
min-height: 130px;
}

.MuiCard-root {
display: flex;
flex-direction: column;
justify-content: space-between;
display: flex;
flex-direction: column;
justify-content: space-between;
}

.announcement {
padding: 1rem;
font-size: 1.2em;
color: white;
text-align: center;
background-color: #23272a;
padding: 1rem;
font-size: 1.2em;
color: white;
text-align: center;
background-color: #23272a;
}
156 changes: 81 additions & 75 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,89 +1,95 @@
import React, { useEffect, useState } from "react";
import { BrowserRouter, Route, Routes } from "react-router-dom";
import { DateTime } from "luxon";
import React, { useEffect, useState } from 'react';
import { BrowserRouter, Route, Routes } from 'react-router-dom';
import { DateTime } from 'luxon';

import Navbar from "./components/Navbar";
import ListPage from "./pages/ListPage";
import MapPage from "./pages/MapPage";
import NotFoundPage from "./pages/NotFoundPage";
import { queryLocations, getLocationStatus } from "./util/queryLocations";
import "./App.css";
import Navbar from './components/Navbar';
import ListPage from './pages/ListPage';
import MapPage from './pages/MapPage';
import NotFoundPage from './pages/NotFoundPage';
import { queryLocations, getLocationStatus } from './util/queryLocations';
import './App.css';
import {
IReadOnlyExtendedLocation,
IReadOnlyLocation,
} from "./types/locationTypes";
IReadOnlyExtendedLocation,
IReadOnlyLocation,
} from './types/locationTypes';

const CMU_EATS_API_URL = "https://dining.apis.scottylabs.org/locations";
const CMU_EATS_API_URL = 'https://dining.apis.scottylabs.org/locations';
// const CMU_EATS_API_URL = 'http://localhost:5173/example-response.json'; // for debugging purposes (note that you need an example-response.json file in the /public folder)
// const CMU_EATS_API_URL = 'http://localhost:5010/locations'; // for debugging purposes (note that you need an example-response.json file in the /public folder)
function App() {
// Load locations
const [locations, setLocations] = useState<IReadOnlyLocation[]>();
const [extendedLocationData, setExtendedLocationData] =
useState<IReadOnlyExtendedLocation[]>();
useEffect(() => {
queryLocations(CMU_EATS_API_URL).then((parsedLocations) => {
setLocations(parsedLocations);
});
}, []);
// Load locations
const [locations, setLocations] = useState<IReadOnlyLocation[]>();
const [extendedLocationData, setExtendedLocationData] =
useState<IReadOnlyExtendedLocation[]>();
useEffect(() => {
queryLocations(CMU_EATS_API_URL).then((parsedLocations) => {
setLocations(parsedLocations);
});
}, []);

useEffect(() => {
const intervalId = setInterval(
(function updateExtendedLocationData() {
if (locations !== undefined) {
// Remove .setZone('America/New_York') and change time in computer settings when testing
// Alternatively, simply set now = DateTime.local(2023, 12, 22, 18, 33); where the parameters are Y,M,D,H,M
const now = DateTime.now().setZone("America/New_York");
setExtendedLocationData(
locations.map((location) => ({
...location,
...getLocationStatus(location.times, now), // populate location with more detailed info relevant to current time
})),
);
}
return updateExtendedLocationData; // returns itself here
})(), // self-invoking function
1 * 1000, // updates every second
);
return () => clearInterval(intervalId);
}, [locations]);
useEffect(() => {
const intervalId = setInterval(
(function updateExtendedLocationData() {
if (locations !== undefined) {
// Remove .setZone('America/New_York') and change time in computer settings when testing
// Alternatively, simply set now = DateTime.local(2023, 12, 22, 18, 33); where the parameters are Y,M,D,H,M
const now = DateTime.now().setZone('America/New_York');
setExtendedLocationData(
locations.map((location) => ({
...location,
...getLocationStatus(location.times, now), // populate location with more detailed info relevant to current time
})),
);
}
return updateExtendedLocationData; // returns itself here
})(), // self-invoking function
1 * 1000, // updates every second
);
return () => clearInterval(intervalId);
}, [locations]);

// Auto-refresh the page when the user goes online after previously being offline
useEffect(() => {
function handleOnline() {
if (navigator.onLine) {
// Refresh the page
window.location.reload();
}
}
// Auto-refresh the page when the user goes online after previously being offline
useEffect(() => {
function handleOnline() {
if (navigator.onLine) {
// Refresh the page
window.location.reload();
}
}

window.addEventListener("online", handleOnline);
window.addEventListener('online', handleOnline);

return () => window.removeEventListener("online", handleOnline);
}, []);
return () => window.removeEventListener('online', handleOnline);
}, []);

return (
<React.StrictMode>
<BrowserRouter>
<div className="App">
<div className="MainContent">
<Routes>
<Route
path="/"
element={<ListPage locations={extendedLocationData} />}
/>
<Route
path="/map"
element={<MapPage locations={extendedLocationData} />}
/>
<Route path="*" element={<NotFoundPage />} />
</Routes>
</div>
<Navbar />
</div>
</BrowserRouter>
</React.StrictMode>
);
return (
<React.StrictMode>
<BrowserRouter>
<div className="App">
<div className="MainContent">
<Routes>
<Route
path="/"
element={
<ListPage
locations={extendedLocationData}
/>
}
/>
<Route
path="/map"
element={
<MapPage locations={extendedLocationData} />
}
/>
<Route path="*" element={<NotFoundPage />} />
</Routes>
</div>
<Navbar />
</div>
</BrowserRouter>
</React.StrictMode>
);
}

export default App;
Loading

0 comments on commit 24d5406

Please sign in to comment.