add marquee for overflowing info

feat/vaults
Tomáš Mládek 2021-06-20 00:00:47 +02:00
parent 41a4358f07
commit 7f7b132121
3 changed files with 136 additions and 42 deletions

View File

@ -1,34 +1,31 @@
<template> <template>
<div :class="['address', { identified: Boolean(inferredIds) }]" ref="root"> <div :class="['address', { identified: Boolean(inferredIds) }]" ref="root">
<hash-badge :address="address" class="hash-badge" /> <hash-badge :address="address" class="hash-badge" />
<up-link v-if="isFile" :to="{ entity: address }"> <Marquee>
{{ address }} <up-link v-if="isFile" :to="{ entity: address }">
</up-link> {{ address }}
<template v-else>
<up-link v-if="link" :to="{ entity: address }">
{{ inferredIds.join(" | ") || address }}
</up-link> </up-link>
<template v-else> <template v-else>
{{ inferredIds.join(" | ") || address }} <up-link v-if="link" :to="{ entity: address }">
{{ inferredIds.join(" | ") || address }}
</up-link>
<template v-else>
{{ inferredIds.join(" | ") || address }}
</template>
</template> </template>
</template> </Marquee>
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { identify, useEntity } from "@/lib/entity"; import { identify, useEntity } from "@/lib/entity";
import { import { computed, ComputedRef, defineComponent, onMounted, ref } from "vue";
computed,
ComputedRef,
defineComponent,
onMounted,
ref,
} from "vue";
import HashBadge from "./HashBadge.vue"; import HashBadge from "./HashBadge.vue";
import UpLink from "./UpLink.vue"; import UpLink from "./UpLink.vue";
import Marquee from "./Marquee.vue";
export default defineComponent({ export default defineComponent({
components: { HashBadge, UpLink }, components: { HashBadge, UpLink, Marquee },
name: "Address", name: "Address",
props: { props: {
address: { address: {

View File

@ -0,0 +1,76 @@
<template>
<div
class="marquee"
:class="{ overflowed }"
:style="`--shift-width: ${shiftWidth}`"
ref="root"
>
<div class="inner" ref="inner">
<slot></slot>
</div>
</div>
</template>
<script lang="ts">
import { defineComponent, onMounted, ref } from "vue";
export default defineComponent({
name: "Marquee",
setup() {
const root = ref<HTMLDivElement | null>(null);
const inner = ref<HTMLDivElement | null>(null);
const overflowed = ref(false);
const shiftWidth = ref("unset");
onMounted(() => {
const resizeObserver = new ResizeObserver(() => {
overflowed.value = root.value!.scrollWidth > root.value!.clientWidth;
shiftWidth.value = `-${
inner.value!.clientWidth - root.value!.clientWidth
}px`;
});
resizeObserver.observe(inner.value!);
});
return {
root,
inner,
overflowed,
shiftWidth,
};
},
});
</script>
<style scoped lang="scss">
.marquee {
line-height: 1;
overflow: hidden;
}
.inner {
white-space: nowrap;
display: inline-block;
}
</style>
<style lang="scss">
.overflowed .inner {
animation: marquee 12s ease-in-out infinite;
--padding: .5em;
}
@keyframes marquee {
0% {
transform: translateX(var(--padding));
}
50% {
transform: translateX(calc(var(--shift-width) - var(--padding)));
}
100% {
transform: translateX(var(--padding));
}
}
</style>

View File

@ -21,6 +21,11 @@
{{ types[typeAddr]?.name || "???" }} {{ types[typeAddr]?.name || "???" }}
</h3> </h3>
<table> <table>
<colgroup>
<col class="attr-action-col" />
<col />
<col />
</colgroup>
<tr> <tr>
<th></th> <th></th>
<th>Attribute</th> <th>Attribute</th>
@ -30,16 +35,20 @@
<td class="attr-action"> <td class="attr-action">
<sl-icon-button name="x-circle" @click="removeEntry(id)" /> <sl-icon-button name="x-circle" @click="removeEntry(id)" />
</td> </td>
<td>{{ entry.attribute }}</td>
<td> <td>
<Address <Marquee>{{ entry.attribute }}</Marquee>
link </td>
v-if="entry.value.t === 'Address'" <td>
:address="entry.value.c" <Marquee>
/> <Address
<template v-else> link
{{ entry.value.c }} v-if="entry.value.t === 'Address'"
</template> :address="entry.value.c"
/>
<template v-else>
{{ entry.value.c }}
</template>
</Marquee>
</td> </td>
</tr> </tr>
</table> </table>
@ -50,6 +59,11 @@
Other attributes Other attributes
</h3> </h3>
<table> <table>
<colgroup>
<col class="attr-action-col" />
<col />
<col />
</colgroup>
<tr> <tr>
<th></th> <th></th>
<th>Attribute</th> <th>Attribute</th>
@ -59,16 +73,20 @@
<td class="attr-action"> <td class="attr-action">
<sl-icon-button name="x-circle" @click="removeEntry(id)" /> <sl-icon-button name="x-circle" @click="removeEntry(id)" />
</td> </td>
<td>{{ entry.attribute }}</td>
<td> <td>
<Address <Marquee>{{ entry.attribute }}</Marquee>
link </td>
v-if="entry.value.t === 'Address'" <td>
:address="entry.value.c" <Marquee>
/> <Address
<template v-else> link
{{ entry.value.c }} v-if="entry.value.t === 'Address'"
</template> :address="entry.value.c"
/>
<template v-else>
{{ entry.value.c }}
</template>
</Marquee>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -94,10 +112,14 @@
</tr> </tr>
<tr v-for="[id, entry] in backlinks" :key="id"> <tr v-for="[id, entry] in backlinks" :key="id">
<td> <td>
<Address link :address="entry.entity" /> <Marquee>
<Address link :address="entry.entity" />
</Marquee>
</td> </td>
<td> <td>
{{ entry.attribute }} <Marquee>
{{ entry.attribute }}
</Marquee>
</td> </td>
</tr> </tr>
</table> </table>
@ -113,6 +135,7 @@
<script lang="ts"> <script lang="ts">
import Address from "@/components/Address.vue"; import Address from "@/components/Address.vue";
import BlobPreview from "@/components/BlobPreview.vue"; import BlobPreview from "@/components/BlobPreview.vue";
import Marquee from "@/components/Marquee.vue";
import { query, useEntity } from "@/lib/entity"; import { query, useEntity } from "@/lib/entity";
import { UpType } from "@/lib/types"; import { UpType } from "@/lib/types";
import { IEntry } from "@/types/base"; import { IEntry } from "@/types/base";
@ -123,6 +146,7 @@ export default defineComponent({
components: { components: {
Address, Address,
BlobPreview, BlobPreview,
Marquee,
}, },
props: { props: {
address: { address: {
@ -248,12 +272,9 @@ export default defineComponent({
</script> </script>
<style lang="scss"> <style lang="scss">
.inspect {
overflow: auto;
}
table { table {
width: 100%; width: 100%;
table-layout: fixed;
th { th {
text-align: left; text-align: left;
@ -270,8 +291,8 @@ table {
} }
} }
sl-input { .attr-action-col {
max-width: 8em; width: 2em;
} }
} }