Add breadcrumbs

This commit is contained in:
Rūdolfs Ošiņš
2024-09-13 13:54:39 +02:00
parent 33e0b52e23
commit 5725cec33f
9 changed files with 320 additions and 47 deletions
+45
View File
@@ -0,0 +1,45 @@
<script lang="ts">
import { createIcon } from "@app/lib/blockies";
export let nodeId: string;
function createContainer(source: string) {
const seed = source.toLowerCase();
const avatar = createIcon({
seed,
size: 8,
scale: 16,
});
return avatar.toDataURL();
}
</script>
<style>
.avatar {
display: block;
width: inherit;
object-fit: cover;
background-size: cover;
background-repeat: no-repeat;
width: 1rem;
height: 1rem;
clip-path: polygon(
0 2px,
2px 2px,
2px 0,
calc(100% - 2px) 0,
calc(100% - 2px) 2px,
100% 2px,
100% calc(100% - 2px),
calc(100% - 2px) calc(100% - 2px),
calc(100% - 2px) calc(100% - 2px),
calc(100% - 2px) 100%,
2px 100%,
2px calc(100% - 2px),
0 calc(100% - 2px)
);
background-color: red;
}
</style>
<img title={nodeId} src={createContainer(nodeId)} class="avatar" alt="avatar" />
+55 -38
View File
@@ -11,7 +11,7 @@
.header {
padding: 0 0.5rem;
gap: 0.25rem;
height: 3rem;
height: 5rem;
}
.wrapper {
width: 100%;
@@ -27,7 +27,7 @@
top: 0;
left: 0.5rem;
right: 0.5rem;
height: 3rem;
height: 5rem;
z-index: -1;
background-color: var(--color-background-float);
@@ -53,44 +53,61 @@
</style>
<div class="header global-flex">
<div class="wrapper global-flex">
<div class="wrapper-left global-flex" style:gap="0">
<div class="global-flex" style:gap="0">
<NakedButton
variant="ghost"
onclick={() => {
window.history.back();
}}>
<Icon name="arrow-left" />
</NakedButton>
<NakedButton
variant="ghost"
onclick={() => {
window.history.forward();
}}>
<Icon name="arrow-right" />
</NakedButton>
<div
class="global-flex"
style:flex-direction="column"
style:width="100%"
style:align-items="flex-start">
<div class="wrapper global-flex">
<div class="wrapper-left global-flex" style:gap="0">
<div class="global-flex" style:gap="0">
<NakedButton
variant="ghost"
onclick={() => {
window.history.back();
}}>
<Icon name="arrow-left" />
</NakedButton>
<NakedButton
variant="ghost"
onclick={() => {
window.history.forward();
}}>
<Icon name="arrow-right" />
</NakedButton>
</div>
<slot name="icon-left" />
</div>
<slot name="center" />
<div class="global-flex" style:gap="0.5rem">
<OutlineButton variant="ghost">
<Icon name="offline" />
Offline
</OutlineButton>
<Popover popoverPositionRight="0" popoverPositionTop="3rem">
<NakedButton
variant="ghost"
slot="toggle"
let:toggle
onclick={toggle}>
<Icon name="more-vertical" />
</NakedButton>
<Border variant="ghost" slot="popover" stylePadding="0.5rem 1rem">
<div style="display: flex; gap: 2rem; align-items: center;">
Theme <ThemeSwitch />
</div>
</Border>
</Popover>
</div>
<slot name="icon-left" />
</div>
<slot name="center" />
<div class="global-flex" style:gap="0.5rem">
<OutlineButton variant="ghost">
<Icon name="offline" />
Offline
</OutlineButton>
<Popover popoverPositionRight="0" popoverPositionTop="3rem">
<NakedButton variant="ghost" slot="toggle" let:toggle onclick={toggle}>
<Icon name="more-vertical" />
</NakedButton>
<Border variant="ghost" slot="popover" stylePadding="0.5rem 1rem">
<div style="display: flex; gap: 2rem; align-items: center;">
Theme <ThemeSwitch />
</div>
</Border>
</Popover>
<div
class="global-flex txt-tiny txt-semibold"
style:gap="0.5rem"
style:margin-left="1rem"
style:min-height="1.5rem">
<slot name="breadcrumbs" />
</div>
</div>
<div class="bottom-pixel-corners"></div>
+40
View File
@@ -0,0 +1,40 @@
<script lang="ts">
import { truncateId } from "@app/lib/utils";
import Avatar from "./Avatar.svelte";
export let nodeId: string;
export let alias: string | undefined = undefined;
export let styleFontSize: string | undefined = "var(--font-size-small)";
export let styleFontFamily: string | undefined =
"var(--font-family-monospace)";
</script>
<style>
.avatar-alias {
display: flex;
align-items: center;
gap: 0.375rem;
height: 1rem;
font-weight: var(--font-weight-semibold);
}
.no-alias {
color: var(--color-foreground-dim);
}
</style>
<div
class="avatar-alias"
style:font-size={styleFontSize}
style:font-family={styleFontFamily}>
<Avatar {nodeId} />
{#if alias}
<span class="txt-overflow">
{alias}
</span>
{:else}
<span class="no-alias">
{truncateId(nodeId)}
</span>
{/if}
</div>