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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
// let markdownStyles = (~background, ~text) => {
// Printf.sprintf(
// {|
// .markdown h1 {
// font-size: 2.25rem;
// font-weight: bold;
// line-height: 2.5;
// }
// .markdown h2 {
// font-size: 1.875rem;
// font-weight: bold;
// line-height: 2.5;
// }
// .markdown h3 {
// font-size: 1.5rem;
// font-weight: bold;
// line-height: 2.5;
// }
// .markdown h4 {
// font-size: 1.25rem;
// font-weight: bold;
// line-height: 2.5;
// }
// .markdown h5 {
// font-size: 1.125rem;
// font-weight: bold;
// line-height: 2.5;
// }
// .markdown h6 {
// font-size: 1rem;
// font-weight: bold;
// line-height: 2.5;
// }
// .markdown p {
// font-size: 1rem;
// margin-bottom: 1rem;
// }
// .markdown ul, .markdown ol {
// padding-left: 2rem;
// margin-bottom: 1rem;
// }
// .markdown li {
// margin-bottom: 0.5rem;
// }
// .markdown blockquote {
// border-left: 4px solid %s;
// padding-left: 1rem;
// margin: 1.5rem 0;
// font-style: italic;
// }
// .markdown pre {
// padding: 1rem;
// margin: 1.5rem 0;
// background-color: %s;
// color: %s;
// border-radius: 0.375rem;
// }
// .markdown code {
// display: block;
// margin: 1rem;
// padding-left: 1rem;
// padding-right: 1rem;
// font-family: monospace;
// background-color: %s;
// color: %s;
// padding: 0.25rem 0.5rem;
// border-radius: 0.25rem;
// }
// |},
// background,
// background,
// text,
// background,
// text,
// );
// };
module App = {
[@react.async.component]
let make = (~selectedId, ~isEditing, ~searchText) => {
Lwt.return(
<html>
<head>
<meta charSet="utf-8" />
<link rel="stylesheet" href="/output.css" />
</head>
// <style
// dangerouslySetInnerHTML={
// "__html":
// markdownStyles(
// ~background=Theme.Color.gray2,
// ~text=Theme.Color.gray12,
// ),
// }
// />
<body>
<div id="root">
<DemoLayout background=Theme.Color.Gray2 mode=FullScreen>
<div className="flex flex-row gap-8">
<section
className="flex-1 basis-1/4 gap-4 min-w-[400px]"
key="sidebar">
<section
className="flex flex-col gap-1 z-1 max-w-[85%] pointer-events-none mb-6"
key="sidebar-header">
<Text size=Large weight=Bold>
"server-reason-react notes"
</Text>
<p>
<Text color=Theme.Color.Gray10> "migrated from " </Text>
<Link.Text
size=Text.Small
href="https://github.com/reactjs/server-components-demo">
"reactjs/server-components-demo"
</Link.Text>
<Text color=Theme.Color.Gray10>
" with (server)-reason-react and Melange"
</Text>
</p>
</section>
<section
className="mt-4 mb-4 flex flex-row gap-2"
role="menubar"
key="menubar">
<SearchField searchText selectedId isEditing />
</section>
<nav className="mt-4">
<div className="mb-4"> <Hr /> </div>
<div className="mb-4">
<Button noteId=None>
{React.string("Create a note")}
</Button>
</div>
<Hr />
<React.Suspense fallback={<NoteListSkeleton />}>
<NoteList searchText />
</React.Suspense>
</nav>
</section>
<section
key="note-viewer" className="flex-1 basis-3/4 max-w-[75%]">
<React.Suspense fallback={<NoteSkeleton isEditing />}>
<NoteItem selectedId isEditing />
</React.Suspense>
</section>
</div>
</DemoLayout>
</div>
</body>
</html>,
);
};
};
let handler = request => {
let selectedId =
Dream.query(request, "selectedId")
|> Option.map(string => int_of_string_opt(string))
|> Option.value(~default=None);
let isEditing =
Dream.query(request, "isEditing")
|> Option.map(v => v == "true")
|> Option.value(~default=false);
let searchText =
Dream.query(request, "searchText") |> Option.value(~default="");
Rsc.DreamRSC.create_from_request(
~bootstrap_modules=["/static/RouterRSC.re.js"],
<App selectedId isEditing searchText />,
request,
);
};
|