Skip to content

Commit

Permalink
Add connection indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
audrey-yang committed Dec 16, 2024
1 parent f5ce27f commit 5a84c4a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "taskflow2",
"version": "0.1.5",
"version": "0.1.6",
"description": "a little task manager",
"main": ".vite/build/main/index.js",
"author": "@audrey-yang",
Expand Down
15 changes: 12 additions & 3 deletions src/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { createTheme, ThemeProvider } from "@mui/material/styles";
import CssBaseline from "@mui/material/CssBaseline";
import Typography from "@mui/material/Typography";
import { STATUS } from "./types";
import DuckClose from "./assets/duck-close.png";
import DuckOpen from "./assets/duck-open.png";

const Header = lazy(() => import("./components/Header"));
const TaskList = lazy(() => import("./components/TaskList"));
Expand All @@ -22,6 +24,11 @@ const darkTheme = createTheme({
});

const App: () => JSX.Element = () => {
// Connection status
const [isConnected, setIsConnected] = useState(window.navigator.onLine);
window.addEventListener("online", () => setIsConnected(true));
window.addEventListener("offline", () => setIsConnected(false));

const [isLoggedIn, setIsLoggedIn] = useState(
window.localStorage.getItem("loggedIn") === "y" &&
window.localStorage.getItem("username") != null &&
Expand Down Expand Up @@ -51,10 +58,12 @@ const App: () => JSX.Element = () => {
return (
<ThemeProvider theme={darkTheme}>
<CssBaseline />

<div className="App">
<Typography variant="h3" className="my-2">
Taskflow
</Typography>
<div className="flex flex-row items-center">
<Typography variant="h2">Taskflow</Typography>
<img src={isConnected ? DuckOpen : DuckClose} alt="connection status" className="h-24" />
</div>
{isLoggedIn ? (
<>
<Header
Expand Down
Binary file added src/renderer/assets/duck-close.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 src/renderer/assets/duck-open.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5a84c4a

Please sign in to comment.