Git Product home page Git Product logo

vue-dock-menu's Introduction

logo

Build Status DeepScan grade DeepSource Codacy Badge Language grade: JavaScript Depfu Known Vulnerabilities https://badgen.net/bundlephobia/minzip/vue-dock-menu

demo

Features

  • ⚓  Dock your menu with ease.
  • 🤏  Dock the Menubar by dragging and dropping to the edges of the screen.
  • 👆  Touch support.
  • 👍  Support for nested menus up to any levels.
  • 👓  The Menus adjust to any docked position and enables an intuitive menu navigation.
  • ⌨  Keyboard Accessible.
  • 🎨  Icon support.
  • ⚡  Zero dependencies.
  • 💪  Built with Typescript.
  • 🧰  Intuitive API with data driven behavior.
  • 🌠  Built with the all new Vue 3.

Table of Contents

⚡ Installation

yarn install vue-dock-menu

🚀 Getting Started

vue-dock-menu has some great defaults. Please check the prop section for all available options.

The following snippet creates a simple Menubar and docks it to the top of the page.

<template>
  <vue-dock-menu :items="items">
  </vue-dock-menu>
</template>

<script>
import { DockMenu } from "vue-dock-menu";
import "vue-dock-menu/dist/vue-dock-menu.css";

export default {
  name: "example",
  components: {
    DockMenu
  },
  data() {
    return {
      items = [
        {
          name: "File",
          menu: [{ name: "Open"}, {name: "New Window"}, {name: "Exit"}]
        },
        {
          name: "Edit",
          menu: [{ name: "Cut"}, {name: "Copy"}, {name: "Paste"}]
        }
      ]
    }
  }
}
</script>

sample1

Props

Name Description Default
dock default docking position. Can be any one of TOP, LEFT, RIGHT, BOTTOM TOP
on-selected Callback that will be called on a menu item selection
items Data for the Menu bar []
theme prop to customize the color theme
draggable enables/disbales dragging on the menubar. True

⚓ Dock

use the dock prop to dock the menubar to your preferred position. The prop can accept the following values TOP, BOTTOM, LEFT, RIGHT.

Here we dock the Menu bar to the right side of the screen.

<vue-dock-menu>
  :items="items"
  dock="RIGHT"
</vue-dock-menu>

📡 on-selected

The on-selected prop is used to retrieve the selected menu item. The callback receives an object with name and a path property.

  • name - Name of the selected menu item.
  • path - Full path of the selected menu item.

if you select the Copy menu item under the Edit menu, below would be the payload received on the on-selected callback.

{
  name: "Copy",
  path: "edit>copy"
}

⚡ Populating Menu

Use the items prop to create Simple or Nested menus of your liking.

Here we create a simple Menu structure with 3 Menu items with Edit and Open Recent having sub menus.

  • To include a divider, set an empty item object with just a isDivider property set to true.
  • To disable an item, set disable to true.
const items = [
  { name: "New" },
  { isDivider: true },
  {
    name: "Edit",
    menu: {
      name: "edit-items",
      disable:  true
    },
  },
  { isDivider: true },
  {
    name: "Open Recent",
    menu: {
      name: "recent-items",
    },
  },
  { isDivider: true },
  { name: "Save", disable: true },
  { name: "Save As..." },
  { isDivider: true },
  { name: "Close" },
  { name: "Exit" },
]
  <vue-dock-menu>
    :items="items"
    dock="BOTTOM"
  </vue-dock-menu>

🎨 Custom color scheme

use the theme prop to customize the colors of the menu bar.

  <menu-bar
    :items="items"
    :on-selected="selected"
    :theme="{
      primary: '#001B48',
      secondary: '#02457a',
      tertiary: '#018abe',
      textColor: '#fff'
    }"
  />

theme

🎭 Icon support

Each menu item can be iconified and the component uses slots to inject the icons.

Pass individual icons (or images) as templates marked with a unique slot id. please make sure the ids match the iconSlot property in the items array.

<menu-bar
  :items="items"
  :on-selected="selected"
>
  <template #file>
    <img
      src="../assets/file.svg"
      alt="file"
      :style="style"
    >
  </template>
  <template #window>
    <img
      src="../assets/window-maximize.svg"
      alt="file"
      :style="style"
    >
  </template>
</menu-bar>

export default defineComponent({
  name: "MenuExample",
  data()  {
    return {
      items: [
        { name: "New File", iconSlot: "file" },
        { name: "New Window", iconSlot: "window" },
      ]
    }
  }
})

menu-icon

This works seamlessly even for nested menu structure. Make sure the slot ids match and the component will render the icons appropriately.

<menu-bar
  :items="items"
  :on-selected="selected"
>
  <template #window>
    <img
      src="../assets/window-maximize.svg"
      alt="file"
      :style="style"
    >
  </template>
</menu-bar>

export default defineComponent({
  name: "MenuExample",
  data()  {
    return {
      items: [
        { name: "New File",
        subMenu: [{ name: "New Window", iconSlot: "window" }]},
      ]
    }
  }
});

What's coming next

  • support for react.
  • accordion style rendering on sidebar mode.

📦 Build Setup

# install dependencies
yarn install

# start dev
yarn run dev

# package lib
npm run rollup

# run css linting
yarn run lint:css

🔨 Contributing

  1. Fork it ( https://github.com/prabhuignoto/vue-dock-menu/fork )
  2. Create your feature branch (git checkout -b new-feature)
  3. Commit your changes (git commit -am 'Add feature')
  4. Push to the branch (git push origin new-feature)
  5. Create a new Pull Request

🧱 Built with

📄 Notes

  • The project uses vite instead of @vue/cli. I choose vite for speed and i also believe vite will be the future.

Meta

Prabhu Murthy – @prabhumurthy2[email protected]

https://www.prabhumurthy.com

Distributed under the MIT license. See LICENSE for more information.

https://github.com/prabhuingoto/

vue-dock-menu's People

Contributors

imgbot[bot] avatar imgbotapp avatar prabhuignoto avatar sunhwan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

vue-dock-menu's Issues

Disable all menu options

I couldn't find a possibility to disable all option of the menu at once. It is necessary sometimes... I can disable all menus one by one, but I need to store also their content to enable them back as they were. This is a lot of additional code. So a possibility to disable all menus at one and enable them as they were would be nice to have.

Add "ID" prop for selected menu item

Hello! It will be a good idea if you will add "id" param for selected menu item. For example:

{
	name: "File",
	menu: [
		{
			name: "Close",
			id: "menu_close"
		}
	],
}

That feature can help to uniqualize menu items. Any menu actions will depend on its selected menu item id, not on its path or name. This will be very useful when developer will edit text of menu item or change language:

MenuSelect(e) {
	switch(e.id) {
		case "menu_close":
			app.quit();
			break;
	}
}

Help: Adding menu items with custom properties

You are planning to have icons in menu. I assume this would a property on each item to define an icon or not.

Can we have other custom properties on menu like hidden or a function to define its visibility url to be used when item is passed on selected function with those properties.

This functionality might already be there and if it is it would be good to have an example of some common scenarios like:

  1. Attach a url to menu item and set it to open in new tab or window

  2. Hide certain menu items or disable them from being selected.

Thanks a lot for such a nice component.

Include d.ts file

Describe the bug
This package lacks a d.ts file for typescript. Please add at least a basic file so it works in that environment.

Screenshots
image

Menu prop expects array

Describe the bug
image
image

Tried a simple example as as described in README section "Populating Menu".
Got above warning.

To Reproduce
Steps to reproduce the behavior:

<script> import { DockMenu } from "vue-dock-menu"; import "vue-dock-menu/dist/vue-dock-menu.css"; export default { name: "anonMenuBar", components: { DockMenu }, data() { return { items: [ { name: "Login", }, ] } }, methods: { selected(item) { console.log("test", item) } } } </script>

Expected behavior
A clickable item without sub-menus.

Additional context
Everything works fine with the addition of an array menu prop.
items: [ { name: "Login", menu: [{name: "login"}], }, ]

A warning is also produced with the README documentation example:

{ name: "Edit", menu: { name: "edit-items", disable: true }, },

Thanks!

on-selected never get out the active on root menu

Describe the bug
The "on-selected" props never get out the active on root menu but just the div below.

To Reproduce
Steps to reproduce the behavior:

I bind the methods on the "on-select" and also the menu items:

  <dock-menu :items="items" :on-selected="selected"></dock-menu>

In my method I just route to another place

  methods: {
    selected(item) {
      router.push(item.name);
    },
  },

The menu close but but root "Menu" stay active. I need to click twice to re-open the "Menu" path (image below)
image

Expected behavior
After the "on-selected" is call the root menu can be accessible in one click

Desktop (please complete the following information):

  • OS: Windows
  • Browser: Chrome
  • Version 90.0.4430.93 (Build officiel) (64 bits)

edit: Version of "vue-dock-menu": "^1.0.3"

npm run error: [vite] Failed to resolve module import.....

I just run "npm i" and "npm run dev", and it's output:
"[vite] Failed to resolve module import "vue/dist/vue.runtime.esm-bundler.jsode_modules
uedist
ue.runtime.esm-bundler.js". (imported by /src/App.vue)"
图片

How can I fix it? thanks.

More than two items with menu will be error.

More than two items with menu will be error.
It will show two menus at the same time.

See as the following picture.
image

Did I miss some settings? Please tell me if I am wrong.
Thank you very much.

CDN version for use with <script> tag

Hi there

Is it possible to have your wonderful library working via CDN that I can use via the script tag?

I am currently using Vue2 but I guess if possible it can work with vue-demi.

Thank you.

Depfu Error: No dependency files found

Hello,

We've tried to activate or update your repository on Depfu and couldn't find any supported dependency files. If we were to guess, we would say that this is not actually a project Depfu supports and has probably been activated by error.

Monorepos

Please note that Depfu currently only searches for your dependency files in the root folder. We do support monorepos and non-root files, but don't auto-detect them. If that's the case with this repo, please send us a quick email with the folder you want Depfu to work on and we'll set it up right away!

How to deactivate the project

  • Go to the Settings page of either your own account or the organization you've used
  • Go to "Installed Integrations"
  • Click the "Configure" button on the Depfu integration
  • Remove this repo (prabhuignoto/vue-dock-menu) from the list of accessible repos.

Please note that using the "All Repositories" setting doesn't make a lot of sense with Depfu.

If you think that this is a mistake

Please let us know by sending an email to [email protected].


This is an automated issue by Depfu. You're getting it because someone configured Depfu to automatically update dependencies on this project.

Add "ID" prop for selected menu item

Hello! It will be a good idea if you will add "id" param for selected menu item. For example:

{
	name: "File",
	menu: [
		{
			name: "Close",
			id: "menu_close"
		}
	],
}

That feature can help to uniqualize menu items. Any menu actions will depend on its selected menu item id, not on its path or name. This will be very useful when developer will edit text of menu item or change language:

MenuSelect(e) {
	switch(e.id) {
		case "menu_close":
			app.quit();
			break;
	}
}

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.