GithubHelp home page GithubHelp logo

sthales / vue-context Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rawilk/vue-context

0.0 0.0 0.0 2.9 MB

A simple vue context menu component.

License: MIT License

JavaScript 77.56% HTML 13.59% CSS 8.85%

vue-context's Introduction

vue-context

npm version npm downloads GitHub issues GitHub stars VueJS version

vue-context provides a simple yet flexible context menu for Vue. It is styled for the standard <ul> tag, but any menu template can be used. The menu is lightweight with its only dependency being vue-clickaway. The menu has some basic styles applied to it but they can be easily overridden by your own styles.

The menu disappears when you expect by utilizing vue-clickaway and it also optionally disappears when clicked on.

Screenshot

Getting Started

The following instructions will help you get the vue-context menu up and running on your project.

Installation

Using npm:

npm i vue-context

Basic Usage

Import the component and use it in your app.

import Vue from 'vue';
import { VueContext } from 'vue-context';

new Vue({
    components: {
        VueContext
    },
    
    methods: {
        onClick (text) {
            alert(`You clicked ${text}!`);
        }
    }
}).$mount('#app');

Next add an element to the page that will trigger the context menu to appear, and also add the context menu to the page.

<div id="app">

    <div>
        <p @contextmenu.prevent="$refs.menu.open">
            Right click on me
        </p>    
    </div>
    
    <vue-context ref="menu">
        <li>
            <a href="#" @click.prevent="onClick($event.target.innerText)">Option 1</a>
        </li>
        <li>
            <a href="#" @click.prevent="onClick($event.target.innerText)">Option 2</a>
        </li>
    </vue-context>
    
</div>

Notice: As of version 4.1.0, the menu styles are not automatically included by default anymore. You will need to manually import them now in your own stylesheets.

@import '~vue-context/dist/css/vue-context.css';

Documentation/Demo

For full documentation and demos, go here: https://vue-context.com/docs

License

vue-context uses the MIT License (MIT). Please see the license file for more information.

vue-context's People

Contributors

rawilk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.