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' }} + /> + + + + { - return ( - - {value.option.value} - {value.option.value && value.option.value !== 'None' && ( - - )} - - ); - }} - onChange={(value) => - setSelectedTheme({ - ...selectedTheme, - backgroundImage: value, - }) - } - /> - - - - - {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 - - + + Random Theme} + labelPosition='left' + checked={currentTheme === 'random'} + onChange={(e) => { + setValue(e.target.checked ? 'random' : 'blackboard'); }} - > - - + color={theme.primaryColor} + /> {themesList.map((theme: any) => ( - - - - - - { - createTheme({ - method: 'PATCH', - endpoint: 'api/themes', - body: { ...theme, randomEnabled: !theme.randomEnabled }, - }); - }} - > - - - handleOpen(theme)} - > - - - - - - - - - handleDeleteTheme(theme)} - > - - - - + /> + )} + + ))} - - - - - - - handleOpen(theme)} - > - - - - - - - - - handleDeleteTheme(theme)} - > - - - - -