Skip to content

Commit 725015c

Browse files
committed
feat(settings): adds custom background colour option
1 parent 101a154 commit 725015c

10 files changed

+158
-4
lines changed

src/components/container/ContainerComponent.ce.vue

+11-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const override: GlobalThemeOverrides = {
3030
};
3131
3232
const { drawer, open, dropdown } = NavbarService;
33-
const { enabledRoutes } = useExtensionSettingsStoreRefs();
33+
const { enabledRoutes, backgroundColor } = useExtensionSettingsStoreRefs();
3434
const { root } = useAppStateStoreRefs();
3535
3636
onBeforeMount(() => addCustomProgressProperty());
@@ -40,7 +40,10 @@ onBeforeMount(() => addCustomProgressProperty());
4040
<div
4141
id="trakt-extension-root"
4242
ref="root"
43-
:style="{ '--tab-count': enabledRoutes.length + 1 }"
43+
:style="{
44+
'--tab-count': enabledRoutes.length + 1,
45+
'--background-color': backgroundColor,
46+
}"
4447
>
4548
<NConfigProvider :theme="theme" :theme-overrides="override" abstract>
4649
<AppComponent />
@@ -123,6 +126,8 @@ onBeforeMount(() => addCustomProgressProperty());
123126
124127
#trakt-extension-root {
125128
height: 100%;
129+
background-color: var(--background-color, transparent);
130+
transition: background-color 0.5s var(--n-bezier);
126131
}
127132
128133
.notification-container.n-notification-container.n-notification-container {
@@ -262,4 +267,8 @@ onBeforeMount(() => addCustomProgressProperty());
262267
padding-right: 0;
263268
}
264269
}
270+
271+
.n-card {
272+
border-radius: 0.75rem;
273+
}
265274
</style>

src/components/icons/IconPencil.vue

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<template>
2+
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">
3+
<g
4+
fill="none"
5+
stroke="currentColor"
6+
stroke-linecap="round"
7+
stroke-linejoin="round"
8+
stroke-width="1.5"
9+
>
10+
<path
11+
stroke-dasharray="56"
12+
stroke-dashoffset="56"
13+
d="M3 21l2 -6l11 -11c1 -1 3 -1 4 0c1 1 1 3 0 4l-11 11l-6 2"
14+
>
15+
<animate
16+
fill="freeze"
17+
attributeName="stroke-dashoffset"
18+
dur="0.6s"
19+
values="56;0"
20+
/>
21+
</path>
22+
<path stroke-dasharray="8" stroke-dashoffset="8" d="M15 5l4 4">
23+
<animate
24+
fill="freeze"
25+
attributeName="stroke-dashoffset"
26+
begin="0.6s"
27+
dur="0.2s"
28+
values="8;0"
29+
/>
30+
</path>
31+
<path stroke-dasharray="6" stroke-dashoffset="6" stroke-width="1" d="M6 15l3 3">
32+
<animate
33+
fill="freeze"
34+
attributeName="stroke-dashoffset"
35+
begin="0.6s"
36+
dur="0.2s"
37+
values="6;0"
38+
/>
39+
</path>
40+
</g>
41+
</svg>
42+
</template>

src/components/views/settings/SettingsBadge.vue

+9
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,13 @@ const container = ref();
6464
.form-select {
6565
min-width: 8rem;
6666
}
67+
68+
.form-switch {
69+
display: flex;
70+
flex: 1 1 auto;
71+
justify-content: center;
72+
min-width: 5rem;
73+
padding: 0 0.5rem;
74+
font-size: 0.75rem;
75+
}
6776
</style>

src/components/views/settings/SettingsComponent.vue

+5
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ onDeactivated(() => {
194194
z-index: var(--length);
195195
}
196196
197+
&:active,
198+
&:hover {
199+
border-color: var(--border-white);
200+
}
201+
197202
&.target {
198203
border-color: var(--n-color-target);
199204
}

src/components/views/settings/SettingsFormItem.vue

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ defineProps({
6666
display: flex;
6767
flex: 1 1 auto;
6868
flex-wrap: wrap;
69+
align-items: center;
6970
justify-content: space-between;
7071
7172
:deep(label) {

src/components/views/settings/SettingsTabs.vue

+68-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
<script lang="ts" setup>
22
import { chromeRuntimeId } from '@dvcol/web-extension-utils/chrome/runtime';
3-
import { NIcon, NSelect, NSwitch, type SelectOption } from 'naive-ui';
3+
import {
4+
NButton,
5+
NButtonGroup,
6+
NIcon,
7+
NSelect,
8+
NSwitch,
9+
type SelectOption,
10+
} from 'naive-ui';
411
512
import { type Component, computed, h, onBeforeMount, ref, watch } from 'vue';
613
14+
import IconClose from '~/components/icons/IconCloseSmall.vue';
15+
import IconPencil from '~/components/icons/IconPencil.vue';
16+
717
import SettingsFormItem from '~/components/views/settings/SettingsFormItem.vue';
818
import { pageSizeOptions, pageSizeOptionsWithZero } from '~/models/page-size.model';
919
import { ProgressType } from '~/models/progress-type.model';
@@ -42,6 +52,7 @@ const {
4252
loadListsPageSize,
4353
progressType,
4454
enableRatings,
55+
backgroundColor,
4556
} = useExtensionSettingsStoreRefs();
4657
4758
const { getIcon, fetchLists } = useListsStore();
@@ -119,10 +130,38 @@ const { extended: calendarExtended } = useCalendarStoreRefs();
119130
const { extended: historyExtended } = useHistoryStoreRefs();
120131
121132
const container = ref();
133+
const picker = ref<HTMLInputElement>();
134+
const onColor = () => {
135+
picker.value?.focus();
136+
picker.value?.click();
137+
};
122138
</script>
123139

124140
<template>
125141
<div ref="container" class="tabs-container">
142+
<!-- Default tab -->
143+
<SettingsFormItem :label="i18n('label_default_tab')">
144+
<div class="form-button">
145+
<input ref="picker" v-model="backgroundColor" type="color" class="color-picker" />
146+
<NButtonGroup
147+
class="color-picker-button-group"
148+
:style="{ '--color-picker': backgroundColor }"
149+
>
150+
<NButton round tertiary @click="onColor">
151+
Picker
152+
<template #icon>
153+
<NIcon><IconPencil /></NIcon>
154+
</template>
155+
</NButton>
156+
<NButton circle tertiary type="error" @click="backgroundColor = 'transparent'">
157+
<template #icon>
158+
<NIcon><IconClose /></NIcon>
159+
</template>
160+
</NButton>
161+
</NButtonGroup>
162+
</div>
163+
</SettingsFormItem>
164+
126165
<!-- Default tab -->
127166
<SettingsFormItem :label="i18n('label_default_tab')">
128167
<NSelect
@@ -331,6 +370,7 @@ const container = ref();
331370
flex-direction: column;
332371
gap: 1.5rem;
333372
373+
.form-button,
334374
.form-switch {
335375
display: flex;
336376
flex: 1 1 auto;
@@ -378,4 +418,31 @@ const container = ref();
378418
.progress-type {
379419
width: 6rem;
380420
}
421+
422+
.color-picker {
423+
width: 0;
424+
height: 2.5rem;
425+
padding: 0;
426+
border: none;
427+
border-radius: 0;
428+
429+
&-button-group {
430+
button {
431+
border: 2px solid var(--color-picker, transparent);
432+
transition: border-color 0.3s var(--n-bezier);
433+
434+
i {
435+
margin-left: -2px;
436+
}
437+
}
438+
439+
:first-child {
440+
border-right: none;
441+
}
442+
443+
:last-child {
444+
border-left: none;
445+
}
446+
}
447+
}
381448
</style>

src/components/views/settings/SettingsWatching.vue

+9
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,13 @@ const container = ref();
5353
.form-select {
5454
min-width: 10rem;
5555
}
56+
57+
.form-switch {
58+
display: flex;
59+
flex: 1 1 auto;
60+
justify-content: center;
61+
min-width: 5rem;
62+
padding: 0 0.5rem;
63+
font-size: 0.75rem;
64+
}
5665
</style>

src/stores/settings/extension.store.ts

+11
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ type ExtensionSettings = {
4646
loadListsPageSize: number;
4747
progressType: ProgressTypes;
4848
enableRatings: boolean;
49+
backgroundColor: string;
4950
};
5051

5152
const ExtensionSettingsConstants = {
@@ -64,6 +65,7 @@ export const useExtensionSettingsStore = defineStore(ExtensionSettingsConstants.
6465
const initialized = ref<Promise<boolean>>();
6566
const progressType = ref<ExtensionSettings['progressType']>(ProgressType.Show);
6667
const enableRatings = ref(false);
68+
const backgroundColor = ref('transparent');
6769

6870
const clearState = () => {
6971
Object.assign(cacheRetention, DefaultCacheRetention);
@@ -85,6 +87,7 @@ export const useExtensionSettingsStore = defineStore(ExtensionSettingsConstants.
8587
loadListsPageSize: loadListsPageSize.value,
8688
progressType: progressType.value,
8789
enableRatings: enableRatings.value,
90+
backgroundColor: backgroundColor.value,
8891
}),
8992
500,
9093
);
@@ -117,6 +120,7 @@ export const useExtensionSettingsStore = defineStore(ExtensionSettingsConstants.
117120
setLoadLists(Object.values(value), key);
118121
});
119122
}
123+
if (restored?.backgroundColor !== undefined) backgroundColor.value = restored.backgroundColor;
120124

121125
if (!chromeRuntimeId) routeDictionary[Route.Progress] = false;
122126
};
@@ -219,6 +223,13 @@ export const useExtensionSettingsStore = defineStore(ExtensionSettingsConstants.
219223
saveState().catch(err => Logger.error('Failed to save enable ratings extension settings', { value, err }));
220224
},
221225
}),
226+
backgroundColor: computed({
227+
get: () => backgroundColor.value,
228+
set: (value: string) => {
229+
backgroundColor.value = value;
230+
saveState().catch(err => Logger.error('Failed to save background color extension settings', { value, err }));
231+
},
232+
}),
222233
};
223234
});
224235

src/styles/base.scss

+2
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@
109109
--white-mute: #f2f2f2;
110110
--white-10: rgb(255 255 255 / 10%);
111111
--white-15: rgb(255 255 255 / 15%);
112+
--white-20: rgb(255 255 255 / 20%);
113+
--white-30: rgb(255 255 255 / 30%);
112114
--white-50: rgb(255 255 255 / 50%);
113115
--white-70: rgb(255 255 255 / 70%);
114116
--white-80: rgb(255 255 255 / 80%);

src/styles/reset.scss

-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@ h6 {
1212
p,
1313
li,
1414
figcaption {
15-
max-width: 80ch;
1615
text-wrap: pretty;
1716
}

0 commit comments

Comments
 (0)