|
62 | 62 | */ |
63 | 63 | export let functions = false; |
64 | 64 |
|
| 65 | + /** |
| 66 | + * Theme, which can also be customized with CSS variables: |
| 67 | + * --sd-bg-color |
| 68 | + * --sd-label-color |
| 69 | + * --sd-promise-loading-color |
| 70 | + * --sd-promise-error-color |
| 71 | + * --sd-code-default |
| 72 | + * --sd-info |
| 73 | + * --sd-success |
| 74 | + * --sd-redirect |
| 75 | + * --sd-error |
| 76 | + * --sd-code-key |
| 77 | + * --sd-code-string |
| 78 | + * --sd-code-date |
| 79 | + * --sd-code-boolean |
| 80 | + * --sd-code-number |
| 81 | + * --sd-code-bigint |
| 82 | + * --sd-code-null |
| 83 | + * --sd-code-nan |
| 84 | + * --sd-code-undefined |
| 85 | + * --sd-code-function |
| 86 | + * --sd-sb-width |
| 87 | + * --sd-sb-height |
| 88 | + * --sd-sb-track-color |
| 89 | + * --sd-sb-track-color-focus |
| 90 | + * --sd-sb-thumb-color |
| 91 | + * --sd-sb-thumb-color-focus |
| 92 | + * @type {"default" | "vscode"} |
| 93 | + */ |
| 94 | + export let theme = 'default'; |
| 95 | +
|
65 | 96 | /** |
66 | 97 | * @param {unknown} json |
67 | 98 | * @returns {string} |
|
191 | 222 | ); |
192 | 223 | } |
193 | 224 |
|
| 225 | + const themeStyle = |
| 226 | + theme == 'vscode' |
| 227 | + ? ` |
| 228 | + --sd-vscode-bg-color:#1f1f1f; |
| 229 | + --sd-vscode-label-color:#cccccc; |
| 230 | + --sd-vscode-code-default:#8c8a89; |
| 231 | + --sd-vscode-code-key:#9cdcfe; |
| 232 | + --sd-vscode-code-string:#ce9171; |
| 233 | + --sd-vscode-code-number:#b5c180; |
| 234 | + --sd-vscode-code-boolean:#4a9cd6; |
| 235 | + --sd-vscode-code-null:#4a9cd6; |
| 236 | + --sd-vscode-code-undefined:#4a9cd6; |
| 237 | + --sd-vscode-sb-thumb-color:#35373a; |
| 238 | + --sd-vscode-sb-thumb-color-focus:#4b4d50; |
| 239 | + ` |
| 240 | + : undefined; |
| 241 | +
|
194 | 242 | /** @type {EncodeableData} */ |
195 | 243 | let debugData; |
196 | 244 |
|
|
209 | 257 | </script> |
210 | 258 |
|
211 | 259 | {#if display} |
212 | | - <div class="super-debug"> |
| 260 | + <div class="super-debug" style={themeStyle}> |
213 | 261 | <div |
214 | 262 | class="super-debug--status {label === '' |
215 | 263 | ? 'absolute inset-x-0 top-0' |
|
231 | 279 | class="super-debug--pre {label === '' ? 'pt-4' : 'pt-0'}" |
232 | 280 | bind:this={ref}><code class="super-debug--code" |
233 | 281 | ><slot |
234 | | - >{#if assertPromise(debugData, raw, promise)}{#await promiseSyntaxHighlight(debugData)}<div>Loading data...</div>{:then result}{@html result}{/await}{:else}{@html syntaxHighlight( |
| 282 | + >{#if assertPromise(debugData, raw, promise)}{#await promiseSyntaxHighlight(debugData)}<div |
| 283 | + class="super-debug--promise-loading">Loading data...</div>{:then result}{@html result}{:catch error}<div |
| 284 | + class="super-debug--promise-error">{error}</div>{/await}{:else}{@html syntaxHighlight( |
235 | 285 | debugData |
236 | 286 | )}{/if}</slot |
237 | 287 | ></code |
|
311 | 361 | } |
312 | 362 |
|
313 | 363 | .super-debug { |
314 | | - --_sd-bg-color: var(--sd-bg-color, rgb(30, 41, 59)); |
| 364 | + --_sd-bg-color: var( |
| 365 | + --sd-bg-color, |
| 366 | + var(--sd-vscode-bg-color, rgb(30, 41, 59)) |
| 367 | + ); |
315 | 368 | position: relative; |
316 | 369 | background-color: var(--_sd-bg-color); |
317 | 370 | border-radius: 0.5rem; |
|
327 | 380 | } |
328 | 381 |
|
329 | 382 | .super-debug--label { |
330 | | - color: var(--sd-label-color, white); |
| 383 | + color: var(--sd-label-color, var(--sd-vscode-label-color, white)); |
| 384 | + } |
| 385 | +
|
| 386 | + .super-debug--promise-loading { |
| 387 | + color: var( |
| 388 | + --sd-promise-loading-color, |
| 389 | + var(--sd-vscode-promise-loading-color, #999) |
| 390 | + ); |
| 391 | + } |
| 392 | +
|
| 393 | + .super-debug--promise-error { |
| 394 | + color: var( |
| 395 | + --sd-promise-error-color, |
| 396 | + var(--sd-vscode-promise-error-color, #ff475d) |
| 397 | + ); |
331 | 398 | } |
332 | 399 |
|
333 | 400 | .super-debug pre { |
334 | | - color: var(--sd-code-default, #999); |
| 401 | + color: var(--sd-code-default, var(--sd-vscode-code-default, #999)); |
335 | 402 | background-color: var(--_sd-bg-color); |
336 | 403 | margin-bottom: 0px; |
337 | 404 | /** Sakura is doing 0.9em, turn font-size back to 1em **/ |
338 | 405 | font-size: 1em; |
339 | 406 | } |
340 | 407 |
|
341 | 408 | .info { |
342 | | - color: var(--sd-info, rgb(85, 85, 255)); |
| 409 | + color: var(--sd-info, var(--sd-vscode-info, rgb(85, 85, 255))); |
343 | 410 | } |
344 | 411 |
|
345 | 412 | .success { |
346 | | - color: var(--sd-success, #2cd212); |
| 413 | + color: var(--sd-success, var(--sd-vscode-success, #2cd212)); |
347 | 414 | } |
348 | 415 |
|
349 | 416 | .redirect { |
350 | | - color: var(--sd-redirect, #03cae5); |
| 417 | + color: var(--sd-redirect, var(--sd-vscode-redirect, #03cae5)); |
351 | 418 | } |
352 | 419 |
|
353 | 420 | .error { |
354 | | - color: var(--sd-error, #ff475d); |
| 421 | + color: var(--sd-error, var(--sd-vscode-error, #ff475d)); |
355 | 422 | } |
356 | 423 |
|
357 | 424 | :global(.super-debug--code .key) { |
358 | | - color: var(--sd-code-key, #eab308); |
| 425 | + color: var(--sd-code-key, var(--sd-vscode-code-key, #eab308)); |
359 | 426 | } |
360 | 427 |
|
361 | 428 | :global(.super-debug--code .string) { |
362 | | - color: var(--sd-code-string, #6ec687); |
| 429 | + color: var(--sd-code-string, var(--sd-vscode-code-string, #6ec687)); |
363 | 430 | } |
364 | 431 |
|
365 | 432 | :global(.super-debug--code .date) { |
366 | | - color: var(--sd-code-date, #f06962); |
| 433 | + color: var(--sd-code-date, var(--sd-vscode-code-date, #f06962)); |
367 | 434 | } |
368 | 435 |
|
369 | 436 | :global(.super-debug--code .boolean) { |
370 | | - color: var(--sd-code-boolean, #79b8ff); |
| 437 | + color: var(--sd-code-boolean, var(--sd-vscode-code-boolean, #79b8ff)); |
371 | 438 | } |
372 | 439 |
|
373 | 440 | :global(.super-debug--code .number) { |
374 | | - color: var(--sd-code-number, #af77e9); |
| 441 | + color: var(--sd-code-number, var(--sd-vscode-code-number, #af77e9)); |
375 | 442 | } |
376 | 443 |
|
377 | 444 | :global(.super-debug--code .bigint) { |
378 | | - color: var(--sd-code-bigint, #af77e9); |
| 445 | + color: var(--sd-code-bigint, var(--sd-vscode-code-bigint, #af77e9)); |
379 | 446 | } |
380 | 447 |
|
381 | 448 | :global(.super-debug--code .null) { |
382 | | - color: var(--sd-code-null, #238afe); |
| 449 | + color: var(--sd-code-null, var(--sd-vscode-code-null, #238afe)); |
383 | 450 | } |
384 | 451 |
|
385 | 452 | :global(.super-debug--code .nan) { |
386 | | - color: var(--sd-code-nan, #af77e9); |
| 453 | + color: var(--sd-code-nan, var(--sd-vscode-code-nan, #af77e9)); |
387 | 454 | } |
388 | 455 |
|
389 | 456 | :global(.super-debug--code .undefined) { |
390 | | - color: var(--sd-code-undefined, #238afe); |
| 457 | + color: var( |
| 458 | + --sd-code-undefined, |
| 459 | + var(--sd-vscode-code-undefined, #238afe) |
| 460 | + ); |
391 | 461 | } |
392 | 462 |
|
393 | 463 | :global(.super-debug--code .function) { |
394 | | - color: var(--sd-code-function, #f06962); |
| 464 | + color: var(--sd-code-function, var(--sd-vscode-code-function, #f06962)); |
395 | 465 | } |
396 | 466 |
|
397 | 467 | :global(.super-debug--code .symbol) { |
398 | 468 | color: var(--sd-code-symbol, #77e9c3); |
399 | 469 | } |
400 | 470 |
|
401 | 471 | .super-debug pre::-webkit-scrollbar { |
402 | | - width: var(--sd-sb-width, 1.25rem); |
403 | | - height: var(--sd-sb-height, 1.25rem); |
| 472 | + width: var(--sd-sb-width, var(--sd-vscode-sb-width, 1.25rem)); |
| 473 | + height: var(--sd-sb-height, var(--sd-vscode-sb-height, 1.25rem)); |
404 | 474 | opacity: 0.5; |
405 | 475 | } |
406 | 476 |
|
407 | 477 | .super-debug pre::-webkit-scrollbar-track { |
408 | | - background-color: var(--sd-sb-track-color, hsl(0, 0%, 40%, 0.2)); |
| 478 | + background-color: var( |
| 479 | + --sd-sb-track-color, |
| 480 | + --sd-vscode-sb-track-color, |
| 481 | + hsl(0, 0%, 40%, 0.2) |
| 482 | + ); |
409 | 483 | } |
410 | 484 | .super-debug:is(:focus-within, :hover) pre::-webkit-scrollbar-track { |
411 | | - background-color: var(--sd-sb-track-color-focus, hsl(0, 0%, 50%, 0.2)); |
| 485 | + background-color: var( |
| 486 | + --sd-sb-track-color-focus, |
| 487 | + --sd-vscode-sb-track-color-focus, |
| 488 | + hsl(0, 0%, 50%, 0.2) |
| 489 | + ); |
412 | 490 | } |
413 | 491 |
|
414 | 492 | .super-debug pre::-webkit-scrollbar-thumb { |
415 | | - background-color: var(--sd-sb-thumb-color, hsl(217, 50%, 50%, 0.5)); |
| 493 | + background-color: var( |
| 494 | + --sd-sb-thumb-color, |
| 495 | + --sd-vscode-sb-thumb-color, |
| 496 | + hsl(217, 50%, 50%, 0.5) |
| 497 | + ); |
416 | 498 | } |
417 | 499 | .super-debug:is(:focus-within, :hover) pre::-webkit-scrollbar-thumb { |
418 | | - background-color: var(--sd-sb-thumb-color-focus, hsl(217, 50%, 50%)); |
| 500 | + background-color: var( |
| 501 | + --sd-sb-thumb-color-focus, |
| 502 | + --sd-vscode-sb-thumb-color-focus, |
| 503 | + hsl(217, 50%, 50%) |
| 504 | + ); |
419 | 505 | } |
420 | 506 | </style> |
0 commit comments