-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Keyblock microblocks table (#382)
Co-authored-by: luekromanowicz <lromanowicz1@gmail.com>
- Loading branch information
1 parent
097104a
commit 950aa3b
Showing
7 changed files
with
264 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<template> | ||
<app-panel | ||
v-if="microblocks" | ||
class="keyblock-microblock-panel"> | ||
<paginated-content | ||
v-model:page-index="pageIndex" | ||
pagination-style="history" | ||
:entities="microblocks" | ||
:total-count="keyblockDetails.micro_blocks_count" | ||
:limit="limit" | ||
@prev-clicked="loadPrevMicroblocks" | ||
@next-clicked="loadNextMicroblocks"> | ||
<keyblock-microblocks-table | ||
:microblocks="microblocks" | ||
class="keyblock-microblock-panel__table"/> | ||
<keyblock-microblocks-table-condensed | ||
:microblocks="microblocks" | ||
class="keyblock-microblock-panel__table-condensed"/> | ||
</paginated-content> | ||
</app-panel> | ||
</template> | ||
<script setup> | ||
import { storeToRefs } from 'pinia' | ||
import { computed } from 'vue' | ||
import { useKeyblockDetailsStore } from '@/stores/keyblockDetails' | ||
import PaginatedContent from '@/components/PaginatedContent' | ||
import KeyblockMicroblocksTable from '@/components/KeyblockMicroblocksTable' | ||
import KeyblockMicroblocksTableCondensed from '@/components/KeyblockMicroblocksTableCondensed' | ||
import { isDesktop } from '@/utils/screen' | ||
const { keyblockMicroblocks: microblocks, keyblockDetails } = storeToRefs(useKeyblockDetailsStore()) | ||
const { fetchKeyblockMicroblocks } = useKeyblockDetailsStore() | ||
const route = useRoute() | ||
const limit = computed(() => isDesktop() ? 10 : 3) | ||
if (process.client) { | ||
fetchKeyblockMicroblocks({ | ||
limit: limit.value, | ||
keyblockHash: route.params.id, | ||
}) | ||
} | ||
const pageIndex = ref(1) | ||
const loadPrevMicroblocks = () => | ||
fetchKeyblockMicroblocks( | ||
{ queryParameters: microblocks.value.prev }) | ||
const loadNextMicroblocks = () => | ||
fetchKeyblockMicroblocks( | ||
{ queryParameters: microblocks.value.next }) | ||
</script> | ||
|
||
<style scoped> | ||
.keyblock-microblock-panel { | ||
padding: var(--space-4) var(--space-1) var(--space-4); | ||
margin-top: var(--space-2); | ||
@media (--desktop) { | ||
padding: var(--space-4) var(--space-4) var(--space-4); | ||
} | ||
&__table { | ||
display: none; | ||
@media (--desktop) { | ||
display: revert; | ||
} | ||
} | ||
&__table-condensed { | ||
@media (--desktop) { | ||
display: none; | ||
} | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<template> | ||
<table> | ||
<tr> | ||
<th> | ||
Hash | ||
<hint-tooltip> | ||
{{ keyblocksHints.microblockHash }} | ||
</hint-tooltip> | ||
</th> | ||
<th> | ||
Time | ||
<hint-tooltip> | ||
{{ keyblocksHints.time }} | ||
</hint-tooltip> | ||
</th> | ||
<th> | ||
Transactions Count | ||
<hint-tooltip> | ||
{{ keyblocksHints.transactionsCount }} | ||
</hint-tooltip> | ||
</th> | ||
</tr> | ||
<tr | ||
v-for="microblock in microblocks.data" | ||
:key="microblock.hash"> | ||
<td> | ||
<value-hash-ellipsed | ||
:link-to="`/microblocks/${microblock.hash}`" | ||
:hash="microblock.hash"/> | ||
</td> | ||
<td> | ||
<datetime-label :datetime="microblock.time"/> | ||
</td> | ||
<td> | ||
{{ microblock.transactionsCount }} | ||
</td> | ||
</tr> | ||
</table> | ||
</template> | ||
<script setup> | ||
import { keyblocksHints } from '@/utils/hints/keyblocksHints' | ||
import DatetimeLabel from '@/components/DatetimeLabel' | ||
defineProps({ | ||
microblocks: { | ||
type: Object, | ||
required: true, | ||
}, | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<template> | ||
<div class="keyblock-microblocks-table-condensed"> | ||
<table | ||
v-for="microblock in microblocks.data" | ||
:key="microblock.hash" | ||
class="keyblock-microblocks-table-condensed__table"> | ||
<tbody> | ||
<tr class="keyblock-microblocks-table-condensed__row"> | ||
<th class="keyblock-microblocks-table-condensed__header"> | ||
<app-tooltip> | ||
Hash | ||
<template #tooltip> | ||
{{ keyblocksHints.microblockHash }} | ||
</template> | ||
</app-tooltip> | ||
</th> | ||
<td class="keyblock-microblocks-table-condensed__data"> | ||
<value-hash-ellipsed | ||
:hash="microblock.hash" | ||
:link-to="`/microblocks/${microblock.hash}`"/> | ||
</td> | ||
</tr> | ||
<tr class="keyblock-microblocks-table-condensed__row"> | ||
<th class="keyblock-microblocks-table-condensed__header"> | ||
<app-tooltip> | ||
Time | ||
<template #tooltip> | ||
{{ keyblocksHints.time }} | ||
</template> | ||
</app-tooltip> | ||
</th> | ||
<td class="keyblock-microblocks-table-condensed__data"> | ||
<datetime-label :datetime="microblock.time"/> | ||
</td> | ||
</tr> | ||
<tr class="keyblock-microblocks-table-condensed__row"> | ||
<th class="keyblock-microblocks-table-condensed__header"> | ||
<app-tooltip> | ||
Transactions Count | ||
<template #tooltip> | ||
{{ keyblocksHints.transactionsCount }} | ||
</template> | ||
</app-tooltip> | ||
</th> | ||
<td class="keyblock-microblocks-table-condensed__data"> | ||
<div> | ||
{{ microblock.transactionsCount }} | ||
</div> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</template> | ||
<script setup> | ||
import { keyblocksHints } from '@/utils/hints/keyblocksHints' | ||
import DatetimeLabel from '@/components/DatetimeLabel' | ||
defineProps({ | ||
microblocks: { | ||
type: Object, | ||
required: true, | ||
}, | ||
}) | ||
</script> | ||
|
||
<style scoped> | ||
.keyblock-microblocks-table-condensed { | ||
&__table { | ||
background: var(--color-white); | ||
padding: 0 var(--space-1) var(--space-7); | ||
margin-bottom: var(--space-5); | ||
&:last-of-type { | ||
margin-bottom: var(--space-2); | ||
} | ||
} | ||
&__header { | ||
vertical-align: top; | ||
border-bottom: 1px solid var(--color-midnight-15); | ||
padding-right: var(--space-4); | ||
} | ||
&__row:last-of-type &__header { | ||
border-bottom: 0; | ||
} | ||
&__data { | ||
text-align: right; | ||
font-family: var(--font-monospaced); | ||
font-size: 12px; | ||
line-height: 20px; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const keyblocksHints = { | ||
microblockHash: 'Unique identifier of the microblock.', | ||
time: 'Date and time when the microblock was created.', | ||
transactionsCount: 'Amount of transactions in the microblock.', | ||
} |