Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/mouse over link highlight #75

Merged
merged 2 commits into from
May 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions cypress/integration/link.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,43 @@ describe('[rd3g-graph] link tests', function() {
this.link34PO.shouldHaveColor('blue');
});
});

describe('when mouse is over some link', function() {
beforeEach(function() {
// small hack to disable any previous highlight behavior
this.sandboxPO.fullScreenMode().click();
});

it('should highlight the link and the intervening nodes', function() {
// mouse over link between nodes 1 and 4
// should highlight nodes 1 and 4 as well as they're connection
this.link14PO
.getLine()
.click()
.trigger('mouseover');

this.node1PO.getColor().should('eq', 'red');
this.node1PO.getFontWeight().should('eq', 'bold');

this.node2PO.getColor().should('eq', '#d3d3d3');
this.node2PO.getOpacity().should('eq', '0.2');

this.node3PO.getColor().should('eq', '#d3d3d3');
this.node3PO.getOpacity().should('eq', '0.2');

this.node4PO.getColor().should('eq', 'red');
this.node4PO.getFontWeight().should('eq', 'bold');

this.link12PO.shouldHaveColor('rgb(211, 211, 211)');
this.link12PO.shouldHaveOpacity(0.2);

this.link13PO.shouldHaveColor('rgb(211, 211, 211)');
this.link13PO.shouldHaveOpacity(0.2);

this.link14PO.shouldHaveColor('blue');

this.link34PO.shouldHaveColor('rgb(211, 211, 211)');
this.link34PO.shouldHaveOpacity(0.2);
});
});
});
1 change: 1 addition & 0 deletions cypress/page-objects/sandbox.po.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function SandboxPO() {
this.checkboxes = ['node.renderLabel', 'staticGraph'];

// actions
this.fullScreenMode = () => cy.get('.container__graph > :nth-child(1) > :nth-child(1)');
this.playGraph = () => cy.get('.container__graph > :nth-child(1) > :nth-child(2)').click();
this.pauseGraph = () => cy.get('.container__graph > :nth-child(1) > :nth-child(3)').click();
this.addNode = () => cy.get('.container__graph > :nth-child(1) > :nth-child(5)').click();
Expand Down
9 changes: 8 additions & 1 deletion src/components/graph/graph.renderer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,14 @@ function _buildLinks(nodes, links, linksMatrix, config, linkCallbacks, highlight
*/
function _buildNodes(nodes, nodeCallbacks, config, highlightedNode, highlightedLink, transform) {
return Object.keys(nodes).map(nodeId => {
const props = buildNodeProps(nodes[nodeId], config, nodeCallbacks, highlightedNode, highlightedLink, transform);
const props = buildNodeProps(
Object.assign({}, nodes[nodeId], { id: `${nodeId}` }),
config,
nodeCallbacks,
highlightedNode,
highlightedLink,
transform
);

return <Node key={nodeId} {...props} />;
});
Expand Down