Skip to content

Commit 41d3194

Browse files
authored
Merge pull request #55 from abiddiscombe/dev
Release v1.5.2 - Dev to Main
2 parents d935258 + 2a6a9e0 commit 41d3194

16 files changed

+204
-185
lines changed

Diff for: package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "notedeck",
33
"private": true,
4-
"version": "1.5.1",
4+
"version": "1.5.2",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",

Diff for: src/App.tsx

+28-63
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,36 @@
1-
import { createContext, useEffect, useState } from "react";
21
import { isMobile } from "react-device-detect";
3-
import { serviceSettings } from "./database/serviceSettings";
4-
import { AppUnsupported } from "./AppUnsupported";
5-
import { Main } from "./layout/Main/Main";
6-
import { AppSplash } from "./AppSplash";
7-
import { Header } from "./layout/Header/Header";
8-
import { update } from "./utilities/update";
9-
10-
interface AppContextType {
11-
loaded: boolean;
12-
updateAvailable: boolean;
13-
updateTargetVersion: string;
14-
}
15-
16-
export const AppContext = createContext<AppContextType | null>(null);
2+
import { AppRoot } from "./AppRoot";
3+
import { appInfo } from "./utilities/constants";
4+
import { Typography } from "./components/Typography";
5+
import { ExternalLink } from "./components/ExternalLink";
176

187
export function App() {
19-
const [context, setContext] = useState<AppContextType>({
20-
loaded: false,
21-
updateAvailable: false,
22-
updateTargetVersion: "",
23-
});
24-
25-
async function init() {
26-
await serviceSettings.instantiate();
27-
28-
const autoUpdateCheck = await serviceSettings.read("autoUpdateCheck");
29-
if (autoUpdateCheck) {
30-
const updateCheckEvent = await update.check();
31-
if (updateCheckEvent?.updateAvailable) {
32-
setContext((prevState) => ({
33-
...prevState,
34-
...updateCheckEvent,
35-
}));
36-
}
37-
}
38-
39-
setTimeout(() => {
40-
// Experimental! Increases the visible time
41-
// of the Splash Screen by 250 ms in order to
42-
// reduce "flicker" on app load.
43-
44-
setContext((prevState) => ({
45-
...prevState,
46-
loaded: true,
47-
}));
48-
}, 250);
49-
}
50-
51-
useEffect(() => {
52-
init();
53-
}, []);
54-
55-
if (!context.loaded) {
56-
return <AppSplash />;
57-
}
8+
// If the app is loaded on a mobile device, bypass
9+
// initialization and data loading to improve performance.
5810

5911
if (isMobile) {
60-
return <AppUnsupported />;
61-
}
62-
63-
return (
64-
<AppContext.Provider value={context}>
12+
return (
6513
<div className="grid h-screen grid-rows-[auto,_1fr] bg-primary-50 dark:bg-primary-950">
66-
<Header />
67-
<Main />
14+
<header className="p-10">
15+
<Typography.H1>{appInfo.name}</Typography.H1>
16+
</header>
17+
<main className="m-auto max-w-sm p-10 pb-20">
18+
<Typography.H2>
19+
Sorry, mobile devices are not supported :/
20+
</Typography.H2>
21+
<Typography.Body>
22+
To explore {appInfo.name}, open this page on your
23+
desktop or laptop. More information about {appInfo.name}{" "}
24+
is available in the{" "}
25+
<ExternalLink href={appInfo.sourceUrl}>
26+
project documentation
27+
</ExternalLink>{" "}
28+
on GitHub.
29+
</Typography.Body>
30+
</main>
6831
</div>
69-
</AppContext.Provider>
70-
);
32+
);
33+
}
34+
35+
return <AppRoot />;
7136
}

Diff for: src/AppRoot.tsx

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { createContext, useEffect, useState } from "react";
2+
import { serviceSettings } from "./database/serviceSettings";
3+
import { update } from "./utilities/update";
4+
import { AppSplash } from "./AppSplash";
5+
import { Main } from "./layout/Main/Main";
6+
import { Header } from "./layout/Header/Header";
7+
8+
interface AppContextType {
9+
loaded: boolean;
10+
updateAvailable: boolean;
11+
updateTargetVersion: string;
12+
}
13+
14+
export const AppContext = createContext<AppContextType | null>(null);
15+
16+
export function AppRoot() {
17+
const [context, setContext] = useState<AppContextType>({
18+
loaded: false,
19+
updateAvailable: false,
20+
updateTargetVersion: "",
21+
});
22+
23+
async function init() {
24+
await serviceSettings.instantiate();
25+
26+
const autoUpdateCheck = await serviceSettings.read("autoUpdateCheck");
27+
if (autoUpdateCheck) {
28+
const updateCheckEvent = await update.check();
29+
if (updateCheckEvent?.updateAvailable) {
30+
setContext((prevState) => ({
31+
...prevState,
32+
...updateCheckEvent,
33+
}));
34+
}
35+
}
36+
37+
setTimeout(() => {
38+
// Experimental! Increases the visible time
39+
// of the Splash Screen by 250 ms in order to
40+
// reduce "flicker" on app load.
41+
42+
setContext((prevState) => ({
43+
...prevState,
44+
loaded: true,
45+
}));
46+
}, 250);
47+
}
48+
49+
useEffect(() => {
50+
init();
51+
}, []);
52+
53+
if (!context.loaded) {
54+
return <AppSplash />;
55+
}
56+
57+
return (
58+
<AppContext.Provider value={context}>
59+
<div className="grid h-screen grid-rows-[auto,_1fr] bg-primary-50 dark:bg-primary-950">
60+
<Header />
61+
<Main />
62+
</div>
63+
</AppContext.Provider>
64+
);
65+
}

Diff for: src/AppUnsupported.tsx

-29
This file was deleted.

Diff for: src/components/Dialog.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ export function Dialog(p: DialogProps) {
6161
{p.title}
6262
</Typography.H2>
6363
</DialogTitle>
64-
<CloseButton className="rounded-full outline outline-8 outline-white/0 hover:bg-primary-50 hover:outline-primary-50 active:bg-primary-100 active:outline-primary-100 dark:hover:bg-primary-700 dark:hover:outline-primary-700 dark:active:bg-primary-600 dark:active:outline-primary-600">
64+
<CloseButton
65+
aria-label="Close Dialog"
66+
className="rounded-full outline outline-8 outline-white/0 hover:bg-primary-50 hover:outline-primary-50 active:bg-primary-100 active:outline-primary-100 dark:hover:bg-primary-700 dark:hover:outline-primary-700 dark:active:bg-primary-600 dark:active:outline-primary-600"
67+
>
6568
<XMarkIcon className="h-6 text-primary-600 dark:text-primary-200" />
6669
</CloseButton>
6770
</div>

Diff for: src/layout/Header/Header.tsx

+14-37
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,29 @@
1-
import { useState } from "react";
21
import { useLiveQuery } from "dexie-react-hooks";
32
import { serviceNote } from "../../database/serviceNote";
4-
import { Cog6ToothIcon } from "@heroicons/react/16/solid";
5-
import { Button } from "../../components/Button";
6-
import { Tooltip } from "../../components/Tooltip";
7-
import { Settings } from "../Settings/Settings";
83
import { HeaderLogo } from "./HeaderLogo";
94
import { HeaderBackup } from "./HeaderBackup";
105
import { HeaderNewNote } from "./HeaderNewNote";
116
import { HeaderDeleteNotes } from "./HeaderDeleteNotes";
127
import { HeaderThemeSwitch } from "./HeaderThemeSwitch";
138
import { HeaderUpdateNotification } from "./HeaderUpdateNotification";
9+
import { HeaderSettings } from "./HeaderSettings";
1410

1511
export function Header() {
1612
const notes = useLiveQuery(() => serviceNote.list());
17-
const [showSettings, setShowSettings] = useState(false);
1813

1914
return (
20-
<>
21-
<Settings
22-
isOpen={showSettings}
23-
setIsOpen={setShowSettings}
24-
/>
25-
<header className="flex items-center gap-2 border-b border-b-primary-200 bg-white px-4 py-1.5 dark:border-b-primary-800 dark:bg-primary-900">
26-
<HeaderLogo />
27-
<HeaderUpdateNotification />
28-
{!!notes?.length && (
29-
<>
30-
<HeaderNewNote />
31-
<HeaderDeleteNotes />
32-
</>
33-
)}
34-
<HeaderThemeSwitch />
35-
<HeaderBackup />
36-
<Tooltip
37-
label="Settings"
38-
className="right-0"
39-
>
40-
<Button
41-
size="sm"
42-
variant="ghost"
43-
onClick={() => setShowSettings(true)}
44-
className="bg-primary-50 dark:bg-primary-800"
45-
>
46-
<Cog6ToothIcon />
47-
</Button>
48-
</Tooltip>
49-
</header>
50-
</>
15+
<header className="flex items-center gap-2 border-b border-b-primary-200 bg-white px-4 py-1.5 dark:border-b-primary-800 dark:bg-primary-900">
16+
<HeaderLogo />
17+
<HeaderUpdateNotification />
18+
{!!notes?.length && (
19+
<>
20+
<HeaderNewNote />
21+
<HeaderDeleteNotes />
22+
</>
23+
)}
24+
<HeaderThemeSwitch />
25+
<HeaderBackup />
26+
<HeaderSettings />
27+
</header>
5128
);
5229
}

Diff for: src/layout/Header/HeaderBackup.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { Tooltip } from "../../components/Tooltip";
1111

1212
export function HeaderBackup() {
1313
const [backupDone, setBackupDone] = useState(false);
14+
const label = "Download Backup";
1415

1516
async function handleDownloadBackup() {
1617
const parsedDate = convertDate();
@@ -22,10 +23,11 @@ export function HeaderBackup() {
2223
}
2324

2425
return (
25-
<Tooltip label="Download Backup">
26+
<Tooltip label={label}>
2627
<Button
2728
size="sm"
2829
variant="ghost"
30+
aria-label={label}
2931
className="bg-primary-50 dark:bg-primary-800"
3032
onClick={() => handleDownloadBackup()}
3133
>

Diff for: src/layout/Header/HeaderDeleteNotes.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { Typography } from "../../components/Typography";
1111
export function HeaderDeleteNotes() {
1212
const [showModal, setShowModal] = useState(false);
1313
const [retainPriorityNotes, setRetainPriorityNotes] = useState(true);
14+
const label = "Delete All Notes";
1415

1516
// // Revert the "Retain Priority Notes" checkbox to
1617
// // "checked" when the modal is re-opened.
@@ -60,10 +61,11 @@ export function HeaderDeleteNotes() {
6061
</>
6162
</Button>
6263
</Dialog>
63-
<Tooltip label="Delete All Notes">
64+
<Tooltip label={label}>
6465
<Button
6566
size="sm"
6667
variant="ghost"
68+
aria-label={label}
6769
onClick={() => setShowModal(true)}
6870
className="bg-primary-50 dark:bg-primary-800"
6971
>

Diff for: src/layout/Header/HeaderLogo.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export function HeaderLogo() {
77
<Typography.H1 noMargin={true}>{appInfo.name}</Typography.H1>
88
<Typography.Body
99
noMargin={true}
10-
className="hidden text-[0.7rem] text-primary-400 sm:block dark:text-primary-500"
10+
className="hidden text-[0.7rem] text-primary-700 sm:block dark:text-primary-200"
1111
>
1212
v{appInfo.semVer}
1313
</Typography.Body>

Diff for: src/layout/Header/HeaderNewNote.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { Button } from "../../components/Button";
44
import { Tooltip } from "../../components/Tooltip";
55

66
export function HeaderNewNote() {
7+
const label = "New Note";
8+
79
function handleCreateNote() {
810
serviceNote.create({
911
theme: "yellow",
@@ -13,8 +15,6 @@ export function HeaderNewNote() {
1315
});
1416
}
1517

16-
const label = "New Note";
17-
1818
return (
1919
<Tooltip
2020
label={label}
@@ -23,6 +23,7 @@ export function HeaderNewNote() {
2323
<Button
2424
size="sm"
2525
variant="solid"
26+
aria-label={label}
2627
onClick={() => handleCreateNote()}
2728
>
2829
<PlusIcon />

0 commit comments

Comments
 (0)