feat: add default page option

This commit is contained in:
sethburkart123
2024-06-24 11:09:44 +10:00
parent 188759b59d
commit dc11997b96
11 changed files with 53 additions and 50 deletions
+2 -1
View File
@@ -24,7 +24,8 @@ export const SettingsContextProvider: React.FC<{ children: ReactNode }> = ({ chi
customshortcuts: [],
transparencyEffects: false,
selectedTheme: '',
animations: true
animations: true,
defaultPage: 'home'
});
const [showPicker, setShowPicker] = useState<boolean>(false);
+7
View File
@@ -0,0 +1,7 @@
export default function Select({ state, onChange, options }: { state: string, onChange: (value: string) => void, options: { value: string, label: string }[] }) {
return (
<select className='px-4 py-1.5 text-[0.75rem] dark:bg-[#38373D] bg-[#DDDDDD] dark:text-white focus:border-none rounded-md mt-2 block w-full border-0 pl-3 pr-10 text-gray-900 focus:outline-none sm:text-sm sm:leading-6' value={state} onChange={(e) => onChange(e.target.value)}>
{options.map((option) => <option key={option.value} value={option.value}>{option.label}</option>)}
</select>
)
}
+5 -2
View File
@@ -26,7 +26,8 @@ const useSettingsState = ({ settingsState, setSettingsState }: SettingsProps) =>
transparencyEffects: result.transparencyEffects,
selectedTheme: result.selectedTheme,
timeFormat: result.timeFormat,
animations: result.animations
animations: result.animations,
defaultPage: result.defaultPage
});
});
});
@@ -43,11 +44,13 @@ const useSettingsState = ({ settingsState, setSettingsState }: SettingsProps) =>
"transparencyEffects": "transparencyEffects",
"selectedTheme": "selectedTheme",
"timeFormat": "timeFormat",
"animations": "animations"
"animations": "animations",
"defaultPage": "defaultPage"
}), []);
const storageChangeListener = (changes: browser.Storage.StorageChange) => {
for (const [key, { newValue }] of Object.entries(changes)) {
console.log(key, newValue)
if (key === "DarkMode") {
if (key === "DarkMode" && newValue) {
document.body.classList.add('dark');
@@ -8,6 +8,7 @@ import { useSettingsContext } from '../../SettingsContext';
import browser from 'webextension-polyfill'
import { memo, useState } from 'react';
import { toast } from 'react-toastify';
import Select from '../../components/Select';
const Settings: React.FC = () => {
const { settingsState, setSettingsState } = useSettingsContext();
@@ -92,6 +93,19 @@ const Settings: React.FC = () => {
description: "Prefer 12 hour time format for SEQTA",
modifyElement: <Switch state={settingsState.timeFormat == "12"} onChange={(isOn: boolean) => switchChange('timeFormat', isOn ? "12" : "24")} />
},
{
title: "Default Page",
description: "The page to load when SEQTA Learn is opened.",
modifyElement: <Select state={settingsState.defaultPage} onChange={(value: string) => switchChange('defaultPage', value)} options={[
{ value: 'home', label: 'Home' },
{ value: 'dashboard', label: 'Dashboard' },
{ value: 'timetable', label: 'Timetable' },
{ value: 'welcome', label: 'Welcome' },
{ value: 'messages', label: 'Messages' },
{ value: 'documents', label: 'Documents' },
{ value: 'reports', label: 'Reports' },
]} />
},
{
title: "BetterSEQTA+",
description: "Enables BetterSEQTA+ features",
+2 -40
View File
@@ -11,10 +11,7 @@ export interface SettingsState {
transparencyEffects: boolean;
timeFormat?: string;
animations: boolean;
}
interface ToggleItem {
toggle: boolean;
defaultPage: string;
}
interface Shortcut {
@@ -26,39 +23,4 @@ export interface CustomShortcut {
name: string;
url: string;
icon: string;
}
/* export interface MainConfig {
DarkMode: boolean;
animatedbk: boolean;
bksliderinput: string;
customshortcuts: CustomShortcut[];
defaultmenuorder: any[];
lessonalert: boolean;
menuitems: {
assessments: ToggleItem;
courses: ToggleItem;
dashboard: ToggleItem;
documents: ToggleItem;
forums: ToggleItem;
goals: ToggleItem;
home: ToggleItem;
messages: ToggleItem;
myed: ToggleItem;
news: ToggleItem;
notices: ToggleItem;
portals: ToggleItem;
reports: ToggleItem;
settings: ToggleItem;
timetable: ToggleItem;
welcome: ToggleItem;
};
menuorder: any[];
notificationcollector: boolean;
onoff: boolean;
selectedColor: string;
shortcuts: Shortcut[];
subjectfilters: Record<string, any>;
transparencyEffects: boolean;
selectedTheme: string;
} */
}