diff --git a/ui/src/components/dialog-modal.tsx b/ui/src/components/dialog-modal.tsx
new file mode 100644
index 0000000..791be09
--- /dev/null
+++ b/ui/src/components/dialog-modal.tsx
@@ -0,0 +1,36 @@
+import { ComponentProps, JSX, useContext } from "solid-js";
+import {
+ AlertDialog,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogTitle,
+ AlertDialogTrigger
+} from "~/components/ui/alert-dialog";
+import { Button } from "~/components/ui/button";
+import { IThemeContext, ThemeContext } from "~/context/ThemeContext.tsx";
+
+export interface DialogModalProps extends ComponentProps<"div"> {
+ children?: JSX.Element;
+ title?: string;
+ trigger?: JSX.Element;
+}
+
+export function DialogModal(props: DialogModalProps) {
+ const themeContext: IThemeContext = useContext(ThemeContext);
+
+ return (
+
+ {props.trigger || }
+
+
+ {props.title}
+
+ {props.children}
+
+
+ );
+}
diff --git a/ui/src/components/settings.tsx b/ui/src/components/settings.tsx
index b08e3a0..98fae43 100644
--- a/ui/src/components/settings.tsx
+++ b/ui/src/components/settings.tsx
@@ -1,11 +1,4 @@
-import { ComponentProps, useContext } from "solid-js";
-import {
- AlertDialog,
- AlertDialogContent,
- AlertDialogDescription,
- AlertDialogTitle,
- AlertDialogTrigger
-} from "~/components/ui/alert-dialog";
+import { useContext } from "solid-js";
import {
Select,
SelectContent,
@@ -14,44 +7,32 @@ import {
SelectValue
} from "~/components/ui/select.tsx";
import { OcGear3 } from "solid-icons/oc";
-import { IThemeContext, ThemeContext } from "~/context/ThemeContext.tsx";
+import { IThemeContext, ThemeContext, themeOptions } from "~/context/ThemeContext.tsx";
+import { DialogModal } from "~/components/dialog-modal.tsx";
export function Settings() {
- const availableThemes = ["blackout", "logan", "lavender", "light", "blue"];
const themeContext: IThemeContext = useContext(ThemeContext);
return (
-
-
-
-
- }>
+
+
+
+ >{state => state.selectedOption()}
+
+
+
+
);
}
diff --git a/ui/src/context/ThemeContext.tsx b/ui/src/context/ThemeContext.tsx
index e31b777..64659f9 100644
--- a/ui/src/context/ThemeContext.tsx
+++ b/ui/src/context/ThemeContext.tsx
@@ -6,19 +6,23 @@ export interface ThemeContextProviderProps {
}
export interface IThemeContext {
- theme: string;
- setTheme: (theme: string) => void;
+ theme: Theme;
+ setTheme: (theme: Theme) => void;
}
+export type Theme = "blackout" | "logan" | "lavender" | "light" | "blue";
+export const themeOptions: Theme[] = ["blackout", "logan", "lavender", "light", "blue"];
+
export const ThemeContext = createContext({} as IThemeContext);
const ACCURIBET_THEME_KEY: string = "accuribet-theme";
export function ThemeContextProvider(props: ThemeContextProviderProps) {
- let preferredTheme = localStorage.getItem(ACCURIBET_THEME_KEY);
+ let storedTheme: Theme | undefined = localStorage.getItem(ACCURIBET_THEME_KEY) as Theme;
+ let preferredTheme: Theme = themeOptions.includes(storedTheme) ? storedTheme : "blackout";
const [themeStore, setThemeStore] = createStore({
- theme: preferredTheme ? preferredTheme : "blackout",
- setTheme(theme: string) {
+ theme: preferredTheme,
+ setTheme(theme: Theme) {
localStorage.setItem(ACCURIBET_THEME_KEY, theme);
setThemeStore("theme", theme);
}