Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
csouchet authored Jul 12, 2023
1 parent 91b90b3 commit 1f77e36
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/component/mxgraph/style/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ const convertDirection = (direction: GradientDirection): string => {
return mxConstants.DIRECTION_NORTH;
case 'top-to-bottom':
return mxConstants.DIRECTION_SOUTH;
default:
return mxConstants.DIRECTION_EAST;
}
};

Expand Down Expand Up @@ -154,6 +156,6 @@ export const isShapeStyleUpdate = (style: StyleUpdate): style is ShapeStyleUpdat
return style && typeof style === 'object' && 'fill' in style;
};

export const isFillColorGradient = (color: string | FillColorGradient): color is FillColorGradient => {
return color && typeof color !== 'string';
const isFillColorGradient = (color: string | FillColorGradient): color is FillColorGradient => {
return color && typeof color === 'object';
};
4 changes: 2 additions & 2 deletions test/integration/mxGraph.model.style.api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ describe('mxGraph model - update style', () => {
label: 'Service Task 1.2',
});

const fill: Fill = { color: { startColor: 'gold', endColor: 'pink', direction: <GradientDirection>'right-to-left' } };
const fill: Fill = { color: { startColor: 'gold', endColor: 'pink', direction: 'right-to-left' } };
bpmnVisualization.bpmnElementsRegistry.updateStyle('serviceTask_1_2', { fill });

// Check that the style has been updated
Expand Down Expand Up @@ -953,7 +953,7 @@ describe('mxGraph model - reset style', () => {
const elementId = 'userTask_2_2';

// Apply custom style
const fill = { color: { startColor: 'gold', endColor: 'pink', direction: <GradientDirection>'top-to-bottom' } };
const fill = { color: { startColor: 'gold', endColor: 'pink', direction: 'top-to-bottom' } };
bpmnVisualization.bpmnElementsRegistry.updateStyle(elementId, { fill });

// Reset style
Expand Down
2 changes: 1 addition & 1 deletion test/shared/visu/bpmn-page-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export class PageTester {
if ('fill' in styleUpdate) {
const fill = (<ShapeStyleUpdate>styleUpdate).fill;

if (typeof fill.color !== 'string') {
if (typeof fill.color === 'object') {
fill.color.startColor && (url += `&style.api.fill.color.startColor=${fill.color.startColor}`);
fill.color.endColor && (url += `&style.api.fill.color.endColor=${fill.color.endColor}`);
fill.color.direction && (url += `&style.api.fill.color.direction=${fill.color.direction}`);
Expand Down

0 comments on commit 1f77e36

Please sign in to comment.