Skip to content

Commit 1526725

Browse files
committed
SuperDebug looks a bit better now when there is no css styling on the page.
1 parent 672e590 commit 1526725

File tree

5 files changed

+99
-18
lines changed

5 files changed

+99
-18
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Fixed
1111

1212
- Array-level errors weren't typed correctly when changing the cardinality of an array field in the schema (for example with `nonempty`).
13+
- SuperDebug looks a bit better now when there is no css styling on the page.
1314

1415
## [1.5.2] - 2023-08-15
1516

src/lib/client/SuperDebug.svelte

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -257,23 +257,25 @@
257257
258258
{#if display}
259259
<div class="super-debug" style={themeStyle}>
260-
<div
261-
class="super-debug--status {label === ''
262-
? 'absolute inset-x-0 top-0'
263-
: ''}"
264-
>
265-
<div class="super-debug--label">{label}</div>
266-
{#if status}
267-
<div
268-
class:info={$page.status < 200}
269-
class:success={$page.status >= 200 && $page.status < 300}
270-
class:redirect={$page.status >= 300 && $page.status < 400}
271-
class:error={$page.status >= 400}
272-
>
273-
{$page.status}
274-
</div>
275-
{/if}
276-
</div>
260+
{#if label || status}
261+
<div
262+
class="super-debug--status {label === ''
263+
? 'absolute inset-x-0 top-0'
264+
: ''}"
265+
>
266+
<div class="super-debug--label">{label}</div>
267+
{#if status}
268+
<div
269+
class:info={$page.status < 200}
270+
class:success={$page.status >= 200 && $page.status < 300}
271+
class:redirect={$page.status >= 300 && $page.status < 400}
272+
class:error={$page.status >= 400}
273+
>
274+
{$page.status}
275+
</div>
276+
{/if}
277+
</div>
278+
{/if}
277279
<pre
278280
class="super-debug--pre {label === '' ? 'pt-4' : 'pt-0'}"
279281
bind:this={ref}><code class="super-debug--code"
@@ -352,6 +354,7 @@
352354
.super-debug--status {
353355
display: flex;
354356
padding: 1em;
357+
padding-bottom: 0;
355358
justify-content: space-between;
356359
font-family: Inconsolata, Monaco, Consolas, 'Lucida Console',
357360
'Courier New', Courier, monospace;
@@ -378,8 +381,8 @@
378381
.super-debug pre {
379382
color: var(--sd-code-default, var(--sd-vscode-code-default, #999));
380383
background-color: var(--_sd-bg-color);
381-
margin-bottom: 0px;
382384
font-size: 1em;
385+
padding: 1em 0 0 1em;
383386
}
384387
385388
.info {
@@ -455,25 +458,29 @@
455458
}
456459
457460
.super-debug pre::-webkit-scrollbar-track {
461+
border-radius: 12px;
458462
background-color: var(
459463
--sd-sb-track-color,
460464
var(--sd-vscode-sb-track-color, hsl(0, 0%, 40%, 0.2))
461465
);
462466
}
463467
.super-debug:is(:focus-within, :hover) pre::-webkit-scrollbar-track {
468+
border-radius: 12px;
464469
background-color: var(
465470
--sd-sb-track-color-focus,
466471
var(--sd-vscode-sb-track-color-focus, hsl(0, 0%, 50%, 0.2))
467472
);
468473
}
469474
470475
.super-debug pre::-webkit-scrollbar-thumb {
476+
border-radius: 12px;
471477
background-color: var(
472478
--sd-sb-thumb-color,
473479
var(--sd-vscode-sb-thumb-color, hsl(217, 50%, 50%, 0.5))
474480
);
475481
}
476482
.super-debug:is(:focus-within, :hover) pre::-webkit-scrollbar-thumb {
483+
border-radius: 12px;
477484
background-color: var(
478485
--sd-sb-thumb-color-focus,
479486
var(--sd-vscode-sb-thumb-color-focus, hsl(217, 50%, 50%))
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { message, superValidate } from '$lib/server';
2+
import { schema } from './schema';
3+
import { fail } from '@sveltejs/kit';
4+
5+
export const load = async () => {
6+
const form = await superValidate(schema);
7+
return { form };
8+
};
9+
10+
export const actions = {
11+
default: async ({ request }) => {
12+
const formData = await request.formData();
13+
console.log(formData);
14+
15+
const form = await superValidate(formData, schema);
16+
console.log('POST', form);
17+
18+
if (!form.valid) return fail(400, { form });
19+
20+
return message(form, 'Posted OK!');
21+
}
22+
};
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<script lang="ts">
2+
import { superForm } from '$lib/client';
3+
import type { PageData } from './$types';
4+
import SuperDebug from '$lib/client/SuperDebug.svelte';
5+
import { schema } from './schema';
6+
import { onMount } from 'svelte';
7+
8+
export let data: PageData;
9+
10+
const { form, errors, tainted, message, enhance } = superForm(data.form, {
11+
//dataType: 'json',
12+
//validators: schema
13+
});
14+
15+
onMount(() => {
16+
document.querySelector('head link[href="./sakura.css"]')?.remove();
17+
});
18+
</script>
19+
20+
<SuperDebug data={{ $form, $errors, $tainted }} status={false} />
21+
22+
{#if $message}<h4>{$message}</h4>{/if}
23+
24+
<form method="POST" use:enhance>
25+
<label>
26+
Name: <input name="name" bind:value={$form.name} />
27+
{#if $errors.name}<span class="invalid">{$errors.name}</span>{/if}
28+
</label>
29+
<div>
30+
<button>Submit</button>
31+
</div>
32+
</form>
33+
34+
<style lang="scss">
35+
form {
36+
margin: 2rem 0;
37+
38+
input {
39+
background-color: #dedede;
40+
}
41+
42+
.invalid {
43+
color: crimson;
44+
}
45+
}
46+
</style>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { z } from 'zod';
2+
3+
export const schema = z.object({
4+
name: z.string().min(1)
5+
});

0 commit comments

Comments
 (0)