dev: gantt ui changes

This commit is contained in:
gurusainath 2023-05-21 19:27:08 +05:30
parent a44cddb0fc
commit 4238f89cec
5 changed files with 35 additions and 14 deletions

View File

@ -18,7 +18,7 @@ export const GanttChartBlocks: FC<{
return ( return (
<div <div
className="relative z-10 mt-[58px] h-full w-[4000px] divide-x divide-gray-300 overflow-hidden overflow-y-auto bg-[#999] bg-opacity-5" className="relative z-10 mt-[58px] h-full w-[4000px] divide-x divide-gray-300 overflow-hidden overflow-y-auto"
style={{ width: `${itemsContainerWidth}px` }} style={{ width: `${itemsContainerWidth}px` }}
> >
<div className="w-full"> <div className="w-full">
@ -44,7 +44,7 @@ export const GanttChartBlocks: FC<{
</div> </div>
<div <div
className="rounded-sm shadow-sm bg-brand-base overflow-hidden relative flex items-center h-[34px] border border-brand-base" className="rounded shadow-sm bg-brand-base overflow-hidden relative flex items-center h-[34px] border border-brand-base"
style={{ style={{
width: `${block?.position?.width}px`, width: `${block?.position?.width}px`,
}} }}

View File

@ -37,6 +37,7 @@ import { datePreview, currentViewDataWithView } from "../data";
import { useChart } from "../hooks"; import { useChart } from "../hooks";
type ChartViewRootProps = { type ChartViewRootProps = {
border: boolean;
title: null | string; title: null | string;
loaderTitle: string; loaderTitle: string;
blocks: any; blocks: any;
@ -46,6 +47,7 @@ type ChartViewRootProps = {
}; };
export const ChartViewRoot: FC<ChartViewRootProps> = ({ export const ChartViewRoot: FC<ChartViewRootProps> = ({
border,
title, title,
blocks = null, blocks = null,
loaderTitle, loaderTitle,
@ -214,10 +216,12 @@ export const ChartViewRoot: FC<ChartViewRootProps> = ({
<div <div
className={`${ className={`${
fullScreenMode ? `fixed top-0 bottom-0 left-0 right-0 z-[999999] bg-brand-base` : `relative` fullScreenMode ? `fixed top-0 bottom-0 left-0 right-0 z-[999999] bg-brand-base` : `relative`
} flex h-full flex-col rounded-sm border border-brand-base select-none bg-brand-base shadow`} } ${
border ? `border border-brand-base` : ``
} flex h-full flex-col rounded-sm select-none bg-brand-base shadow`}
> >
{/* chart title */} {/* chart title */}
<div className="flex w-full flex-shrink-0 flex-wrap items-center gap-5 gap-y-3 whitespace-nowrap p-2 border-b border-brand-base"> {/* <div className="flex w-full flex-shrink-0 flex-wrap items-center gap-5 gap-y-3 whitespace-nowrap p-2 border-b border-brand-base">
{title && ( {title && (
<div className="text-lg font-medium flex gap-2 items-center"> <div className="text-lg font-medium flex gap-2 items-center">
<div>{title}</div> <div>{title}</div>
@ -233,7 +237,7 @@ export const ChartViewRoot: FC<ChartViewRootProps> = ({
{blocks.length} {loaderTitle} {blocks.length} {loaderTitle}
</div> </div>
)} )}
</div> </div> */}
{/* chart header */} {/* chart header */}
<div className="flex w-full flex-shrink-0 flex-wrap items-center gap-5 gap-y-3 whitespace-nowrap p-2"> <div className="flex w-full flex-shrink-0 flex-wrap items-center gap-5 gap-y-3 whitespace-nowrap p-2">
@ -248,10 +252,23 @@ export const ChartViewRoot: FC<ChartViewRootProps> = ({
)} )}
</div> */} </div> */}
<div className="mr-auto text-sm font-medium"> {title && (
{`${datePreview(currentViewData?.data?.startDate)} - ${datePreview( <div className="text-lg font-medium flex gap-2 items-center">
currentViewData?.data?.endDate <div>{title}</div>
)}`} <div className="text-xs rounded-full px-2 py-1 font-bold border border-brand-accent/75 bg-brand-accent/5 text-brand-base">
Gantt View Beta
</div>
</div>
)}
<div className="ml-auto">
{blocks === null ? (
<div className="text-sm font-medium ml-auto">Loading...</div>
) : (
<div className="text-sm font-medium ml-auto">
{blocks.length} {loaderTitle}
</div>
)}
</div> </div>
<div className="flex flex-wrap items-center gap-2"> <div className="flex flex-wrap items-center gap-2">
@ -260,7 +277,7 @@ export const ChartViewRoot: FC<ChartViewRootProps> = ({
allViews.map((_chatView: any, _idx: any) => ( allViews.map((_chatView: any, _idx: any) => (
<div <div
key={_chatView?.key} key={_chatView?.key}
className={`cursor-pointer rounded-sm border border-brand-base p-1 px-2 text-sm font-medium ${ className={`cursor-pointer rounded-sm border border-brand-base p-1 px-2 text-xs ${
currentView === _chatView?.key ? `bg-brand-surface-2` : `hover:bg-brand-surface-1` currentView === _chatView?.key ? `bg-brand-surface-2` : `hover:bg-brand-surface-1`
}`} }`}
onClick={() => handleChartView(_chatView?.key)} onClick={() => handleChartView(_chatView?.key)}
@ -272,7 +289,7 @@ export const ChartViewRoot: FC<ChartViewRootProps> = ({
<div className="flex items-center gap-1"> <div className="flex items-center gap-1">
<div <div
className={`cursor-pointer rounded-sm border border-brand-base p-1 px-2 text-sm font-medium hover:bg-brand-surface-2`} className={`cursor-pointer rounded-sm border border-brand-base p-1 px-2 text-xs hover:bg-brand-surface-2`}
onClick={handleToday} onClick={handleToday}
> >
Today Today

View File

@ -37,7 +37,7 @@ export const MonthChartView: FC<any> = () => {
<div <div
className={`relative h-full w-full flex-1 flex justify-center ${ className={`relative h-full w-full flex-1 flex justify-center ${
["sat", "sun"].includes(_item?.dayData?.shortTitle || "") ["sat", "sun"].includes(_item?.dayData?.shortTitle || "")
? `bg-brand-surface-2` ? `bg-brand-surface-1`
: `` : ``
}`} }`}
> >

View File

@ -5,6 +5,7 @@ import { ChartViewRoot } from "./chart";
import { ChartContextProvider } from "./contexts"; import { ChartContextProvider } from "./contexts";
type GanttChartRootProps = { type GanttChartRootProps = {
border: boolean;
title: null | string; title: null | string;
loaderTitle: string; loaderTitle: string;
blocks: any; blocks: any;
@ -14,6 +15,7 @@ type GanttChartRootProps = {
}; };
export const GanttChartRoot: FC<GanttChartRootProps> = ({ export const GanttChartRoot: FC<GanttChartRootProps> = ({
border = true,
title = null, title = null,
blocks, blocks,
loaderTitle = "blocks", loaderTitle = "blocks",
@ -23,6 +25,7 @@ export const GanttChartRoot: FC<GanttChartRootProps> = ({
}) => ( }) => (
<ChartContextProvider> <ChartContextProvider>
<ChartViewRoot <ChartViewRoot
border={border}
title={title} title={title}
blocks={blocks} blocks={blocks}
loaderTitle={loaderTitle} loaderTitle={loaderTitle}

View File

@ -32,7 +32,7 @@ export const IssueGanttChartView: FC<Props> = ({}) => {
// rendering issues on gantt card // rendering issues on gantt card
const GanttBlockView = ({ data }: any) => ( const GanttBlockView = ({ data }: any) => (
<Link href={`/${workspaceSlug}/projects/${projectId}/issues/${data?.id}`}> <Link href={`/${workspaceSlug}/projects/${projectId}/issues/${data?.id}`}>
<a className="relative flex items-center w-full h-full overflow-hidden shadow-sm"> <a className="relative flex items-center w-full h-full overflow-hidden shadow-sm font-normal">
<div <div
className="flex-shrink-0 w-[4px] h-full" className="flex-shrink-0 w-[4px] h-full"
style={{ backgroundColor: data?.state_detail?.color || "#858e96" }} style={{ backgroundColor: data?.state_detail?.color || "#858e96" }}
@ -68,8 +68,9 @@ export const IssueGanttChartView: FC<Props> = ({}) => {
: []; : [];
return ( return (
<div className="w-full h-full p-3"> <div className="w-full h-full">
<GanttChartRoot <GanttChartRoot
border={false}
title="Issues" title="Issues"
loaderTitle="Issues" loaderTitle="Issues"
blocks={ganttIssues ? blockFormat(ganttIssues) : null} blocks={ganttIssues ? blockFormat(ganttIssues) : null}