Skip to content

Commit 249834b

Browse files
committed
feat(settings): adds navbar position setting
1 parent e1a19a3 commit 249834b

File tree

8 files changed

+68
-10
lines changed

8 files changed

+68
-10
lines changed

src/components/views/about/AboutComponent.vue

+4
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ const openRelease = (url?: string) => {
140140
padding-top: layout.$floating-navbar-height;
141141
}
142142
143+
&.reverse {
144+
padding-bottom: layout.$header-navbar-height;
145+
}
146+
143147
.card {
144148
@include mixin.hover-background($from: var(--bg-black-50), $to: var(--bg-color-80));
145149
}

src/components/views/progress/ProgressComponent.vue

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ const { isWatching } = useWatchingStoreRefs();
3232
const { scrolled, listRef, onClick } = useBackToTop();
3333
const { onItemClick } = usePanelItem();
3434
35+
const { reverse } = useAppStateStoreRefs();
36+
3537
onMounted(() => {
3638
watch(panelOpen, async value => {
3739
if (!value && panelDirty.value) await fetchProgress();
@@ -103,6 +105,7 @@ useActiveAndDocumentVisible({
103105
ref="listRef"
104106
:loading="loading"
105107
:items="progress"
108+
:list-options="reverse ? { paddingBottom: 44 } : {}"
106109
backdrop
107110
hide-date
108111
show-progress

src/components/views/settings/SettingsTabs.vue

+20
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import IconPencil from '~/components/icons/IconPencil.vue';
1717
import SettingsFormItem from '~/components/views/settings/SettingsFormItem.vue';
1818
import { type ListEntity, ListType } from '~/models/list.model';
1919
import { loadingHysteresisOptions } from '~/models/loading-hysteresis.model';
20+
import { NavbarPosition } from '~/models/navbar-position.model';
2021
import { pageSizeOptions, pageSizeOptionsWithZero } from '~/models/page-size.model';
2122
import { ProgressType } from '~/models/progress-type.model';
2223
import { Route } from '~/models/router.model';
@@ -51,6 +52,7 @@ const {
5152
enableRatings,
5253
backgroundColor,
5354
loadingHysteresis,
55+
navbarPosition,
5456
} = useExtensionSettingsStoreRefs();
5557
5658
const { getIcon, fetchLists } = useListsStore();
@@ -73,6 +75,13 @@ const listOptions = computed<ListOption[]>(() =>
7375
})),
7476
);
7577
78+
const navbarOptions = computed<SelectOption[]>(() =>
79+
Object.values(NavbarPosition).map(value => ({
80+
label: i18n(value, 'common', 'navbar_position'),
81+
value,
82+
})),
83+
);
84+
7685
const loadingOption = computed(() =>
7786
loadingHysteresisOptions.map(({ label, value }) => ({
7887
label:
@@ -145,6 +154,16 @@ const onColor = () => {
145154

146155
<template>
147156
<div ref="container" class="tabs-container">
157+
<!-- Navbar Positon -->
158+
<SettingsFormItem :label="i18n('label_navbar_position')">
159+
<NSelect
160+
v-model:value="navbarPosition"
161+
class="navbar-position"
162+
:to="container"
163+
:options="navbarOptions"
164+
/>
165+
</SettingsFormItem>
166+
148167
<!-- Default tab -->
149168
<SettingsFormItem :label="i18n('label_default_tab')">
150169
<NSelect
@@ -429,6 +448,7 @@ const onColor = () => {
429448
}
430449
}
431450
451+
.navbar-position,
432452
.default-tab,
433453
.list-select {
434454
width: 12.5rem;
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"common__navbar_position__top": {
3+
"message": "Top",
4+
"description": "Top of the screen"
5+
},
6+
"common__navbar_position__bottom": {
7+
"message": "Bottom",
8+
"description": "Bottom of the screen"
9+
},
10+
"common__navbar_position__floating": {
11+
"message": "Floating",
12+
"description": "Floating on the screen"
13+
},
14+
"common__navbar_position__auto": {
15+
"message": "Auto",
16+
"description": "Automatically position the navbar"
17+
}
18+
}

src/i18n/en/settings/settings-tabs.json

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
"message": "Default tab",
1212
"description": "Label for the 'Default tab' setting"
1313
},
14+
"settings__tabs__label_navbar_position": {
15+
"message": "Navbar Position",
16+
"description": "Label for the 'Navbar Position' setting"
17+
},
1418
"settings__tabs__label_restore_tab": {
1519
"message": "Restore active tab on startup",
1620
"description": "Label for the 'Restore active tab on startup' setting"

src/models/navbar-position.model.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export const NavbarPosition = {
2+
Top: 'top',
3+
Bottom: 'bottom',
4+
Floating: 'floating',
5+
Auto: 'auto',
6+
} as const;
7+
8+
export type NavbarPositions = (typeof NavbarPosition)[keyof typeof NavbarPosition];

src/stores/app-state.store.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { defineStore, storeToRefs } from 'pinia';
33
import { computed, ref } from 'vue';
44

55
import { MessageType } from '~/models/message/message-type.model';
6+
import { NavbarPosition } from '~/models/navbar-position.model';
67
import { useExtensionSettingsStoreRefs } from '~/stores/settings/extension.store';
78
import { sendMessage } from '~/utils/browser/browser-message.utils';
89
import { useWaitReady } from '~/utils/store.utils';
@@ -61,17 +62,17 @@ export const useAppStateStore = defineStore('app.state', () => {
6162
isWeb,
6263
root,
6364
reverse: computed(() => {
65+
if (navbarPosition.value === NavbarPosition.Bottom) return true;
6466
if (!isWeb.value) return false;
65-
if (navbarPosition.value === 'bottom') return true;
6667
// web and small screen only
67-
return navbarPosition.value === 'auto' && mobile.width;
68+
return navbarPosition.value === NavbarPosition.Auto && mobile.width;
6869
}),
6970
floating: computed(() => {
70-
if (!isWeb.value) return false;
7171
// if (panelOpen.value) return false;
72-
if (navbarPosition.value === 'floating') return true;
72+
if (navbarPosition.value === NavbarPosition.Floating) return true;
73+
if (!isWeb.value) return false;
7374
// web & big screen only
74-
return navbarPosition.value === 'auto' && tablet.width === false;
75+
return navbarPosition.value === NavbarPosition.Auto && tablet.width === false;
7576
}),
7677
};
7778
});

src/stores/settings/extension.store.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { computed, reactive, ref, toRaw } from 'vue';
55

66
import type { ListEntity } from '~/models/list.model';
77

8+
import { NavbarPosition, type NavbarPositions } from '~/models/navbar-position.model';
9+
810
import { PageSize } from '~/models/page-size.model';
911
import { ProgressType, type ProgressTypes } from '~/models/progress-type.model';
1012
import { Route } from '~/models/router.model';
@@ -38,8 +40,6 @@ const DefaultRoutes: RouteDictionary = {
3840
[Route.Search]: true,
3941
};
4042

41-
type NavbarPosition = 'top' | 'bottom' | 'floating' | 'auto';
42-
4343
type ExtensionSettings = {
4444
cacheRetention: CacheRetentionState;
4545
enabledRoutes: RouteDictionary;
@@ -51,7 +51,7 @@ type ExtensionSettings = {
5151
enableRatings: boolean;
5252
backgroundColor: string;
5353
loadingHysteresis: number;
54-
navbarPosition: NavbarPosition;
54+
navbarPosition: NavbarPositions;
5555
};
5656

5757
const ExtensionSettingsConstants = {
@@ -72,7 +72,7 @@ export const useExtensionSettingsStore = defineStore(ExtensionSettingsConstants.
7272
const enableRatings = ref(false);
7373
const backgroundColor = ref('transparent');
7474
const loadingHysteresis = ref(-1);
75-
const navbarPosition = ref<NavbarPosition>('auto');
75+
const navbarPosition = ref<NavbarPositions>(NavbarPosition.Auto);
7676

7777
const clearState = () => {
7878
Object.assign(cacheRetention, DefaultCacheRetention);
@@ -250,7 +250,7 @@ export const useExtensionSettingsStore = defineStore(ExtensionSettingsConstants.
250250
}),
251251
navbarPosition: computed({
252252
get: () => navbarPosition.value,
253-
set: (value: NavbarPosition) => {
253+
set: (value: NavbarPositions) => {
254254
navbarPosition.value = value;
255255
saveState().catch(err => Logger.error('Failed to save navbar position extension settings', { value, err }));
256256
},

0 commit comments

Comments
 (0)