1
1
<script setup lang="ts">
2
- import { NEllipsis , NFlex , NProgress , NSkeleton , NTag } from ' naive-ui' ;
3
-
4
- import { computed , defineProps , type PropType , toRefs } from ' vue' ;
2
+ import {
3
+ NEllipsis ,
4
+ NFlex ,
5
+ NProgress ,
6
+ NSkeleton ,
7
+ NTag ,
8
+ NTooltip ,
9
+ type PopoverProps ,
10
+ } from ' naive-ui' ;
11
+
12
+ import { computed , defineProps , type PropType , ref , toRefs } from ' vue' ;
5
13
6
14
import PosterPlaceholder from ' ~/assets/images/poster-placholder.webp' ;
7
15
import { type ListScrollItem } from ' ~/models/list-scroll.model' ;
@@ -10,7 +18,7 @@ import { useShowStore } from '~/stores/data/show.store';
10
18
import { useI18n } from ' ~/utils' ;
11
19
import { deCapitalise } from ' ~/utils/string.utils' ;
12
20
13
- const i18n = useI18n (' list- item- panel' );
21
+ const i18n = useI18n (' list' , ' item' , ' panel' );
14
22
15
23
const props = defineProps ({
16
24
item: {
@@ -74,6 +82,13 @@ const progress = computed(() => {
74
82
if (! id ) return ;
75
83
return getShowProgress (id ).value ;
76
84
});
85
+
86
+ const innerContainer = ref ();
87
+ const tooltipOptions = computed <PopoverProps >(() => ({
88
+ to: innerContainer .value ,
89
+ showArrow: false ,
90
+ delay: 500 ,
91
+ }));
77
92
</script >
78
93
79
94
<template >
@@ -84,59 +99,95 @@ const progress = computed(() => {
84
99
size =" small"
85
100
:theme-overrides =" { gapSmall: '0' }"
86
101
>
87
- <div class =" meta type" >
88
- <NSkeleton v-if =" loading" text style =" width : 10% " round />
89
- <NEllipsis v-else :line-clamp =" 1" >{{ type }}</NEllipsis >
90
- </div >
91
- <div class =" title" >
92
- <NSkeleton v-if =" loading" text style =" width : 70% " round />
93
- <NEllipsis v-else :line-clamp =" 2" >{{ title }}</NEllipsis >
94
- </div >
95
- <div class =" content" >
96
- <NSkeleton v-if =" loading" text style =" width : 60% " round />
97
- <NEllipsis v-else :line-clamp =" 2" >{{ content }}</NEllipsis >
98
- </div >
99
- <NFlex v-if =" date || tags?.length" size =" medium" class =" tags" >
100
- <template v-for =" tag of tags " :key =" tag .label " >
101
- <NSkeleton v-if =" loading" text style =" width : 6% " />
102
- <NTag
103
- v-else
104
- class =" tag"
105
- :class =" { meta: tag.meta }"
106
- size =" small"
107
- :type =" tag.type"
108
- :bordered =" tag.bordered ?? false"
102
+ <div ref =" innerContainer" >
103
+ <div class =" meta type" >
104
+ <NSkeleton v-if =" loading" text style =" width : 10% " round />
105
+ <NEllipsis v-else :line-clamp =" 1" :tooltip =" tooltipOptions" >{{ type }}</NEllipsis >
106
+ </div >
107
+ <div class =" title" >
108
+ <NSkeleton v-if =" loading" text style =" width : 70% " round />
109
+ <NEllipsis v-else :line-clamp =" 2" :tooltip =" tooltipOptions" >{{
110
+ title
111
+ }}</NEllipsis >
112
+ </div >
113
+ <div class =" content" >
114
+ <NSkeleton v-if =" loading" text style =" width : 60% " round />
115
+ <NEllipsis v-else :line-clamp =" 1" :tooltip =" tooltipOptions" >{{
116
+ content
117
+ }}</NEllipsis >
118
+ </div >
119
+ <NFlex v-if =" date || tags?.length" size =" medium" class =" tags" >
120
+ <template v-for =" tag of tags " :key =" tag .label " >
121
+ <NSkeleton v-if =" loading" text style =" width : 6% " />
122
+ <NTag
123
+ v-else
124
+ class =" tag"
125
+ :class =" { meta: tag.meta }"
126
+ size =" small"
127
+ :type =" tag.type"
128
+ :bordered =" tag.bordered ?? false"
129
+ >
130
+ {{ tag.label }}
131
+ </NTag >
132
+ </template >
133
+ <template v-if =" date " >
134
+ <NSkeleton v-if =" loading" text style =" width : 6% " />
135
+ <NTag v-else class =" tag" size =" small" type =" default" :bordered =" false" >
136
+ {{ date }}
137
+ </NTag >
138
+ </template >
139
+ </NFlex >
140
+ <div v-if =" showProgress" class =" panel-progress" >
141
+ <NTooltip
142
+ class =" panel-progress-tooltip"
143
+ :disabled =" !progress"
144
+ placement =" top-end"
145
+ :delay =" 100"
146
+ :to =" innerContainer"
109
147
>
110
- {{ tag.label }}
111
- </NTag >
112
- </template >
113
- <template v-if =" date " >
114
- <NSkeleton v-if =" loading" text style =" width : 6% " />
115
- <NTag v-else class =" tag" size =" small" type =" default" :bordered =" false" >
116
- {{ date }}
117
- </NTag >
118
- </template >
119
- </NFlex >
120
- <NProgress
121
- v-if =" showProgress"
122
- :data-percentage =" progress?.percentage"
123
- :data-last =" progress?.last_episode"
124
- :data-next =" progress?.next_episode"
125
- class =" progress"
126
- :theme-overrides =" {
127
- railHeight: 'var(--rail-height)',
128
- }"
129
- :percentage =" progress?.percentage ?? 0"
130
- :show-indicator =" false"
131
- color =" var(--trakt-red-dark)"
132
- />
148
+ <NFlex v-if =" progress" vertical align =" flex-end" >
149
+ <div >
150
+ <span class =" metric" >{{ progress?.completed }}</span >
151
+ <span > / </span >
152
+ <span class =" metric" >{{ progress?.total }}</span >
153
+ <span >  ; </span >
154
+ <span >{{ i18n('tooltip_episodes') }}</span >
155
+ </div >
156
+ <div >
157
+ <span class =" metric" >{{ Math.round(progress?.percentage) }}</span >
158
+ <span >%</span >
159
+ <span >  ; </span >
160
+ <span >{{ i18n('tooltip_watched') }}</span >
161
+ </div >
162
+ <div >
163
+ <span class =" metric" >{{ progress?.total - progress?.completed }}</span >
164
+ <span >  ; </span >
165
+ <span >{{ i18n('tooltip_remaining') }}</span >
166
+ </div >
167
+ </NFlex >
168
+ <template #trigger >
169
+ <NProgress
170
+ class =" line"
171
+ :data-show-id =" progress?.id"
172
+ :data-percentage =" progress?.percentage"
173
+ :theme-overrides =" {
174
+ railHeight: 'var(--rail-height)',
175
+ }"
176
+ :percentage =" progress?.percentage ?? 0"
177
+ :show-indicator =" false"
178
+ color =" var(--trakt-red-dark)"
179
+ />
180
+ </template >
181
+ </NTooltip >
182
+ </div >
183
+ </div >
133
184
</NFlex >
134
185
</template >
135
186
136
187
<style lang="scss" scoped>
137
188
.panel {
138
189
flex : 1 1 auto ;
139
- margin : 0.25 rem 0 ;
190
+ margin : 0 0 0.25 rem ;
140
191
141
192
.title {
142
193
margin-top : 0.1rem ;
@@ -168,10 +219,30 @@ const progress = computed(() => {
168
219
}
169
220
}
170
221
171
- .progress {
172
- margin-top : 0.75rem ;
173
-
222
+ .panel-progress {
174
223
--rail-height : 4px ;
224
+
225
+ padding-top : 0.75rem ;
226
+
227
+ & :hover {
228
+ --trakt-red-dark : var (--trakt-red );
229
+ }
230
+
231
+ & -tooltip {
232
+ font-size : 0.8rem ;
233
+
234
+ .metric {
235
+ color : var (--vt-c-white );
236
+ font-weight : bolder ;
237
+ font-variant-numeric : tabular-nums ;
238
+ }
239
+ }
175
240
}
176
241
}
177
242
</style >
243
+
244
+ <style lang="scss">
245
+ .panel-progress-tooltip.n-tooltip.n-tooltip {
246
+ background : var (--bg-color-80 );
247
+ }
248
+ </style >
0 commit comments