Skip to content

Commit 369a8fa

Browse files
committed
fix(Feed): tooltip for tia price
1 parent 8f56da0 commit 369a8fa

File tree

1 file changed

+34
-16
lines changed

1 file changed

+34
-16
lines changed

components/Feed.vue

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<script setup>
2+
/** Vendor */
3+
import { DateTime } from "luxon"
4+
25
/** Services */
36
import { comma, formatBytes, abbreviate } from "@/services/utils"
47
@@ -14,6 +17,7 @@ const appStore = useAppStore()
1417
1518
const head = computed(() => appStore.head)
1619
20+
const series = ref([])
1721
const price = reactive({
1822
value: 0,
1923
diff: 0,
@@ -24,8 +28,9 @@ onMounted(async () => {
2428
const dataPrice = await fetchPrice()
2529
const dataSeries = await fetchPriceSeries()
2630
price.value = parseFloat(dataPrice.close)
31+
series.value = dataSeries
2732
28-
const prevDayClosePrice = parseFloat(dataSeries[1].close)
33+
const prevDayClosePrice = parseFloat(series.value[1].close)
2934
price.diff = (Math.abs(prevDayClosePrice - price.value) / ((prevDayClosePrice + price.value) / 2)) * 100
3035
price.side = price.value - prevDayClosePrice > 0 ? "rise" : "fall"
3136
})
@@ -106,26 +111,39 @@ onMounted(async () => {
106111
</Tooltip>
107112
</Flex>
108113

109-
<Flex align="center" gap="6" :class="$style.stat">
110-
<Icon name="coin" size="12" color="secondary" :class="$style.icon" />
114+
<Tooltip position="end">
115+
<Flex align="center" gap="6" :class="$style.stat">
116+
<Icon name="coin" size="12" color="secondary" :class="$style.icon" />
111117

112-
<Flex align="center" gap="4">
113-
<Text size="12" weight="500" color="tertiary" noWrap :class="$style.key">TIA:</Text>
118+
<Flex align="center" gap="4">
119+
<Text size="12" weight="500" color="tertiary" noWrap :class="$style.key">TIA:</Text>
114120

115-
<Text v-if="price.value" size="12" weight="600" noWrap :class="$style.value"> ${{ price.value.toFixed(2) }} </Text>
116-
<Skeleton v-else w="36" h="12" />
117-
</Flex>
121+
<Text v-if="price.value" size="12" weight="600" noWrap :class="$style.value"> ${{ price.value.toFixed(2) }} </Text>
122+
<Skeleton v-else w="36" h="12" />
123+
</Flex>
118124

119-
<Flex v-if="price.diff" align="center" gap="4">
120-
<Icon v-if="price.side === 'rise'" name="arrow-circle-right-up" size="12" color="neutral-green" />
121-
<Icon v-else name="arrow-circle-right-down" size="12" color="secondary" />
125+
<Flex v-if="price.diff" align="center" gap="4">
126+
<Icon v-if="price.side === 'rise'" name="arrow-circle-right-up" size="12" color="neutral-green" />
127+
<Icon v-else name="arrow-circle-right-down" size="12" color="secondary" />
122128

123-
<Text size="12" weight="600" :color="price.side === 'rise' ? 'neutral-green' : 'secondary'" noWrap>
124-
{{ price.diff.toFixed(2) }}%</Text
125-
>
129+
<Text size="12" weight="600" :color="price.side === 'rise' ? 'neutral-green' : 'secondary'" noWrap>
130+
{{ price.diff.toFixed(2) }}%</Text
131+
>
132+
</Flex>
133+
<Skeleton v-else w="50" h="12" />
126134
</Flex>
127-
<Skeleton v-else w="50" h="12" />
128-
</Flex>
135+
136+
<template #content>
137+
<Flex direction="column" gap="6">
138+
Price diff from the previous day
139+
140+
<Flex align="center" gap="4">
141+
<Text color="tertiary">{{ DateTime.fromISO(series[1].time).setLocale("en").toFormat("ff") }} -></Text>
142+
<Text color="primary">${{ series[1].close }}</Text>
143+
</Flex>
144+
</Flex>
145+
</template>
146+
</Tooltip>
129147
</Flex>
130148
</Flex>
131149
</template>

0 commit comments

Comments
 (0)