Skip to content

Commit 8e431f9

Browse files
committed
feat: move theme selector to main header
1 parent 260eeed commit 8e431f9

File tree

4 files changed

+27
-15
lines changed

4 files changed

+27
-15
lines changed

src/assets/global.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
--base-dimmed: #33393e;
3232
--accent: #ff7b5d;
3333
}
34+
&[data-theme="departure"] {
35+
--base: #c0c0c0;
36+
--background: #222;
37+
--base-dimmed: #6c6c58;
38+
--accent: #ffa133;
39+
}
3440
}
3541
*,
3642
*::before,
@@ -303,3 +309,6 @@ dialog {
303309
text-overflow: ellipsis;
304310
white-space: nowrap;
305311
}
312+
.capitalize {
313+
text-transform: capitalize;
314+
}

src/components/header/main-header.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
<div>
44
<header-summary />
55
<settings-modal />
6+
<button class="main-header__block-button" title="change color theme" type="button" @click="nextTheme">
7+
<icon-palette />
8+
<span class="capitalize">{{ theme }}</span>
9+
</button>
610
<about-modal />
711
<button title="get rate limit" type="button" @click="fetchRateLimit">
812
Rate Limit
@@ -22,8 +26,8 @@
2226
</header>
2327
</template>
2428
<script setup lang="ts">
25-
import { ref } from "vue";
26-
import { IconActivityHeartbeat, IconProgressAlert } from "@tabler/icons-vue";
29+
import { computed, ref } from "vue";
30+
import { IconActivityHeartbeat, IconPalette, IconProgressAlert } from "@tabler/icons-vue";
2731
import { fetchRateLimit, fetchRepositoryFiles, rateLimit } from "@/service/octokit";
2832
import { useEventsStore } from "@/store/events";
2933
import { useLatestVersionsStore } from "@/store/latest-versions";
@@ -38,8 +42,9 @@ import HeaderSummary from "./header-summary.vue";
3842
const { isEmpty, updateRepositories } = useRepositoriesStore();
3943
const { updateLatestVersions } = useLatestVersionsStore();
4044
const { updateEvents } = useEventsStore();
41-
const { needRefresh, updateServiceWorker } = useSettingsStore();
4245
46+
const { settings, needRefresh, updateServiceWorker, nextTheme } = useSettingsStore();
47+
const theme = computed(() => settings.value.theme);
4348
const isUpdating = ref<boolean>(false);
4449
async function update(): Promise<void> {
4550
try {

src/components/modals/settings-modal.vue

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
<input v-model="form.displayBadges" name="displayBadges" type="checkbox">
2424
Display badges
2525
</label>
26-
<input-select v-model="form.theme" name="theme" :items="themes" label="theme:" />
2726
</fieldset>
2827
<fieldset>
2928
<legend>GitHub API</legend>
@@ -72,15 +71,6 @@ import { deepCopy } from "@/helpers/object";
7271
import { fetchCurrentUser, setAuthToken } from "@/service/octokit";
7372
import { useSettingsStore } from "@/store/settings";
7473
import ImportExport from "@/components/import-export.vue";
75-
import InputSelect from "@/components/input-select.vue";
76-
77-
const themes = [
78-
{ name: "github", value: "github" },
79-
{ name: "beige", value: "beige" },
80-
{ name: "blue", value: "blue" },
81-
{ name: "green", value: "green" },
82-
{ name: "red", value: "red" }
83-
] as const;
8474
8575
const { settings } = useSettingsStore();
8676
const dialogRef = useTemplateRef("dialogElement");

src/store/settings.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createSharedComposable, useLocalStorage } from "@vueuse/core";
22
import { useRegisterSW } from "virtual:pwa-register/vue";
33

4-
type Theme = "github" | "blue" | "beige" | "green" | "red";
4+
type Theme = "github" | "blue" | "beige" | "green" | "red" | "departure";
55
export interface SettingsStore {
66
authToken: string
77
username: string
@@ -27,10 +27,18 @@ export const useSettingsStore = createSharedComposable(() => {
2727
Object.assign(settings.value, newSettings);
2828
}
2929

30+
function nextTheme(): void {
31+
const themes: readonly Theme[] = ["github", "blue", "beige", "green", "red", "departure"];
32+
const index = themes.indexOf(settings.value.theme);
33+
const nextIndex = (index + 1) % themes.length;
34+
settings.value.theme = themes[nextIndex];
35+
}
36+
3037
return {
3138
settings,
3239
needRefresh,
3340
updateServiceWorker,
34-
importSettings
41+
importSettings,
42+
nextTheme
3543
};
3644
});

0 commit comments

Comments
 (0)