Skip to content

Commit

Permalink
fix: remove usage of !important to remove the padding of nodes during…
Browse files Browse the repository at this point in the history
… search

to avoid cascading !important in css, it's better to not use it at first.
  • Loading branch information
Gregcop1 committed Feb 14, 2018
1 parent 55e7036 commit 4d8e7d4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 0 additions & 4 deletions src/tree-node/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
padding: 4px;
}

.searchModeOn li.node {
padding-left: 0 !important;
}

.toggle {
white-space: pre;
margin-right: 4px;
Expand Down
7 changes: 4 additions & 3 deletions src/tree-node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import styles from './index.css'
const cx = cn.bind(styles)

const TreeNode = props => {
const { node, onNodeToggle, onCheckboxChange, onAction } = props
const { node, onNodeToggle, onCheckboxChange, onAction, searchModeOn } = props
const actions = node.actions || []
const isLeaf = isEmpty(node._children)
const liCx = cx('node', { leaf: isLeaf, tree: !isLeaf, hide: node.hide }, node.className)
const toggleCx = cx('toggle', { expanded: !isLeaf && node.expanded, collapsed: !isLeaf && !node.expanded })

return (
<li className={liCx} style={{ paddingLeft: `${node._depth * 20}px` }}>
<li className={liCx} style={!searchModeOn ? { paddingLeft: `${node._depth * 20}px` } : {}}>
<i className={toggleCx} onClick={() => onNodeToggle(node._id)} />
<label title={node.title || node.label}>
<input
Expand Down Expand Up @@ -49,7 +49,8 @@ TreeNode.propTypes = {
}).isRequired,
onNodeToggle: PropTypes.func,
onAction: PropTypes.func,
onCheckboxChange: PropTypes.func
onCheckboxChange: PropTypes.func,
searchModeOn: PropTypes.bool
}

export default TreeNode
1 change: 1 addition & 0 deletions src/tree/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const getNodes = props => {
onCheckboxChange={onCheckboxChange}
onNodeToggle={onNodeToggle}
onAction={onAction}
searchModeOn={searchModeOn}
/>
)
}
Expand Down

0 comments on commit 4d8e7d4

Please sign in to comment.