Skip to content

Commit

Permalink
First publishable build
Browse files Browse the repository at this point in the history
  • Loading branch information
Johnathan Barrett committed Sep 13, 2018
1 parent 5418461 commit b047c62
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 42 deletions.
48 changes: 44 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,47 @@
## Usage

```HTML
<ContextMenu :text="hello"></ContextMenu>
<ContextMenu ref="contextMenu" :menu-items="menuItems"/>

<div class="context-menu-trigger"
@click.right.prevent="$refs.contextMenu.open($event)">
Right Click Me!
</div>
```

```javascript
import { ContextMenu } from 'vue-context-menu-popup'
import ContextMenu from 'vue-context-menu-popup'

export default {
data() {
return {
menuItems: [
{
label: 'First Menu Item',
},
{
label: 'Disabled Menu Item',
disabled: true,
},
{
label: 'I have children',
children: [
{
label: 'Child Item 1',
},
{
label: 'I also have children',
children: [
{
label: 'Child Item 2',
},
],
},
],
},
]
}
},
components: {
ContextMenu
}
Expand All @@ -23,11 +57,15 @@ export default {

### context-menu

eslint-disable prefer-destructuring
A simple context menu component

```html
<ContextMenu :menu-items="[....]"/>
```

#### props

- `menu-items` ***Array*** (*optional*)
- `menu-items` ***Array*** (*required*)

#### data

Expand All @@ -45,6 +83,8 @@ eslint-disable prefer-destructuring

- `open(position)`

Accepts an Object with an `x, y` position or an instance of Event

## Installation

```
Expand Down
74 changes: 37 additions & 37 deletions example/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,44 +12,44 @@
</template>

<script>
import ContextMenu from '@/components/ContextMenu.vue';
import ContextMenu from '@/components/ContextMenu.vue';
export default {
name: 'app',
data() {
return {
menuItems: [
{
'label': 'First Menu Item'
},
{
'label': 'Disabled Menu Item',
'disabled': true
},
{
'label': 'I have children',
'children': [
{
'label': 'Child Item 1'
},
{
'label': 'I also have children',
'children': [
{
'label': 'Child Item 2'
}
]
}
]
}
],
consoleMessage: [],
};
},
components: {
ContextMenu,
},
};
export default {
name: 'app',
data() {
return {
menuItems: [
{
label: 'First Menu Item',
},
{
label: 'Disabled Menu Item',
disabled: true,
},
{
label: 'I have children',
children: [
{
label: 'Child Item 1',
},
{
label: 'I also have children',
children: [
{
label: 'Child Item 2',
},
],
},
],
},
],
consoleMessage: [],
};
},
components: {
ContextMenu,
},
};
</script>

<style lang="scss">
Expand Down
11 changes: 11 additions & 0 deletions src/components/ContextMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,18 @@
import ContextMenuItem from './ContextMenuItem.vue';
import ClickOutside from '../directives/ClickOutside';
/**
* A simple context menu component
*
* ```html
* <ContextMenu :menu-items="[....]"/>
* ```
*/
export default {
props: {
menuItems: {
type: Array,
required: true,
},
},
Expand All @@ -39,6 +47,9 @@ export default {
this.visible = false;
},
/**
* Accepts an Object with an `x, y` position or an instance of Event
*/
open(position) {
let x = 0;
let y = 0;
Expand Down
1 change: 1 addition & 0 deletions src/directives/ClickOutside.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-param-reassign */
export default {
bind(el, binding, vnode) {
el.clickOutsideEvent = (event) => {
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import ContextMenu from './components/ContextMenu.vue';

export { ContextMenu };
export default ContextMenu;

0 comments on commit b047c62

Please sign in to comment.