diff --git a/src/pages/settings/components/ThemeCard.tsx b/src/pages/settings/components/ThemeCard.tsx
new file mode 100644
index 0000000..ef66fe9
--- /dev/null
+++ b/src/pages/settings/components/ThemeCard.tsx
@@ -0,0 +1,194 @@
+import { ActionIcon, Box, Button, Group, Stack, Text } from '@mantine/core';
+import { FiCheck, FiEdit, FiTrash } from 'react-icons/fi';
+import { actionIconClasses } from 'styles';
+
+function ThemeCard({ handleOpen, handleDeleteTheme, theme, setValue, createTheme }: any) {
+ return (
+
+
+ {theme.name}
+
+
+
+ {
+ createTheme({
+ method: 'PATCH',
+ endpoint: 'api/themes',
+ body: { ...theme, randomEnabled: !theme.randomEnabled },
+ });
+ }}
+ >
+
+
+ handleOpen(theme)}
+ >
+
+
+ handleDeleteTheme(theme)}
+ >
+
+
+
+
+ );
+}
+
+export default ThemeCard;
diff --git a/src/pages/settings/components/ThemeModal.tsx b/src/pages/settings/components/ThemeModal.tsx
new file mode 100644
index 0000000..a6273a0
--- /dev/null
+++ b/src/pages/settings/components/ThemeModal.tsx
@@ -0,0 +1,267 @@
+import {
+ Button,
+ Card,
+ ColorPicker,
+ ColorSwatch,
+ Divider,
+ Group,
+ Image,
+ Modal,
+ OptionalPortal,
+ Select,
+ Stack,
+ Text,
+ TextInput,
+} from '@mantine/core';
+import { FiSave, FiX } from 'react-icons/fi';
+import { modalClasses, selectClasses, textClasses } from 'styles';
+import ThemeModalContent from './ThemeModalContent';
+
+function ThemeModal({
+ opened,
+ handleClose,
+ selectedTheme,
+ setSelectedTheme,
+ theme,
+ setColorId,
+ colorId,
+ setColorValue,
+ openPicker,
+ backgroundList,
+ pickerOpen,
+ colorValue,
+ closePicker,
+ handleSaveTheme,
+}: any) {
+ return (
+
+
+
+
+ Edit Theme
+
+
+
+
+
+ setSelectedTheme({ ...selectedTheme, name: e.target.value })}
+ styles={{
+ label: {
+ color: theme.primaryColor,
+ },
+ }}
+ />
+
+
+
+
+
+ Primary Color
+
+ {
+ setColorId('primaryColor');
+ openPicker();
+ setColorValue(selectedTheme.primaryColor);
+ }}
+ radius={'sm'}
+ w={'100px'}
+ color={selectedTheme.primaryColor}
+ style={{ cursor: 'pointer' }}
+ />
+
+
+
+ Accent Color
+
+ {
+ setColorId('accentColor');
+ openPicker();
+ setColorValue(selectedTheme.accentColor);
+ }}
+ radius={'sm'}
+ w={'100px'}
+ color={selectedTheme.accentColor}
+ style={{ cursor: 'pointer' }}
+ />
+
+
+
+ Background Color
+
+ {
+ setColorId('background');
+ openPicker();
+ setColorValue(selectedTheme.backgroundColor);
+ }}
+ radius={'sm'}
+ w={'100px'}
+ color={selectedTheme.backgroundColor}
+ style={{ cursor: 'pointer' }}
+ />
+
+
+
+ Border Color
+
+ {
+ setColorId('borderColor');
+ openPicker();
+ setColorValue(selectedTheme.borderColor);
+ }}
+ radius={'sm'}
+ w={'100px'}
+ color={selectedTheme.borderColor}
+ style={{ cursor: 'pointer' }}
+ />
+
+
+
+ Search Background Color
+
+ {
+ setColorId('searchBackground');
+ openPicker();
+ setColorValue(selectedTheme.searchColor);
+ }}
+ radius={'sm'}
+ w={'100px'}
+ color={selectedTheme.searchColor}
+ style={{ cursor: 'pointer' }}
+ />
+
+
+
+
+
+
+
+ {pickerOpen ? (
+ <>
+
+
+ setColorValue(e.target.value)}
+ />
+
+
+
+
+
+ >
+ ) : (
+
+
+ Pick a swatch to edit the color.
+
+
+ )}
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
+export default ThemeModal;
diff --git a/src/pages/settings/components/Themes.tsx b/src/pages/settings/components/Themes.tsx
index 1eb5bb2..e57d479 100644
--- a/src/pages/settings/components/Themes.tsx
+++ b/src/pages/settings/components/Themes.tsx
@@ -1,40 +1,20 @@
-import {
- ActionIcon,
- Button,
- Card,
- ColorPicker,
- ColorSwatch,
- Divider,
- Group,
- Image,
- Modal,
- OptionalPortal,
- Select,
- Stack,
- Text,
- TextInput,
-} from '@mantine/core';
+import { Button, Group, Stack, Switch, Text } from '@mantine/core';
import { useDisclosure, useLocalStorage } from '@mantine/hooks';
import { useMutationAPI, useQueryAPI } from 'hooks';
import { useEffect, useState } from 'react';
-import { FiCheck, FiEdit, FiPlus, FiSave, FiTrash, FiX } from 'react-icons/fi';
+import { FiChevronRight, FiPlus } from 'react-icons/fi';
import '@mantine/core/styles/ModalBase.css';
import '@mantine/core/styles/Modal.css';
import { modals } from '@mantine/modals';
-import {
- actionIconClasses,
- buttonClasses,
- modalClasses,
- selectClasses,
- textClasses,
-} from 'styles';
-import ThemeModalContent from './ThemeModalContent';
+import { buttonClasses, textClasses } from 'styles';
+import ThemeCard from './ThemeCard';
+import ThemeModal from './ThemeModal';
function ThemesSettings({ theme }: any) {
const [opened, { open, close }] = useDisclosure(false);
const [pickerOpen, { open: openPicker, close: closePicker }] = useDisclosure(false);
const [colorId, setColorId] = useState('');
const [colorValue, setColorValue] = useState('#000000');
- const [_, setValue] = useLocalStorage({
+ const [currentTheme, setValue] = useLocalStorage({
key: 'theme',
defaultValue: 'blackboard',
});
@@ -95,393 +75,86 @@ function ThemesSettings({ theme }: any) {
close();
};
- const randomColor = () => {
- return `rgba(${Math.random() * 255},${Math.random() * 255},${Math.random() * 255},1)`;
- };
-
return (
<>
-
-
-
-
- Edit Theme
-
-
-
-
-
-
- setSelectedTheme({ ...selectedTheme, name: e.target.value })
- }
- styles={{
- label: {
- color: theme.primaryColor,
- },
- }}
- />
-
-
-
-
-
- Primary Color
-
- {
- setColorId('primaryColor');
- openPicker();
- setColorValue(selectedTheme.primaryColor);
- }}
- radius={'sm'}
- w={'100px'}
- color={selectedTheme.primaryColor}
- style={{ cursor: 'pointer' }}
- />
-
-
-
- Accent Color
-
- {
- setColorId('accentColor');
- openPicker();
- setColorValue(selectedTheme.accentColor);
- }}
- radius={'sm'}
- w={'100px'}
- color={selectedTheme.accentColor}
- style={{ cursor: 'pointer' }}
- />
-
-
-
- Background Color
-
- {
- setColorId('background');
- openPicker();
- setColorValue(selectedTheme.backgroundColor);
- }}
- radius={'sm'}
- w={'100px'}
- color={selectedTheme.backgroundColor}
- style={{ cursor: 'pointer' }}
- />
-
-
-
- Border Color
-
- {
- setColorId('borderColor');
- openPicker();
- setColorValue(selectedTheme.borderColor);
- }}
- radius={'sm'}
- w={'100px'}
- color={selectedTheme.borderColor}
- style={{ cursor: 'pointer' }}
- />
-
-
-
- Search Background Color
-
- {
- setColorId('searchBackground');
- openPicker();
- setColorValue(selectedTheme.searchColor);
- }}
- radius={'sm'}
- w={'100px'}
- color={selectedTheme.searchColor}
- style={{ cursor: 'pointer' }}
- />
-
-
-
-
-
-
-
- {pickerOpen ? (
- <>
-
-
- setColorValue(e.target.value)}
- />
-
-
-
-
-
- >
- ) : (
-
-
- Pick a swatch to edit the color.
-
-
- )}
-
-
-
-
-
-
-
-
-
-
+ handleClose={handleClose}
+ selectedTheme={selectedTheme}
+ setSelectedTheme={setSelectedTheme}
+ theme={theme}
+ setColorId={setColorId}
+ colorId={colorId}
+ setColorValue={setColorValue}
+ openPicker={openPicker}
+ backgroundList={backgroundList}
+ pickerOpen={pickerOpen}
+ colorValue={colorValue}
+ closePicker={closePicker}
+ handleSaveTheme={handleSaveTheme}
+ />
-
-
- Themes
-
-
+ color={theme.primaryColor}
+ />
{themesList.map((theme: any) => (
-
-
-
+ {theme.name === currentTheme && (
+ {
- setValue(theme.name);
- }}
- >
- {theme.name}
-
-
-
- {
- createTheme({
- method: 'PATCH',
- endpoint: 'api/themes',
- body: { ...theme, randomEnabled: !theme.randomEnabled },
- });
- }}
- >
-
-
- handleOpen(theme)}
- >
-
-
-
-
-
-
-
-
- handleDeleteTheme(theme)}
- >
-
-
-
-
+ />
+ )}
+
+
))}
-
-
- {
- setValue('random');
- }}
- >
- Random
-
-
-
-
- handleOpen(theme)}
- >
-
-
-
-
-
-
-
-
- handleDeleteTheme(theme)}
- >
-
-
-
-
-
>