├── babel.config.js
├── public
├── favicon.ico
└── index.html
├── src
├── assets
│ └── logo.png
├── main.js
├── components
│ ├── Menu
│ │ ├── slide.vue
│ │ ├── elastic.vue
│ │ ├── stack.vue
│ │ ├── push.vue
│ │ ├── reveal.vue
│ │ ├── bubble.vue
│ │ ├── fallDown.vue
│ │ ├── scaleDown.vue
│ │ ├── pushRotate.vue
│ │ └── scaleRotate.vue
│ ├── index.js
│ └── Menu.vue
└── App.vue
├── vue.config.js
├── .gitignore
├── LICENSE
├── package.json
└── README.md
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [
3 | '@vue/app'
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mkdillard/vue3-burger-menu/HEAD/public/favicon.ico
--------------------------------------------------------------------------------
/src/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mkdillard/vue3-burger-menu/HEAD/src/assets/logo.png
--------------------------------------------------------------------------------
/src/main.js:
--------------------------------------------------------------------------------
1 | import { h, createApp } from 'vue'
2 | import App from './App.vue'
3 |
4 | createApp({
5 | render: () => { return h(App) }
6 | }).mount('#app')
7 |
--------------------------------------------------------------------------------
/vue.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | css: {
3 | extract: false
4 | },
5 | configureWebpack: {
6 | output: {
7 | libraryExport: 'default'
8 | }
9 | }
10 | }
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | /dist
4 |
5 | # local env files
6 | .env.local
7 | .env.*.local
8 |
9 | # Log files
10 | npm-debug.log*
11 | yarn-debug.log*
12 | yarn-error.log*
13 |
14 | # Editor directories and files
15 | .idea
16 | .vscode
17 | *.suo
18 | *.ntvs*
19 | *.njsproj
20 | *.sln
21 | *.sw*
22 |
--------------------------------------------------------------------------------
/src/components/Menu/slide.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/components/index.js:
--------------------------------------------------------------------------------
1 | // Different CSS animations
2 |
3 | import Slide from './Menu/slide'
4 | import Bubble from './Menu/bubble'
5 | import Reveal from './Menu/reveal'
6 | import Push from './Menu/push'
7 | import Elastic from './Menu/elastic'
8 | import FallDown from './Menu/fallDown'
9 | import PushRotate from './Menu/pushRotate'
10 | import Stack from './Menu/stack'
11 | import ScaleRotate from './Menu/scaleRotate'
12 | import ScaleDown from './Menu/scaleDown'
13 | import Menu from './Menu'
14 |
15 | export default {
16 | Menu,
17 | Slide,
18 | Bubble,
19 | Reveal,
20 | Push,
21 | PushRotate,
22 | ScaleDown,
23 | ScaleRotate,
24 | Stack,
25 | FallDown,
26 | Elastic
27 | }
--------------------------------------------------------------------------------
/src/components/Menu/elastic.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
38 |
--------------------------------------------------------------------------------
/src/components/Menu/stack.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2018-present, Mohit Bajoria
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | vue3-burger-menu
11 |
14 |
15 |
16 |
23 |
24 |
25 |
26 |
27 |
28 | We're sorry but vue3-burger-menu doesn't work properly without JavaScript enabled. Please enable it to continue.
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/src/components/Menu/push.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue3-burger-menu",
3 | "version": "1.1.1",
4 | "private": false,
5 | "author": {
6 | "name": "Michael Dillard",
7 | "email": "mkdillard@hotmail.com"
8 | },
9 | "scripts": {
10 | "serve": "vue-cli-service serve",
11 | "build": "vue-cli-service build",
12 | "lint": "vue-cli-service lint",
13 | "build-bundle": "vue-cli-service build --target lib --name vue3-burger-menu ./src/components/index.js"
14 | },
15 | "main": "./dist/vue3-burger-menu.common.js",
16 | "files": [
17 | "dist/vue3-burger-menu.common.js",
18 | "dist/vue3-burger-menu.umd.js"
19 | ],
20 | "dependencies": {
21 | "vue": "^3.0.0-0"
22 | },
23 | "devDependencies": {
24 | "@vue/cli-plugin-babel": "^4.5.0",
25 | "@vue/cli-plugin-eslint": "^4.5.0",
26 | "@vue/cli-service": "^4.5.0",
27 | "@vue/compiler-sfc": "^3.0.0-0",
28 | "babel-eslint": "^10.1.0",
29 | "eslint": "^6.7.2",
30 | "eslint-plugin-vue": "^7.0.0-0",
31 | "less": "^3.8.1",
32 | "less-loader": "^4.1.0"
33 | },
34 | "eslintConfig": {
35 | "root": true,
36 | "env": {
37 | "node": true
38 | },
39 | "extends": [
40 | "plugin:vue/vue3-essential",
41 | "eslint:recommended"
42 | ],
43 | "rules": {},
44 | "parserOptions": {
45 | "parser": "babel-eslint"
46 | }
47 | },
48 | "postcss": {
49 | "plugins": {
50 | "autoprefixer": {}
51 | }
52 | },
53 | "browserslist": [
54 | "> 1%",
55 | "last 2 versions",
56 | "not ie <= 8"
57 | ],
58 | "keywords": [
59 | "vuejs",
60 | "menu",
61 | "hamburger",
62 | "sidebar"
63 | ],
64 | "license": "MIT",
65 | "repository": {
66 | "type": "git",
67 | "url": "git+https://github.com/mkdillard/vue3-burger-menu.git"
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/components/Menu/reveal.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/src/components/Menu/bubble.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
60 |
--------------------------------------------------------------------------------
/src/components/Menu/fallDown.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
71 |
--------------------------------------------------------------------------------
/src/components/Menu/scaleDown.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/src/components/Menu/pushRotate.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/src/components/Menu/scaleRotate.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vue3-burger-menu [](https://github.com/prettier/prettier)
2 |
3 | [](https://www.npmjs.com/package/vue3-burger-menu)
4 |
5 | Updated to vue3 from the vue-burger-menu by Mohit Bajoria [`https://github.com/mbj36/vue-burger-menu`](https://github.com/mbj36/vue-burger-menu)
6 |
7 | An off-canvas sidebar Vue component with a collection of effects and styles using CSS transitions and SVG path animations.
8 |
9 | ## Demo & examples
10 |
11 | Live demo - https://vue3-burger-menu.netlify.app/
12 |
13 | To build the examples locally, run:
14 |
15 | ```
16 | npm i
17 | npm run serve
18 | ```
19 |
20 | ```
21 | yarn
22 | yarn serve
23 | ```
24 |
25 | Then open [`localhost:8083`](http://localhost:8083) in a browser
26 |
27 | ## Installation
28 |
29 | ```
30 | npm install vue3-burger-menu --save
31 | ```
32 |
33 | ```
34 | yarn add vue3-burger-menu
35 | ```
36 |
37 | ## Usage
38 |
39 | Items should be passed as child elements of the components
40 |
41 | ```javascript
42 | import { Slide } from 'vue3-burger-menu' // import the CSS transitions you wish to use, in this case we are using `Slide`
43 |
44 | export default {
45 | components: {
46 | Slide // Register your component
47 | }
48 | }
49 | ```
50 |
51 | In your template
52 |
53 | ```
54 |
55 |
56 |
57 | Home
58 |
59 |
60 |
61 | ```
62 |
63 | ### Animations
64 |
65 | The example above imported `slide` which renders a menu that slides in on the page when the burger icon is clicked. To use a different animation you can subsitute slide with any of the following
66 |
67 | * Slide
68 | * ScaleDown
69 | * ScaleRotate
70 | * Reveal
71 | * Push
72 | * PushRotate
73 |
74 | ATTENTION - the below animations are in WIP
75 |
76 | * FallDown
77 | * Stack
78 | * Elastic
79 | * Bubble
80 |
81 | ### Properties
82 |
83 | Some animation require certain other elements on your page
84 |
85 | * Page wrapper - an element wrapping the rest of the content on yur page, placed after the menu component
86 |
87 | ```javascript
88 |
89 |
90 |
91 | .
92 | .
93 |
94 |
95 | ```
96 |
97 | * Outer container called `app` - an element containing everything including the menu component
98 |
99 | ```javascript
100 |
101 |
102 |
103 | .
104 | .
105 | .
106 |
107 |
108 | ```
109 |
110 | Check this table to see which animations require these elements:
111 |
112 | Animation | `pageWrapId` | `appId`
113 | --- | :---: | :---:
114 | `Slide` | |
115 | `Push` | ✓ | ✓
116 | `PushRotate` | ✓ | ✓
117 | `ScaleDown` | ✓ | ✓
118 | `ScaleRotate` | ✓ | ✓
119 | `Reveal` | ✓ | ✓
120 |
121 | ### Position
122 |
123 | The menu opens from left by default. To have it open from the right, use the `right` prop. It's just a boolean so you don't need to specify a value.
124 |
125 | ```javascript
126 |
127 | ```
128 |
129 | ### Width
130 |
131 | You can specify the width of the menu with the `width` prop. The default is `300px`
132 |
133 | ```javascript
134 |
135 | ```
136 |
137 | ### Open state
138 |
139 | You can control whether the sidebar is open or closed with the `isOpen` prop. This is useful if you need to close the menu after a user clicks on an item in it, for example, or if you want to open the menu from some other button in addition to the standard burger icon. The default value is `false`
140 |
141 | ```javascript
142 | // To render the menu open
143 |
144 |
145 |
146 | ex:
147 |
148 | Open Menu
149 |
150 |
151 |
152 | // Component
153 | data() {
154 | return {
155 | isOpen: false
156 | }
157 | }
158 |
159 | ```
160 | ### Menu events
161 |
162 | If you want to get a notification when the menu open or close you can use the `openMenu` and `closeMenu` notifications. This way you can update your application state when the menu open or close
163 |
164 | ```javascript
165 | // To bind the open and close events
166 |
167 |
171 | ```
172 | ### Close on Outside Click
173 |
174 | You can turn off the menu closing when an an outside click is triggered with `disableOutsideClick`.
175 |
176 | ``` javascript
177 |
178 | ```
179 |
180 | ### Close on Escape
181 |
182 | By default, the menu will close when the Escape key is pressed. To disable this behavior, you can pass the `disableCloseOnEsc` prop. This is useful in cases where you want the menu to be open all the time, for example if you're implementing a responsive menu that behaves differently depending on the browser width.
183 |
184 | ``` javascript
185 |
186 | ```
187 |
188 | ### Close on Navigation
189 |
190 | By default, the menu will not close when a link inside the menu is clicked. To disable this behavior, you can pass the `closeOnNavigation` prop. This is useful in cases where you want the menu to close when a navigation link is clicked as this then stops the user having to make an extra click to close the menu.
191 |
192 | ``` javascript
193 |
194 | ```
195 |
196 | ### Overlay
197 |
198 | You can turn off the default overlay with `noOverlay`.
199 |
200 | ``` javascript
201 |
202 | ```
203 |
204 | ### Burger Icon and Cross Icon
205 |
206 | You can disable both icons by passing burgerIcon and crossIcon to `false`. This can be useful if you want to keep the menu open and don't want the user to close the menu
207 |
208 | ```javascript
209 |
210 | ```
211 |
212 | ### Styling
213 |
214 | Visual styles (color, font etc) need to be supplied with the help of CSS
215 |
216 | #### CSS
217 | The component has following helper class
218 |
219 | ```CSS
220 | .bm-burger-button {
221 | position: fixed;
222 | width: 36px;
223 | height: 30px;
224 | left: 36px;
225 | top: 36px;
226 | cursor: pointer;
227 | }
228 | .bm-burger-bars {
229 | background-color: #373a47;
230 | }
231 | .line-style {
232 | position: absolute;
233 | height: 20%;
234 | left: 0;
235 | right: 0;
236 | }
237 | .cross-style {
238 | position: absolute;
239 | top: 12px;
240 | right: 2px;
241 | cursor: pointer;
242 | }
243 | .bm-cross {
244 | background: #bdc3c7;
245 | }
246 | .bm-cross-button {
247 | height: 24px;
248 | width: 24px;
249 | }
250 | .bm-menu {
251 | height: 100%; /* 100% Full-height */
252 | width: 0; /* 0 width - change this with JavaScript */
253 | position: fixed; /* Stay in place */
254 | z-index: 1000; /* Stay on top */
255 | top: 0;
256 | left: 0;
257 | background-color: rgb(63, 63, 65); /* Black*/
258 | overflow-x: hidden; /* Disable horizontal scroll */
259 | padding-top: 60px; /* Place content 60px from the top */
260 | transition: 0.5s; /*0.5 second transition effect to slide in the sidenav*/
261 | }
262 |
263 | .bm-overlay {
264 | background: rgba(0, 0, 0, 0.3);
265 | }
266 | .bm-item-list {
267 | color: #b8b7ad;
268 | margin-left: 10%;
269 | font-size: 20px;
270 | }
271 | .bm-item-list > * {
272 | display: flex;
273 | text-decoration: none;
274 | padding: 0.7em;
275 | }
276 | .bm-item-list > * > span {
277 | margin-left: 10px;
278 | font-weight: 700;
279 | color: white;
280 | }
281 | ```
282 |
283 | ## Browser Support
284 |
285 | Chrome and Firefox have full support, but Safari and IE have strange behavior for some of the menus.
286 |
287 | ## Author
288 |
289 | © [Mohit Bajoria](https://mbj36.xyz)
290 |
291 | Updated to vue3 by Michael Dillard
292 |
293 | ## License
294 |
295 | [MIT](https://github.com/mbj36/vue3-burger-menu/blob/master/LICENSE)
--------------------------------------------------------------------------------
/src/components/Menu.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
212 |
213 |
285 |
286 |
--------------------------------------------------------------------------------
/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
54 |
55 |
56 |
112 |
113 |
371 |
--------------------------------------------------------------------------------