react-treebeard icon indicating copy to clipboard operation
react-treebeard copied to clipboard

parent background color

Open dk4210 opened this issue 8 years ago • 2 comments

How to I control the background color of the top parent only?

dk4210 avatar Aug 30 '17 14:08 dk4210

Some one anyone?

dk4210 avatar Aug 31 '17 12:08 dk4210

I think you need to add a decorator.

Something like this (semi pseudo code):

in custom-decorators.js

import { decorators } from 'react-treebeard'; 

function HeaderDecorator(props) {
  const { style, node, ...restProps } = props;

  let newStyle = style;

  if (node.isTopParrent) { // <-- your condition to recognize the parent node
    newStyle = {
      ...style,
      // override the relevant props
    };
  }
 
  return <decorators.Header style={newStyle} node={node} {...restProps} />;
}

export default {
  ...decorators,
  Header: HeaderDecorator,
};

in your component.js

import customDecorators from './sustom_decorators';

//

render() {
    return (
      <Treebeard
        // data and other things
        decorators={customDecorators}
      />
    );
  }

//

igor-dv avatar Aug 31 '17 15:08 igor-dv