Skip to content

Commit f0709f4

Browse files
committed
fix(loading): fix styling and loading indicator
1 parent c3cbbc5 commit f0709f4

File tree

4 files changed

+68
-21
lines changed

4 files changed

+68
-21
lines changed

src/components/common/list/ListItem.vue

+61-16
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,15 @@ const loading = computed(() => props.item.loading);
7373
<NTimelineItem
7474
:key="item.id"
7575
class="timeline-item"
76-
:class="{ 'no-header': noHeader, 'next-has-header': nextHasHead }"
76+
:class="{
77+
'no-header': noHeader,
78+
'next-has-header': nextHasHead,
79+
'show-date': !hideDate,
80+
}"
7781
:data-key="item.id"
7882
:data-index="index"
79-
:line-type="item.loading ? 'dashed' : lineType"
80-
:color="item.loading ? 'grey' : color"
83+
:line-type="loading ? 'dashed' : lineType"
84+
:color="loading ? 'grey' : color"
8185
@mouseenter="onHover(true)"
8286
@mouseleave="onHover(false)"
8387
>
@@ -88,7 +92,13 @@ const loading = computed(() => props.item.loading);
8892
<slot name="before" />
8993
</template>
9094
<template #default>
91-
<NFlex class="content" :class="{ 'no-border': noHeader }" :wrap="false">
95+
<NFlex
96+
class="content"
97+
:class="{ 'no-border': noHeader }"
98+
size="small"
99+
:theme-overrides="{ gapSmall: '0' }"
100+
:wrap="false"
101+
>
92102
<NFlex
93103
v-if="!hideDate"
94104
class="header"
@@ -99,16 +109,16 @@ const loading = computed(() => props.item.loading);
99109
size="small"
100110
:theme-overrides="{ gapSmall: '0.25rem' }"
101111
>
102-
<template v-if="date && !noHeader">
112+
<template v-if="date && !noHeader && !loading">
103113
<NTime class="month" :time="date" format="MMM" />
104114
<NTime class="day" :time="date" format="dd" />
105-
<NTime :time="date" format="eee" />
115+
<NTime class="week" :time="date" format="eee" />
106116
<NTime v-if="!sameYear" class="year" :time="date" format="yyyy" />
107117
</template>
108118
<template v-else-if="loading">
109-
<NSkeleton text style="width: 1rem" />
110-
<NSkeleton text style="width: 2rem" />
111-
<NSkeleton text style="width: 1rem" />
119+
<NSkeleton class="loading month" text round />
120+
<NSkeleton class="loading day" text round />
121+
<NSkeleton class="loading week" text round />
112122
</template>
113123
</NFlex>
114124
<NFlex class="tile" :wrap="false">
@@ -121,8 +131,8 @@ const loading = computed(() => props.item.loading);
121131
:preview-src="poster"
122132
:fallback-src="PosterPlaceholder"
123133
/>
124-
<ListItemPanel :item="item" :loading="item.loading">
125-
<slot :item="item" :index="index" :loading="item.loading" />
134+
<ListItemPanel :item="item" :loading="loading">
135+
<slot :item="item" :index="index" :loading="loading" />
126136
</ListItemPanel>
127137
</NFlex>
128138
</NFlex>
@@ -140,9 +150,11 @@ const loading = computed(() => props.item.loading);
140150
.timeline-item {
141151
margin: 0 1rem;
142152
143-
.content {
144-
padding: 0.5rem;
153+
&.show-date {
154+
margin-left: 4rem;
155+
}
145156
157+
.content {
146158
.tile {
147159
@include mixin.hover-background(
148160
$from: transparent,
@@ -151,14 +163,18 @@ const loading = computed(() => props.item.loading);
151163
);
152164
153165
flex: 1 1 auto;
166+
padding: 0.5rem;
154167
}
155168
}
156169
157170
.header {
158-
width: 2.5rem;
159-
margin: 0.25rem 0.5rem 0 -0.25rem;
171+
position: absolute;
172+
top: 0;
173+
left: -3.75rem;
174+
width: 3.5rem;
160175
color: var(--n-text-color);
161176
font-size: 14px;
177+
border-top: 1px solid var(--border-grey);
162178
163179
&.hover {
164180
color: var(--trakt-red);
@@ -167,6 +183,7 @@ const loading = computed(() => props.item.loading);
167183
}
168184
169185
.month {
186+
margin-top: 0.75rem;
170187
font-weight: bold;
171188
}
172189
@@ -178,6 +195,31 @@ const loading = computed(() => props.item.loading);
178195
.year {
179196
color: var(--n-meta-text-color);
180197
}
198+
199+
.loading {
200+
margin-bottom: 0.25rem;
201+
202+
&.month {
203+
width: 1.5rem;
204+
height: 0.8rem;
205+
}
206+
207+
&.day {
208+
width: 2rem;
209+
height: 1rem;
210+
}
211+
212+
&.week {
213+
width: 1.6rem;
214+
height: 0.75rem;
215+
}
216+
}
217+
}
218+
219+
&.no-header {
220+
.header {
221+
border-top: 1px solid transparent;
222+
}
181223
}
182224
183225
.poster {
@@ -198,6 +240,8 @@ const loading = computed(() => props.item.loading);
198240
199241
.n-timeline.n-timeline--left-placement {
200242
.timeline-item.n-timeline-item .n-timeline-item-timeline {
243+
--n-icon-size: 12px;
244+
201245
top: calc(0% - var(--n-icon-size) / 2);
202246
}
203247
@@ -212,6 +256,7 @@ const loading = computed(() => props.item.loading);
212256
}
213257
214258
.timeline-item.n-timeline-item .n-timeline-item-content {
259+
margin-left: calc(var(--n-icon-size) + 0.125rem);
215260
border-top: 1px solid transparent;
216261
217262
.n-timeline-item-content__title {
@@ -220,7 +265,7 @@ const loading = computed(() => props.item.loading);
220265
}
221266
222267
.timeline-item.n-timeline-item:not(.no-header) .n-timeline-item-content {
223-
border-top: 1px solid rgba(255 255 255 / 10%);
268+
border-top: 1px solid var(--border-grey);
224269
}
225270
}
226271
</style>

src/components/common/list/ListItemPanel.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,19 @@ const type = computed(() => {
6060
:theme-overrides="{ gapSmall: '0' }"
6161
>
6262
<div class="meta type">
63-
<NSkeleton v-if="loading" text style="width: 10%" />
63+
<NSkeleton v-if="loading" text style="width: 10%" round />
6464
<NEllipsis v-else :line-clamp="1">{{ type }}</NEllipsis>
6565
</div>
6666
<div class="title">
67-
<NSkeleton v-if="loading" text style="width: 70%" />
67+
<NSkeleton v-if="loading" text style="width: 70%" round />
6868
<NEllipsis v-else :line-clamp="2">{{ title }}</NEllipsis>
6969
</div>
7070
<div class="content">
71-
<NSkeleton v-if="loading" text style="width: 60%" />
71+
<NSkeleton v-if="loading" text style="width: 60%" round />
7272
<NEllipsis v-else :line-clamp="2">{{ content }}</NEllipsis>
7373
</div>
7474
<div class="meta time">
75-
<NSkeleton v-if="loading" text style="width: 20%" />
75+
<NSkeleton v-if="loading" text style="width: 20%" round />
7676
<NEllipsis v-else :line-clamp="1">{{ date }}</NEllipsis>
7777
</div>
7878
</NFlex>

src/stores/router.store.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ export const useRouterStore = defineStore('router', () => {
2727
const setLastRoute = (_route: RouteLocationNormalized) => {
2828
if (lastRoute.value?.name === _route.name) return;
2929
lastRoute.value = _route;
30-
return storage.local.set('app.state.last-route', _route);
30+
const { matched, ...jsonSafeRoute } = _route;
31+
return storage.local.set('app.state.last-route', jsonSafeRoute);
3132
};
3233

3334
const restoreLastRoute = async () => {

src/styles/base.scss

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
--bg-red-70: rgba(255 222 223 / 70%);
3333
--bg-red-80: rgba(255 222 223 / 80%);
3434
--bg-red-90: rgba(255 222 223 / 90%);
35+
--border-grey: rgb(70 70 70);
3536
--primary-color: #63e2b7;
3637
--primary-color-lighter: #7fe7c4;
3738
--primary-color-disabled: #548272;

0 commit comments

Comments
 (0)