2022-02-09 20:59:21 +01:00
|
|
|
<script lang="ts">
|
2022-03-22 21:54:46 +01:00
|
|
|
import { createEventDispatcher, onMount, tick } from "svelte";
|
2022-02-09 20:59:21 +01:00
|
|
|
import { normUrl } from "../util/history";
|
|
|
|
|
|
|
|
import Inspect from "./Inspect.svelte";
|
|
|
|
import IconButton from "./utils/IconButton.svelte";
|
|
|
|
const dispatch = createEventDispatcher();
|
|
|
|
|
|
|
|
export let address: string;
|
|
|
|
export let index: number;
|
|
|
|
export let only: boolean;
|
|
|
|
|
|
|
|
let editable = false;
|
2022-02-09 23:58:56 +01:00
|
|
|
let detail = only;
|
|
|
|
let detailChanged = false;
|
|
|
|
$: if (!detailChanged) detail = only;
|
2022-03-20 16:43:50 +01:00
|
|
|
$: if (detailChanged) tick().then(() => dispatch("detail", detail));
|
2022-02-09 20:59:21 +01:00
|
|
|
|
2022-03-22 21:54:46 +01:00
|
|
|
onMount(() => {
|
|
|
|
// Required to make detail mode detection work in Browse
|
|
|
|
dispatch("detail", detail);
|
|
|
|
});
|
|
|
|
|
2022-02-09 20:59:21 +01:00
|
|
|
function visit() {
|
|
|
|
window.open(normUrl(`/browse/${address}`), "_blank");
|
|
|
|
}
|
2023-03-07 19:32:33 +01:00
|
|
|
|
|
|
|
let width = 460;
|
|
|
|
function drag(ev: MouseEvent) {
|
|
|
|
const startWidth = width;
|
|
|
|
const startX = ev.screenX;
|
|
|
|
|
|
|
|
function onMouseMove(ev: MouseEvent) {
|
|
|
|
width = startWidth + (ev.screenX - startX);
|
|
|
|
width = width < 300 ? 300 : width;
|
|
|
|
}
|
|
|
|
function onMouseUp(_: MouseEvent) {
|
|
|
|
window.removeEventListener("mousemove", onMouseMove);
|
|
|
|
window.removeEventListener("mouseup", onMouseUp);
|
|
|
|
}
|
|
|
|
window.addEventListener("mousemove", onMouseMove);
|
|
|
|
window.addEventListener("mouseup", onMouseUp);
|
|
|
|
}
|
2022-02-09 20:59:21 +01:00
|
|
|
</script>
|
|
|
|
|
2023-03-07 21:46:53 +01:00
|
|
|
<div class="column" class:detail>
|
|
|
|
<div class="view" class:editable style="--width: {width}px">
|
2023-03-07 19:32:33 +01:00
|
|
|
<header>
|
|
|
|
<IconButton
|
|
|
|
name="pencil"
|
|
|
|
on:click={() => (editable = !editable)}
|
|
|
|
active={editable}
|
2023-04-23 13:14:36 +02:00
|
|
|
>
|
|
|
|
Edit
|
|
|
|
</IconButton>
|
2023-03-07 19:32:33 +01:00
|
|
|
<IconButton
|
2023-04-20 21:15:03 +02:00
|
|
|
name={detail ? "zoom-out" : "zoom-in"}
|
2023-03-07 19:32:33 +01:00
|
|
|
on:click={() => {
|
|
|
|
detail = !detail;
|
|
|
|
detailChanged = true;
|
|
|
|
}}
|
|
|
|
active={detail}
|
2023-04-23 13:14:36 +02:00
|
|
|
>
|
|
|
|
Detail
|
|
|
|
</IconButton>
|
|
|
|
<IconButton name="link" on:click={() => visit()} disabled={only}>
|
2023-04-23 19:25:09 +02:00
|
|
|
Detach
|
2023-04-23 13:14:36 +02:00
|
|
|
</IconButton>
|
2023-03-07 19:32:33 +01:00
|
|
|
<IconButton
|
|
|
|
name="x-circle"
|
|
|
|
on:click={() => dispatch("close")}
|
|
|
|
disabled={only}
|
2023-04-23 13:14:36 +02:00
|
|
|
>
|
|
|
|
Close
|
|
|
|
</IconButton>
|
2023-03-07 19:32:33 +01:00
|
|
|
</header>
|
|
|
|
<Inspect
|
|
|
|
{address}
|
|
|
|
editable={editable || false}
|
|
|
|
{index}
|
|
|
|
{detail}
|
|
|
|
on:resolved
|
|
|
|
on:close
|
2022-02-09 23:58:56 +01:00
|
|
|
/>
|
2023-03-07 19:32:33 +01:00
|
|
|
</div>
|
|
|
|
<div class="resizeHandle" on:mousedown|preventDefault={drag} />
|
2022-02-09 20:59:21 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<style lang="scss">
|
2023-03-07 19:32:33 +01:00
|
|
|
.column {
|
|
|
|
display: flex;
|
|
|
|
}
|
|
|
|
|
2023-03-07 21:46:53 +01:00
|
|
|
.column.detail {
|
|
|
|
width: 100%;
|
2023-04-20 21:15:03 +02:00
|
|
|
|
2023-03-07 21:46:53 +01:00
|
|
|
.view {
|
|
|
|
min-width: 75vw;
|
|
|
|
max-width: 1920px;
|
|
|
|
margin-left: auto;
|
|
|
|
margin-right: auto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-09 20:59:21 +01:00
|
|
|
.view {
|
2023-03-07 19:32:33 +01:00
|
|
|
min-width: var(--width);
|
|
|
|
max-width: var(--width);
|
2022-02-09 20:59:21 +01:00
|
|
|
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
|
|
background: var(--background-lighter);
|
|
|
|
color: var(--foreground-lighter);
|
|
|
|
border: 1px solid var(--foreground-lightest);
|
|
|
|
border-radius: 0.5em;
|
|
|
|
padding: 1rem;
|
|
|
|
|
2022-09-04 22:53:23 +02:00
|
|
|
// transition: min-width 0.2s, max-width 0.2s;
|
|
|
|
// TODO - container has nowhere to scroll, breaking `detail` scroll
|
|
|
|
|
2022-02-09 23:35:17 +01:00
|
|
|
&.editable {
|
|
|
|
border-style: dashed;
|
|
|
|
}
|
|
|
|
|
2022-02-09 20:59:21 +01:00
|
|
|
header {
|
|
|
|
font-size: 20px;
|
|
|
|
position: relative;
|
|
|
|
min-height: 1em;
|
|
|
|
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
|
|
flex: none;
|
|
|
|
}
|
|
|
|
}
|
2023-03-07 19:32:33 +01:00
|
|
|
|
|
|
|
.resizeHandle {
|
|
|
|
cursor: ew-resize;
|
|
|
|
height: 100%;
|
|
|
|
width: 0.5rem;
|
|
|
|
}
|
2022-02-09 20:59:21 +01:00
|
|
|
</style>
|