learn and share notes on atproto (wip) 馃
malfestio.stormlightlabs.org/
readability
solid
axum
atproto
srs
1import { AppLayout } from "$components/layout/AppLayout";
2import { OnboardingDialog } from "$components/OnboardingDialog";
3import type { Persona } from "$lib/model";
4import { authStore, prefStore } from "$lib/store";
5import About from "$pages/About";
6import DeckNew from "$pages/DeckNew";
7import DeckPreview from "$pages/DeckPreview";
8import DeckView from "$pages/DeckView";
9import Discovery from "$pages/Discovery";
10import Feed from "$pages/Feed";
11import Help from "$pages/Help";
12import Home from "$pages/Home";
13import Import from "$pages/Import";
14import Landing from "$pages/Landing";
15import LectureImport from "$pages/LectureImport";
16import Library from "$pages/Library";
17import Login from "$pages/Login";
18import LoginSuccess from "$pages/LoginSuccess";
19import NoteEdit from "$pages/NoteEdit";
20import NoteNew from "$pages/NoteNew";
21import Notes from "$pages/Notes";
22import NoteView from "$pages/NoteView";
23import NotFound from "$pages/NotFound";
24import Review from "$pages/Review";
25import Search from "$pages/Search";
26import Settings from "$pages/Settings";
27import { Route, Router } from "@solidjs/router";
28import type { Component, ParentComponent } from "solid-js";
29import { createEffect, createSignal, onMount, Show } from "solid-js";
30import { Motion, Presence } from "solid-motionone";
31
32const LoadingScreen: Component = () => (
33 <Motion.div
34 exit={{ opacity: 0 }}
35 transition={{ duration: 0.5 }}
36 class="fixed inset-0 bg-[#161616] flex items-center justify-center z-50">
37 <div class="text-[#0F62FE] animate-spin text-4xl w-12 h-12">
38 <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">
39 <g fill="none" fill-rule="evenodd">
40 <path d="m12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.018-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z" />
41 <path
42 fill="currentColor"
43 d="M12 4.5a7.5 7.5 0 1 0 0 15a7.5 7.5 0 0 0 0-15M1.5 12C1.5 6.201 6.201 1.5 12 1.5S22.5 6.201 22.5 12S17.799 22.5 12 22.5S1.5 17.799 1.5 12"
44 opacity="0.1" />
45 <path
46 fill="currentColor"
47 d="M12 4.5a7.46 7.46 0 0 0-5.187 2.083a1.5 1.5 0 0 1-2.075-2.166A10.46 10.46 0 0 1 12 1.5a1.5 1.5 0 0 1 0 3" />
48 </g>
49 </svg>
50 </div>
51 </Motion.div>
52);
53
54const ProtectedLayout: ParentComponent = (props) => {
55 const [showOnboarding, setShowOnboarding] = createSignal(false);
56
57 onMount(async () => {
58 if (authStore.isAuthenticated()) {
59 await prefStore.fetchPrefs();
60 }
61 });
62
63 createEffect(() => {
64 if (prefStore.needsOnboarding()) {
65 setShowOnboarding(true);
66 }
67 });
68
69 const handleOnboardingComplete = (_persona: Persona) => {
70 setShowOnboarding(false);
71 prefStore.fetchPrefs();
72 };
73
74 return (
75 <Presence>
76 <Show when={authStore.loading()}>
77 <LoadingScreen />
78 </Show>
79 <Show when={!authStore.loading()}>
80 <Show when={authStore.isAuthenticated()} fallback={<Landing />}>
81 <AppLayout>{props.children}</AppLayout>
82 <OnboardingDialog open={showOnboarding()} onComplete={handleOnboardingComplete} />
83 </Show>
84 </Show>
85 </Presence>
86 );
87};
88
89const App: Component = () => {
90 return (
91 <Router>
92 <Route path="/login" component={Login} />
93 <Route path="/login/success" component={LoginSuccess} />
94 <Route path="/about" component={About} />
95 <Route path="/help" component={Help} />
96 <Route path="/" component={ProtectedLayout}>
97 <Route path="/" component={Home} />
98 <Route path="/decks" component={Home} />
99 <Route path="/decks/new" component={DeckNew} />
100 <Route path="/notes/new" component={NoteNew} />
101 <Route path="/notes/edit/:id" component={NoteEdit} />
102 <Route path="/notes/:id" component={NoteView} />
103 <Route path="/notes" component={Notes} />
104 <Route path="/decks/:id" component={DeckView} />
105 <Route path="/import" component={Import} />
106 <Route path="/import/lecture" component={LectureImport} />
107 <Route path="/review" component={Review} />
108 <Route path="/review/:deckId" component={Review} />
109 <Route path="/feed" component={Feed} />
110 <Route path="/search" component={Search} />
111 <Route path="/discovery" component={Discovery} />
112 <Route path="/library" component={Library} />
113 <Route path="/library/preview" component={DeckPreview} />
114 <Route path="/settings" component={Settings} />
115 <Route path="*" component={NotFound} />
116 </Route>
117 </Router>
118 );
119};
120
121export default App;