mirror of
https://github.com/JoshiCodes/knock.git
synced 2026-12-04 15:09:41 +01:00
Design pass: fewer boxes, one emphasis signal, type glyphs in the JSON form
- Welcome screen: the mark as a peephole and actions as plain lines instead of a card grid and key chips - Title bar: search as a small button, documentation (F1) next to it; help entries in the command palette - The vertical cyan rule marks what needs attention (redirect URI, inactive environment, banners) instead of nested framed boxes - JSON form: fixed key column so types and values line up at any depth, type glyphs in the code view's colours, row actions float on hover - Crisper corners; Send carries the mark; Saved instead of a disabled Save button - Open tabs are restored after a restart again
This commit is contained in:
+11
-1
@@ -19,6 +19,7 @@
|
|||||||
import { sendTab } from '$lib/send.svelte';
|
import { sendTab } from '$lib/send.svelte';
|
||||||
import type { TreeNode } from '$lib/types';
|
import type { TreeNode } from '$lib/types';
|
||||||
import { onDeepLink } from '$lib/deeplink';
|
import { onDeepLink } from '$lib/deeplink';
|
||||||
|
import { openDocs } from '$lib/help';
|
||||||
|
|
||||||
let ready = $state(false);
|
let ready = $state(false);
|
||||||
|
|
||||||
@@ -51,6 +52,11 @@
|
|||||||
|
|
||||||
function onKey(e: KeyboardEvent) {
|
function onKey(e: KeyboardEvent) {
|
||||||
const mod = e.ctrlKey || e.metaKey;
|
const mod = e.ctrlKey || e.metaKey;
|
||||||
|
if (e.key === 'F1') {
|
||||||
|
e.preventDefault();
|
||||||
|
openDocs();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!mod) {
|
if (!mod) {
|
||||||
if (e.key === 'F2' || e.key === 'Escape') return;
|
if (e.key === 'F2' || e.key === 'Escape') return;
|
||||||
return;
|
return;
|
||||||
@@ -130,7 +136,11 @@
|
|||||||
{ id: 'a:import', label: 'Import from Postman, Bruno, Insomnia, OpenAPI or cURL…', group: 'Actions', onselect: () => dialogs.importer() },
|
{ id: 'a:import', label: 'Import from Postman, Bruno, Insomnia, OpenAPI or cURL…', group: 'Actions', onselect: () => dialogs.importer() },
|
||||||
{ id: 'a:layout', label: 'Toggle response below / beside', group: 'Actions', onselect: () => ws.setLayout(ws.layout === 'columns' ? 'rows' : 'columns') },
|
{ id: 'a:layout', label: 'Toggle response below / beside', group: 'Actions', onselect: () => ws.setLayout(ws.layout === 'columns' ? 'rows' : 'columns') },
|
||||||
{ id: 'a:mask', label: ws.maskSecrets ? 'Show secrets' : 'Mask secrets', group: 'Actions', onselect: () => ws.setMask(!ws.maskSecrets) },
|
{ id: 'a:mask', label: ws.maskSecrets ? 'Show secrets' : 'Mask secrets', group: 'Actions', onselect: () => ws.setMask(!ws.maskSecrets) },
|
||||||
{ id: 'a:settings', label: 'Settings', group: 'Actions', onselect: () => ws.openSpecial('settings', null, null, 'Settings') }
|
{ id: 'a:settings', label: 'Settings', group: 'Actions', onselect: () => ws.openSpecial('settings', null, null, 'Settings') },
|
||||||
|
{ id: 'a:docs', label: 'Documentation', group: 'Help', hint: 'F1', keywords: ['help', 'docs', 'manual'], onselect: () => openDocs() },
|
||||||
|
{ id: 'a:docs-oauth', label: 'Documentation: OAuth 2.0 and OpenID Connect', group: 'Help', onselect: () => openDocs('oauth-2-0-and-openid-connect') },
|
||||||
|
{ id: 'a:docs-format', label: 'Documentation: collection format', group: 'Help', onselect: () => openDocs('collection-format') },
|
||||||
|
{ id: 'a:docs-keys', label: 'Documentation: keyboard shortcuts', group: 'Help', onselect: () => openDocs('keyboard-shortcuts') }
|
||||||
);
|
);
|
||||||
if (ws.focusCol) {
|
if (ws.focusCol) {
|
||||||
const col = ws.focusCol;
|
const col = ws.focusCol;
|
||||||
|
|||||||
+1
-1
@@ -45,7 +45,7 @@
|
|||||||
--ck-warning: #9a5b00;
|
--ck-warning: #9a5b00;
|
||||||
--ck-font-sans: 'Space Grotesk', system-ui, sans-serif;
|
--ck-font-sans: 'Space Grotesk', system-ui, sans-serif;
|
||||||
--ck-font-mono: 'JetBrains Mono', ui-monospace, monospace;
|
--ck-font-mono: 'JetBrains Mono', ui-monospace, monospace;
|
||||||
--ck-radius-scale: 0.75;
|
--ck-radius-scale: 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dark,
|
.dark,
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import { openUrl } from '@tauri-apps/plugin-opener';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export function openDocs(page = 'introduction') {
|
||||||
|
openUrl(`https://docs.joshicodes.de/b/knock/${page}`).catch(() => {});
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ContextMenu, MenuItem, MenuSeparator, Popover, Switch, toast } from '@joshicodes/cock';
|
import { ContextMenu, DropdownMenu, MenuItem, MenuSeparator, Popover, Switch, toast } from '@joshicodes/cock';
|
||||||
import Icon from '$lib/ui/Icon.svelte';
|
import Icon from '$lib/ui/Icon.svelte';
|
||||||
import VarInput from '$lib/ui/VarInput.svelte';
|
import VarInput from '$lib/ui/VarInput.svelte';
|
||||||
import { dialogs } from '$lib/state/dialogs.svelte';
|
import { dialogs } from '$lib/state/dialogs.svelte';
|
||||||
@@ -193,6 +193,18 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
let menuRow = $state<Row | null>(null);
|
let menuRow = $state<Row | null>(null);
|
||||||
|
|
||||||
|
const KEY_W = 230;
|
||||||
|
// Type glyphs use the code view's syntax colours, so form and code read alike.
|
||||||
|
const GLYPH: Record<Kind, { g: string; cls: string }> = {
|
||||||
|
string: { g: '"', cls: 'text-ok' },
|
||||||
|
number: { g: '#', cls: 'text-post' },
|
||||||
|
boolean: { g: '?', cls: 'text-put' },
|
||||||
|
null: { g: '∅', cls: 'text-put' },
|
||||||
|
object: { g: '{}', cls: 'text-soft' },
|
||||||
|
array: { g: '[]', cls: 'text-soft' },
|
||||||
|
variable: { g: '{{}}', cls: 'text-get' }
|
||||||
|
};
|
||||||
let popoverOpen = $state<Record<number, boolean>>({});
|
let popoverOpen = $state<Record<number, boolean>>({});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -221,8 +233,7 @@
|
|||||||
role="treeitem"
|
role="treeitem"
|
||||||
aria-selected="false"
|
aria-selected="false"
|
||||||
tabindex="-1"
|
tabindex="-1"
|
||||||
class="group relative flex min-h-[30px] items-center gap-1 pr-2 hover:bg-hover/40 {dropTarget?.id === n.id ? (dropTarget.after ? 'shadow-[inset_0_-2px_0_var(--knock-cyan)]' : 'shadow-[inset_0_2px_0_var(--knock-cyan)]') : ''}"
|
class="group relative flex min-h-[30px] items-center gap-1.5 pr-2 hover:bg-hover/40 {dropTarget?.id === n.id ? (dropTarget.after ? 'shadow-[inset_0_-2px_0_var(--knock-cyan)]' : 'shadow-[inset_0_2px_0_var(--knock-cyan)]') : ''}"
|
||||||
style:padding-left="{6 + r.depth * 18}px"
|
|
||||||
use:focusKey={n.id}
|
use:focusKey={n.id}
|
||||||
oncontextmenu={() => (menuRow = r)}
|
oncontextmenu={() => (menuRow = r)}
|
||||||
ondragover={(e) => {
|
ondragover={(e) => {
|
||||||
@@ -235,41 +246,40 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
onDrop(r);
|
onDrop(r);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{#if r.parent}
|
<!-- Key column: fixed width; the nesting lives inside it so types and values line up. -->
|
||||||
<span
|
<div class="flex shrink-0 items-center" style:width="{KEY_W}px" style:padding-left="{4 + r.depth * 16}px">
|
||||||
class="grid w-3.5 cursor-grab place-items-center text-fg-subtle opacity-0 group-hover:opacity-100"
|
{#if r.parent}
|
||||||
draggable="true"
|
<span
|
||||||
role="button"
|
class="grid w-3.5 shrink-0 cursor-grab place-items-center text-fg-subtle opacity-0 group-hover:opacity-100"
|
||||||
tabindex="-1"
|
draggable="true"
|
||||||
title="Drag to reorder"
|
role="button"
|
||||||
ondragstart={() => (drag = r)}
|
tabindex="-1"
|
||||||
ondragend={() => {
|
title="Drag to reorder"
|
||||||
drag = null;
|
ondragstart={() => (drag = r)}
|
||||||
dropTarget = null;
|
ondragend={() => {
|
||||||
}}><Icon name="grip" size={12} /></span
|
drag = null;
|
||||||
>
|
dropTarget = null;
|
||||||
{:else}
|
}}><Icon name="grip" size={12} /></span
|
||||||
<span class="w-3.5"></span>
|
>
|
||||||
{/if}
|
{:else}
|
||||||
{#if isContainer}
|
<span class="w-3.5 shrink-0"></span>
|
||||||
<button
|
{/if}
|
||||||
class="grid size-4 place-items-center text-fg-subtle hover:text-fg"
|
{#if isContainer}
|
||||||
onclick={() => {
|
<button
|
||||||
if (collapsed.has(n.id)) collapsed.delete(n.id);
|
class="grid size-4 shrink-0 place-items-center text-fg-subtle hover:text-fg"
|
||||||
else collapsed.add(n.id);
|
onclick={() => {
|
||||||
collapsed = new Set(collapsed);
|
if (collapsed.has(n.id)) collapsed.delete(n.id);
|
||||||
}}
|
else collapsed.add(n.id);
|
||||||
aria-label={collapsed.has(n.id) ? 'Expand' : 'Collapse'}
|
collapsed = new Set(collapsed);
|
||||||
>
|
}}
|
||||||
<Icon name={collapsed.has(n.id) ? 'chevron-right' : 'chevron-down'} size={12} />
|
aria-label={collapsed.has(n.id) ? 'Expand' : 'Collapse'}
|
||||||
</button>
|
>
|
||||||
{:else}
|
<Icon name={collapsed.has(n.id) ? 'chevron-right' : 'chevron-down'} size={12} />
|
||||||
<span class="w-4"></span>
|
</button>
|
||||||
{/if}
|
{:else}
|
||||||
|
<span class="w-4 shrink-0"></span>
|
||||||
<!-- key -->
|
{/if}
|
||||||
<div class="flex w-[34%] min-w-[90px] max-w-[300px] shrink-0 items-center">
|
|
||||||
{#if r.entry}
|
{#if r.entry}
|
||||||
<VarInput
|
<VarInput
|
||||||
value={r.entry.key}
|
value={r.entry.key}
|
||||||
@@ -288,14 +298,21 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<select
|
<DropdownMenu label="Type" placement="bottom-start">
|
||||||
class="k-field mono !w-[86px] shrink-0 !px-1 text-[11.5px] !text-fg-muted"
|
{#snippet trigger(attrs)}
|
||||||
value={n.kind}
|
<button
|
||||||
onchange={(e) => setKind(r, (e.currentTarget as HTMLSelectElement).value as Kind)}
|
{...attrs}
|
||||||
title="Type"
|
class="mono grid h-6 w-9 shrink-0 place-items-center rounded-sm border border-transparent text-[12px] font-bold {GLYPH[n.kind].cls} hover:border-line hover:bg-input"
|
||||||
>
|
title="{n.kind}, click to change"
|
||||||
{#each KINDS as k}<option value={k}>{k}</option>{/each}
|
>{GLYPH[n.kind].g}</button>
|
||||||
</select>
|
{/snippet}
|
||||||
|
{#each KINDS as k}
|
||||||
|
<MenuItem onselect={() => setKind(r, k)}>
|
||||||
|
{#snippet icon()}<span class="mono w-6 text-center text-[12px] font-bold {GLYPH[k].cls}">{GLYPH[k].g}</span>{/snippet}
|
||||||
|
{k}
|
||||||
|
</MenuItem>
|
||||||
|
{/each}
|
||||||
|
</DropdownMenu>
|
||||||
|
|
||||||
<!-- value -->
|
<!-- value -->
|
||||||
<div class="flex min-w-0 flex-1 items-center gap-1">
|
<div class="flex min-w-0 flex-1 items-center gap-1">
|
||||||
@@ -394,7 +411,7 @@
|
|||||||
<span class="shrink-0 text-[11px] text-delete" title={errs.join('\n')}><Icon name="alert" size={12} /></span>
|
<span class="shrink-0 text-[11px] text-delete" title={errs.join('\n')}><Icon name="alert" size={12} /></span>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div class="flex shrink-0 items-center opacity-0 group-focus-within:opacity-100 group-hover:opacity-100">
|
<div class="pointer-events-none absolute right-1 top-1/2 flex -translate-y-1/2 items-center rounded-sm bg-panel opacity-0 shadow-[-14px_0_12px_var(--k-panel)] group-focus-within:pointer-events-auto group-focus-within:opacity-100 group-hover:pointer-events-auto group-hover:opacity-100">
|
||||||
{#if isContainer}
|
{#if isContainer}
|
||||||
<button class="grid size-6 place-items-center rounded text-fg-subtle hover:bg-hover hover:text-fg" title={n.kind === 'object' ? 'Add field' : 'Add item'} onclick={() => addChild(r)}>
|
<button class="grid size-6 place-items-center rounded text-fg-subtle hover:bg-hover hover:text-fg" title={n.kind === 'object' ? 'Add field' : 'Add item'} onclick={() => addChild(r)}>
|
||||||
<Icon name="plus" size={12} />
|
<Icon name="plus" size={12} />
|
||||||
@@ -415,7 +432,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{#if isContainer && !collapsed.has(n.id) && n.kind === 'object' && ctx && suggestions(r).length}
|
{#if isContainer && !collapsed.has(n.id) && n.kind === 'object' && ctx && suggestions(r).length}
|
||||||
<div class="flex flex-wrap items-center gap-1 py-1" style:padding-left="{6 + (r.depth + 1) * 18 + 36}px">
|
<div class="flex flex-wrap items-center gap-1 py-1" style:padding-left="{KEY_W + 50}px">
|
||||||
<span class="text-[11px] text-fg-subtle">Schema:</span>
|
<span class="text-[11px] text-fg-subtle">Schema:</span>
|
||||||
{#each suggestions(r) as key}
|
{#each suggestions(r) as key}
|
||||||
{@const req = ctx.resolve(r.schema)?.required?.includes(key)}
|
{@const req = ctx.resolve(r.schema)?.required?.includes(key)}
|
||||||
|
|||||||
@@ -108,7 +108,10 @@ class Workspace {
|
|||||||
// ------------------------------------------------------------ collections
|
// ------------------------------------------------------------ collections
|
||||||
|
|
||||||
async restore() {
|
async restore() {
|
||||||
|
// Read everything first: opening a collection saves the (still empty) tab list.
|
||||||
const open: string[] = load('knock.open', []);
|
const open: string[] = load('knock.open', []);
|
||||||
|
const savedTabs: { kind: TabKind; col: string | null; id: string | null }[] = load('knock.tabs', []);
|
||||||
|
const active = load<string | null>('knock.activeTab', null);
|
||||||
for (const root of open) {
|
for (const root of open) {
|
||||||
try {
|
try {
|
||||||
this.upsert(await api.collectionOpen(root));
|
this.upsert(await api.collectionOpen(root));
|
||||||
@@ -116,12 +119,11 @@ class Workspace {
|
|||||||
/* folder moved or deleted; it simply is not reopened */
|
/* folder moved or deleted; it simply is not reopened */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const savedTabs: { kind: TabKind; col: string | null; id: string | null }[] = load('knock.tabs', []);
|
|
||||||
for (const t of savedTabs) {
|
for (const t of savedTabs) {
|
||||||
if (t.kind === 'request' && t.col && t.id) await this.openRequest(t.col, t.id, false);
|
if (t.kind === 'request' && t.col && t.id) await this.openRequest(t.col, t.id, false);
|
||||||
}
|
}
|
||||||
const active = load<string | null>('knock.activeTab', null);
|
|
||||||
if (active && this.tabs.some((t) => t.key === active)) this.activeKey = active;
|
if (active && this.tabs.some((t) => t.key === active)) this.activeKey = active;
|
||||||
|
this.persistOpen();
|
||||||
}
|
}
|
||||||
|
|
||||||
persistOpen() {
|
persistOpen() {
|
||||||
|
|||||||
@@ -41,7 +41,8 @@
|
|||||||
filter: 'M2.5 3h11L9 8.5V13l-2-1V8.5z',
|
filter: 'M2.5 3h11L9 8.5V13l-2-1V8.5z',
|
||||||
bolt: 'M9 1.5L3.5 9H8l-1 5.5L12.5 7H8z',
|
bolt: 'M9 1.5L3.5 9H8l-1 5.5L12.5 7H8z',
|
||||||
wrap: 'M2.5 4h11M2.5 8h9a2 2 0 0 1 0 4H9M10.5 10.5 9 12l1.5 1.5M2.5 12h4',
|
wrap: 'M2.5 4h11M2.5 8h9a2 2 0 0 1 0 4H9M10.5 10.5 9 12l1.5 1.5M2.5 12h4',
|
||||||
door: 'M4 14V2.5h8V14M2.5 14h11M9.5 8.5h.01'
|
door: 'M4 14V2.5h8V14M2.5 14h11M9.5 8.5h.01',
|
||||||
|
help: 'M8 14.5a6.5 6.5 0 1 0 0-13 6.5 6.5 0 0 0 0 13zM6.2 6.2a1.9 1.9 0 0 1 3.6.8c0 1.3-1.8 1.6-1.8 2.8M8 11.6h.01'
|
||||||
};
|
};
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
import Mark from '$lib/ui/Mark.svelte';
|
import Mark from '$lib/ui/Mark.svelte';
|
||||||
import EnvSwitcher from './EnvSwitcher.svelte';
|
import EnvSwitcher from './EnvSwitcher.svelte';
|
||||||
import { ws } from '$lib/state/workspace.svelte';
|
import { ws } from '$lib/state/workspace.svelte';
|
||||||
import { Kbd } from '@joshicodes/cock';
|
import { openDocs } from '$lib/help';
|
||||||
|
|
||||||
const win = getCurrentWindow();
|
const win = getCurrentWindow();
|
||||||
let maximized = $state(false);
|
let maximized = $state(false);
|
||||||
@@ -38,16 +38,17 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-1 justify-center">
|
<div class="flex-1"></div>
|
||||||
<button
|
|
||||||
class="flex h-7 w-full max-w-[420px] items-center gap-2 rounded border border-line bg-panel px-2.5 text-left text-fg-subtle hover:border-border-strong"
|
<button
|
||||||
onclick={() => (ws.paletteOpen = true)}
|
class="flex h-7 items-center gap-2 rounded-sm px-2 text-fg-subtle hover:bg-hover hover:text-fg"
|
||||||
>
|
title="Find requests, environments and actions (Ctrl+K)"
|
||||||
<Icon name="search" size={13} />
|
onclick={() => (ws.paletteOpen = true)}
|
||||||
<span class="flex-1 truncate">Find requests, environments, actions</span>
|
>
|
||||||
<Kbd>Ctrl K</Kbd>
|
<Icon name="search" size={13} />
|
||||||
</button>
|
<span class="text-[12px]">Search</span>
|
||||||
</div>
|
<span class="mono text-[11px] text-fg-subtle/80">Ctrl K</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<button
|
<button
|
||||||
@@ -64,6 +65,13 @@
|
|||||||
>
|
>
|
||||||
<Icon name={ws.maskSecrets ? 'eye-off' : 'eye'} />
|
<Icon name={ws.maskSecrets ? 'eye-off' : 'eye'} />
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
class="grid size-8 place-items-center text-fg-muted hover:text-fg"
|
||||||
|
title="Documentation (F1)"
|
||||||
|
onclick={() => openDocs()}
|
||||||
|
>
|
||||||
|
<Icon name="help" />
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
class="grid size-8 place-items-center text-fg-muted hover:text-fg"
|
class="grid size-8 place-items-center text-fg-muted hover:text-fg"
|
||||||
title="Settings"
|
title="Settings"
|
||||||
|
|||||||
@@ -2,10 +2,11 @@
|
|||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { open as openDialog } from '@tauri-apps/plugin-dialog';
|
import { open as openDialog } from '@tauri-apps/plugin-dialog';
|
||||||
import Icon from '$lib/ui/Icon.svelte';
|
import Icon from '$lib/ui/Icon.svelte';
|
||||||
|
import Mark from '$lib/ui/Mark.svelte';
|
||||||
import { api } from '$lib/api';
|
import { api } from '$lib/api';
|
||||||
import { ws } from '$lib/state/workspace.svelte';
|
import { ws } from '$lib/state/workspace.svelte';
|
||||||
import { dialogs } from '$lib/state/dialogs.svelte';
|
import { dialogs } from '$lib/state/dialogs.svelte';
|
||||||
import { Kbd } from '@joshicodes/cock';
|
import { openDocs } from '$lib/help';
|
||||||
|
|
||||||
let recent = $state<string[]>([]);
|
let recent = $state<string[]>([]);
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
@@ -18,54 +19,81 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const home = (p: string) => p.replace(/^\/home\/[^/]+/, '~');
|
const home = (p: string) => p.replace(/^\/home\/[^/]+/, '~');
|
||||||
|
// Last two segments, because collection folders are often just called "knock".
|
||||||
|
const parts = (p: string) => {
|
||||||
|
const segs = home(p).split('/');
|
||||||
|
const name = segs.slice(-2).join('/');
|
||||||
|
return { dir: segs.slice(0, -2).join('/') + '/', name };
|
||||||
|
};
|
||||||
|
|
||||||
|
const actions = [
|
||||||
|
{ label: 'New request', keys: 'Ctrl T', run: () => ws.newScratch() },
|
||||||
|
{ label: 'Open a collection folder', keys: 'Ctrl O', run: openCollection },
|
||||||
|
{ label: 'Create a collection', keys: '', run: () => dialogs.newCollection() },
|
||||||
|
{ label: 'Import from Postman, Bruno, Insomnia, OpenAPI or cURL', keys: '', run: () => dialogs.importer() }
|
||||||
|
];
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="k-scroll h-full">
|
<div class="k-scroll h-full">
|
||||||
<div class="mx-auto flex max-w-[620px] flex-col gap-10 px-8 py-16">
|
<div class="mx-auto flex min-h-full max-w-[720px] flex-col justify-center gap-10 px-10 py-16">
|
||||||
<div>
|
<div class="flex items-center gap-7">
|
||||||
<img src="/wordmark.svg" alt="knock" class="h-9 [:root:not(.dark)_&]:hidden" />
|
<!-- The peephole: the mark, large and quiet, like the view through a door. -->
|
||||||
<img src="/wordmark-light.svg" alt="knock" class="hidden h-9 [:root:not(.dark)_&]:block" />
|
<div class="grid size-28 shrink-0 place-items-center rounded-full border border-line">
|
||||||
<p class="mt-4 text-fg-muted">Knock on an API and see what comes back. Collections are folders of YAML files you keep in git.</p>
|
<Mark size={72} class="text-hover [:root:not(.dark)_&]:text-line" />
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid grid-cols-2 gap-px overflow-hidden rounded border border-line bg-line">
|
|
||||||
{#each [
|
|
||||||
{ label: 'New request', hint: 'Ctrl T', icon: 'plus', run: () => ws.newScratch() },
|
|
||||||
{ label: 'Open collection', hint: 'Ctrl O', icon: 'folder', run: openCollection },
|
|
||||||
{ label: 'New collection', hint: '', icon: 'layers', run: () => dialogs.newCollection() },
|
|
||||||
{ label: 'Import', hint: 'Postman, Bruno, cURL', icon: 'download', run: () => dialogs.importer() }
|
|
||||||
] as a}
|
|
||||||
<button class="flex items-center gap-3 bg-panel px-4 py-4 text-left hover:bg-hover/50" onclick={a.run}>
|
|
||||||
<Icon name={a.icon} class="text-accent" />
|
|
||||||
<span class="flex-1 text-strong">{a.label}</span>
|
|
||||||
{#if a.hint.startsWith('Ctrl')}<Kbd>{a.hint}</Kbd>{:else}<span class="text-[12px] text-fg-subtle">{a.hint}</span>{/if}
|
|
||||||
</button>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{#if recent.length}
|
|
||||||
<div>
|
|
||||||
<div class="k-label mb-2">Recent</div>
|
|
||||||
{#each recent as r}
|
|
||||||
<div class="group flex items-center">
|
|
||||||
<button class="mono min-w-0 flex-1 truncate py-1.5 text-left text-[12.5px] text-soft hover:text-accent" onclick={() => ws.open(r)}>{home(r)}</button>
|
|
||||||
<button
|
|
||||||
class="px-2 text-fg-subtle opacity-0 hover:text-fg group-hover:opacity-100"
|
|
||||||
title="Remove from list"
|
|
||||||
onclick={async () => {
|
|
||||||
await api.recentForget(r);
|
|
||||||
recent = recent.filter((x) => x !== r);
|
|
||||||
}}><Icon name="x" size={12} /></button
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
{/each}
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
<div>
|
||||||
|
<h1 class="text-[26px] font-bold leading-tight tracking-tight text-strong">Nobody has knocked yet.</h1>
|
||||||
|
<p class="mt-2 max-w-[48ch] text-fg-muted">Pick an API and see what comes back. Collections are folders of YAML files; they live in your repository, not in a cloud.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="grid grid-cols-[auto_1fr] gap-x-6 gap-y-1.5 text-[12.5px]">
|
<div class="flex flex-col gap-10 pl-[140px]">
|
||||||
{#each [['Ctrl Enter', 'Send'], ['Ctrl S', 'Save'], ['Ctrl K', 'Find anything'], ['Ctrl P', 'Filter requests'], ['Ctrl E', 'Switch environment'], ['Ctrl L', 'Focus URL'], ['Ctrl Shift J', 'JSON form / code']] as [k, v]}
|
<ul class="-ml-3 flex flex-col">
|
||||||
<Kbd class="justify-self-start">{k}</Kbd><span class="text-fg-muted">{v}</span>
|
{#each actions as a}
|
||||||
{/each}
|
<li>
|
||||||
|
<button
|
||||||
|
class="group flex w-full items-baseline gap-4 border-l-2 border-transparent py-1.5 pl-3 pr-2 text-left hover:border-cyan hover:bg-hover/40"
|
||||||
|
onclick={a.run}
|
||||||
|
>
|
||||||
|
<span class="text-[14px] text-fg group-hover:text-strong">{a.label}</span>
|
||||||
|
<span class="flex-1 border-b border-dotted border-line"></span>
|
||||||
|
<span class="mono text-[11.5px] text-fg-subtle">{a.keys}</span>
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
{/each}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{#if recent.length}
|
||||||
|
<div>
|
||||||
|
<div class="k-label mb-2">Recent</div>
|
||||||
|
<ul class="-ml-3 flex flex-col">
|
||||||
|
{#each recent as r}
|
||||||
|
{@const p = parts(r)}
|
||||||
|
<li class="group flex items-center">
|
||||||
|
<button class="flex min-w-0 flex-1 items-baseline gap-2 border-l-2 border-transparent py-1 pl-3 text-left hover:border-cyan hover:bg-hover/40" onclick={() => ws.open(r)}>
|
||||||
|
<span class="shrink-0 text-strong">{p.name}</span>
|
||||||
|
<span class="mono truncate text-[11.5px] text-fg-subtle">{p.dir}</span>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class="px-2 text-fg-subtle opacity-0 hover:text-fg group-hover:opacity-100"
|
||||||
|
title="Remove from list"
|
||||||
|
onclick={async () => {
|
||||||
|
await api.recentForget(r);
|
||||||
|
recent = recent.filter((x) => x !== r);
|
||||||
|
}}><Icon name="x" size={12} /></button
|
||||||
|
>
|
||||||
|
</li>
|
||||||
|
{/each}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<p class="mono flex flex-wrap gap-x-4 gap-y-1 text-[11.5px] text-fg-subtle">
|
||||||
|
{#each [['Ctrl Enter', 'send'], ['Ctrl S', 'save'], ['Ctrl K', 'find'], ['Ctrl E', 'environment'], ['Ctrl Shift J', 'JSON form/code']] as [k, v]}
|
||||||
|
<span class="whitespace-nowrap"><span class="text-fg-muted">{k}</span> {v}</span>
|
||||||
|
{/each}
|
||||||
|
<button class="whitespace-nowrap text-fg-muted underline decoration-dotted underline-offset-4 hover:text-fg" onclick={() => openDocs()}>F1 documentation</button>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -164,7 +164,7 @@
|
|||||||
|
|
||||||
<div class="flex flex-col gap-4">
|
<div class="flex flex-col gap-4">
|
||||||
{#if grant === 'authorization_code'}
|
{#if grant === 'authorization_code'}
|
||||||
<div class="rounded border border-cyan-deep/60 bg-input px-3 py-2.5">
|
<div class="border-l-2 border-cyan bg-input/60 py-2.5 pl-4 pr-3 [:root:not(.dark)_&]:border-cyan-deep">
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<span class="k-label">Redirect URI</span>
|
<span class="k-label">Redirect URI</span>
|
||||||
<span class="flex-1"></span>
|
<span class="flex-1"></span>
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{#if tab.diskChanged}
|
{#if tab.diskChanged}
|
||||||
<div class="flex shrink-0 items-center gap-3 border-b border-line bg-post/10 px-3 py-1.5 text-[12px]">
|
<div class="flex shrink-0 items-center gap-3 border-b border-l-2 border-b-line border-l-post bg-post/8 px-3 py-1.5 text-[12px]">
|
||||||
<Icon name="alert" size={13} class="text-post" />
|
<Icon name="alert" size={13} class="text-post" />
|
||||||
<span class="flex-1 text-fg">This file changed on disk while you had unsaved edits.</span>
|
<span class="flex-1 text-fg">This file changed on disk while you had unsaved edits.</span>
|
||||||
<button class="text-accent hover:underline" onclick={reloadFromDisk}>Load the disk version</button>
|
<button class="text-accent hover:underline" onclick={reloadFromDisk}>Load the disk version</button>
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{#if tab.draft?.settings && !tab.draft.settings.verify_tls}
|
{#if tab.draft?.settings && !tab.draft.settings.verify_tls}
|
||||||
<div class="flex shrink-0 items-center gap-2 border-b border-line bg-delete/10 px-3 py-1 text-[12px] text-delete">
|
<div class="flex shrink-0 items-center gap-2 border-b border-l-2 border-b-line border-l-delete bg-delete/8 px-3 py-1 text-[12px] text-delete">
|
||||||
<Icon name="lock" size={12} />TLS verification is off for this request
|
<Icon name="lock" size={12} />TLS verification is off for this request
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { DropdownMenu, MenuItem, MenuSeparator, Kbd } from '@joshicodes/cock';
|
import { DropdownMenu, MenuItem, MenuSeparator } from '@joshicodes/cock';
|
||||||
|
import Mark from '$lib/ui/Mark.svelte';
|
||||||
import CodeEditor from '$lib/editor/CodeEditor.svelte';
|
import CodeEditor from '$lib/editor/CodeEditor.svelte';
|
||||||
import Icon from '$lib/ui/Icon.svelte';
|
import Icon from '$lib/ui/Icon.svelte';
|
||||||
import { METHODS, methodColor, mergeQuery, parseQuery, pathParamNames } from '$lib/request';
|
import { METHODS, methodColor, mergeQuery, parseQuery, pathParamNames } from '$lib/request';
|
||||||
@@ -94,9 +95,9 @@
|
|||||||
Cancel
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
{:else}
|
{:else}
|
||||||
<button class="flex h-8 items-center gap-2 rounded bg-accent px-4 font-bold text-accent-fg hover:bg-accent-hover" onclick={() => sendTab(tab)} title="Send (Ctrl+Enter)">
|
<button class="flex h-8 items-center gap-2 rounded bg-accent pl-3 pr-4 font-bold text-accent-fg hover:bg-accent-hover" onclick={() => sendTab(tab)} title="Send (Ctrl+Enter)">
|
||||||
|
<Mark size={15} />
|
||||||
Send
|
Send
|
||||||
<Kbd class="!border-accent-fg/25 !bg-transparent !text-accent-fg/80">Ctrl ⏎</Kbd>
|
|
||||||
</button>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if authHint}
|
{#if authHint}
|
||||||
<div class="flex shrink-0 items-start gap-2 border-b border-line bg-delete/8 px-3 py-2 text-[12px]">
|
<div class="flex shrink-0 items-start gap-2 border-b border-l-2 border-b-line border-l-delete bg-delete/8 px-3 py-2 text-[12px]">
|
||||||
<Icon name="lock" size={13} class="mt-0.5 text-delete" />
|
<Icon name="lock" size={13} class="mt-0.5 text-delete" />
|
||||||
<div class="min-w-0 flex-1">
|
<div class="min-w-0 flex-1">
|
||||||
{#if out.auth.kind === 'none' || !out.auth.kind}
|
{#if out.auth.kind === 'none' || !out.auth.kind}
|
||||||
|
|||||||
@@ -88,13 +88,13 @@
|
|||||||
<div class="mono text-[12px] text-fg-subtle">{root}/knock.yaml</div>
|
<div class="mono text-[12px] text-fg-subtle">{root}/knock.yaml</div>
|
||||||
</div>
|
</div>
|
||||||
<button class="rounded px-3 py-1.5 text-fg-muted hover:text-fg" onclick={exportPostman}>Export as Postman</button>
|
<button class="rounded px-3 py-1.5 text-fg-muted hover:text-fg" onclick={exportPostman}>Export as Postman</button>
|
||||||
<button class="rounded bg-accent px-4 py-1.5 font-bold text-accent-fg disabled:opacity-40 hover:bg-accent-hover" disabled={!dirty} onclick={save}>Save</button>
|
{#if dirty}<button class="rounded bg-accent px-4 py-1.5 font-bold text-accent-fg hover:bg-accent-hover" onclick={save} title="Save (Ctrl+S)">Save</button>{:else}<span class="px-4 py-1.5 text-fg-subtle">Saved</span>{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<h2 class="k-label mb-2">Auth</h2>
|
<h2 class="k-label mb-2">Auth</h2>
|
||||||
<p class="mb-2 text-[12px] text-fg-subtle">Default for every request that inherits.</p>
|
<p class="mb-2 text-[12px] text-fg-subtle">Default for every request that inherits.</p>
|
||||||
<div class="rounded border border-line"><AuthPanel bind:auth={m.auth!} level="collection" {col} /></div>
|
<div class="-mx-3"><AuthPanel bind:auth={m.auth!} level="collection" {col} /></div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
|
|||||||
@@ -159,12 +159,12 @@
|
|||||||
<input class="min-w-0 flex-1 rounded bg-transparent px-1 text-[20px] font-bold text-strong outline-none hover:bg-input focus:bg-input" bind:value={() => data!.name ?? env!, (v) => (data!.name = v)} />
|
<input class="min-w-0 flex-1 rounded bg-transparent px-1 text-[20px] font-bold text-strong outline-none hover:bg-input focus:bg-input" bind:value={() => data!.name ?? env!, (v) => (data!.name = v)} />
|
||||||
<button class="rounded px-3 py-1.5 text-fg-muted hover:text-fg" onclick={duplicateEnv}>Duplicate</button>
|
<button class="rounded px-3 py-1.5 text-fg-muted hover:text-fg" onclick={duplicateEnv}>Duplicate</button>
|
||||||
<button class="rounded px-3 py-1.5 text-fg-muted hover:text-delete" onclick={remove}>Delete</button>
|
<button class="rounded px-3 py-1.5 text-fg-muted hover:text-delete" onclick={remove}>Delete</button>
|
||||||
<button class="rounded bg-accent px-4 py-1.5 font-bold text-accent-fg disabled:opacity-40 hover:bg-accent-hover" disabled={!dirty} onclick={save}>Save</button>
|
{#if dirty}<button class="rounded bg-accent px-4 py-1.5 font-bold text-accent-fg hover:bg-accent-hover" onclick={save} title="Save (Ctrl+S)">Save</button>{:else}<span class="px-4 py-1.5 text-fg-subtle">Saved</span>{/if}
|
||||||
</div>
|
</div>
|
||||||
<div class="mono -mt-4 text-[12px] text-fg-subtle">environments/{env}.yaml</div>
|
<div class="mono -mt-4 text-[12px] text-fg-subtle">environments/{env}.yaml</div>
|
||||||
|
|
||||||
{#if ws.env(col) !== env}
|
{#if ws.env(col) !== env}
|
||||||
<div class="flex items-center gap-3 rounded border border-post/50 bg-post/10 px-4 py-2.5">
|
<div class="flex items-center gap-3 border-l-2 border-post bg-post/8 py-2.5 pl-4 pr-3">
|
||||||
<Icon name="alert" size={14} class="text-post" />
|
<Icon name="alert" size={14} class="text-post" />
|
||||||
<span class="flex-1 text-fg">
|
<span class="flex-1 text-fg">
|
||||||
Not active. Requests use {ws.env(col) ? `"${collection?.environments.find((e) => e.id === ws.env(col))?.name}"` : 'no environment'}, so these variables do not apply yet.
|
Not active. Requests use {ws.env(col) ? `"${collection?.environments.find((e) => e.id === ws.env(col))?.name}"` : 'no environment'}, so these variables do not apply yet.
|
||||||
@@ -173,7 +173,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div class="flex items-center gap-4 rounded border border-line px-4 py-3">
|
<div class="flex items-center gap-4 border-y border-line py-3">
|
||||||
<div class="flex-1">
|
<div class="flex-1">
|
||||||
<div>Protected</div>
|
<div>Protected</div>
|
||||||
<div class="text-[12px] text-fg-subtle">Shows a banner while active and asks before DELETE and PUT</div>
|
<div class="text-[12px] text-fg-subtle">Shows a banner while active and asks before DELETE and PUT</div>
|
||||||
|
|||||||
@@ -62,12 +62,12 @@
|
|||||||
<div class="mono text-[12px] text-fg-subtle">{id}/folder.yaml</div>
|
<div class="mono text-[12px] text-fg-subtle">{id}/folder.yaml</div>
|
||||||
</div>
|
</div>
|
||||||
<button class="rounded px-3 py-1.5 text-fg-muted hover:text-fg" onclick={() => dialogs.runner(col, id)}>Run folder</button>
|
<button class="rounded px-3 py-1.5 text-fg-muted hover:text-fg" onclick={() => dialogs.runner(col, id)}>Run folder</button>
|
||||||
<button class="rounded bg-accent px-4 py-1.5 font-bold text-accent-fg disabled:opacity-40 hover:bg-accent-hover" disabled={!dirty} onclick={save}>Save</button>
|
{#if dirty}<button class="rounded bg-accent px-4 py-1.5 font-bold text-accent-fg hover:bg-accent-hover" onclick={save} title="Save (Ctrl+S)">Save</button>{:else}<span class="px-4 py-1.5 text-fg-subtle">Saved</span>{/if}
|
||||||
</div>
|
</div>
|
||||||
<section>
|
<section>
|
||||||
<h2 class="k-label mb-2">Auth</h2>
|
<h2 class="k-label mb-2">Auth</h2>
|
||||||
<p class="mb-2 text-[12px] text-fg-subtle">Requests in this folder that use "inherit" get this auth.</p>
|
<p class="mb-2 text-[12px] text-fg-subtle">Requests in this folder that use "inherit" get this auth.</p>
|
||||||
<div class="rounded border border-line"><AuthPanel bind:auth={meta.auth!} level="folder" {col} /></div>
|
<div class="-mx-3"><AuthPanel bind:auth={meta.auth!} level="folder" {col} /></div>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section>
|
||||||
<h2 class="k-label mb-2">Headers</h2>
|
<h2 class="k-label mb-2">Headers</h2>
|
||||||
|
|||||||
Reference in New Issue
Block a user