Skip to content

Commit 0f15097

Browse files
committed
feat(panel): translate notification with i18n and adjust styling
1 parent a7ec4e2 commit 0f15097

File tree

6 files changed

+80
-3
lines changed

6 files changed

+80
-3
lines changed

src/components/container/ContainerComponent.ce.vue

+25-2
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ const root = ref<HTMLElement>();
8080
</template>
8181

8282
<style lang="scss">
83+
/* stylelint-disable selector-class-pattern -- library class name */
84+
8385
@use '~/styles/base.scss';
8486
@use '~/styles/mixin' as mixin;
8587
@use '~/styles/layout' as layout;
@@ -137,6 +139,8 @@ const root = ref<HTMLElement>();
137139
}
138140
}
139141
142+
.n-notification-container .n-notification,
143+
.n-message-wrapper .n-message,
140144
.n-dropdown-menu,
141145
.n-date-panel,
142146
.n-virtual-list {
@@ -146,6 +150,27 @@ const root = ref<HTMLElement>();
146150
);
147151
}
148152
153+
.n-notification-container .n-notification,
154+
.n-message-wrapper .n-message.n-message--error-type {
155+
--custom-bg-color: var(--bg-color-error-80);
156+
--custom-bg-color-hover: var(--bg-color-error);
157+
}
158+
159+
.n-message-wrapper .n-message.n-message--success-type {
160+
--custom-bg-color: var(--bg-color-success-80);
161+
--custom-bg-color-hover: var(--bg-color-success);
162+
}
163+
164+
.n-message-wrapper .n-message.n-message--info-type {
165+
--custom-bg-color: var(--bg-color-info-80);
166+
--custom-bg-color-hover: var(--bg-color-info);
167+
}
168+
169+
.n-message-wrapper .n-message.n-message--warning-type {
170+
--custom-bg-color: var(--bg-color-warning-80);
171+
--custom-bg-color-hover: var(--bg-color-warning);
172+
}
173+
149174
.n-popselect-menu,
150175
.n-select-menu {
151176
@include mixin.hover-background(
@@ -163,8 +188,6 @@ const root = ref<HTMLElement>();
163188
background: transparent;
164189
}
165190
166-
.n-message-wrapper .n-message,
167-
.n-notification-container .n-notification,
168191
.n-tooltip.n-tooltip,
169192
.n-popover-arrow.n-popover-arrow.n-popover-arrow {
170193
background: var(--custom-bg-color, var(--bg-color-60));

src/i18n/en/common/list.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"common__list__list": {
3+
"message": "List",
4+
"description": "List of media items"
5+
},
6+
"common__list__collaboration": {
7+
"message": "Collaboration",
8+
"description": "Shared list of media items"
9+
},
10+
"common__list__collection": {
11+
"message": "Collection",
12+
"description": "Collection of media items"
13+
},
14+
"common__list__watchlist": {
15+
"message": "Watchlist",
16+
"description": "Watchlisted media items"
17+
},
18+
"common__list__favorites": {
19+
"message": "Favorites",
20+
"description": "List of favorites media items"
21+
},
22+
"common__list__history": {
23+
"message": "History",
24+
"description": "List of watched media items"
25+
}
26+
}

src/i18n/en/common/notification.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"common__notification__added_to": {
3+
"message": "added to",
4+
"description": "Notification message when an item is added to a list"
5+
},
6+
"common__notification__removed_from": {
7+
"message": "removed from",
8+
"description": "Notification message when an item is removed from a list"
9+
}
10+
}

src/services/trakt.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ export class TraktService {
322322
},
323323
{
324324
cache: this.caches.trakt,
325-
retention: CacheRetention.Day,
325+
retention: CacheRetention.Hour * 2,
326326
key: JSON.stringify({
327327
template: {
328328
method: 'GET',

src/stores/data/list.store.ts

+16
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { ListScrollItemType } from '~/models/list-scroll.model';
1818
import { NotificationService } from '~/services/notification.service';
1919
import { TraktService } from '~/services/trakt.service';
2020
import { useUserSettingsStoreRefs } from '~/stores/settings/user.store';
21+
import { useI18n } from '~/utils';
2122
import { storage } from '~/utils/browser/browser-storage.utils';
2223
import { debounceLoading, useBelowThreshold, useLoadingPlaceholder, useSearchFilter } from '~/utils/store.utils';
2324

@@ -306,6 +307,8 @@ export const useListStore = defineStore('data.list', () => {
306307
}
307308
};
308309

310+
const i18n = useI18n('common', 'notification');
311+
309312
const addToOrRemoveFromList = async ({
310313
list,
311314
itemType,
@@ -368,6 +371,19 @@ export const useListStore = defineStore('data.list', () => {
368371
} else {
369372
console.error(`Unknown list type ${listType}.`);
370373
}
374+
NotificationService.message.success(
375+
[
376+
i18n(itemType, 'common', 'media', 'type'),
377+
i18n(remove ? 'removed_from' : 'added_to'),
378+
i18n(list.type, 'common', 'list').toLowerCase(),
379+
list.type === ListType.List ? `'${list.name}'` : '',
380+
]
381+
.filter(Boolean)
382+
.join(' '),
383+
{
384+
duration: 50000,
385+
},
386+
);
371387
} catch (e) {
372388
console.error('Failed to add item to list');
373389
NotificationService.error(`Failed to add item to list '${list.name}'`, e);

src/styles/base.scss

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
--bg-red-90: rgba(255 222 223 / 90%);
4343
--bg-color-primary: rgb(24 42 36);
4444
--bg-color-primary-80: rgba(24 42 36 / 80%);
45+
--bg-color-success: var(--bg-color-primary);
46+
--bg-color-success-80: var(--bg-color-primary-80);
4547
--bg-color-info: rgb(22 35 42);
4648
--bg-color-info-80: rgb(22 35 42 / 80%);
4749
--bg-color-warning: rgb(43 37 25);

0 commit comments

Comments
 (0)