Coder Social home page Coder Social logo

Comments (7)

fkhadra avatar fkhadra commented on August 14, 2024

Hello @PriyankGahtori ,

I don't know if you still need to add a context menu. Anyway I made a POC using my library react-contexify.

You can check the demo here : http://sniphpet.github.io/react-treebeard/

from react-treebeard.

andrewex avatar andrewex commented on August 14, 2024

Hello @sniphpet I am having problems implementing your example above is there any chance you can share the source.

Thanks!

from react-treebeard.

fkhadra avatar fkhadra commented on August 14, 2024

Hello, @andrewex . Sorry, I should have given more details.

The work is located under the feature/context-menu branch.

I made some changes only inside treebeard.js :

...
import { menuProvider } from 'react-contexify';

class TreeBeard extends React.Component {
    constructor(props){
        ...
       // Menu provider is a higher order component. We will use it on the TreeNode component
        this.node = props.contextMenuId !== false ? menuProvider(props.contextMenuId)(TreeNode) : TreeNode;
    }

...

TreeBeard.propTypes = {
   ...
    contextMenuId: React.PropTypes.string
};

TreeBeard.defaultProps = {
    ...
    contextMenuId: false
};

Then React-contexify take care of the rest.

Here is the source example implementation. There are 2 interesting parts :

  • The context menu file. This is where I declare what I want inside my context menu and which id I'll use.
  • The app file. This file is almost the same as the original, here are the differences :
// import the menu and the menu id
import ContextMenu, { menuId } from './ContextMenu';
...

//Inside the render of the DemoTree component, pass the menuId that we will use
<Treebeard  ...  contextMenuId={menuId} />
//The context menu to render. Don't pay attention to animation and theme it's only sugar 
<ContextMenu animation={this.state.ctxAnimation} theme={this.state.ctxTheme}/>

I hope I gave you enough details to help. Otherwise please tell me.
If you are interested in this feature maybe I can take the time to make a better implementation.

from react-treebeard.

andrewex avatar andrewex commented on August 14, 2024

Thanks works great!

from react-treebeard.

fkhadra avatar fkhadra commented on August 14, 2024

I'm glad it works for you :)

from react-treebeard.

tblazz avatar tblazz commented on August 14, 2024

Hello,
Is there a possibility to merge this feature created by @sniphpet with the current master ? (To have this feature directly by npm )

from react-treebeard.

fkhadra avatar fkhadra commented on August 14, 2024

Hello @tblasig ,
If the author wants to add the context menu I need to review the implementation. It was a quick and dirty implementation 😁 .
Anyway I would love to contribute.

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.