From 44690397574ee550c65c19065ad503f7b4513204 Mon Sep 17 00:00:00 2001 From: Ruidy Nemausat Date: Fri, 17 Apr 2020 12:51:34 +0200 Subject: [PATCH] Splitted ProgressBar and Info into 2 components; add progress bar to horizontal card top --- README.md | 1 + client/src/components/HorizontalCard.tsx | 6 ++- client/src/components/ProgressBar.tsx | 50 ++++++-------------- client/src/components/ProgressInfo.tsx | 42 +++++++++++++++++ client/src/components/ProjectCard.tsx | 60 +++++++++++++++++------- client/src/components/ProjectList.tsx | 22 +++------ client/src/pages/ProjectPage.tsx | 5 +- 7 files changed, 114 insertions(+), 72 deletions(-) create mode 100644 client/src/components/ProgressInfo.tsx diff --git a/README.md b/README.md index bf36f53..887ea1b 100644 --- a/README.md +++ b/README.md @@ -54,3 +54,4 @@ - [x] Azure - [ ] Refactor TabPanels code - [ ] Refactor Lists code +- [ ] Query project members in UserPage diff --git a/client/src/components/HorizontalCard.tsx b/client/src/components/HorizontalCard.tsx index 8f5763a..1ba66a4 100644 --- a/client/src/components/HorizontalCard.tsx +++ b/client/src/components/HorizontalCard.tsx @@ -4,13 +4,13 @@ import { makeStyles } from "@material-ui/core/styles"; import Card from "@material-ui/core/Card"; import CardActions from "@material-ui/core/CardActions"; import CardContent from "@material-ui/core/CardContent"; -import Button from "@material-ui/core/Button"; import Typography from "@material-ui/core/Typography"; -import { getRemainingdays } from "../utils/methods"; +import { ProgressBar } from "./ProgressBar"; interface IProps { title?: string; link?: string; + progress?: number; content: ReactNode; actions?: ReactNode; } @@ -26,11 +26,13 @@ export const HorizontalCard: FC = ({ link = "#", content, actions, + progress = 0, }) => { const classes = useStyles(); return ( + diff --git a/client/src/components/ProgressBar.tsx b/client/src/components/ProgressBar.tsx index 86d95cf..ef1a8da 100644 --- a/client/src/components/ProgressBar.tsx +++ b/client/src/components/ProgressBar.tsx @@ -6,10 +6,6 @@ import { PlaylistAddCheck } from "@material-ui/icons"; type IProps = { value: number; - max?: number; - tasksTotalCount?: number; - tasksDone?: number; - remainingDays?: number; }; const useStyles = makeStyles((theme: Theme) => @@ -17,19 +13,13 @@ const useStyles = makeStyles((theme: Theme) => root: { width: "100%", "& > * + *": { - marginTop: theme.spacing(2) - } - } + marginTop: theme.spacing(2), + }, + }, }) ); -export const ProgressBar: FC = ({ - value, - // max = 100, - tasksDone, - tasksTotalCount, - remainingDays -}) => { +export const ProgressBar: FC = ({ value }) => { // const styleString: CSSProperties = { width: `${value}%` }; // let barColor: string = "green"; @@ -46,27 +36,17 @@ export const ProgressBar: FC = ({ const classes = useStyles(); return ( - <> -
- -
- - {/* */} -
-
- {/*
-
-
*/} - - - - {tasksDone}/{tasksTotalCount} - - - Due {remainingDays} days - - + +
+ + {/* */}
- +
); }; + +{ + /*
+
+
*/ +} diff --git a/client/src/components/ProgressInfo.tsx b/client/src/components/ProgressInfo.tsx new file mode 100644 index 0000000..0faadc4 --- /dev/null +++ b/client/src/components/ProgressInfo.tsx @@ -0,0 +1,42 @@ +import React, { FC } from "react"; +import { makeStyles, Theme, createStyles } from "@material-ui/core/styles"; +import LinearProgress from "@material-ui/core/LinearProgress"; +import { Box } from "@material-ui/core"; +import { PlaylistAddCheck } from "@material-ui/icons"; + +type IProps = { + tasksTotalCount?: number; + tasksDone?: number; + remainingDays?: number; +}; + +const useStyles = makeStyles((theme: Theme) => + createStyles({ + root: { + width: "100%", + "& > * + *": { + marginTop: theme.spacing(2), + }, + }, + }) +); + +export const ProgressInfo: FC = ({ + tasksDone, + tasksTotalCount, + remainingDays, +}) => { + const classes = useStyles(); + + return ( + + + + {tasksDone}/{tasksTotalCount} + + + Due {remainingDays} days + + + ); +}; diff --git a/client/src/components/ProjectCard.tsx b/client/src/components/ProjectCard.tsx index 802f8de..bc9a1ef 100644 --- a/client/src/components/ProjectCard.tsx +++ b/client/src/components/ProjectCard.tsx @@ -1,34 +1,60 @@ -import React, { FC, MouseEvent } from "react"; +import React, { FC } from "react"; import { HorizontalCard } from "./HorizontalCard"; -import { Typography } from "@material-ui/core"; +import { Typography, makeStyles, Theme, createStyles } from "@material-ui/core"; import { getRemainingdays } from "../utils/methods"; +import { User } from "../types/User"; +import { AvatarList } from "./AvatarList"; +import { ProgressBar } from "./ProgressBar"; +import { ProgressInfo } from "./ProgressInfo"; interface IProps { title?: string; remainingDays?: string; link?: string; + members?: User[]; + progress?: number; } -const ProjectCard: FC = ({ title, remainingDays, link = "#" }) => { +const useStyles = makeStyles((theme: Theme) => + createStyles({ + progress: { + paddingTop: theme.spacing(4), + paddingBottom: theme.spacing(4), + }, + }) +); + +const ProjectCard: FC = ({ + title, + remainingDays, + link = "#", + members, + progress = 0, +}) => { + const classes = useStyles(); + const Content: FC = () => { return ( - - - Due{" "} - {remainingDays ? ( - getRemainingdays(remainingDays) - ) : ( - - Too much 0 - - )}{" "} - days - - + <> + {members && } +
+ {/* + Progression: + */} + +
+ ); }; - return } />; + return ( + } + progress={progress} + /> + ); }; export default ProjectCard; diff --git a/client/src/components/ProjectList.tsx b/client/src/components/ProjectList.tsx index 8fb8af7..d9720b6 100644 --- a/client/src/components/ProjectList.tsx +++ b/client/src/components/ProjectList.tsx @@ -6,14 +6,9 @@ import { createStyles, Theme, } from "@material-ui/core"; -import { HorizontalCard } from "./HorizontalCard"; import { FilterBar } from "./FilterBar"; -import { Ticket } from "../types/Ticket"; -import { HttpResponse } from "../types/HttpResponse"; -import { Project } from "../types/Project"; -import { put } from "../utils/http"; -import { Constants } from "../utils/Constants"; import ProjectCard from "./ProjectCard"; +import { Project } from "../types/Project"; const useStyles = makeStyles((theme: Theme) => createStyles({ @@ -37,7 +32,7 @@ export const ProjectList: FC = ({ projects }) => { setFilterText(e.target.value); }; - let filteredTickets = projects.filter( + let filteredProjects = projects.filter( (t) => t.status !== "Done" && t.title.toLowerCase().includes(filterText.toLowerCase()) @@ -65,22 +60,17 @@ export const ProjectList: FC = ({ projects }) => {
- {filteredTickets.length === 0 ? ( + {filteredProjects.length === 0 ? ( ) : ( - filteredTickets.map((t: Project) => ( + filteredProjects.map((t: Project) => ( { - // e.preventDefault(); - // await put>( - // `${Constants.ticketsURI}/${t.id}/closed`, - // {} - // ); - // }} + members={t.users} + progress={t.progression} /> )) )} diff --git a/client/src/pages/ProjectPage.tsx b/client/src/pages/ProjectPage.tsx index 32b8aed..ee3cea3 100644 --- a/client/src/pages/ProjectPage.tsx +++ b/client/src/pages/ProjectPage.tsx @@ -8,6 +8,7 @@ import { UsersModal } from "../components/UsersModal"; import { ProjectTabPanel } from "../components/ProjectTabPanel"; import ProjectVM from "../VM/ProjectVM"; import PageLayout from "../layouts/PageLayout"; +import { ProgressInfo } from "../components/ProgressInfo"; interface IProps { viewModel: ProjectVM; @@ -67,8 +68,8 @@ export const ProjectPage: FC = ({ viewModel }) => {
- +