From 2430f84837a28a4c836394874f56b259749335ca Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Sat, 31 Aug 2024 17:26:40 +0200 Subject: [PATCH] Update categories settings cards styling --- src/screens/settings/Categories.tsx | 134 +++++++++++++++------------- 1 file changed, 71 insertions(+), 63 deletions(-) diff --git a/src/screens/settings/Categories.tsx b/src/screens/settings/Categories.tsx index 5303510a..c734923e 100644 --- a/src/screens/settings/Categories.tsx +++ b/src/screens/settings/Categories.tsx @@ -7,16 +7,12 @@ */ import { useMemo, useState, useContext, useEffect } from 'react'; -import List from '@mui/material/List'; -import ListItem from '@mui/material/ListItem'; -import ListItemText from '@mui/material/ListItemText'; -import ListItemIcon from '@mui/material/ListItemIcon'; import IconButton from '@mui/material/IconButton'; import Tooltip from '@mui/material/Tooltip'; -import { DragDropContext, Draggable, DropResult, DraggingStyle, NotDraggingStyle } from 'react-beautiful-dnd'; +import { DragDropContext, Draggable, DraggableProvided, DropResult } from 'react-beautiful-dnd'; import DragHandleIcon from '@mui/icons-material/DragHandle'; import EditIcon from '@mui/icons-material/Edit'; -import { useTheme, Palette } from '@mui/material/styles'; +import { useTheme } from '@mui/material/styles'; import Fab from '@mui/material/Fab'; import AddIcon from '@mui/icons-material/Add'; import DeleteIcon from '@mui/icons-material/Delete'; @@ -29,6 +25,11 @@ import DialogTitle from '@mui/material/DialogTitle'; import Checkbox from '@mui/material/Checkbox'; import FormControlLabel from '@mui/material/FormControlLabel'; import { useTranslation } from 'react-i18next'; +import Box from '@mui/material/Box'; +import Card from '@mui/material/Card'; +import CardContent from '@mui/material/CardContent'; +import Stack from '@mui/material/Stack'; +import Typography from '@mui/material/Typography'; import { requestManager } from '@/lib/requests/RequestManager.ts'; import { StrictModeDroppable } from '@/lib/StrictModeDroppable'; import { DEFAULT_FULL_FAB_HEIGHT } from '@/components/util/StyledFab'; @@ -36,23 +37,65 @@ import { NavBarContext } from '@/components/context/NavbarContext'; import { LoadingPlaceholder } from '@/components/util/LoadingPlaceholder.tsx'; import { EmptyViewAbsoluteCentered } from '@/components/util/EmptyViewAbsoluteCentered.tsx'; import { defaultPromiseErrorHandler } from '@/util/defaultPromiseErrorHandler.ts'; -import { GetCategoriesSettingsQuery, GetCategoriesSettingsQueryVariables } from '@/lib/graphql/generated/graphql.ts'; +import { + CategoryType, + GetCategoriesSettingsQuery, + GetCategoriesSettingsQueryVariables, +} from '@/lib/graphql/generated/graphql.ts'; import { GET_CATEGORIES_SETTINGS } from '@/lib/graphql/queries/CategoryQuery.ts'; import { CategoryIdInfo } from '@/lib/data/Categories.ts'; -const getItemStyle = ( - isDragging: boolean, - draggableStyle: DraggingStyle | NotDraggingStyle | undefined, - palette: Palette, -) => ({ - // styles we need to apply on draggables - ...draggableStyle, +const CategoryCard = ({ + category, + provided, + onEdit, +}: { + category: Pick; + provided: DraggableProvided; + onEdit: () => void; +}) => { + const { t } = useTranslation(); - ...(isDragging && { - background: palette.mode === 'dark' ? '#424242' : 'rgb(235,235,235)', - }), -}); + const deleteCategory = () => { + requestManager.deleteCategory(category.id); + }; + return ( + + + + + + {category.name} + + + + + + + + + + + + + + + + + ); +}; export function Categories() { const { t } = useTranslation(); @@ -136,11 +179,6 @@ export function Categories() { } }; - const deleteCategory = (index: number) => { - const category = categories[index]; - requestManager.deleteCategory(category.id); - }; - if (loading) { return ; } @@ -160,50 +198,20 @@ export function Categories() { {(droppableProvided) => ( - - {categories.map((item, index) => ( - - {(draggableProvided, snapshot) => ( - - - - - - - { - handleEditDialogOpen(index); - }} - size="large" - > - - - - - { - deleteCategory(index); - }} - size="large" - > - - - - + + {categories.map((category, index) => ( + + {(draggableProvided) => ( + handleEditDialogOpen(index)} + /> )} ))} {droppableProvided.placeholder} - + )}