Skip to content

Commit 68a8fc2

Browse files
Merge pull request #49 from johndatserakis/jd-tidy-before-v-4
Tidy before merge
2 parents ad7ef5e + e8704b2 commit 68a8fc2

24 files changed

+8232
-23342
lines changed

.editorconfig

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
# editorconfig.org
2-
31
root = true
42

53
[*]
6-
indent_style = space
7-
indent_size = 2
8-
end_of_line = lf
94
charset = utf-8
10-
trim_trailing_whitespace = true
5+
end_of_line = lf
6+
indent_size = 2
7+
indent_style = space
118
insert_final_newline = true
9+
trim_trailing_whitespace = true
1210

1311
[*.md]
1412
trim_trailing_whitespace = false

.prettierrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"printWidth": 100,
3+
"semi": true,
4+
"singleQuote": true,
5+
"tabWidth": 2,
6+
"trailingComma": "all",
7+
"useTabs": false
8+
}

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# CHANGELOG.md
22

3+
## 4.0.0
4+
5+
- Upgrade package to support Vue 3. Vue 2 support can be found at `v3.4.2`. Thank you @danielelkington.
6+
7+
## 3.4.2
8+
9+
- Add menu-closed event. Thank you @rttmax.
10+
311
## 3.4.1
412

513
- Add support for HTML content in `option.name`. Thank you @mikeerickson.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2018 Promosis, Inc.
3+
Copyright (c) 2018 John Datserakis, Inc.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 36 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,15 @@ Simple context-menu component built for Vue. Works well with both left and right
1010
<img src="https://img.shields.io/twitter/url/https/github.com/johndatserakis/vue-simple-context-menu.svg?style=social" alt="Tweet"></a>
1111
</p>
1212

13-
### Demo
13+
[View Demo](https://johndatserakis.github.io/vue-simple-context-menu/) | [GitHub](https://github.com/johndatserakis/vue-simple-context-menu) | [npm](https://www.npmjs.com/package/vue-simple-context-menu)
1414

15-
[View demo](https://johndatserakis.github.io/vue-simple-context-menu/)
15+
## Vue 3 Support
1616

17-
[View on npm](https://www.npmjs.com/package/vue-simple-context-menu)
17+
Vue 3 is supported from `v4.0.0` and beyond (current `master`). To use `vue-simple-context-menu` with Vue 2, use `v3.4.2`.
1818

19-
[View on GitHub](https://github.com/johndatserakis/vue-simple-context-menu)
20-
21-
### Install
19+
## Install
2220

2321
```
24-
# npm
25-
npm i vue-simple-context-menu
26-
27-
# yarn
2822
yarn add vue-simple-context-menu
2923
```
3024

@@ -40,25 +34,25 @@ Or you can include it through the browser at the bottom of your page along with
4034
/>
4135
```
4236

43-
### About
37+
## About
4438

45-
Just a simple little menu to be shown where a click happens - closes after use automatically by clicking an option or outside of the menu. Multiple menus are supported - just make sure to use a unique string as your `elementId` prop value.
39+
Just a simple little menu to be shown where a click happens - closes after use automatically by clicking an option or outside of the menu. Multiple menus are supported - just make sure to use a unique string as your `element-id` prop value.
4640

4741
A nice feature that comes baked in is the menu placement after a click - it sits just ever so slightly under your click location - so that any hover style you had on the item that was clicked gets removed nicely. I modeled it after the macOS right click menu.
4842

49-
### Usage Example
43+
## Usage Example
5044

5145
```css
52-
/* css import for when you want to import the component css into your css file/files */
53-
@import "/path/to/node_modules/vue-simple-context-menu.css";
46+
/* CSS import for when you want to import the component CSS into your CSS file/files */
47+
@import '/path/to/node_modules/vue-simple-context-menu.css';
5448
```
5549

5650
```js
57-
// css import for when you're importing the css directly in your js
58-
import "vue-simple-context-menu/dist/vue-simple-context-menu.css";
59-
import VueSimpleContextMenu from "vue-simple-context-menu";
51+
// CSS import for when you're importing the CSS directly in your JS
52+
import 'vue-simple-context-menu/dist/vue-simple-context-menu.css';
53+
import VueSimpleContextMenu from 'vue-simple-context-menu';
6054

61-
Vue.component("vue-simple-context-menu", VueSimpleContextMenu);
55+
Vue.component('vue-simple-context-menu', VueSimpleContextMenu);
6256
```
6357

6458
```html
@@ -78,9 +72,9 @@ Each item has a click event that ties to a function. See the demo for a full exa
7872
<!-- Make sure you add the `ref` attribute, as that is what gives you the ability
7973
to open the menu. -->
8074
<vue-simple-context-menu
81-
:elementId="'myUniqueId'"
75+
element-id="myUniqueId"
8276
:options="options"
83-
:ref="'vueSimpleContextMenu'"
77+
ref="vueSimpleContextMenu"
8478
@option-clicked="optionClicked"
8579
/>
8680
```
@@ -100,31 +94,31 @@ Note - you must pass the click event-info variable to the `showMenu()` function
10094

10195
Note - make sure to use `@click.prevent.stop` (or `@contextmenu.prevent.stop` for right click) when setting up the click handler.
10296

103-
### Props
97+
## Props
10498

10599
| prop | type | description | required |
106100
| --------------- | ------ | -------------------------------------------------------------------------------------------- | -------- |
107101
| `elementId` | String | Unique String that acts as the id of your menu. | Yes |
108102
| `options` | Array | Array of menu options to show. Component will use the `name` parameter as the label. | Yes |
109-
| `options.name` | Array | Label for the option. | Yes |
103+
| `options.name` | String | Label for the option. | Yes |
110104
| `options.class` | String | A custom class that will be applied to the option. | No |
111105
| `options.type` | String | Only one possible value at the moment - `divider`. Pass this to set the object as a divider. | No |
112106
| `ref` | String | Unique String that allows you to show the menu on command. | Yes |
113107

114-
### Methods
108+
## Methods
115109

116110
| method | parameters | description |
117111
| ---------- | --------------------------------- | -------------------------------------------------------------------- |
118112
| `showMenu` | event (MouseEvent), item (Object) | Used to show the menu. Make sure to pass a MouseEvent and an Object. |
119113

120-
### Events
114+
## Events
121115

122116
| event | value | description |
123117
| ---------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
124118
| `option-clicked` | Object | When a menu item is clicked the component will emit an event with a value containing the clicked item and the menu option that was clicked. Register for this event to capture the selection result. |
125119
| `menu-closed` | | Emitted when the menu is closed |
126120

127-
### SASS Structure
121+
## SASS Structure
128122

129123
```scss
130124
.vue-simple-context-menu {
@@ -141,38 +135,36 @@ Note - make sure to use `@click.prevent.stop` (or `@contextmenu.prevent.stop` fo
141135
}
142136
```
143137

144-
### Development
138+
## Development
145139

146140
```bash
147-
# install dependencies
148-
npm install
141+
# Install dependencies
142+
yarn
149143

150-
# serve with hot reload
151-
npm run watch
144+
# Serve with hot reload
145+
yarn watch
152146

153-
# run the tests
154-
npm run test
147+
# Run the tests
148+
yarn test
155149

156-
# build demo page
157-
npm run build:example
150+
# Build demo page
151+
yarn build:example
158152

159-
# build library
160-
npm run build:library
153+
# Build library
154+
yarn build:library
161155

162-
# build everything and run tests
163-
npm run build
156+
# Build everything and run tests
157+
yarn build
164158
```
165159

166-
### Other
160+
## Other
167161

168162
Go ahead and fork the project! Submit an issue if needed. Have fun!
169163

170-
### Thank You
164+
## Thank You
171165

172166
Influenced by [Lucas Calazans](https://codepen.io/lucascalazans)'s [pen](https://codepen.io/lucascalazans/pen/ALvVVw). Go ahead and check out his other work.
173167

174-
### License
168+
## License
175169

176170
[MIT](http://opensource.org/licenses/MIT)
177-
178-
Packaged with a mixture of [vue-lib-template](https://github.com/biigpongsatorn/vue-lib-template) and [vue-sfc-rollup](https://github.com/team-innovation/vue-sfc-rollup).

dist/vue-simple-context-menu.css

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
.vue-simple-context-menu {
2-
top: 0;
2+
background-color: #ecf0f1;
3+
border-bottom-width: 0px;
4+
border-radius: 4px;
5+
box-shadow: 0 3px 6px 0 rgba(51, 51, 51, 0.2);
6+
display: none;
7+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
38
left: 0;
9+
list-style: none;
410
margin: 0;
511
padding: 0;
6-
display: none;
7-
list-style: none;
812
position: absolute;
13+
top: 0;
914
z-index: 1000000;
10-
background-color: #ecf0f1;
11-
border-bottom-width: 0px;
12-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
13-
box-shadow: 0 3px 6px 0 rgba(51, 51, 51, 0.2);
14-
border-radius: 4px;
1515
}
1616
.vue-simple-context-menu--active {
1717
display: block;
1818
}
1919
.vue-simple-context-menu__item {
20-
display: flex;
20+
align-items: center;
2121
color: #333;
2222
cursor: pointer;
23+
display: flex;
2324
padding: 5px 15px;
24-
align-items: center;
2525
}
2626
.vue-simple-context-menu__item:hover {
2727
background-color: #007aff;
2828
color: #fff;
2929
}
3030
.vue-simple-context-menu__divider {
31+
background-clip: content-box;
32+
background-color: #c0cdd1;
3133
box-sizing: content-box;
3234
height: 2px;
33-
background-color: #c0cdd1;
3435
padding: 4px 0;
35-
background-clip: content-box;
3636
pointer-events: none;
3737
}
3838
.vue-simple-context-menu li:first-of-type {

0 commit comments

Comments
 (0)