Skip to content

Commit

Permalink
Merge pull request #45 from graasp/fix-hiding-buttons-size-and-style
Browse files Browse the repository at this point in the history
Fix hiding buttons size and style
  • Loading branch information
swouf authored Jan 10, 2023
2 parents cb543cb + c5ac879 commit f771ec1
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 18 deletions.
8 changes: 6 additions & 2 deletions src/components/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ const theme = createTheme({
},
typography: {
h2: {
fontSize: '2rem',
fontSize: '1.5rem',
},
h3: {
fontSize: '1.8rem',
fontSize: '1.2rem',
fontWeight: 'bold',
},
h4: {
fontSize: '1.2rem',
},
},
status: {
Expand Down
19 changes: 14 additions & 5 deletions src/components/main/tasks/TasksList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next';
import { Button } from '@graasp/ui';

import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import { useTheme } from '@mui/material';
import { styled, useTheme } from '@mui/material';
import Paper from '@mui/material/Paper';
import Stack from '@mui/material/Stack';
import Typography from '@mui/material/Typography';
Expand All @@ -20,6 +20,10 @@ import AddTask from './AddTask';
import DraggableTask from './DraggableTask';
import TasksListTitle from './TasksListTitle';

const FullHeightStack = styled(Stack)(() => ({
height: '100%',
}));

type TasksListProps = {
title: string;
tasks: List<ExistingTaskType>;
Expand Down Expand Up @@ -70,10 +74,11 @@ const TasksList: FC<TasksListProps> = ({
position: 'relative',
zIndex: 1,
boxShadow: isOver ? `0 0 1em ${theme.palette.primary.light}` : 'none',
maxWidth: '40em',
}}
key={label}
>
<Stack alignItems="center" position="relative">
<FullHeightStack alignItems="center" position="relative">
<TasksListTitle title={title} tasksNumber={tasks.size} />
<Button
size="small"
Expand All @@ -84,7 +89,11 @@ const TasksList: FC<TasksListProps> = ({
<ExpandMoreIcon />
</Button>

<Stack ref={setNodeRef} spacing={1} sx={{ m: 1, width: '100%' }}>
<FullHeightStack
ref={setNodeRef}
spacing={1}
sx={{ m: 1, width: '100%' }}
>
{addComponent && <AddTask addTask={addTask} label={label} />}
{tasks.size ? (
tasks.map((task: ExistingTaskType, key: number) => (
Expand All @@ -101,8 +110,8 @@ const TasksList: FC<TasksListProps> = ({
{t('NO_TASKS', { title })}
</Typography>
)}
</Stack>
</Stack>
</FullHeightStack>
</FullHeightStack>
</Paper>
);
};
Expand Down
17 changes: 8 additions & 9 deletions src/components/main/tasks/TasksListMinimized.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
import { List } from 'immutable';

import React, { forwardRef } from 'react';

import ArrowForwardIosIcon from '@mui/icons-material/ArrowForwardIos';
import { Badge } from '@mui/material';
import Button from '@mui/material/Button';

import { ExistingTaskType } from '../../../config/appDataTypes';
import TasksListTitle from './TasksListTitle';
import Typography from '@mui/material/Typography';

type TasksListMinimizedProps = {
title: string;
tasks: List<ExistingTaskType>;
tasksNumber?: number;
onShow: () => void;
};

const TasksListMinimized = forwardRef<
HTMLButtonElement,
TasksListMinimizedProps
>(({ title, tasks, onShow }, ref) => (
>(({ title, tasksNumber = 0, onShow }, ref) => (
<Button
ref={ref}
variant="outlined"
endIcon={<ArrowForwardIosIcon />}
onClick={onShow}
sx={{ width: '100%', mt: 2 }}
sx={{ width: '100%', mt: 2, pt: 2, pb: 2 }}
>
<TasksListTitle title={title} tasksNumber={tasks.size} />
<Badge badgeContent={tasksNumber} color="secondary">
<Typography>{title}</Typography>
</Badge>
</Button>
));

Expand Down
16 changes: 14 additions & 2 deletions src/components/views/TasksManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ const TasksManager: FC = () => {
[TASK_LABELS.COMPLETED]: false,
});

const numberOfColumnsInGridForVisibleList =
12 /
Object.values(hiddenLists).reduce(
(total, x) => (x === false ? total + 1 : total),
0,
);

const [activeTask, setActiveTask] = useState<ExistingTaskType | null>(null);

const filteredMembersSetting = appSettingArray.find(
Expand Down Expand Up @@ -182,7 +189,12 @@ const TasksManager: FC = () => {
unmountOnExit
style={{ height: 'auto' }}
>
<Grid item sm={12} md={4} height="100%">
<Grid
item
sm={12}
md={numberOfColumnsInGridForVisibleList}
height="100%"
>
<TasksList
title={title}
label={label}
Expand Down Expand Up @@ -217,7 +229,7 @@ const TasksManager: FC = () => {
>
<TasksListMinimized
title={title}
tasks={tasksArray}
tasksNumber={tasksArray.size}
onShow={() => handleHide(label, false)}
/>
</Slide>
Expand Down

0 comments on commit f771ec1

Please sign in to comment.