Skip to content

Commit

Permalink
feat: add support for multiple colorschemes
Browse files Browse the repository at this point in the history
  • Loading branch information
BrewingWeasel committed Nov 6, 2024
1 parent 74a90a1 commit a4c69ee
Show file tree
Hide file tree
Showing 7 changed files with 288 additions and 55 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@vitejs/plugin-vue": "^4.6.2",
"autoprefixer": "^10.4.20",
"tailwindcss": "^3.4.10",
"tw-colors": "^3.3.2",
"typescript": "^5.5.4",
"vite": "^4.5.3",
"vue-tsc": "^2.0.29"
Expand Down
55 changes: 55 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { StartupState } from "./types";
import GettingStarted from "./pages/GettingStarted.vue";
import { ref } from "vue";
import { invoke } from "@tauri-apps/api/core";
import { useColorMode } from "@vueuse/core";
import PageFrame from "./PageFrame.vue";
import { Toaster } from "@/components/ui/sonner";
import {
Expand Down Expand Up @@ -33,6 +34,28 @@ const isNew = ref(
potentiallyNewVersion: versionDetails.version,
}),
);
let mode = useColorMode({
modes: {
"Rose Pine Dawn": "rosePineDawn",
"Rose Pine Moon": "rosePineMoon",
"Rose Pine Dark": "rosePine",
"Simple Dark": "simpleDark",
"Simple Light": "simpleLight",
},
});
console.log(mode.value);
switch (mode.value) {
case "light":
mode.value = "Simple Light";
break;
case "dark":
mode.value = "Rose Pine Moon";
break;
case "auto":
mode.value = "Simple Light";
}
</script>

<template>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ExportButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ whenever(keys.ctrl_shift_e, async () => {
"
>
<div class="flex bottom-0 justify-center py-3">
<Button variant="destructive"> Export </Button>
<Button> Export </Button>
</div>
</DialogTrigger>
<DialogContent class="select-none">
Expand Down
3 changes: 0 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { createApp } from "vue";
import { createRouter, createWebHistory } from "vue-router";
import { useDark } from "@vueuse/core";

import App from "./App.vue";
import Settings from "./pages/settings/Index.vue";
Expand Down Expand Up @@ -45,5 +44,3 @@ const app = createApp(SyncApp);
app.use(router);

app.mount("#app");

useDark();
26 changes: 23 additions & 3 deletions src/pages/settings/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { type Ref, ref, watch, reactive, nextTick } from "vue";
import { Label } from "@/components/ui/label";
import { Input } from "@/components/ui/input";
import type { Settings } from "@/types";
import { useDark } from "@vueuse/core";
import { useColorMode } from "@vueuse/core";
import {
Collapsible,
CollapsibleContent,
Expand All @@ -41,8 +41,17 @@ import {
} from "@/components/ui/number-field";
import EnableStanza from "@/components/EnableStanza.vue";
import { Separator } from "@/components/ui/separator";
import StyledCombobox from "@/components/StyledCombobox.vue";
const isDark = useDark();
const mode = useColorMode({
modes: {
"Rose Pine Dawn": "rosePineDawn",
"Rose Pine Moon": "rosePineMoon",
"Rose Pine Dark": "rosePine",
"Simple Dark": "simpleDark",
"Simple Light": "simpleLight",
},
});
const router = useRouter();
const installed = await invoke<boolean>("check_stanza_installed").catch(
Expand Down Expand Up @@ -214,7 +223,18 @@ async function newLanguage(language: string) {
title="Appearance"
description="Configure how Kalba looks"
/>
<Switch id="theme" v-model:checked="isDark" />
<StyledCombobox
id="theme"
v-model="mode"
item-being-selected="colorscheme"
:options="[
'Rose Pine Dawn',
'Rose Pine Moon',
'Rose Pine Dark',
'Simple Dark',
'Simple Light',
]"
/>
<Label for="theme">Use dark mode</Label>

<h2 class="mt-1">Definition styling</h2>
Expand Down
Loading

0 comments on commit a4c69ee

Please sign in to comment.