Skip to content

Commit

Permalink
Merge pull request #12 from prabhuignoto/disable-menu-items
Browse files Browse the repository at this point in the history
🔒 disable menu items
  • Loading branch information
prabhuignoto authored Dec 1, 2020
2 parents 83848da + 329857d commit 63fd7dc
Show file tree
Hide file tree
Showing 10 changed files with 257 additions and 5,218 deletions.
11 changes: 11 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version = 1

[[analyzers]]
name = "javascript"
enabled = true

[analyzers.meta]
environment = ["browser"]
plugins = ["vue"]
style_guide = "standard"
dialect = "typescript"
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/prabhuignoto/vue-dock-menu.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/prabhuignoto/vue-dock-menu/context:javascript)
[![Depfu](https://badges.depfu.com/badges/f3a16c4fe1fcbd36df15d6949d9846bc/overview.svg)](https://depfu.com/github/prabhuignoto/vue-dock-menu?project_id=16495)
[![Known Vulnerabilities](https://snyk.io/test/github/prabhuignoto/vue-dock-menu/badge.svg?targetFile=package.json)](https://snyk.io/test/github/prabhuignoto/vue-dock-menu?targetFile=package.json)
![https://badgen.net/bundlephobia/min/vue-dock-menu](https://badgen.net/bundlephobia/min/vue-dock-menu)
![https://badgen.net/bundlephobia/minzip/vue-dock-menu](https://badgen.net/bundlephobia/minzip/vue-dock-menu)

![demo](./readme-assets/demo-small.gif)

Expand Down Expand Up @@ -135,21 +135,33 @@ 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`.
```sh
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" },
]
```
Expand Down Expand Up @@ -181,7 +193,6 @@ use the `theme` prop to customize the colors of the menu bar.
## What's coming next
- keyboard accessibility.
- support for react.
- support for icons in the menu.
- accordion style rendering on sidebar mode.
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-dock-menu",
"version": "0.2.1",
"version": "0.2.2",
"license": "MIT",
"author": "Prabhu Murthy",
"description": "Dockable menu bar for Vue 3",
Expand Down Expand Up @@ -40,28 +40,28 @@
"focus-visible": "^5.2.0"
},
"devDependencies": {
"@interactjs/types": "^1.10.0",
"@interactjs/types": "^1.10.1",
"@rollup/plugin-beep": "^0.2.0",
"@rollup/plugin-buble": "^0.21.3",
"@rollup/plugin-commonjs": "^16.0.0",
"@rollup/plugin-node-resolve": "^10.0.0",
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-node-resolve": "^11.0.0",
"@rollup/plugin-sucrase": "^3.1.0",
"@typescript-eslint/eslint-plugin": "^4.8.2",
"@typescript-eslint/parser": "^4.8.2",
"@vue/compiler-sfc": "^3.0.2",
"@typescript-eslint/eslint-plugin": "^4.9.0",
"@typescript-eslint/parser": "^4.9.0",
"@vue/compiler-sfc": "^3.0.3",
"eslint": "^7.14.0",
"eslint-plugin-vue": "^7.1.0",
"husky": "^4.3.0",
"lint-staged": "^10.5.1",
"rollup": "^2.33.3",
"lint-staged": "^10.5.2",
"rollup": "^2.34.0",
"rollup-plugin-scss": "^2.6.1",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-vue": "^6.0.0-beta.11",
"rollup-plugin-vue": "^6.0.0",
"sass": "^1.29.0",
"stylelint": "^13.8.0",
"stylelint-config-standard": "^20.0.0",
"typescript": "^4.1.2",
"vite": "^1.0.0-rc.9",
"vite": "^1.0.0-rc.13",
"vue": "^3.0.2"
},
"peerDependencies": {},
Expand Down
3 changes: 1 addition & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export default {
name: "FloatMenu",
globals: {
vue: "vue",
nanoid: "nanoid",
},
},
],
Expand All @@ -59,5 +58,5 @@ export default {
resolve(),
terser()
],
external: ["vue", "nanoid"],
external: ["vue"],
};
2 changes: 1 addition & 1 deletion src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default defineComponent({
},
{ name: "Open Workspace" },
{ isDivider: true },
{ name: "Save" },
{ name: "Save", disable: true },
{ name: "Save As..." },
{ isDivider: true },
{ name: "Close" },
Expand Down
6 changes: 6 additions & 0 deletions src/components/Menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
'is-parent': !!item.menu,
highlight: index === highlightedIndex,
divider: item.isDivider,
disable: item.disable,
},
]"
:style="menuItemStyle"
Expand All @@ -38,6 +39,7 @@
event: $event,
name: item.name,
isParent: !!item.menu,
disable: item.disable,
})
"
>
Expand Down Expand Up @@ -161,6 +163,10 @@ export default defineComponent({
selectedItem.event.stopPropagation();
selectedItem.event.preventDefault();
if (selectedItem.disable) {
return;
}
if (selectedItem.isParent) {
showSubMenu.value = !showSubMenu.value;
return;
Expand Down
4 changes: 4 additions & 0 deletions src/components/menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
transform: rotate(180deg);
}
}

&.disable {
filter: opacity(0.5);
}
}

.sub-menu-wrapper {
Expand Down
1 change: 1 addition & 0 deletions src/models/SelectedItemModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export interface SelectedItemModel {
path: string;
event: MouseEvent | KeyboardEvent;
isParent?: boolean;
disable?: boolean;
}
Loading

0 comments on commit 63fd7dc

Please sign in to comment.