diff --git a/src/App.tsx b/src/App.tsx
index baa3960..acd1830 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -22,11 +22,14 @@ function App() {
))}
+ Settings
+
+
>
);
diff --git a/src/features/guides/hooks/useGuideForm.ts b/src/features/guides/hooks/useGuideForm.ts
index cc014f7..ff12307 100644
--- a/src/features/guides/hooks/useGuideForm.ts
+++ b/src/features/guides/hooks/useGuideForm.ts
@@ -117,7 +117,7 @@ export default function useGuideForm(initial?: CompiledGuideType) {
);
};
- const handleSaveGuide = async (e: React.FormEvent) => {
+ const handleSaveGuide = async (e: React.SubmitEvent) => {
e.preventDefault();
if (!db) return;
@@ -138,6 +138,8 @@ export default function useGuideForm(initial?: CompiledGuideType) {
setGuide(makeEmptyGuide());
setFrames([]);
}
+
+ e.target.reset();
};
return {
diff --git a/src/features/guides/hooks/useSettings.ts b/src/features/guides/hooks/useSettings.ts
new file mode 100644
index 0000000..027f386
--- /dev/null
+++ b/src/features/guides/hooks/useSettings.ts
@@ -0,0 +1,17 @@
+import { useIDB } from "../../../lib/contexts/dbinit.context";
+import { useGuides } from "../../../lib/contexts/guide.context";
+
+export const useSettings = () => {
+ const { db } = useIDB();
+ const { setGuides } = useGuides();
+
+ const deleteAllGuides = () => {
+ if (!db) return;
+ db.clear("guides");
+ setGuides([]);
+ };
+
+ return {
+ deleteAllGuides,
+ };
+};
diff --git a/src/features/guides/routes/Settings.tsx b/src/features/guides/routes/Settings.tsx
new file mode 100644
index 0000000..2a7ec60
--- /dev/null
+++ b/src/features/guides/routes/Settings.tsx
@@ -0,0 +1,11 @@
+import { useSettings } from "../hooks/useSettings";
+
+export default function Settings() {
+ const { deleteAllGuides } = useSettings();
+
+ return (
+
+
+
+ );
+}
diff --git a/src/router.tsx b/src/router.tsx
index be8fda3..ed80c04 100644
--- a/src/router.tsx
+++ b/src/router.tsx
@@ -3,6 +3,7 @@ import App from "./App.tsx";
import GuideForm from "./features/guides/routes/GuideForm.tsx";
import NotFound from "./components/not-found/NotFound.tsx";
import Guide from "./features/guides/routes/Guide.tsx";
+import Settings from "./features/guides/routes/Settings.tsx";
export const router = createBrowserRouter([
{
@@ -21,6 +22,10 @@ export const router = createBrowserRouter([
path: "/edit-guide/:id",
Component: GuideForm,
},
+ {
+ path: "/settings",
+ Component: Settings,
+ },
],
},
{
diff --git a/src/styles/App.css b/src/styles/App.css
index ab718b6..f9289fa 100644
--- a/src/styles/App.css
+++ b/src/styles/App.css
@@ -8,10 +8,10 @@
html,
body {
font-family: system-ui, Arial, sans-serif;
+ position: relative;
}
#root {
- display: flex;
min-height: 100vh;
}
@@ -21,7 +21,9 @@ body {
}
header {
- flex: 0 0 var(--sidebar-width);
+ position: fixed;
+ height: 100%;
+ width: var(--sidebar-width);
padding: 1rem;
display: flex;
flex-direction: column;
@@ -31,18 +33,19 @@ header {
}
main {
+ margin-left: var(--sidebar-width);
flex: 1;
padding: 1rem;
}
footer {
- position: absolute;
+ position: fixed;
bottom: 0;
left: 0;
- right: 0;
margin: 0 auto;
- padding-block: 0.5rem;
+ padding: 0.5rem;
text-align: center;
+ width: var(--sidebar-width);
}
nav {