-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(inscription, metaPin): add load more functionality
- Loading branch information
1 parent
de0cbe9
commit 3f87026
Showing
10 changed files
with
269 additions
and
101 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,23 @@ | ||
<script lang="ts" setup> | ||
const props = defineProps<{ | ||
class?: string | ||
}>() | ||
console.log(props) | ||
</script> | ||
|
||
<template> | ||
<svg | ||
fill="none" | ||
viewBox="0 0 24 24" | ||
xmlns="http://www.w3.org/2000/svg" | ||
:class="['animate-spin h-5 w-5 text-white', props.class]" | ||
> | ||
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle> | ||
<path | ||
class="opacity-75" | ||
fill="currentColor" | ||
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" | ||
></path> | ||
</svg> | ||
</template> |
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,75 @@ | ||
<script setup lang="ts"> | ||
import dayjs from 'dayjs' | ||
import { ref, computed } from 'vue' | ||
import BRCToken from './BRCToken.vue' | ||
import { useRouter } from 'vue-router' | ||
import { getAddress } from '@/lib/account' | ||
import LoadingIcon from '@/components/LoadingIcon.vue' | ||
import { useInscriptionsInfiniteQuery } from '@/queries/inscribe' | ||
const size = ref(10) | ||
const address = ref() | ||
const router = useRouter() | ||
getAddress('btc').then((_address) => { | ||
address.value = _address | ||
}) | ||
const { data, isLoading, hasNextPage, fetchNextPage, isFetchingNextPage } = useInscriptionsInfiniteQuery( | ||
address, | ||
size, | ||
{ | ||
enabled: computed(() => !!address.value), | ||
} | ||
) | ||
const inscriptions = computed(() => (data.value ? data.value.pages.flatMap((page) => page.list) : [])) | ||
const toBRC20Detail = (inscriptionId: string) => { | ||
router.push({ | ||
name: 'brc20Detail', | ||
params: { | ||
address: address.value, | ||
inscriptionId, | ||
}, | ||
}) | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="space-y-4"> | ||
<div v-if="isLoading" class="w-full py-3 text-center text-sm text-gray-500">Ordinals loading...</div> | ||
<div v-else-if="inscriptions.length"> | ||
<div class="px-3 py-4 grid grid-cols-3 gap-x-3 gap-y-7"> | ||
<div | ||
v-for="inscription in inscriptions" | ||
@click="toBRC20Detail(inscription.inscriptionId)" | ||
class="flex flex-col items-center justify-center rounded-md cursor-pointer text-[#999999]" | ||
> | ||
<BRCToken :value="inscription.outputValue" :contentBody="inscription.contentBody" /> | ||
<span class="text-sm text-center mt-3 truncate" :title="'# ' + inscription.inscriptionNumber">{{ | ||
inscription.utxoHeight === 0 ? 'Uncomfirmed' : `# ${inscription.inscriptionNumber}` | ||
}}</span> | ||
<span class="text-xs text-center mt-1 h-[30px]">{{ | ||
dayjs(inscription.timestamp * 1000).format('YYYY/MM/DD HH:mm:ss') | ||
}}</span> | ||
</div> | ||
</div> | ||
<div | ||
v-if="hasNextPage" | ||
:disabled="isFetchingNextPage" | ||
@click="() => fetchNextPage()" | ||
:class="[ | ||
'text-gray-primary flex items-center gap-2 justify-center', | ||
!isFetchingNextPage ? 'cursor-pointer hover:text-blue-500 hover:underline' : 'cursor-not-allowed', | ||
]" | ||
> | ||
<span>Load more Ordinals</span> | ||
<LoadingIcon v-if="isFetchingNextPage" class="!text-gray-primary" /> | ||
</div> | ||
</div> | ||
<div v-else class="w-full py-3 text-center text-sm text-gray-500">No Ordinals yet.</div> | ||
</div> | ||
</template> | ||
|
||
<style lang="less" scoped></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
Oops, something went wrong.