prototypey.org - atproto lexicon typescript toolkit - mirror https://github.com/tylersayshi/prototypey

mobile ready

Tyler 01cb3812 ea95cbd7

+24 -14
+24 -14
packages/site/src/components/Playground.tsx
··· 191 191 Playground available on desktop 192 192 </div> 193 193 194 - <MobileStaticDemo /> 194 + <MobileStaticDemo code={code} json={output.json} /> 195 195 </div> 196 196 </> 197 197 ); ··· 227 227 return indentedLines.join("\n"); 228 228 } 229 229 230 - function MobileStaticDemo({ 231 - code, 232 - json, 233 - }: { 234 - code: string; 235 - json: string; 236 - }) { 230 + function MobileStaticDemo({ code, json }: { code: string; json: string }) { 237 231 // Calculate line counts to size editors appropriately 238 232 const codeLines = code.split("\n").length; 239 233 const jsonLines = json.split("\n").length; 240 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 + 241 247 return ( 242 248 <div style={{ display: "flex", flexDirection: "column", gap: "1rem" }}> 243 249 {/* You write section */} ··· 266 272 }} 267 273 > 268 274 <MonacoEditor 269 - height={`${Math.min(codeLines * 19 + 32, 500)}px`} 275 + height={`${codeWrappedLines * 18 + 32}px`} 270 276 defaultLanguage="typescript" 271 277 value={code} 272 278 theme="vs-light" ··· 280 286 padding: { top: 16, bottom: 16 }, 281 287 scrollbar: { 282 288 vertical: "hidden", 283 - horizontal: "auto", 284 - horizontalScrollbarSize: 8, 289 + horizontal: "hidden", 290 + verticalScrollbarSize: 0, 291 + horizontalScrollbarSize: 0, 292 + handleMouseWheel: false, 285 293 }, 286 294 wordWrap: "on", 287 295 overviewRulerLanes: 0, ··· 316 324 }} 317 325 > 318 326 <MonacoEditor 319 - height={`${Math.min(jsonLines * 19 + 32, 600)}px`} 327 + height={`${jsonWrappedLines * 18 + 32}px`} 320 328 defaultLanguage="json" 321 329 value={json} 322 330 theme="vs-light" ··· 330 338 padding: { top: 16, bottom: 16 }, 331 339 scrollbar: { 332 340 vertical: "hidden", 333 - horizontal: "auto", 334 - horizontalScrollbarSize: 8, 341 + horizontal: "hidden", 342 + verticalScrollbarSize: 0, 343 + horizontalScrollbarSize: 0, 344 + handleMouseWheel: false, 335 345 }, 336 346 wordWrap: "on", 337 347 overviewRulerLanes: 0,