-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.tsx
More file actions
70 lines (64 loc) · 2.1 KB
/
app.tsx
File metadata and controls
70 lines (64 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// @refresh reload
// file: src/app.tsx
import { mergeProps, Suspense } from 'solid-js';
import { Route, Router, useSearchParams } from '@solidjs/router';
import { MetaProvider } from '@solidjs/meta';
import { EditButton } from './components/edit-button';
import { SearchField } from './components/search-field';
import { BriefList } from './components/brief-list';
import { Note } from './routes/note';
import { NoteNew } from './routes/note-new';
import { NoteNone } from './routes/note-none';
import { NotFound } from './routes/not-found';
import './styles/critical.scss';
import type { ParentProps } from 'solid-js';
import type { RouteSectionProps } from '@solidjs/router';
import type { SearchParams } from './route-path';
function Layout(props: ParentProps) {
const [searchParams] = useSearchParams<SearchParams>();
return (
<MetaProvider>
<main class="c-main">
<section class="c-sidebar c-main__column">
<section class="c-sidebar__header">
<img
class="c-logo"
src="/logo.svg"
width="22px"
height="20px"
alt=""
role="presentation"
/>
<strong>Solid Notes</strong>
</section>
<section class="c-sidebar__menu" role="menubar">
<SearchField />
<EditButton kind={'new'}>New</EditButton>
</section>
<Suspense>
<BriefList searchText={searchParams.search} />
</Suspense>
</section>
<section class="c-note-view c-main__column">
<Suspense>{props.children}</Suspense>
</section>
</main>
</MetaProvider>
);
}
type NotePropsMerge = [{ edit: boolean }, RouteSectionProps];
export default function App() {
const Edit = (props: RouteSectionProps) =>
Note(mergeProps<NotePropsMerge>({ edit: true }, props));
const Display = (props: RouteSectionProps) =>
Note(mergeProps<NotePropsMerge>({ edit: false }, props));
return (
<Router root={Layout}>
<Route path="/new" component={NoteNew} />
<Route path="/notes/:noteId/edit" component={Edit} />
<Route path="/notes/:noteId" component={Display} />
<Route path="/" component={NoteNone} />
<Route path="*404" component={NotFound} />
</Router>
);
}