Skip to content
This repository was archived by the owner on Oct 5, 2022. It is now read-only.

Commit b5e5c32

Browse files
author
rawilk
committed
wip
1 parent aa85273 commit b5e5c32

13 files changed

+465
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ overridden by your own styles.
1212
<br><br>
1313
The menu disappears when you expect by utilizing `vue-clickaway` and it also optionally disappears when clicked on.
1414

15-
![Screenshot](screenshot.jpg)
15+
![Screenshot](docs/images/screenshot.jpg)
1616

1717
## Getting Started
1818

docs/api/_index.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: Api
3+
sort: 3
4+
---

docs/api/api.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: Vue-Context
3+
sort: 1
4+
---
5+
6+
## Slots
7+
8+
| Slot | Description |
9+
| --- | --- |
10+
| default | The default slot also serves as a scoped slot which receives any data passed to the menu |
11+
12+
## Props
13+
14+
| Prop | Type | Default | Description |
15+
| --- | --- | --- | --- |
16+
| `closeOnClick` | Boolean | `true` | If set to `false`, context menu will not automatically close when clicked on |
17+
| `closeOnScroll` | Boolean | `true` | If set to `true`, context menu will automatically close on window scroll |
18+
| `lazy` | Boolean | `false` | If set to `true`, context menu will be rendered with a `v-if` instead of `v-show` |
19+
| `itemSelector` | Array, String | `['.v-context-item', '.v-context > li > a']` | The selector of the menu items the menu will use to look for to set accessibility attributes and for keyboard navigation. |
20+
| `role` | String | `menu` | Used for the `role` attribute on the context menu |
21+
| `subMenuOffset` | Number | `10` | Specify the offset in pixels of the submenus |
22+
| `tag` | String | `ul` | Used as the root element of the context menu |
23+
| `heightOffset` | Number | `25` | Specify distance from the menu to top/bottom of screen |
24+
| `widthOffset` | Number | `25` | Specify distance from menu to left of screen |
25+
| `useScrollHeight` | Boolean | `false` | Use the menu's scroll height instead of offset height to calculate positioning |
26+
| `useScrollWidth` | Boolean | `false` | Use the menu's scroll width instead of offset width to calculate positioning |
27+
28+
## Events
29+
30+
| Event | Arguments | Description |
31+
| --- | --- | --- |
32+
| `close` | none | Emits when the context menu is closed |
33+
| `open` | `event`, `data`, `top`, `left` | Emits when the menu is opened. the event, context menu data, top and left position are all sent through as parameters |
34+
35+
[View source](https://github.com/rawilk/vue-context/blob/master/src/js/vue-context.vue)

docs/changelog.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: Changelog
3+
sort: 4
4+
---
5+
6+
All notable changes for laravel-breadcrumbs are documented [on Github](https://github.com/rawilk/vue-context/blob/master/CHANGELOG.md).

docs/demos/_index.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: Demos
3+
sort: 2
4+
---

docs/demos/basic.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: Basic Usage
3+
sort: 1
4+
---
File renamed without changes.

docs/installation.md

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
title: Quickstart
3+
sort: 2
4+
---
5+
6+
## Installation
7+
8+
vue-context can be installed via npm:
9+
10+
```bash
11+
npm i vue-context
12+
```
13+
14+
## Usage
15+
16+
Import the component and use it in your app.
17+
18+
```js
19+
import Vue from 'vue';
20+
import VueContext from 'vue-context';
21+
22+
new Vue({
23+
components: {
24+
VueContext,
25+
},
26+
27+
methods: {
28+
onClick(text) {
29+
alert(`You clicked ${text}!`);
30+
}
31+
}
32+
}).$mount('#app');
33+
```
34+
35+
For styling, you will need to import the component's styles into your own stylesheets, or into your JavaScript.
36+
It's recommended to import into a stylesheet, however. If you are using sass, you can do the following:
37+
38+
```css
39+
@import '~vue-context/src/sass/vue-context';
40+
41+
// Or
42+
// @import '~vue-context/dist/css/vue-context.css';
43+
```
44+
45+
Now add an element to the page that will trigger the context menu to appear, and also add the context menu to the page.
46+
47+
```html
48+
<div id="app">
49+
50+
<div>
51+
<p @contextmenu.prevent="$refs.menu.open">
52+
Right click on me
53+
</p>
54+
</div>
55+
56+
<vue-context ref="menu">
57+
<li>
58+
<a @click.prevent="onClick($event.target.innerText)">Option 1</a>
59+
</li>
60+
<li>
61+
<a @click.prevent="onClick($event.target.innerText)">Option 2</a>
62+
</li>
63+
</vue-context>
64+
65+
</div>
66+
```
67+
68+
`@contextmenu.prevent` is the event listener needed to open the context menu. It is using `.prevent` as a modifier
69+
to prevent the default behavior. In this example, the context menu has a ref of `menu`, which is what `$refs.menu` is
70+
referring to. When each item is clicked on, the text of the item is sent to the `onClick` method on the Vue instance,
71+
which is then shown via an alert.
72+
73+
{.tip}
74+
> The context menu defaults to a `<ul>` tag. For best results, make each menu item an `<a>` tag wrapped inside
75+
> of an `<li>` tag.

docs/introduction.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: Introduction
3+
sort: 1
4+
---
5+
6+
## Introduction
7+
8+
`vue-context` provides a simple yet flexible context menu for Vue. It is styled for the standard `<ul>` tag, but any menu
9+
template can be used. The menu is lightweight with its only dependency being `vue-clickaway`. The menu has some basic
10+
styles applied to it, but they can be easily overridden by your own styles.
11+
12+
The menu disappears when you expect by utilizing `vue-clickaway` and it also optionally disappears when clicked on.
13+
14+
![vue-context screenshot](../images/screenshot.jpg)
15+
16+
By default, the menu is set up to use a `<ul>` tag for the menu, which is given the attribute `role="menu"` automatically.
17+
The component will also automatically apply the attribute `role="menuitem"` to each menu item when the context menu is opened.
18+
19+
## License
20+
21+
`vue-context` uses the MIT License (MIT). Please see the [license file](https://github.com/rawilk/vue-context/blob/master/LICENSE) for more information.

docs/questions-and-issues.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: Questions & Issues
3+
sort: 3
4+
---
5+
6+
Find yourself stuck using the package? Found a bug? Do you have general questions or suggestions for improving the package?
7+
Feel free to [create an issue on Github](https://github.com/rawilk/vue-context/issues) and I'll try to address it as soon as possible.
8+
9+
If you've found a bug regarding security please email [[email protected]](mailto:[email protected]) instead of using the issue tracker.

docs/usage/_index.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: Usage
3+
sort: 1
4+
---

0 commit comments

Comments
 (0)