Skip to content

Commit 8395628

Browse files
committed
feat: implement a theme downloader button
1 parent 6ad5108 commit 8395628

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

bun.lockb

4.57 KB
Binary file not shown.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"@kitbag/router": "^0.20.6",
1515
"@tanstack/vue-query": "^5.87.4",
1616
"@vueuse/core": "^13.9.0",
17+
"file-saver": "^2.0.5",
18+
"jszip": "^3.10.1",
1719
"pinia": "^3.0.3",
1820
"ua-parser-js": "^2.0.5",
1921
"vue": "^3.5.18",
@@ -28,6 +30,7 @@
2830
"@iconify-json/simple-icons": "^1.2.52",
2931
"@iconify-json/stash": "^1.2.4",
3032
"@stylistic/eslint-plugin": "^5.3.1",
33+
"@types/file-saver": "^2.0.7",
3134
"@types/node": "^24.3.1",
3235
"@unocss/eslint-config": "^66.5.1",
3336
"@vitejs/plugin-vue": "^6.0.1",

src/components/themes/ThemeGenerator.vue

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import LauncherThemed from "@/components/themes/windows/LauncherThemed.vue";
1010
import SettingsThemed from "@/components/themes/windows/SettingsThemed.vue";
1111
import type { TranslationsReferenceType } from "@/types/translations-reference.type.ts";
1212
import { TranslationsContextKey } from "@/constants/application.ts";
13+
import { saveAs } from "file-saver";
14+
import JSZip from "jszip";
1315
1416
const translations = inject<TranslationsReferenceType>(TranslationsContextKey);
1517
@@ -28,6 +30,31 @@ function selectColor({
2830
function resetColors() {
2931
colors.value = { ...DefaultColors };
3032
}
33+
34+
function downloadTheme() {
35+
const zip = new JSZip;
36+
const randomKey = Math.floor(Math.random() * 10_000);
37+
const folder = zip.folder(`customTheme${randomKey}`);
38+
39+
if (!folder) {
40+
return;
41+
}
42+
43+
folder.file("themeStyle.css", "/* WIP */");
44+
folder.file("theme.json", JSON.stringify({
45+
"colors": {
46+
...colors.value,
47+
"fadeAmount": 0.5,
48+
"fadeColor" : "#000000",
49+
},
50+
"name" : `A Custom Theme <${randomKey}>`,
51+
"widgets": "Fusion",
52+
}, null, 2));
53+
54+
zip.generateAsync({ "type": "blob" }).then(content => {
55+
saveAs(content, `customTheme${randomKey}.zip`);
56+
});
57+
}
3158
</script>
3259

3360
<template>
@@ -62,6 +89,9 @@ function resetColors() {
6289
</button>
6390
</div>
6491
<div class="w-full flex flex-col gap-4 py-4 pr-4">
92+
<button @click="downloadTheme" class="w-fit rounded-md p-3 leading-none transition-[background-color] hover:bg-catppuccin-800">
93+
Download
94+
</button>
6595
<ColorGenerator
6696
v-if="selected === 'colors'"
6797
:colors="colors"

0 commit comments

Comments
 (0)