Reduce tree DOM nodes by 33%
This commit is contained in:
@@ -38,6 +38,15 @@ const styles = (theme: Theme) => {
|
|||||||
hover: {
|
hover: {
|
||||||
backgroundColor: theme.palette.type === 'dark' ? 'rgba(100, 100, 100, 0.55)' : 'rgba(200, 200, 200, 0.55)',
|
backgroundColor: theme.palette.type === 'dark' ? 'rgba(100, 100, 100, 0.55)' : 'rgba(200, 200, 200, 0.55)',
|
||||||
},
|
},
|
||||||
|
title: {
|
||||||
|
borderRadius: '4px',
|
||||||
|
lineHeight: '1em',
|
||||||
|
display: 'inline-block' as 'inline-block',
|
||||||
|
whiteSpace: 'nowrap' as 'nowrap',
|
||||||
|
padding: '1px 4px 0px 4px',
|
||||||
|
height: '14px',
|
||||||
|
margin: '1px 0px 2px 0px',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,7 +245,7 @@ class TreeNode extends React.Component<Props, State> {
|
|||||||
<div>
|
<div>
|
||||||
<div
|
<div
|
||||||
key={this.props.treeNode.hash()}
|
key={this.props.treeNode.hash()}
|
||||||
className={`${classes.node} ${this.props.className}`}
|
className={`${classes.node} ${this.props.className} ${highlightClass} ${classes.title} `}
|
||||||
onMouseOver={this.mouseOver}
|
onMouseOver={this.mouseOver}
|
||||||
onMouseOut={this.mouseOut}
|
onMouseOut={this.mouseOut}
|
||||||
onClick={this.didClickTitle}
|
onClick={this.didClickTitle}
|
||||||
@@ -249,13 +258,10 @@ class TreeNode extends React.Component<Props, State> {
|
|||||||
collapsed={this.collapsed()}
|
collapsed={this.collapsed()}
|
||||||
treeNode={this.props.treeNode}
|
treeNode={this.props.treeNode}
|
||||||
name={this.props.name}
|
name={this.props.name}
|
||||||
className={highlightClass}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className={classes.subnodes}>
|
|
||||||
{this.renderNodes()}
|
{this.renderNodes()}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,9 +94,7 @@ const styles = (theme: Theme) => ({
|
|||||||
list: {
|
list: {
|
||||||
display: 'block' as 'block',
|
display: 'block' as 'block',
|
||||||
clear: 'both' as 'both',
|
clear: 'both' as 'both',
|
||||||
},
|
marginLeft: theme.spacing(1.5),
|
||||||
listItem: {
|
|
||||||
padding: `0px 0px 0px ${theme.spacing(1)}`,
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ export interface TreeNodeProps extends React.HTMLAttributes<HTMLElement> {
|
|||||||
treeNode: q.TreeNode<TopicViewModel>
|
treeNode: q.TreeNode<TopicViewModel>
|
||||||
name?: string | undefined
|
name?: string | undefined
|
||||||
collapsed?: boolean | undefined
|
collapsed?: boolean | undefined
|
||||||
classes: any
|
|
||||||
didSelectNode: any
|
didSelectNode: any
|
||||||
toggleCollapsed: any
|
toggleCollapsed: any
|
||||||
|
classes: any
|
||||||
}
|
}
|
||||||
|
|
||||||
class TreeNodeTitle extends React.Component<TreeNodeProps, {}> {
|
class TreeNodeTitle extends React.Component<TreeNodeProps, {}> {
|
||||||
@@ -34,7 +34,7 @@ class TreeNodeTitle extends React.Component<TreeNodeProps, {}> {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.props.collapsed ? '▶' : '▼'
|
return <span className={this.props.classes.expander} onClick={this.props.toggleCollapsed}>{this.props.collapsed ? '▶' : '▼'}</span>
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderCollapsedSubnodes() {
|
private renderCollapsedSubnodes() {
|
||||||
@@ -46,16 +46,13 @@ class TreeNodeTitle extends React.Component<TreeNodeProps, {}> {
|
|||||||
return <span className={this.props.classes.collapsedSubnodes}>({this.props.treeNode.childTopicCount()} topics, {messages} messages)</span>
|
return <span className={this.props.classes.collapsedSubnodes}>({this.props.treeNode.childTopicCount()} topics, {messages} messages)</span>
|
||||||
}
|
}
|
||||||
public render() {
|
public render() {
|
||||||
const { classes, style, className } = this.props
|
const { style, className } = this.props
|
||||||
return (
|
return ([
|
||||||
<span
|
this.renderExpander(),
|
||||||
className={`${classes.title} ${className}`}
|
this.renderSourceEdge(),
|
||||||
style={style}
|
this.renderCollapsedSubnodes(),
|
||||||
>
|
this.renderValue(),
|
||||||
<span className={classes.expander} onClick={this.props.toggleCollapsed}>{this.renderExpander()}</span>
|
])
|
||||||
{this.renderSourceEdge()} {this.renderCollapsedSubnodes()} {this.renderValue()}
|
|
||||||
</span>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,15 +72,6 @@ const styles = (theme: Theme) => ({
|
|||||||
cursor: 'pointer' as 'pointer',
|
cursor: 'pointer' as 'pointer',
|
||||||
paddingRight: theme.spacing(0.25),
|
paddingRight: theme.spacing(0.25),
|
||||||
},
|
},
|
||||||
title: {
|
|
||||||
borderRadius: '4px',
|
|
||||||
lineHeight: '1em',
|
|
||||||
display: 'inline-block' as 'inline-block',
|
|
||||||
whiteSpace: 'nowrap' as 'nowrap',
|
|
||||||
padding: '1px 4px 0px 4px',
|
|
||||||
height: '14px',
|
|
||||||
margin: '1px 0px 2px 0px',
|
|
||||||
},
|
|
||||||
collapsedSubnodes: {
|
collapsedSubnodes: {
|
||||||
color: theme.palette.text.secondary,
|
color: theme.palette.text.secondary,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user