Skip to content

Commit

Permalink
Merge pull request #28 from johndatserakis/jd-add-divider
Browse files Browse the repository at this point in the history
Add divider support
  • Loading branch information
johndatserakis authored Sep 6, 2020
2 parents bf63a8f + a53a3a0 commit adb3de6
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 12 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,12 @@ Note - make sure to use `@click.prevent.stop` (or `@contextmenu.prevent.stop` fo

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

### Methods

Expand All @@ -115,7 +116,7 @@ Note - make sure to use `@click.prevent.stop` (or `@contextmenu.prevent.stop` fo

### SASS Structure

```sass
```scss
.vue-simple-context-menu {
&--active {
}
Expand All @@ -124,6 +125,8 @@ Note - make sure to use `@click.prevent.stop` (or `@contextmenu.prevent.stop` fo
&:hover {
}
}

&__divider {}
}
```

Expand Down
7 changes: 7 additions & 0 deletions dist/vue-simple-context-menu.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion dist/vue-simple-context-menu.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,12 @@ var __vue_render__ = function() {
{
key: index,
staticClass: "vue-simple-context-menu__item",
class: option.class,
class: [
option.class,
option.type === "divider"
? "vue-simple-context-menu__divider"
: ""
],
on: {
click: function($event) {
$event.stopPropagation();
Expand Down
2 changes: 1 addition & 1 deletion dist/vue-simple-context-menu.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion dist/vue-simple-context-menu.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,12 @@
{
key: index,
staticClass: "vue-simple-context-menu__item",
class: option.class,
class: [
option.class,
option.type === "divider"
? "vue-simple-context-menu__divider"
: ""
],
on: {
click: function($event) {
$event.stopPropagation();
Expand Down
2 changes: 1 addition & 1 deletion docs/build.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions example/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ export default {
name: 'Duplicate',
slug: 'duplicate'
},
{
type: 'divider'
},
{
name: 'Edit',
slug: 'edit'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-simple-context-menu",
"version": "3.2.0",
"version": "3.3.0",
"description": "Simple context-menu component built for Vue. Works well with both left and right clicks. Nothing too fancy, just works and is simple to use.",
"author": "John Datserakis <[email protected]>",
"license": "MIT",
Expand Down
10 changes: 9 additions & 1 deletion src/vue-simple-context-menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
:key="index"
@click.stop="optionClicked(option)"
class="vue-simple-context-menu__item"
:class="option.class"
:class="[option.class, (option.type === 'divider' ? 'vue-simple-context-menu__divider' : '')]"
>
{{option.name}}
</li>
Expand Down Expand Up @@ -146,6 +146,14 @@ $black: #333;
}
}
&__divider {
height: 10px;
background-color: $grey;
padding: 4px 0;
background-clip: content-box;
pointer-events: none;
}
// Have to use the element so we can make use of `first-of-type` and
// `last-of-type`
li {
Expand Down

0 comments on commit adb3de6

Please sign in to comment.