Skip to content

Commit 1e0cdb8

Browse files
committed
feat(panel): adds remove/cancel labels
1 parent 439225b commit 1e0cdb8

9 files changed

+226
-42
lines changed

src/components/icons/IconCancel.vue

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<template>
2+
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">
3+
<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="2">
4+
<path
5+
stroke-dasharray="60"
6+
stroke-dashoffset="60"
7+
d="M5.63604 5.63603C9.15076 2.12131 14.8492 2.12131 18.364 5.63603C21.8787 9.15075 21.8787 14.8492 18.364 18.364C14.8492 21.8787 9.15076 21.8787 5.63604 18.364C2.12132 14.8492 2.12132 9.15075 5.63604 5.63603Z"
8+
>
9+
<animate
10+
fill="freeze"
11+
attributeName="stroke-dashoffset"
12+
dur="0.5s"
13+
values="60;0"
14+
/>
15+
</path>
16+
<path stroke-dasharray="18" stroke-dashoffset="18" d="M6 6L18 18">
17+
<animate
18+
fill="freeze"
19+
attributeName="stroke-dashoffset"
20+
begin="0.6s"
21+
dur="0.2s"
22+
values="18;0"
23+
/>
24+
</path>
25+
</g>
26+
</svg>
27+
</template>

src/components/icons/IconCheckAll.vue

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<template>
2+
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">
3+
<defs>
4+
<mask id="lineMdCheckAll0">
5+
<g
6+
fill="none"
7+
stroke="#fff"
8+
stroke-dasharray="22"
9+
stroke-dashoffset="22"
10+
stroke-linecap="round"
11+
stroke-linejoin="round"
12+
stroke-width="2"
13+
>
14+
<path d="M2 13.5l4 4l10.75 -10.75">
15+
<animate
16+
fill="freeze"
17+
attributeName="stroke-dashoffset"
18+
dur="0.4s"
19+
values="22;0"
20+
/>
21+
</path>
22+
<path stroke="#000" stroke-width="4" d="M7.5 13.5l4 4l10.75 -10.75" opacity="0">
23+
<set attributeName="opacity" begin="0.4s" to="1" />
24+
<animate
25+
fill="freeze"
26+
attributeName="stroke-dashoffset"
27+
begin="0.4s"
28+
dur="0.4s"
29+
values="22;0"
30+
/>
31+
</path>
32+
<path d="M7.5 13.5l4 4l10.75 -10.75" opacity="0">
33+
<set attributeName="opacity" begin="0.4s" to="1" />
34+
<animate
35+
fill="freeze"
36+
attributeName="stroke-dashoffset"
37+
begin="0.4s"
38+
dur="0.4s"
39+
values="22;0"
40+
/>
41+
</path>
42+
</g>
43+
</mask>
44+
</defs>
45+
<rect width="24" height="24" fill="currentColor" mask="url(#lineMdCheckAll0)" />
46+
</svg>
47+
</template>

src/components/views/panel/MoviePanelDetails.vue

+22-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,19 @@ const i18n = useI18n('panel', 'detail');
2424
const released = computed(() => {
2525
if (!movie?.value) return;
2626
if (!movie.value?.released) return '-';
27-
return new Date(movie.value?.released).toLocaleDateString();
27+
return new Date(movie.value?.released);
28+
});
29+
30+
const releasedDate = computed(() => {
31+
if (!released.value) return;
32+
if (typeof released.value === 'string') return released.value;
33+
return released.value.toLocaleDateString();
34+
});
35+
36+
const releasedTime = computed(() => {
37+
if (!released.value) return;
38+
if (typeof released.value === 'string') return released.value;
39+
return released.value.toLocaleTimeString();
2840
});
2941
3042
const runtime = computed(() => {
@@ -78,8 +90,15 @@ const country = computed(() => {
7890
<NFlex class="row" size="large">
7991
<!-- Release date -->
8092
<PanelDetail
81-
:label="i18n('released')"
82-
:value="released"
93+
:label="i18n('released_date')"
94+
:value="releasedDate"
95+
:skeleton="{ width: '5.125rem' }"
96+
/>
97+
98+
<!-- Release Time -->
99+
<PanelDetail
100+
:label="i18n('released_time')"
101+
:value="releasedTime"
83102
:skeleton="{ width: '5.125rem' }"
84103
/>
85104

src/components/views/panel/PanelButtonProgress.vue

+30-13
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
type TooltipProps,
1010
} from 'naive-ui';
1111
12-
import { type Component, h, type PropType, ref } from 'vue';
12+
import { type Component, computed, h, type PropType, ref, toRefs } from 'vue';
1313
1414
import type {
1515
EpisodeProgress,
@@ -21,7 +21,7 @@ import type {
2121
import ProgressTooltip from '~/components/common/tooltip/ProgressTooltip.vue';
2222
import { useI18n } from '~/utils';
2323
24-
defineProps({
24+
const props = defineProps({
2525
select: {
2626
type: Object as PropType<PopselectProps>,
2727
required: true,
@@ -58,6 +58,13 @@ defineProps({
5858
},
5959
});
6060
61+
const { percentage } = toRefs(props);
62+
63+
const progressBackground = computed(() => {
64+
if (percentage?.value === undefined) return false;
65+
return percentage.value > 0 && percentage.value < 100;
66+
});
67+
6168
const renderLabel = (option: SelectOption & { icon: Component }) => [
6269
h(NIcon, {
6370
style: {
@@ -72,6 +79,7 @@ const renderLabel = (option: SelectOption & { icon: Component }) => [
7279
const i18n = useI18n('panel', 'buttons');
7380
7481
const root = ref();
82+
const trigger = ref();
7583
</script>
7684

7785
<template>
@@ -80,7 +88,7 @@ const root = ref();
8088
class="button-progress-container"
8189
:data-progress="percentage"
8290
:style="{
83-
'--progress': `${ percentage }%`,
91+
'--progress': `${percentage}%`,
8492
'--progress-color': `var(--${type}-color-dark)`,
8593
}"
8694
>
@@ -95,17 +103,20 @@ const root = ref();
95103
>
96104
<NPopselect
97105
:style="{
98-
'--custom-bg-color': `var(--bg-color-${ type }-80)`,
106+
'--custom-bg-color': `var(--bg-color-${type}-80)`,
99107
'--custom-bg-color-hover': `var(--bg-color-${type})`,
100108
}"
101109
:to="root"
102110
:render-label="renderLabel"
103111
trigger="focus"
104112
:disabled="disabled"
105113
v-bind="select"
114+
:on-update:show="_show => !_show && trigger?.$el?.blur()"
106115
>
107116
<NButton
108-
:class="{ filled, progress }"
117+
ref="trigger"
118+
class="button"
119+
:class="{ filled, progress: progressBackground }"
109120
round
110121
:secondary="!filled"
111122
:disabled="disabled"
@@ -127,24 +138,30 @@ const root = ref();
127138
margin-left: calc(0% - var(--n-icon-margin));
128139
}
129140
130-
.progress:not(.filled) {
131-
background: linear-gradient(
132-
to right,
133-
var(--progress-color) 0%,
134-
var(--progress-color) var(--progress, 0%),
135-
var(--n-color) var(--progress, 0%),
136-
var(--n-color) 100%
137-
);
141+
.button {
142+
background: linear-gradient(to right, var(--n-color) 0%, var(--n-color) 100%);
138143
transition:
139144
color 0.3s var(--n-bezier),
145+
background 0.3s var(--n-bezier),
140146
background-color 0.3s var(--n-bezier),
141147
opacity 0.3s var(--n-bezier),
142148
border-color 0.3s var(--n-bezier),
143149
filter 0.3s var(--n-bezier);
150+
will-change: color, background, background-color, opacity, border-color, filter;
144151
145152
&:hover {
146153
filter: brightness(1.2);
147154
}
148155
}
156+
157+
.progress:not(.filled) {
158+
background: linear-gradient(
159+
to right,
160+
var(--progress-color) 0%,
161+
var(--progress-color) var(--progress, 0%),
162+
var(--n-color) var(--progress, 0%),
163+
var(--n-color) 100%
164+
);
165+
}
149166
}
150167
</style>

src/components/views/panel/PanelButtons.vue

+36-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import { NButton, NFlex, NIcon } from 'naive-ui';
33
import { computed, onMounted, type PropType, ref, toRefs } from 'vue';
44
55
import IconCalendar from '~/components/icons/IconCalendar.vue';
6+
import IconCancel from '~/components/icons/IconCancel.vue';
67
import IconCheckedList from '~/components/icons/IconCheckedList.vue';
8+
import IconClose from '~/components/icons/IconClose.vue';
79
import IconCloseSmall from '~/components/icons/IconCloseSmall.vue';
810
import IconGrid from '~/components/icons/IconGrid.vue';
911
import IconGridEmpty from '~/components/icons/IconGridEmpty.vue';
@@ -94,6 +96,37 @@ const timeOptions = [
9496
{ label: i18n('label__other'), value: 'custom', icon: IconCalendar },
9597
];
9698
99+
const cancelOption = {
100+
label: i18n('label__cancel'),
101+
value: 'cancel',
102+
icon: IconCancel,
103+
};
104+
105+
const removeOption = {
106+
label: i18n('label__remove'),
107+
value: 'remove',
108+
icon: IconClose,
109+
};
110+
111+
const removeOptions = [removeOption, cancelOption];
112+
const mixedOptions = [...timeOptions, removeOption];
113+
114+
const watchedOptions = computed(() => {
115+
if (watched.value) return removeOptions;
116+
if (watchedPercentage.value > 0 && watchedPercentage.value < 100) {
117+
return mixedOptions;
118+
}
119+
return timeOptions;
120+
});
121+
122+
const collectionOptions = computed(() => {
123+
if (collected.value) return removeOptions;
124+
if (collectionPercentage.value > 0 && collectionPercentage.value < 100) {
125+
return mixedOptions;
126+
}
127+
return timeOptions;
128+
});
129+
97130
const { lists } = useListsStoreRefs();
98131
const { fetchLists, getIcon } = useListsStore();
99132
@@ -129,7 +162,7 @@ onMounted(() => {
129162
}"
130163
/>
131164
</template>
132-
<span>{{ i18n(`label__${ checkin ? 'cancel' : 'checkin' }`) }}</span>
165+
<span>{{ i18n(`label__${ checkin ? 'cancel_checkin' : 'checkin' }`) }}</span>
133166
</NButton>
134167
</NFlex>
135168

@@ -156,7 +189,7 @@ onMounted(() => {
156189
<NFlex class="button-container collection" justify="center" align="center">
157190
<PanelButtonProgress
158191
:select="{
159-
options: timeOptions,
192+
options: collectionOptions,
160193
}"
161194
:tooltip="{
162195
disabled: !['show', 'season'].includes(mode),
@@ -166,7 +199,6 @@ onMounted(() => {
166199
:progress="collectionProgress"
167200
:percentage="collectionPercentage"
168201
:filled="collected"
169-
:disabled="collected === undefined"
170202
type="info"
171203
>
172204
{{ i18n(`label__collection__${ collected ? 'remove' : 'add' }`) }}
@@ -177,7 +209,7 @@ onMounted(() => {
177209
<NFlex class="button-container history" justify="center" align="center">
178210
<PanelButtonProgress
179211
:select="{
180-
options: timeOptions,
212+
options: watchedOptions,
181213
}"
182214
:tooltip="{
183215
disabled: !['show', 'season'].includes(mode),
@@ -186,7 +218,6 @@ onMounted(() => {
186218
:progress="watchedProgress"
187219
:percentage="watchedPercentage"
188220
:filled="watched"
189-
:disabled="watched === undefined"
190221
>
191222
{{ i18n(`label__history__${ watched ? 'remove' : 'add' }`) }}
192223
</PanelButtonProgress>

src/components/views/panel/PanelOverview.vue

+1-5
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ const { openTab } = useExtensionSettingsStore();
4141
<NSkeleton v-else class="title-skeleton" style="width: 40dvh" round />
4242

4343
<div v-if="overview">{{ overview }}</div>
44-
<template v-else>
45-
<NSkeleton style="width: 100%" />
46-
<NSkeleton style="width: 100%" />
47-
<NSkeleton style="width: 100%" />
48-
</template>
44+
<NSkeleton v-else style="width: 100%" :repeat="3" :sharp="false" />
4945
</NFlex>
5046
</template>
5147

0 commit comments

Comments
 (0)