)}
-
+ >
);
}
@@ -318,7 +318,7 @@ export class BackgroundLayer extends React.Component {
const overlappsDisplayedInterval =
this.props.startDateTimeline.isSameOrBefore(currentDate) && this.props.endDateTimeline.isSameOrAfter(currentDate);
return (
-
+ <>
{nowMarker && overlappsDisplayedInterval && (
)}
-
+ >
);
}
render() {
return (
-
+ <>
{this.renderHighlightedWeekends()}
{this.renderCustomComponents(this.props.highlightedIntervals)}
{this.renderNowMarker()}
{this.renderCustomComponents(this.props.markers)}
{this.renderVerticalGrid()}
-
+ >
);
}
}
diff --git a/src/components/GanttDataCell.tsx b/src/components/GanttDataCell.tsx
new file mode 100644
index 00000000..0488bf62
--- /dev/null
+++ b/src/components/GanttDataCell.tsx
@@ -0,0 +1,18 @@
+import { DataCell } from 'fixed-data-table-2';
+import React from 'react';
+import { GanttContext } from '../utils/GanttContext';
+
+export interface GanttDataCellProperties {
+ rowIndex: number,
+ content: () => string | React.ReactNode
+}
+
+export class GanttDataCell extends React.Component
{
+ static contextType = GanttContext;
+ context!: React.ContextType;
+
+ render(): React.ReactNode {
+ const {rows} = this.context;
+ return this.props.rowIndex < rows.length ? {this.props.content()} : ;
+ }
+}
\ No newline at end of file
diff --git a/src/components/SimpleGanttTable.tsx b/src/components/SimpleGanttTable.tsx
new file mode 100644
index 00000000..5245dcf2
--- /dev/null
+++ b/src/components/SimpleGanttTable.tsx
@@ -0,0 +1,38 @@
+import React from "react";
+import { Table, Column, DataCell } from 'fixed-data-table-2';
+import { GanttDataCell } from "./GanttDataCell";
+import { GanttContext } from "../utils/GanttContext";
+
+export interface SimpleGanttTableProperties {
+ field: string,
+ header?: string | React.ReactNode
+ width?: number
+}
+
+/**
+ * @author Daniela Buzatu
+ */
+export class SimpleGanttTable extends React.Component {
+ static contextType = GanttContext;
+ static defaultProps = {
+ width: 130,
+ header: undefined
+ }
+ context!: React.ContextType;
+
+ render(): React.ReactNode {
+ const { rows, configureTable } = this.context;
+ return (
+ configureTable(
+
+ {this.props.header ? this.props.header : ""}}
+ cell={({ rowIndex }) => rows[rowIndex][this.props.field]} />} />
+
+ )
+ );
+ }
+}
\ No newline at end of file
diff --git a/src/index.js b/src/index.js
index f89b5018..41208cb5 100644
--- a/src/index.js
+++ b/src/index.js
@@ -19,6 +19,8 @@ export {Marker} from './components/Marker';
export {default as Selectbox} from './components/selector';
export {BackgroundLayer} from './components/BackgroundLayer';
export {HighlightedInterval} from './components/HighlightedInterval';
+export {SimpleGanttTable} from './components/SimpleGanttTable';
+export {GanttDataCell} from './components/GanttDataCell';
// consts
export {timebarFormat} from './consts/timebarConsts';
diff --git a/src/stories/backgroundLayer/BackgroundLayer.stories.tsx b/src/stories/backgroundLayer/BackgroundLayer.stories.tsx
index bc0b0dd4..9be474f5 100644
--- a/src/stories/backgroundLayer/BackgroundLayer.stories.tsx
+++ b/src/stories/backgroundLayer/BackgroundLayer.stories.tsx
@@ -1,12 +1,11 @@
-import React from 'react';
-import Timeline from '../../timeline';
import { BackgroundLayer } from '../../components/BackgroundLayer';
import { HighlightedInterval } from '../../components/HighlightedInterval';
import { Marker } from '../../components/Marker';
-import { someHumanResources, startOfCurrentMonth, endOfCurrentMonth, dateAndHourOfCurrentMonth } from '../sampleData';
-import { backgroundLayerScenarios } from './BackgroundLayerScenarios';
+import { SimpleGanttTable } from '../../components/SimpleGanttTable';
+import Timeline from '../../timeline';
import { Item } from '../../types';
-import { Table, Column, DataCell} from 'fixed-data-table-2';
+import { dateAndHourOfCurrentMonth, endOfCurrentMonth, someHumanResources, startOfCurrentMonth } from '../sampleData';
+import { backgroundLayerScenarios } from './BackgroundLayerScenarios';
export default {
title: 'Features/Background Layer'
};
@@ -21,13 +20,7 @@ export const Main = () => {
return (
- Title}
- cell={({rowIndex}) => {rowIndex < someHumanResources.length ? someHumanResources[rowIndex].title : ""}}/>
- }
+ table={}
backgroundLayer={
{
return (
- Title}
- cell={({rowIndex}) => {rowIndex < someHumanResources.length ? someHumanResources[rowIndex].title : ""}}/>
- }
+ table={}
backgroundLayer={
{
CustomClassNamesAndStyles.parameters = {
scenarios: [
backgroundLayerScenarios.verticalGridClassName,
- backgroundLayerScenarios.nowMaSrkerClassName,
+ backgroundLayerScenarios.nowMarkerClassName,
backgroundLayerScenarios.highlightWeekendsClassName,
backgroundLayerScenarios.classNameForMarker,
backgroundLayerScenarios.highlightedIntervalClassName
diff --git a/src/stories/basic/Basic.stories.mdx b/src/stories/basic/Basic.stories.mdx
index 0aba0e29..7aac4ff0 100644
--- a/src/stories/basic/Basic.stories.mdx
+++ b/src/stories/basic/Basic.stories.mdx
@@ -71,6 +71,6 @@ const start = this.getStartFromItem(item);
**IMPORTANT**: By default the gantt diagram displayes without any table associated.
-If you want to display a table (like in the majority of our examples) you should set the table property:
+If you want to display a table (like in the majority of our examples) you should set the `table` property:
\ No newline at end of file
diff --git a/src/stories/basic/Basic.stories.tsx b/src/stories/basic/Basic.stories.tsx
index 17e95da3..fab52ae3 100644
--- a/src/stories/basic/Basic.stories.tsx
+++ b/src/stories/basic/Basic.stories.tsx
@@ -1,10 +1,9 @@
-import React from 'react';
+import { ComponentStory } from '@storybook/react';
+import { SimpleGanttTable } from '../../components/SimpleGanttTable';
+import { Group, Item } from '../../index';
import Timeline from '../../timeline';
import { timelineScenarios } from '../TimelineScenarios';
import { d, someHumanResources, someTasks } from '../sampleData';
-import { ComponentStory } from '@storybook/react';
-import { Group, Item } from '../../index';
-import { Table, Column, DataCell } from 'fixed-data-table-2';
export default {
title: 'Features/Basic'
@@ -34,13 +33,7 @@ export const Main = () => {
{/* 2/ You'll probably have a better flex-box layout, i.e. not hardcoded. 3/ Use CSS classes and not styles. */}
- Title}
- cell={({rowIndex}) => {rowIndex < humanResources.length ? humanResources[rowIndex].title : ""}}/>
- }
+ table={}
/>
>
@@ -80,13 +73,7 @@ export const AlternativeRowColoring: ComponentStory = () => {
- Title}
- cell={({rowIndex}) => {rowIndex < someHumanResources.length ? someHumanResources[rowIndex].title : ""}}/>
- }/>
+ table={}/>
>
);
@@ -118,14 +105,7 @@ const tasks: Item[] = [
{/* 2/ You'll probably have a better flex-box layout, i.e. not hardcoded. 3/ Use CSS classes and not styles. */}
- Title}
- cell={({rowIndex}) => {rowIndex < someHumanResources.length ? someHumanResources[rowIndex].title : ""}}/>
- }
- />
+ table={}/>
>
);
diff --git a/src/stories/contextMenuAndSelection/ContextMenuAndSelection.stories.tsx b/src/stories/contextMenuAndSelection/ContextMenuAndSelection.stories.tsx
index b92fa821..15442dca 100644
--- a/src/stories/contextMenuAndSelection/ContextMenuAndSelection.stories.tsx
+++ b/src/stories/contextMenuAndSelection/ContextMenuAndSelection.stories.tsx
@@ -3,11 +3,11 @@ import { Alert } from 'antd';
import moment from 'moment';
import { useState } from 'react';
import { Button, Icon, Menu } from 'semantic-ui-react';
+import { SimpleGanttTable } from '../../components/SimpleGanttTable';
import Timeline from '../../timeline';
import { IGanttAction, IGanttOnContextMenuShowParam, Item } from '../../types';
import { d, someHumanResources, someTasks } from '../sampleData';
import { contextMenuScenarios, selectionScenarios } from './ContextMenuAndSelectionScenarios';
-import { Table, Column, DataCell } from 'fixed-data-table-2';
export default {
title: 'Features/Context Menu And Selection',
@@ -84,14 +84,8 @@ export const ContextMenu = () => {
return actions;
}}
- table={
- Title}
- cell={({rowIndex}) => {rowIndex < someHumanResources.length ? someHumanResources[rowIndex].title : ""}}/>
-
}
- />
+ table={}
+ />
>);
};
@@ -124,13 +118,8 @@ export const Selection = () => {