Skip to content

Commit 54d8b2f

Browse files
authored
Hide properties (#7)
* Hide properties from the tree * Make path straight
1 parent abac08c commit 54d8b2f

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

DotNetSyntaxTreeVisualizer/ClientApp/src/components/Home.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
import React, { Component } from 'react';
22
import Tree from 'react-d3-tree';
33

4-
const svgSquare = {
5-
shape: 'rect',
6-
shapeProps: {
7-
width: 20,
8-
height: 20,
9-
x: -10,
10-
y: -10,
11-
}
12-
}
13-
144
const containerStyles = {
155
width: '100%',
166
height: '100vh',
@@ -57,7 +47,7 @@ export class Home extends Component {
5747
<React.Fragment>
5848
<textarea defaultValue={helloWorldCode} onChange={this.handleChanged} style={{ height: '230px', width: '100%' }} />
5949
<div id="treeWrapper" style={containerStyles} ref={tc => (this.treeContainer = tc)}>
60-
<Tree data={this.state.treeJson} nodeSvgShape={svgSquare} orientation="vertical" translate={this.state.translate} />
50+
<Tree data={this.state.treeJson} orientation="vertical" translate={this.state.translate} pathFunc="straight" />
6151
</div>
6252
</React.Fragment>
6353
);

DotNetSyntaxTreeVisualizer/SyntaxTreeNode.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ public class SyntaxTreeNode
99
{
1010
public string Name { get; }
1111

12-
public IDictionary<string, string> Attributes { get; }
12+
public IDictionary<string, string> Properties { get; }
1313
public IList<SyntaxTreeNode> Children { get; } = new List<SyntaxTreeNode>();
1414

15-
public SyntaxTreeNode(IDictionary<string, string> attributes) =>
16-
(Attributes, Name) = (attributes, attributes.Values.First());
15+
public SyntaxTreeNode(IDictionary<string, string> properties) =>
16+
(Properties, Name) = (properties, properties.Values.First());
1717

1818
public void AddChild(SyntaxTreeNode child)
1919
{
@@ -22,7 +22,7 @@ public void AddChild(SyntaxTreeNode child)
2222

2323
public override string ToString()
2424
{
25-
return Attributes.Values.First();
25+
return Properties.Values.First();
2626
}
2727
}
2828
}

0 commit comments

Comments
 (0)