Comments (11)
@bkniffler That makes sense to me. The only problem is, we will have to push the onClick to the toggle component as well, which makes it more complicated overall. Especially when you have custom toggle and header decorators, you will have to remember to use onClick twice. What do you think?
from react-treebeard.
I think it would make sense to join header and toggle decorators, this would give us more flexibility. What do you think about that?
from react-treebeard.
Just as an example, this is how my header looks like now. It checks weather its a terminal node to insert the caret. Also, it checks for active state for bold font. And if a 'code' is present, an additional link is displayed.
const {id, toggled, code, name, active, terminal} = props.node;
<div onClick={toggle} style={{...props.style.base}}>
{!terminal ? <strong style={{display: 'table-cell', width:'20px'}}>
<i className={"icon caret " + (toggled ? 'down' : 'right')} style={{position:'absolute', top:'1px'}}></i>
</strong> : <strong style={{display: 'table-cell', width:'20px'}}> </strong>}
{code ? <a onClick={activate} href="javascript:;" style={{display: 'table-cell', minWidth: '27px', paddingRight:'10px', whiteSpace: 'nowrap'}}>{code}</a> : null}
<span style={{display: 'table-cell', fontWeight: active?'bold':'initial'}}>{name}</span>
</div>
from react-treebeard.
Its a difficult one. Because a lot of times you will want to use another header, but keep the toggle the same, as a lot of people will be happy with the default toggle decorator. But the header must be changed for simple things like icons. I'll have a think about it.
from react-treebeard.
Its true. So why not adding a 'row' decorator? The default one would just render the default toggle and header.
{row: [toggle, header]}
Row could be something like renderRow(props, onToggle, DefaultToggle, DefaultHeader)
. onToggle could also live within the props object.
Also you could think about handing the decorators one by one as props, e.g. renderToggle, renderHeader, renderRow, renderLoader. Your current approach only allows for all or nothing.
from react-treebeard.
+1 I was looking for this exact functionality! Otherwise parts of the tree get toggled when all the user wants to do is select a particular item.
from react-treebeard.
@bkniffler @gbmhunter I agree with you guys. I'm going to look into this issue in more depth, to find a good balance between extensibility and out-of-the-box usability. I'll take some ideas from @bkniffler's work and try to get a good mix.
from react-treebeard.
@bkniffler @gbmhunter. I have release 1.1.0
to npm. This includes a new decorator called Container
which should allow you to fully rewrite a node. It also pulls down the onClick event. Most of this comes from @bkniffler's work, so id like to say thanks to him for helping out with this one!
from react-treebeard.
Cool, couldn't be happier with your new version
import {Treebeard, decorators} from 'react-treebeard';
import TreeStyle from './tree-style';
var Container = (props)=>{
// Handle node render with inline loading indicator, custom toggle and header
}
const Loading = (props) => <div></div>;
<Treebeard data={lists} decorators={{...decorators, Loading, Container}} onToggle={updateTreeItem} style={TreeStyle} animations={false}/>
Separating the decorators as multiple props would still make this a bit better. But it works great!
from react-treebeard.
ps. Feel free to remove my pull requests as soon as you're done incorporating the parts you like.
from react-treebeard.
We also need to be able to expand/collapse the tree only by the toggle icon.
Can anyone please share their solution?
Thanks
from react-treebeard.
Related Issues (20)
- Example doesn't work HOT 2
- Is it possible to change the Icon? HOT 1
- [Question] Is it possible to expand node without selecting it? HOT 15
- How to get name for parent node?
- Example code does not work as expected. Parent and child nodes all get highlighted when expanded
- How to handle right click events over folders and nodes (files)? HOT 4
- style object is mutated by a component it's passed to HOT 1
- its impossible to update treebeard from client side dynamically?
- How to Pass nodes in custom toggle decorater
- Performance for large numbers of files
- Update data when new file is added HOT 1
- Using array for multiple root nodes fails when interacting with tree (example included) HOT 3
- responsive
- Uncaught Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of `VelocityTransitionGroup`. HOT 2
- Show buttons to the right when hovering on a node? HOT 1
- [Request] Do not show polygon if no children are provided.
- Dynamically add children through API
- [Question] Display more than the name HOT 1
- [Bug] Arrows in markdown are way off on the right HOT 1
- [Question] Remove onToggle from file nodes? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-treebeard.