Skip to content

Commit 115ba4f

Browse files
authored
Merge pull request xyflow#260 from wbkd/develop
Develop
2 parents 8bbe578 + 0558ff8 commit 115ba4f

File tree

31 files changed

+192
-164
lines changed

31 files changed

+192
-164
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ const targetHandleWithValidation = (
188188
- `onConnect`: function that gets triggered on connect
189189
- `isValidConnection`: function receives a connection `{ target: 'some-id', source: 'another-id' }` as param, returns a boolean - true by default
190190
- `style`: css properties
191+
- `className`: additional class name
191192

192193
#### Multiple Handles
193194

assets/icons/unlock.svg

Lines changed: 1 addition & 1 deletion
Loading

cypress/integration/flow/basic.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe('Basic Graph Rendering', () => {
66
cy.get('.react-flow-basic-example'); // check if className prop works
77
cy.get('.react-flow__node').should('have.length', 4);
88
cy.get('.react-flow__edge').should('have.length', 2);
9-
cy.get('.react-flow__node').children('div').children('.react-flow__handle');
9+
cy.get('.react-flow__node').children('.react-flow__handle');
1010
});
1111

1212
it('renders a grid', () => {

cypress/integration/flow/inactive.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ describe('Inactive Graph Rendering', () => {
55
cy.get('.react-flow__renderer');
66
cy.get('.react-flow__node').should('have.length', 4);
77
cy.get('.react-flow__edge').should('have.length', 2);
8-
cy.get('.react-flow__node').children('div').children('.react-flow__handle');
8+
cy.get('.react-flow__node').children('.react-flow__handle');
99
});
1010

1111
it('tries to select a node by click', () => {

example/src/CustomNode/ColorSelectorNode.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ import React from 'react';
22

33
import { Handle } from 'react-flow-renderer';
44

5-
export default ({ data, styles }) => {
5+
export default ({ data }) => {
66
return (
7-
<div
8-
style={{ background: '#eee', border: '1px solid #ddd', padding: 10, borderRadius: 5, ...styles }}
9-
>
7+
<>
108
<Handle
119
type="target"
1210
position="left"
@@ -27,6 +25,6 @@ export default ({ data, styles }) => {
2725
id="b"
2826
style={{ bottom: 10, top: 'auto', background: '#fff' }}
2927
/>
30-
</div>
28+
</>
3129
);
3230
};

example/src/CustomNode/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const CustomNodeFlow = () => {
3737

3838
setElements([
3939
{ id: '1', type: 'input', data: { label: 'An input node' }, position: { x: 0, y: 50 }, sourcePosition: 'right' },
40-
{ id: '2', type: 'selectorNode', data: { onChange: onChange, color: initBgColor }, position: { x: 250, y: 50 } },
40+
{ id: '2', type: 'selectorNode', data: { onChange: onChange, color: initBgColor }, style: { border: '1px solid #777' }, position: { x: 250, y: 50 } },
4141
{ id: '3', type: 'output', data: { label: 'Output A' }, position: { x: 550, y: 25 }, targetPosition: 'left' },
4242
{ id: '4', type: 'output', data: { label: 'Output B' }, position: { x: 550, y: 100 }, targetPosition: 'left' },
4343

example/src/Horizontal/index.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,20 @@ const onLoad = (graph) => {
99
const initialElements = [
1010
{ id: '1', sourcePosition: 'right', type: 'input', className: 'dark-node', data: { label: 'Input' }, position: { x: 0, y: 80 } },
1111
{ id: '2', sourcePosition: 'right', targetPosition: 'left', data: { label: 'A Node' }, position: { x: 250, y: 0 } },
12-
{ id: '3', sourcePosition: 'right', targetPosition: 'left', data: { label: 'Another node' }, position: { x: 250, y: 160 } },
13-
{ id: '4', sourcePosition: 'right', targetPosition: 'left', data: { label: 'Node 4' }, position: { x: 500, y: 80 } },
12+
{ id: '3', sourcePosition: 'right', targetPosition: 'left', data: { label: 'Node 3' }, position: { x: 250, y: 160 } },
13+
{ id: '4', sourcePosition: 'right', targetPosition: 'left', data: { label: 'Node 4' }, position: { x: 500, y: 0 } },
14+
{ id: '5', sourcePosition: 'top', targetPosition: 'bottom', data: { label: 'Node 5' }, position: { x: 500, y: 100 } },
15+
{ id: '6', sourcePosition: 'bottom', targetPosition: 'top', data: { label: 'Node 6' }, position: { x: 500, y: 230 } },
16+
{ id: '7', sourcePosition: 'right', targetPosition: 'left', data: { label: 'Node 7' }, position: { x: 750, y: 50 } },
17+
{ id: '8', sourcePosition: 'right', targetPosition: 'left', data: { label: 'Node 8' }, position: { x: 750, y: 300 } },
18+
1419
{ id: 'e1-2', source: '1', target: '2', animated: true, },
1520
{ id: 'e1-3', source: '1', target: '3', animated: true, },
16-
{ id: 'e1-4', source: '2', target: '4', label: 'edge label' }
21+
{ id: 'e1-4', source: '2', target: '4', label: 'edge label' },
22+
{ id: 'e3-5', source: '3', target: '5', animated: true },
23+
{ id: 'e3-6', source: '3', target: '6', animated: true },
24+
{ id: 'e5-7', source: '5', target: '7', animated: true },
25+
{ id: 'e6-8', source: '6', target: '8', animated: true },
1726
];
1827

1928
const HorizontalFlow = () => {

example/src/index.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ nav a.active:before {
136136
color: #111;
137137
}
138138

139-
.dark-node>div {
140-
background: #333 !important;
141-
color: #f8f8f8 !important;
139+
.dark-node {
140+
background: #333;
141+
color: #f8f8f8;
142142
}
143143

144144
@media screen and (min-width: 768px) {

rollup.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ export default [
3737
],
3838
plugins: [
3939
bundleSize(),
40-
postcss(),
40+
postcss({
41+
minimize: isProd,
42+
}),
4143
babel({
4244
exclude: 'node_modules/**',
4345
}),

src/additional-components/Background/index.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
1-
import React, { memo, HTMLAttributes, CSSProperties } from 'react';
1+
import React, { memo, HTMLAttributes } from 'react';
22
import classnames from 'classnames';
33

44
import { useStoreState } from '../../store/hooks';
55
import { BackgroundVariant } from '../../types';
66
import { createGridLinesPath, createGridDotsPath } from './utils';
77

8+
import './style.css';
9+
810
interface BackgroundProps extends HTMLAttributes<SVGElement> {
911
variant?: BackgroundVariant;
1012
gap?: number;
1113
color?: string;
1214
size?: number;
1315
}
1416

15-
const baseStyles: CSSProperties = {
16-
position: 'absolute',
17-
top: 0,
18-
left: 0,
19-
};
20-
2117
const defaultColors = {
2218
[BackgroundVariant.Dots]: '#999',
2319
[BackgroundVariant.Lines]: '#eee',
2420
};
2521

2622
const Background = memo(
27-
({ variant = BackgroundVariant.Dots, gap = 24, size = 0.5, color, style = {}, className = '' }: BackgroundProps) => {
23+
({ variant = BackgroundVariant.Dots, gap = 24, size = 0.5, color, style, className }: BackgroundProps) => {
2824
const width = useStoreState((s) => s.width);
2925
const height = useStoreState((s) => s.height);
3026
const [x, y, scale] = useStoreState((s) => s.transform);
@@ -42,7 +38,7 @@ const Background = memo(
4238
const stroke = isLines ? bgColor : 'none';
4339

4440
return (
45-
<svg width={width} height={height} style={{ ...baseStyles, ...style }} className={bgClasses}>
41+
<svg width={width} height={height} style={style} className={bgClasses}>
4642
<path fill={fill} stroke={stroke} strokeWidth={size} d={path} />
4743
</svg>
4844
);

0 commit comments

Comments
 (0)