mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
add theme selector
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
const downloadTheme = (themeName: string, themeURL: string) => {
|
||||||
|
// send message to the background script
|
||||||
|
chrome.runtime.sendMessage({
|
||||||
|
type: 'currentTab',
|
||||||
|
info: 'SetTheme',
|
||||||
|
body: {
|
||||||
|
themeName: themeName,
|
||||||
|
themeURL: themeURL
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export default function ThemeSelector() {
|
||||||
|
return (
|
||||||
|
<button onClick={() => downloadTheme('Dark', 'https://raw.githubusercontent.com/SethBurkart123/BetterSEQTA-Themes/main/themes/test.json')}>Dark</button>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
import { FC } from 'react';
|
import { FC } from 'react';
|
||||||
import BackgroundSelector from '../components/BackgroundSelector';
|
import BackgroundSelector from '../components/BackgroundSelector';
|
||||||
|
import ThemeSelector from '../components/ThemeSelector';
|
||||||
|
|
||||||
const Themes: FC = () => {
|
const Themes: FC = () => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<BackgroundSelector />
|
<BackgroundSelector />
|
||||||
|
<ThemeSelector />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import localforage from "localforage";
|
|||||||
|
|
||||||
// Utility function to fetch and parse JSON
|
// Utility function to fetch and parse JSON
|
||||||
const fetchJSON = async (url) => {
|
const fetchJSON = async (url) => {
|
||||||
const res = await fetch(url);
|
const res = await fetch(url, {cache: "no-store"});
|
||||||
return await res.json();
|
return await res.json();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -71,11 +71,11 @@ export const downloadTheme = async (themeName, themeUrl) => {
|
|||||||
const themeData = await fetchThemeJSON(themeUrl);
|
const themeData = await fetchThemeJSON(themeUrl);
|
||||||
await saveToIndexedDB(themeData, themeName);
|
await saveToIndexedDB(themeData, themeName);
|
||||||
console.log(`Theme ${themeName} saved to IndexedDB`);
|
console.log(`Theme ${themeName} saved to IndexedDB`);
|
||||||
setTheme(themeName);
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const setTheme = async (themeName, themeUrl) => {
|
export const setTheme = async (themeName, themeUrl) => {
|
||||||
|
await downloadTheme(themeName, themeUrl);
|
||||||
if (!(await themeExistsInDB(themeName))) {
|
if (!(await themeExistsInDB(themeName))) {
|
||||||
await downloadTheme(themeName, themeUrl);
|
await downloadTheme(themeName, themeUrl);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export class MessageHandler {
|
|||||||
this.editSidebar();
|
this.editSidebar();
|
||||||
break;
|
break;
|
||||||
case "SetTheme":
|
case "SetTheme":
|
||||||
|
console.log(request);
|
||||||
setTheme(request.body.themeName, request.body.themeURL);
|
setTheme(request.body.themeName, request.body.themeURL);
|
||||||
break;
|
break;
|
||||||
case "DownloadTheme":
|
case "DownloadTheme":
|
||||||
|
|||||||
Reference in New Issue
Block a user