From ef1921c20747f55ef651675fbae46fe4c4036d07 Mon Sep 17 00:00:00 2001
From: Chris-1010 <122332721@umail.ucc.ie>
Date: Tue, 18 Feb 2025 00:49:18 +0000
Subject: [PATCH] FEAT: Implement quick settings context; UPDATE: Enhance quick
settings UI & theme settings;
---
.../src/components/Settings/QuickSettings.tsx | 14 ++-
.../src/components/Settings/ThemeSetting.tsx | 93 ++++++++++++++-----
frontend/src/context/QuickSettingsContext.tsx | 32 +++++++
3 files changed, 111 insertions(+), 28 deletions(-)
create mode 100644 frontend/src/context/QuickSettingsContext.tsx
diff --git a/frontend/src/components/Settings/QuickSettings.tsx b/frontend/src/components/Settings/QuickSettings.tsx
index 2ad7349..ea6fd49 100644
--- a/frontend/src/components/Settings/QuickSettings.tsx
+++ b/frontend/src/components/Settings/QuickSettings.tsx
@@ -1,17 +1,23 @@
import React from "react";
-import Theme from "./ThemeSetting";
+import ThemeSetting from "./ThemeSetting";
import { useTheme } from "../../context/ThemeContext";
+import { useQuickSettings } from "../../context/QuickSettingsContext";
const QuickSettings: React.FC = () => {
const { theme } = useTheme();
+ const { showQuickSettings } = useQuickSettings();
return (
-
Current Theme: {theme}
-
+ Quick Settings
+
);
};
diff --git a/frontend/src/components/Settings/ThemeSetting.tsx b/frontend/src/components/Settings/ThemeSetting.tsx
index 14f974b..ef9fb16 100644
--- a/frontend/src/components/Settings/ThemeSetting.tsx
+++ b/frontend/src/components/Settings/ThemeSetting.tsx
@@ -1,44 +1,89 @@
import React from "react";
-import { Sun as SunIcon, Moon as MoonIcon, Droplet as BlueIcon, Leaf as GreenIcon, Flame as OrangeIcon } from "lucide-react";
+import { Sun, Moon, Droplet, Leaf, Flame } from "lucide-react";
import { useTheme } from "../../context/ThemeContext";
-const themeIcons = {
- light: ,
- dark: ,
- blue: ,
- green: ,
- orange: ,
-};
+const themeConfig = {
+ light: {
+ icon: Sun,
+ color: "text-yellow-400",
+ background: "bg-white",
+ hoverBg: "hover:bg-gray-100",
+ label: "Light Theme",
+ },
+ dark: {
+ icon: Moon,
+ color: "text-white",
+ background: "bg-gray-800",
+ hoverBg: "hover:bg-gray-700",
+ label: "Dark Theme",
+ },
+ blue: {
+ icon: Droplet,
+ color: "text-blue-500",
+ background: "bg-blue-50",
+ hoverBg: "hover:bg-blue-100",
+ label: "Blue Theme",
+ },
+ green: {
+ icon: Leaf,
+ color: "text-green-500",
+ background: "bg-green-50",
+ hoverBg: "hover:bg-green-100",
+ label: "Green Theme",
+ },
+ orange: {
+ icon: Flame,
+ color: "text-orange-500",
+ background: "bg-orange-50",
+ hoverBg: "hover:bg-orange-100",
+ label: "Orange Theme",
+ },
+} as const;
-const themes = ["light", "dark", "blue", "green", "orange"];
+const themes = Object.keys(themeConfig) as Array;
const ThemeSetting: React.FC = () => {
- const { theme, setTheme } = useTheme();
+ const { theme, setTheme } = useTheme() as {
+ theme: keyof typeof themeConfig;
+ setTheme: (theme: keyof typeof themeConfig) => void;
+ };
const handleNextTheme = () => {
const currentIndex = themes.indexOf(theme);
const nextIndex = (currentIndex + 1) % themes.length;
const nextTheme = themes[nextIndex];
setTheme(nextTheme);
- document.body.setAttribute("data-theme", nextTheme);
+ document.body.setAttribute("data-theme", nextTheme);
};
+ const currentTheme = themeConfig[theme as keyof typeof themeConfig];
+ const Icon = currentTheme.icon;
+
return (
-