tangled
alpha
login
or
join now
tylur.dev
/
prototypey
prototypey.org - atproto lexicon typescript toolkit - mirror https://github.com/tylersayshi/prototypey
1
fork
atom
overview
issues
pulls
pipelines
mobile ready
Tyler
3 months ago
01cb3812
ea95cbd7
+24
-14
1 changed file
expand all
collapse all
unified
split
packages
site
src
components
Playground.tsx
+24
-14
packages/site/src/components/Playground.tsx
···
191
Playground available on desktop
192
</div>
193
194
-
<MobileStaticDemo />
195
</div>
196
</>
197
);
···
227
return indentedLines.join("\n");
228
}
229
230
-
function MobileStaticDemo({
231
-
code,
232
-
json,
233
-
}: {
234
-
code: string;
235
-
json: string;
236
-
}) {
237
// Calculate line counts to size editors appropriately
238
const codeLines = code.split("\n").length;
239
const jsonLines = json.split("\n").length;
240
0
0
0
0
0
0
0
0
0
0
0
0
241
return (
242
<div style={{ display: "flex", flexDirection: "column", gap: "1rem" }}>
243
{/* You write section */}
···
266
}}
267
>
268
<MonacoEditor
269
-
height={`${Math.min(codeLines * 19 + 32, 500)}px`}
270
defaultLanguage="typescript"
271
value={code}
272
theme="vs-light"
···
280
padding: { top: 16, bottom: 16 },
281
scrollbar: {
282
vertical: "hidden",
283
-
horizontal: "auto",
284
-
horizontalScrollbarSize: 8,
0
0
285
},
286
wordWrap: "on",
287
overviewRulerLanes: 0,
···
316
}}
317
>
318
<MonacoEditor
319
-
height={`${Math.min(jsonLines * 19 + 32, 600)}px`}
320
defaultLanguage="json"
321
value={json}
322
theme="vs-light"
···
330
padding: { top: 16, bottom: 16 },
331
scrollbar: {
332
vertical: "hidden",
333
-
horizontal: "auto",
334
-
horizontalScrollbarSize: 8,
0
0
335
},
336
wordWrap: "on",
337
overviewRulerLanes: 0,
···
191
Playground available on desktop
192
</div>
193
194
+
<MobileStaticDemo code={code} json={output.json} />
195
</div>
196
</>
197
);
···
227
return indentedLines.join("\n");
228
}
229
230
+
function MobileStaticDemo({ code, json }: { code: string; json: string }) {
0
0
0
0
0
0
231
// Calculate line counts to size editors appropriately
232
const codeLines = code.split("\n").length;
233
const jsonLines = json.split("\n").length;
234
235
+
const estimateWrappedLines = (text: string, maxCharsPerLine: number) => {
236
+
return text.split("\n").reduce((total, line) => {
237
+
const wrappedLines = Math.ceil(
238
+
Math.max(1, line.length) / maxCharsPerLine,
239
+
);
240
+
return total + wrappedLines;
241
+
}, 0);
242
+
};
243
+
244
+
const codeWrappedLines = estimateWrappedLines(code, 50);
245
+
const jsonWrappedLines = estimateWrappedLines(json, 50);
246
+
247
return (
248
<div style={{ display: "flex", flexDirection: "column", gap: "1rem" }}>
249
{/* You write section */}
···
272
}}
273
>
274
<MonacoEditor
275
+
height={`${codeWrappedLines * 18 + 32}px`}
276
defaultLanguage="typescript"
277
value={code}
278
theme="vs-light"
···
286
padding: { top: 16, bottom: 16 },
287
scrollbar: {
288
vertical: "hidden",
289
+
horizontal: "hidden",
290
+
verticalScrollbarSize: 0,
291
+
horizontalScrollbarSize: 0,
292
+
handleMouseWheel: false,
293
},
294
wordWrap: "on",
295
overviewRulerLanes: 0,
···
324
}}
325
>
326
<MonacoEditor
327
+
height={`${jsonWrappedLines * 18 + 32}px`}
328
defaultLanguage="json"
329
value={json}
330
theme="vs-light"
···
338
padding: { top: 16, bottom: 16 },
339
scrollbar: {
340
vertical: "hidden",
341
+
horizontal: "hidden",
342
+
verticalScrollbarSize: 0,
343
+
horizontalScrollbarSize: 0,
344
+
handleMouseWheel: false,
345
},
346
wordWrap: "on",
347
overviewRulerLanes: 0,