Skip to content

Commit 8781e22

Browse files
Merge pull request #3 from CarstenWickner/code-clean-up
2 parents 4bf39cc + 54f0c8f commit 8781e22

42 files changed

Lines changed: 828 additions & 533 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import * as React from "react";
2+
import { HorizontalStroke } from "./HorizontalStroke";
23

34
export const ContentElement: React.FunctionComponent<{
4-
children: React.ReactChild;
5+
children: React.ReactNode;
56
}> = ({ children }) => (
67
<>
78
<div className="arrow" />
89
<div className="flow-element content-element">{children}</div>
10+
<HorizontalStroke className="optional" />
911
</>
1012
);

src/component/FlowModeler.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
border-radius: 0.25em;
4747
min-width: $standardElementSize;
4848
min-height: $standardElementSize / 2;
49-
flex-grow: 1;
5049
}
5150
&.gateway-element {
5251
border: ($strokeStrength / 2) solid $standardElementColor;

src/component/FlowModeler.tsx

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import * as PropTypes from "prop-types";
22
import * as React from "react";
33

4-
import { Start, ContentElement, Gateway, GatewayToElementConnector, ElementToGatewayConnector, StrokeExtension, End } from "./flow-element";
4+
import { ContentElement } from "./ContentElement";
5+
import { Gateway } from "./Gateway";
6+
import { HorizontalStroke } from "./HorizontalStroke";
57
import { GridCell } from "./GridCell";
68
import { buildRenderData } from "./renderDataUtils";
79
import { GridCellData, ElementType } from "../types/GridCellData";
@@ -10,10 +12,10 @@ import { FlowModelerProps } from "../types/FlowModelerProps";
1012
import "./FlowModeler.scss";
1113

1214
export class FlowModeler extends React.Component<FlowModelerProps> {
13-
renderFlowElement(cellData: GridCellData): React.ReactChild {
15+
renderFlowElement(cellData: GridCellData): React.ReactNode {
1416
switch (cellData.type) {
1517
case ElementType.Start:
16-
return <Start />;
18+
return <div className="flow-element start-element" />;
1719
case ElementType.Content:
1820
const { renderContent } = this.props;
1921
return (
@@ -35,30 +37,35 @@ export class FlowModeler extends React.Component<FlowModelerProps> {
3537
})}
3638
</Gateway>
3739
);
40+
case ElementType.GatewayConverging:
41+
return <Gateway type="converging" />;
3842
case ElementType.ConnectGatewayToElement:
3943
const { renderGatewayConditionValue } = this.props;
4044
return (
41-
<GatewayToElementConnector connectionType={cellData.connectionType}>
45+
<HorizontalStroke incomingConnection={cellData.connectionType}>
4246
{renderGatewayConditionValue &&
4347
renderGatewayConditionValue({
4448
conditionData: cellData.data,
4549
branchElementId: cellData.elementId,
4650
gatewayElementId: cellData.gatewayId
4751
})}
48-
</GatewayToElementConnector>
52+
</HorizontalStroke>
4953
);
5054
case ElementType.ConnectElementToGateway:
51-
return <ElementToGatewayConnector connectionType={cellData.connectionType} />;
52-
case ElementType.GatewayConverging:
53-
return <Gateway type="converging" />;
55+
return <HorizontalStroke outgoingConnection={cellData.connectionType} />;
5456
case ElementType.StrokeExtension:
55-
return <StrokeExtension />;
57+
return <div className="stroke-horizontal" />;
5658
case ElementType.End:
57-
return <End />;
59+
return (
60+
<>
61+
<div className="arrow" />
62+
<div className="flow-element end-element" />
63+
</>
64+
);
5865
}
5966
}
6067

61-
renderGridCell = ((cellData: GridCellData): React.ReactChild => {
68+
renderGridCell = ((cellData: GridCellData): React.ReactNode => {
6269
const { options } = this.props;
6370
const verticalAlign = options && options.verticalAlign;
6471
const { colStartIndex, colEndIndex, rowStartIndex, rowEndIndex } = cellData;
@@ -76,8 +83,9 @@ export class FlowModeler extends React.Component<FlowModelerProps> {
7683
}).bind(this);
7784

7885
render(): React.ReactElement {
79-
const { flow } = this.props;
80-
const { gridCellData, columnCount } = buildRenderData(flow);
86+
const { flow, options } = this.props;
87+
const verticalModelAlign = options && options.verticalAlign === "bottom" ? "bottom" : "top";
88+
const { gridCellData, columnCount } = buildRenderData(flow, verticalModelAlign);
8189
return (
8290
<div className="flow-modeler" style={{ gridTemplateColumns: `repeat(${columnCount}, max-content)` }}>
8391
{gridCellData.map(this.renderGridCell)}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import * as React from "react";
22

33
import { HorizontalStroke } from "./HorizontalStroke";
44

5-
export const Gateway: React.FunctionComponent<{ type: "converging" } | { type: "diverging"; children?: React.ReactChild }> = ({ type, children }) => (
5+
export const Gateway: React.FunctionComponent<{ type: "converging"; children?: never } | { type: "diverging"; children?: React.ReactNode }> = ({
6+
type,
7+
children
8+
}) => (
69
<>
710
<div className="arrow" />
811
<div className={`flow-element gateway-element ${type}`} />

src/component/GridCell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const GridCell: React.FunctionComponent<{
55
colEndIndex?: number;
66
rowStartIndex: number;
77
rowEndIndex?: number;
8-
children: React.ReactChild;
8+
children: React.ReactNode;
99
}> = ({ colStartIndex, colEndIndex, rowStartIndex, rowEndIndex, children }) => (
1010
<div
1111
className="grid-cell"

src/component/flow-element/HorizontalStroke.tsx renamed to src/component/HorizontalStroke.tsx

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from "react";
22

3-
import { ConnectionType } from "../../types/GridCellData";
3+
import { ConnectionType } from "../types/GridCellData";
44

55
const getConnectionClassName = (connectionType: ConnectionType): string => {
66
switch (connectionType) {
@@ -14,9 +14,10 @@ const getConnectionClassName = (connectionType: ConnectionType): string => {
1414
};
1515

1616
export class HorizontalStroke extends React.Component<
17-
{ className?: string } & (
18-
| { incomingConnection: null | ConnectionType; outgoingConnection: null; children?: React.ReactChild }
19-
| { incomingConnection: null; outgoingConnection: ConnectionType }
17+
{ className?: string; children?: React.ReactNode } & (
18+
| { incomingConnection: ConnectionType; outgoingConnection?: never }
19+
| { incomingConnection?: never; outgoingConnection?: never }
20+
| { incomingConnection?: never; outgoingConnection: ConnectionType }
2021
),
2122
{ wrapperTopHeight: number }
2223
> {
@@ -35,12 +36,12 @@ export class HorizontalStroke extends React.Component<
3536
}
3637
}
3738

38-
render(): React.ReactChild {
39+
render(): React.ReactNode {
3940
const { className, incomingConnection, outgoingConnection, children } = this.props;
4041
const classNameSuffix = className ? ` ${className}` : "";
4142
return (
4243
<>
43-
{incomingConnection !== null && <div className={`stroke-vertical ${getConnectionClassName(incomingConnection)}${classNameSuffix}`} />}
44+
{incomingConnection && <div className={`stroke-vertical ${getConnectionClassName(incomingConnection)}${classNameSuffix}`} />}
4445
{!children && <div className={`stroke-horizontal${classNameSuffix}`} />}
4546
{children && (
4647
<div className={`centered-line-wrapper${classNameSuffix}`}>
@@ -54,16 +55,8 @@ export class HorizontalStroke extends React.Component<
5455
/>
5556
</div>
5657
)}
57-
{outgoingConnection !== null && <div className={`stroke-vertical ${getConnectionClassName(outgoingConnection)}${classNameSuffix}`} />}
58+
{outgoingConnection && <div className={`stroke-vertical ${getConnectionClassName(outgoingConnection)}${classNameSuffix}`} />}
5859
</>
5960
);
6061
}
61-
62-
static defaultProps: {
63-
incomingConnection: null;
64-
outgoingConnection: null;
65-
} = {
66-
incomingConnection: null,
67-
outgoingConnection: null
68-
};
6962
}

src/component/flow-element/ElementToGatewayConnector.tsx

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/component/flow-element/End.tsx

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/component/flow-element/GatewayToElementConnector.tsx

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/component/flow-element/Start.tsx

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)