-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.vue
127 lines (113 loc) · 3.75 KB
/
index.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<script lang="ts">
export default {
name: 'ProjectCard'
}
</script>
<script lang="ts" setup>
import { computed, PropType } from 'vue'
import useGitHubRepository from '~/composables/github/useGitHubRepository'
import { CampaignCampaignSummary } from '~/generated/tendermint-spn-ts-client/tendermint.spn.campaign/rest'
import { getUserAndRepositoryFromUrl } from '~/utils/github'
import ProjectCardDescription from './ProjectCardDescription.vue'
import ProjectCardHeader from './ProjectCardHeader.vue'
import ProjectCardIncentives from './ProjectCardIncentives.vue'
import ProjectCardShareAllocation from './ProjectCardShareAllocation.vue'
import ProjectCardStatus from './ProjectCardStatus.vue'
const props = defineProps({
loading: Boolean,
campaignSummary: {
type: Object as PropType<CampaignCampaignSummary>,
default: () => ({})
}
})
// variables
const githubUrl = props.campaignSummary?.mostRecentChain?.sourceURL ?? ''
const { githubUser, githubRepo } = getUserAndRepositoryFromUrl(githubUrl)
// composables
const { repository, isLoading: isGitHubRepositoryLoading } =
useGitHubRepository(githubUser, githubRepo)
// computed
const isLoading = computed(function () {
return props.loading || isGitHubRepositoryLoading.value
})
const showAllocation = computed(function () {
const campaignSummary = props.campaignSummary
const hasAtLeastOneShare = campaignSummary?.rewards?.some((supply) => {
const campaignId = campaignSummary.campaign?.campaignID
const isShare = supply.denom?.startsWith(`v/${campaignId}`)
return isShare
})
return (
!isLoading.value &&
props.campaignSummary?.incentivized &&
hasAtLeastOneShare
)
})
const showIncentives = computed(function () {
const campaignSummary = props.campaignSummary
const hasAtLeastOneIncentive = campaignSummary?.rewards?.some((supply) => {
const campaignId = campaignSummary.campaign?.campaignID
const isIncentive = !supply.denom?.startsWith(`v/${campaignId}`)
return isIncentive
})
return (
!isLoading.value &&
props.campaignSummary?.incentivized &&
hasAtLeastOneIncentive
)
})
</script>
<template>
<router-link
:to="{
path: `/projects/${campaignSummary.campaign?.campaignID ?? '0'}/overview`
}"
:class="isLoading ? 'pointer-events-none cursor-default' : 'cursor-pointer'"
>
<div class="project-card shadow-max">
<ProjectCardHeader :loading="isLoading" />
<div>
<ProjectCardDescription
:campaign="campaignSummary.campaign"
:loading="isLoading"
:github-url="githubUrl"
:github-description="repository?.description ?? ''"
class="project-card__row"
/>
<ProjectCardShareAllocation
v-if="showAllocation"
class="project-card__row"
:campaign-summary="campaignSummary"
/>
<ProjectCardIncentives
v-if="showIncentives"
class="project-card__row"
:campaign-summary="campaignSummary"
/>
<ProjectCardStatus
class="project-card__row"
:loading="isLoading"
:project-id="campaignSummary.campaign?.campaignID ?? '0'"
:validator-count="campaignSummary.mostRecentChain?.validatorNb ?? '0'"
:request-count="campaignSummary.mostRecentChain?.requestNb ?? '0'"
:stargazer-count="repository?.stargazers_count?.toString() ?? '0'"
/>
</div>
</div>
</router-link>
</template>
<style scoped lang="postcss">
.project-card {
@apply overflow-hidden rounded-md bg-white-1000;
box-shadow: 16px 32px 128px 8px rgba(0, 0, 0, 0.07);
&__row {
@apply border-t border-gray-70 py-7 px-6 md:px-7.5;
&:first-child {
@apply border-t-0 pt-8.5;
}
&._gray {
@apply border-t-0 bg-gray-50 pt-6 pb-8.5;
}
}
}
</style>