All Projects β†’ johndatserakis β†’ vue-simple-context-menu

johndatserakis / vue-simple-context-menu

Licence: MIT License
πŸ“Œ 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.

Programming Languages

Vue
7211 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to vue-simple-context-menu

Bmenu
A general purpose terminal menu that focuses on ease of configuration and use.
Stars: ✭ 94 (-41.98%)
Mutual labels:  simple, menu
react-native-panel
A Customizable React Native Panel for Android and iOS
Stars: ✭ 35 (-78.4%)
Mutual labels:  simple, menu
django-menu-generator
A straightforward menu generator for Django
Stars: ✭ 24 (-85.19%)
Mutual labels:  simple, menu
gunstore.io
Store your data in Gun DB by sending simple HTTP requests - based on jsonstore.io πŸ’Ύ πŸš€
Stars: ✭ 32 (-80.25%)
Mutual labels:  simple
MultiStateToggleButton
Android's ToggleButton offers only two states, MultiStateToggleButton fixes this by offering as many states depending on the number of drawable resources passed in.
Stars: ✭ 20 (-87.65%)
Mutual labels:  simple
laravel-mjml
Laravel MJML offers support for rendering MJML syntax into in-line HTML that can be sent within mails.
Stars: ✭ 26 (-83.95%)
Mutual labels:  content
SlidingUpMenu
πŸš€ A very customizable library that allows you to present menu items (from menu resource and/or other sources) to users as a bottom sheet.
Stars: ✭ 26 (-83.95%)
Mutual labels:  menu
Maeevick
my global strategy about continuous learnings and improvements, projects and activities
Stars: ✭ 23 (-85.8%)
Mutual labels:  content
core
🌈 light, fast, and easy to use, dependencies free javascript syntax highlighter, with automatic language detection
Stars: ✭ 40 (-75.31%)
Mutual labels:  simple
roller
Mirror of Apache Roller
Stars: ✭ 107 (-33.95%)
Mutual labels:  content
unitscss
UNITS is a simple and beautiful CSS component set.
Stars: ✭ 13 (-91.98%)
Mutual labels:  simple
SimpleCore
.NET C# common/utilities library
Stars: ✭ 11 (-93.21%)
Mutual labels:  simple
mr-brown
Mr.Brown is a responsive Jekyll theme
Stars: ✭ 21 (-87.04%)
Mutual labels:  simple
munich-scripts
Some useful scripts simplifying bureaucracy
Stars: ✭ 105 (-35.19%)
Mutual labels:  simple
menu
基于jQueryηš„θ½»ι‡ηΊ§ε“εΊ”εΌθœε•ζ’δ»Ά
Stars: ✭ 18 (-88.89%)
Mutual labels:  menu
ministaller
Lightweight installer/updater for portable desktop applications
Stars: ✭ 15 (-90.74%)
Mutual labels:  simple
MotionLayoutMenuA
Dribble menu design built with Android MotionLayout
Stars: ✭ 36 (-77.78%)
Mutual labels:  menu
picamera-motion
Raspberry Pi python PiCamera Lightweight Motion Detection. Includes easy curl script install/upgrade, whiptail admin menu system, single file web server and Rclone for uploading to a variety of web storage services.
Stars: ✭ 80 (-50.62%)
Mutual labels:  simple
react-native-simple-stepper
A super simple react-native implementation of the UIStepper control from iOS.
Stars: ✭ 100 (-38.27%)
Mutual labels:  simple
wip
WIP & naenae: CLI utilities to easily manage Work In Progress with Git
Stars: ✭ 46 (-71.6%)
Mutual labels:  simple

vue-simple-context-menu

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.

NPM Version NPM Downloads License Tweet

Demo

View demo

View on npm

View on GitHub

Install

# npm
npm i vue-simple-context-menu

# yarn
yarn add vue-simple-context-menu

Or you can include it through the browser at the bottom of your page along with the css:

<script src="https://unpkg.com/vue-simple-context-menu/dist/vue-simple-context-menu.min.js"></script>

<link
  rel="stylesheet"
  type="text/css"
  href="https://unpkg.com/vue-simple-context-menu/dist/vue-simple-context-menu.css"
/>

About

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.

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.

Usage Example

/* css import for when you want to import the component css into your css file/files */
@import "/path/to/node_modules/vue-simple-context-menu.css";
// css import for when you're importing the css directly in your js
import "vue-simple-context-menu/dist/vue-simple-context-menu.css";
import VueSimpleContextMenu from "vue-simple-context-menu";

Vue.component("vue-simple-context-menu", VueSimpleContextMenu);
<!-- This is a basic use case where you have an array of items that you want
to allow to be clicked. In this case, `items` is an array of objects.
Each item has a click event that ties to a function. See the demo for a full example (with multiple menus as well). -->
<div class="item-wrapper">
  <div
    v-for="item in items"
    @click.prevent.stop="handleClick($event, item)"
    class="item-wrapper__item"
  >
    {{item.name}}
  </div>
</div>

<!-- Make sure you add the `ref` attribute, as that is what gives you the ability
to open the menu. -->
<vue-simple-context-menu
  :elementId="'myUniqueId'"
  :options="options"
  :ref="'vueSimpleContextMenu'"
  @option-clicked="optionClicked"
/>
handleClick (event, item) {
  this.$refs.vueSimpleContextMenu.showMenu(event, item)
}


optionClicked (event) {
  window.alert(JSON.stringify(event))
}

Note - you must pass the click event-info variable to the showMenu() function because that's how we know where to show the menu.

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

Props

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
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

method parameters description
showMenu event (MouseEvent), item (Object) Used to show the menu. Make sure to pass a MouseEvent and an Object.

Events

event value description
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.
menu-closed Emitted when the menu is closed

SASS Structure

.vue-simple-context-menu {
  &--active {
  }

  &__item {
    &:hover {
    }
  }

  &__divider {
  }
}

Development

# install dependencies
npm install

# serve with hot reload
npm run watch

# run the tests
npm run test

# build demo page
npm run build:example

# build library
npm run build:library

# build everything and run tests
npm run build

Other

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

Thank You

Influenced by Lucas Calazans's pen. Go ahead and check out his other work.

License

MIT

Packaged with a mixture of vue-lib-template and vue-sfc-rollup.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].