Coder Social home page Coder Social logo

Comments (4)

covelloz avatar covelloz commented on August 14, 2024 1

@eladhayun @LiguidCool @sarahmarciano

You can change the background color using
tree > node > activeLink

However, simply adding color: "blue" to activeLink section doesn't do the trick.
This is because the text is actually tree > node > header > base which has an inline-style hardcoded in there.

I did figure out a way to do it using a custom decorator:

import { Treebeard, decorators } from 'react-treebeard';

class ListTree extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      cursor: '',
      prevNode: ''
    };
    this.onToggle = this.onToggle.bind(this);
  }

  onToggle(node, toggled) {
    // Store previous node & de-activate
    if (this.state.prevNode !== '') {
      let stateUpdate = Object.assign({}, this.state);
      stateUpdate.prevNode.active = false;
      this.setState(stateUpdate);
    }
    this.setState({prevNode: node});

    // Activate new node
    node.active = true;
    if(node.children) {
      node.toggled = toggled;
    }
    this.setState({cursor: node});
  }

  render() {
    const mydecorator =  {
      Header: (props) => {
        const activeColor = this.state.cursor.id === props.node.id ? '#428BCA' : '#9DA5AB';
        return (
          <div style={props.style.base}>
            <div id={props.node.id} style={{'color':activeColor}}>
              {props.node.name}
            </div>
          </div>
        );
      }
    }
  return (
            <Treebeard
              data={data}
              onToggle={this.onToggle}
              decorators={{...decorators, Header: mydecorator.Header}}
            />
  )
  }
export default ListTree;

from react-treebeard.

eladhayun avatar eladhayun commented on August 14, 2024

tree > node > header > base
add color: '#FFFFFF' for example...

from react-treebeard.

sarahmarciano avatar sarahmarciano commented on August 14, 2024

@eladhayun this change the color of the whole tree I would want to change just the color of the selected node
do you know how can I do that?
thank you.

from react-treebeard.

elenilson-costa avatar elenilson-costa commented on August 14, 2024

How to set the arrow color in treebeard ?

from react-treebeard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.