An open API service indexing awesome lists of open source software.

https://github.com/pocesar/react-semantic-ui-contextmenu

Thin wrapper for (context) menu using React Semantic-UI
https://github.com/pocesar/react-semantic-ui-contextmenu

contextmenu electron react react-component react-components reactjs right-click semantic-ui semantic-ui-react

Last synced: about 2 months ago
JSON representation

Thin wrapper for (context) menu using React Semantic-UI

Awesome Lists containing this project

README

          

# React Semantic-UI context menu
Thin wrapper for (context) menu using React Semantic-UI

## Usage

```jsx
import React from 'react'
import { ContextMenu } from 'react-semantic-ui-contextmenu'
import { Dropdown } from 'semantic-ui-react'

class MyContextMenuComponent extends React.Component {
divRef = React.createRef()
div2Ref = React.createRef()

menuContent = ({ close, target }) => (

{/* it's actually a Menu.Item with some ready-to-use functionality */}
{ doSomething().then(close) }}>
Open in new window


Close menu


{this.div2Ref.current === target ? (

This only exists in "Also right click me"

) : null}

{/* behaves exactly like https://react.semantic-ui.com/collections/menu/#content-sub-menu */}








)

/*
takes an array of refs, multiple items can trigger the same context menu,
but can trigger the open/close from outside using isOpen
*/

contextTargets = [this.divRef, this.div2Ref]

onOpen = ({ target }) => {
console.log('context menu opened', target)
}

onClose = () => {
console.log('context menu closed')
}

render() {
return (



{this.menuContent}

Right click me

Also right click me


)
}
}
```

## Why reusing Menu (and Menu.Item)?

The Semantic-UI Menu component makes it able to create complex, multi level menus without a major effort, making it really easy to create complex menus that are reusable and context-aware

## License

MIT