69 lines
1.6 KiB
Svelte
69 lines
1.6 KiB
Svelte
<script lang="ts">
|
|
import { useNavigate, useParams } from "svelte-navigator";
|
|
import BrowseColumn from "../components/BrowseColumn.svelte";
|
|
import { updateTitle } from "../util/title";
|
|
const navigate = useNavigate();
|
|
const params = useParams();
|
|
|
|
let root: HTMLDivElement;
|
|
let identities: string[] = [];
|
|
$: addresses = $params.addresses.split(",");
|
|
|
|
function close(idx: number) {
|
|
let _addresses = addresses.concat();
|
|
_addresses.splice(idx, 1);
|
|
if (_addresses.length) {
|
|
navigate(`/browse/${_addresses.join(",")}`);
|
|
} else {
|
|
navigate("/");
|
|
}
|
|
}
|
|
|
|
$: {
|
|
addresses;
|
|
|
|
root?.scrollTo({
|
|
left: root.scrollWidth,
|
|
behavior: "smooth",
|
|
});
|
|
}
|
|
|
|
function onIdentified(index: number, ev: CustomEvent<string[]>) {
|
|
for (let i = 0; i < addresses.length; i++) {
|
|
if (!identities[i]) {
|
|
identities[i] = "?";
|
|
}
|
|
identities[index] = ev.detail.join("/");
|
|
}
|
|
identities = identities;
|
|
}
|
|
|
|
$: updateTitle("Browse", identities.join(" / "));
|
|
</script>
|
|
|
|
<div class="browser" bind:this={root}>
|
|
{#each addresses as address, index}
|
|
<BrowseColumn
|
|
{address}
|
|
{index}
|
|
only={addresses.length === 1}
|
|
on:close={() => close(index)}
|
|
on:resolved={(ev) => onIdentified(index, ev)}
|
|
/>
|
|
{/each}
|
|
</div>
|
|
|
|
<style scoped lang="scss">
|
|
.browser {
|
|
display: flex;
|
|
overflow-x: auto;
|
|
gap: 1rem;
|
|
padding: 0 1rem;
|
|
|
|
// header margin magic
|
|
height: calc(100% - 3.5rem - 1rem - 1px);
|
|
margin-top: 1rem;
|
|
margin-bottom: var(--footer-height);
|
|
}
|
|
</style>
|