Skip to content

Commit b047c62

Browse files
author
Johnathan Barrett
committed
First publishable build
1 parent 5418461 commit b047c62

File tree

5 files changed

+94
-42
lines changed

5 files changed

+94
-42
lines changed

README.md

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,47 @@
66
## Usage
77

88
```HTML
9-
<ContextMenu :text="hello"></ContextMenu>
9+
<ContextMenu ref="contextMenu" :menu-items="menuItems"/>
10+
11+
<div class="context-menu-trigger"
12+
@click.right.prevent="$refs.contextMenu.open($event)">
13+
Right Click Me!
14+
</div>
1015
```
1116

1217
```javascript
13-
import { ContextMenu } from 'vue-context-menu-popup'
18+
import ContextMenu from 'vue-context-menu-popup'
1419

1520
export default {
21+
data() {
22+
return {
23+
menuItems: [
24+
{
25+
label: 'First Menu Item',
26+
},
27+
{
28+
label: 'Disabled Menu Item',
29+
disabled: true,
30+
},
31+
{
32+
label: 'I have children',
33+
children: [
34+
{
35+
label: 'Child Item 1',
36+
},
37+
{
38+
label: 'I also have children',
39+
children: [
40+
{
41+
label: 'Child Item 2',
42+
},
43+
],
44+
},
45+
],
46+
},
47+
]
48+
}
49+
},
1650
components: {
1751
ContextMenu
1852
}
@@ -23,11 +57,15 @@ export default {
2357

2458
### context-menu
2559

26-
eslint-disable prefer-destructuring
60+
A simple context menu component
61+
62+
```html
63+
<ContextMenu :menu-items="[....]"/>
64+
```
2765

2866
#### props
2967

30-
- `menu-items` ***Array*** (*optional*)
68+
- `menu-items` ***Array*** (*required*)
3169

3270
#### data
3371

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

4684
- `open(position)`
4785

86+
Accepts an Object with an `x, y` position or an instance of Event
87+
4888
## Installation
4989

5090
```

example/App.vue

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,44 +12,44 @@
1212
</template>
1313

1414
<script>
15-
import ContextMenu from '@/components/ContextMenu.vue';
15+
import ContextMenu from '@/components/ContextMenu.vue';
1616
17-
export default {
18-
name: 'app',
19-
data() {
20-
return {
21-
menuItems: [
22-
{
23-
'label': 'First Menu Item'
24-
},
25-
{
26-
'label': 'Disabled Menu Item',
27-
'disabled': true
28-
},
29-
{
30-
'label': 'I have children',
31-
'children': [
32-
{
33-
'label': 'Child Item 1'
34-
},
35-
{
36-
'label': 'I also have children',
37-
'children': [
38-
{
39-
'label': 'Child Item 2'
40-
}
41-
]
42-
}
43-
]
44-
}
45-
],
46-
consoleMessage: [],
47-
};
48-
},
49-
components: {
50-
ContextMenu,
51-
},
52-
};
17+
export default {
18+
name: 'app',
19+
data() {
20+
return {
21+
menuItems: [
22+
{
23+
label: 'First Menu Item',
24+
},
25+
{
26+
label: 'Disabled Menu Item',
27+
disabled: true,
28+
},
29+
{
30+
label: 'I have children',
31+
children: [
32+
{
33+
label: 'Child Item 1',
34+
},
35+
{
36+
label: 'I also have children',
37+
children: [
38+
{
39+
label: 'Child Item 2',
40+
},
41+
],
42+
},
43+
],
44+
},
45+
],
46+
consoleMessage: [],
47+
};
48+
},
49+
components: {
50+
ContextMenu,
51+
},
52+
};
5353
</script>
5454

5555
<style lang="scss">

src/components/ContextMenu.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,18 @@
1717
import ContextMenuItem from './ContextMenuItem.vue';
1818
import ClickOutside from '../directives/ClickOutside';
1919
20+
/**
21+
* A simple context menu component
22+
*
23+
* ```html
24+
* <ContextMenu :menu-items="[....]"/>
25+
* ```
26+
*/
2027
export default {
2128
props: {
2229
menuItems: {
2330
type: Array,
31+
required: true,
2432
},
2533
},
2634
@@ -39,6 +47,9 @@ export default {
3947
this.visible = false;
4048
},
4149
50+
/**
51+
* Accepts an Object with an `x, y` position or an instance of Event
52+
*/
4253
open(position) {
4354
let x = 0;
4455
let y = 0;

src/directives/ClickOutside.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-param-reassign */
12
export default {
23
bind(el, binding, vnode) {
34
el.clickOutsideEvent = (event) => {

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import ContextMenu from './components/ContextMenu.vue';
22

3-
export { ContextMenu };
3+
export default ContextMenu;

0 commit comments

Comments
 (0)