add className prop to ReactFlow container component closes #238
This commit is contained in:
@@ -3,6 +3,7 @@ describe('Basic Graph Rendering', () => {
|
|||||||
cy.visit('/basic');
|
cy.visit('/basic');
|
||||||
|
|
||||||
cy.get('.react-flow__renderer');
|
cy.get('.react-flow__renderer');
|
||||||
|
cy.get('.react-flow-basic-example'); // check if className prop works
|
||||||
cy.get('.react-flow__node').should('have.length', 4);
|
cy.get('.react-flow__node').should('have.length', 4);
|
||||||
cy.get('.react-flow__edge').should('have.length', 2);
|
cy.get('.react-flow__edge').should('have.length', 2);
|
||||||
cy.get('.react-flow__node').children('div').children('.react-flow__handle');
|
cy.get('.react-flow__node').children('div').children('.react-flow__handle');
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ const BasicFlow = () => {
|
|||||||
onNodeDragStop={onNodeDragStop}
|
onNodeDragStop={onNodeDragStop}
|
||||||
style={{ width: '100%', height: '100%' }}
|
style={{ width: '100%', height: '100%' }}
|
||||||
backgroundType="lines"
|
backgroundType="lines"
|
||||||
|
className="react-flow-basic-example"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
onClick={updatePos}
|
onClick={updatePos}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import React, { useMemo, CSSProperties, HTMLAttributes } from 'react';
|
import React, { useMemo, CSSProperties, HTMLAttributes } from 'react';
|
||||||
|
import cx from 'classnames';
|
||||||
import { StoreProvider } from 'easy-peasy';
|
import { StoreProvider } from 'easy-peasy';
|
||||||
|
|
||||||
const nodeEnv: string = process.env.NODE_ENV as string;
|
const nodeEnv: string = process.env.NODE_ENV as string;
|
||||||
@@ -44,12 +45,14 @@ export interface ReactFlowProps extends Omit<HTMLAttributes<HTMLDivElement>, 'on
|
|||||||
snapGrid: [number, number];
|
snapGrid: [number, number];
|
||||||
onlyRenderVisibleNodes: boolean;
|
onlyRenderVisibleNodes: boolean;
|
||||||
isInteractive: boolean;
|
isInteractive: boolean;
|
||||||
|
className: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ReactFlow = ({
|
const ReactFlow = ({
|
||||||
style,
|
style,
|
||||||
onElementClick,
|
onElementClick,
|
||||||
elements = [],
|
elements = [],
|
||||||
|
className,
|
||||||
children,
|
children,
|
||||||
nodeTypes,
|
nodeTypes,
|
||||||
edgeTypes,
|
edgeTypes,
|
||||||
@@ -75,7 +78,7 @@ const ReactFlow = ({
|
|||||||
const edgeTypesParsed = useMemo(() => createEdgeTypes(edgeTypes), []);
|
const edgeTypesParsed = useMemo(() => createEdgeTypes(edgeTypes), []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={style} className="react-flow">
|
<div style={style} className={cx('react-flow', className)}>
|
||||||
<StoreProvider store={store}>
|
<StoreProvider store={store}>
|
||||||
<GraphView
|
<GraphView
|
||||||
onLoad={onLoad}
|
onLoad={onLoad}
|
||||||
@@ -137,6 +140,7 @@ ReactFlow.defaultProps = {
|
|||||||
snapGrid: [16, 16],
|
snapGrid: [16, 16],
|
||||||
onlyRenderVisibleNodes: true,
|
onlyRenderVisibleNodes: true,
|
||||||
isInteractive: true,
|
isInteractive: true,
|
||||||
|
className: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ReactFlow;
|
export default ReactFlow;
|
||||||
|
|||||||
Reference in New Issue
Block a user