├── .gitignore
├── .babelrc
├── src
├── index.js
├── vue-accordion.vue
└── vue-accordion-partial.vue
├── webpack.config.js
├── LICENSE
├── package.json
├── docs
└── 0.0.3.md
├── README.md
└── dist
└── vue-accordion.js
/.gitignore:
--------------------------------------------------------------------------------
1 | # Dependency directory
2 | node_modules
--------------------------------------------------------------------------------
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | [
4 | "latest", {
5 | "es2015": { "modules": false }
6 | }
7 | ]
8 | ]
9 | }
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import vueAccordion from './vue-accordion.vue'
2 |
3 | // Why don't you export default?
4 | // https://github.com/webpack/webpack/issues/3560
5 | export {vueAccordion}
6 |
--------------------------------------------------------------------------------
/webpack.config.js:
--------------------------------------------------------------------------------
1 | var webpack = require('webpack');
2 | var path = require('path');
3 |
4 | module.exports = {
5 | entry: './src/index.js',
6 | output: {
7 | path: path.resolve(__dirname, './dist'),
8 | filename: 'vue-accordion.js',
9 | libraryTarget: 'umd'
10 | },
11 | module: {
12 | rules: [
13 | {
14 | test: /\.vue$/,
15 | loader: 'vue-loader'
16 | },
17 | {
18 | test: /\.js$/,
19 | loader: 'babel-loader',
20 | exclude: /node_modules/
21 | }
22 | ]
23 | }
24 | };
25 |
26 | if (process.env.NODE_ENV === 'production') {
27 | module.exports.plugins = (module.exports.plugins || []).concat([
28 | new webpack.DefinePlugin({
29 | 'process.env': {
30 | NODE_ENV: '"production"'
31 | }
32 | }),
33 | new webpack.optimize.UglifyJsPlugin({
34 | sourceMap: true,
35 | compress: {
36 | warnings: false
37 | }
38 | }),
39 | new webpack.LoaderOptionsPlugin({
40 | minimize: true
41 | })
42 | ])
43 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016
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 all
13 | 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 THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue-accordion",
3 | "version": "1.0.0",
4 | "description": "Simple accordion menu component for Vue.js",
5 | "main": "dist/vue-accordion.js",
6 | "scripts": {
7 | "build": "cross-env NODE_ENV=production webpack --progress --hide-modules",
8 | "dev": "cross-env NODE_ENV=development webpack --watch",
9 | "test": "echo \"Error: no test specified\" && exit 1"
10 | },
11 | "repository": {
12 | "type": "git",
13 | "url": "git+https://github.com/zeratulmdq/vue-accordion.git"
14 | },
15 | "keywords": [
16 | "vue",
17 | "vuejs",
18 | "accordion",
19 | "component"
20 | ],
21 | "author": "Martin Benvenuti",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/zeratulmdq/vue-accordion/issues"
25 | },
26 | "homepage": "https://github.com/zeratulmdq/vue-accordion#readme",
27 | "devDependencies": {
28 | "babel-core": "^6.24.1",
29 | "babel-loader": "^7.0.0",
30 | "babel-preset-latest": "^6.24.1",
31 | "cross-env": "^4.0.0",
32 | "css-loader": "^0.28.1",
33 | "vue-loader": "^12.0.3",
34 | "vue-template-compiler": "^2.3.2",
35 | "webpack": "^2.5.1"
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/vue-accordion.vue:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
43 |
--------------------------------------------------------------------------------
/docs/0.0.3.md:
--------------------------------------------------------------------------------
1 | # vue-accordion
2 | Simple accordion menu component for Vuejs
3 |
4 | You can see a live demo [here](http://zeratulmdq.github.io/vue-accordion/)
5 |
6 | ## Install & usage
7 |
8 | Simply install using npm (only for browserify)
9 |
10 | ```
11 | npm install vue-accordion
12 | ```
13 |
14 | and require it like so
15 |
16 | ```
17 | var Vue = require('vue')
18 | var accordion = require('vue-accordion')
19 |
20 | var vm = new Vue({
21 | ...
22 | components: {
23 | vueAccordion: accordion
24 | }
25 | ...
26 | })
27 | ```
28 |
29 | (you may also use the .vue files in the src folder for more flexibility)
30 |
31 | In your HTML use simply use it like so
32 |
33 |
37 |
38 |
39 | ## Options
40 |
41 | The component accepts four parameters:
42 |
43 | ##### Height
44 | Numeric. The height of the accordion, defaults to 350.
45 |
46 | ##### Width
47 | Numeric. The max width of the accordion, defaults to 900. The component will expand up to this param. If you set it to 0, it'll use 100% of the parent node. If you need to set a percentage width, just set this param to 0 and wrap the component in a X% width html element.
48 |
49 | ##### Top
50 | Numeric. The top margin of the H2 element inside each panel, defaults to 50px.
51 |
52 | ##### Items
53 | The only mandatory param. An array of objects to create the panels inside the accordeon. Each object must have this structure:
54 |
55 | {
56 | title: 'First',
57 | text: 'text',
58 | url: '#',
59 | image: '/images/one.jpg'
60 | }
61 |
62 |
63 | Take into consideration the width of the accordion and the images you use. If the image is shorter, you'll see a an awful grey background.
64 |
65 | ## TODO
66 |
67 | Webpack / globals (help appreciated)
68 |
69 | ## CREDITS
70 |
71 | Most of the CSS belongs to [this guy](http://michael-ferry.com/)
--------------------------------------------------------------------------------
/src/vue-accordion-partial.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
42 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vue-accordion
2 | Simple accordion menu component for Vuejs
3 |
4 | [Check it out live!](http://zeratulmdq.github.io/vue-accordion/)
5 |
6 | ## Note
7 |
8 | The API has changed. Check [v0.0.3 documentation](/docs/0.0.3.md) if you use the old version.
9 |
10 | ## Install
11 |
12 | #### NPM / Yarn
13 |
14 | Install the package:
15 |
16 | ```
17 | npm install vue-accordion
18 | ```
19 |
20 | Then import it in your project
21 |
22 | ```js
23 | import Vue from 'vue'
24 | import {vueAccordion} from 'vue-accordion'
25 |
26 | Vue.component('vue-accordion', vueAccordion)
27 | ```
28 |
29 | #### Browser global
30 |
31 | Just include `vue` & `vue-accordion`
32 |
33 | ```html
34 |
35 |
36 | ```
37 |
38 | If you just want to play around, [unpkg](https://unpkg.com/#/) has ready-to-use packages from NPM.
39 |
40 | ```html
41 |
42 |
43 | ```
44 |
45 | Then register the component:
46 |
47 | ```html
48 |
55 | ```
56 |
57 | ## Usage
58 |
59 | Simply use it like so:
60 |
61 | ```html
62 |
63 | ```
64 |
65 | ## Structure
66 |
67 | Once the accordion has been rendered, it'll create the following structure:
68 |
69 | ````html
70 |
89 | ````
90 |
91 | All CSS is based uppon this structure.
92 |
93 | ```css
94 | .vue-accordion {
95 | ...
96 | }
97 |
98 | .vue-accordion ul {
99 | ...
100 | }
101 |
102 | ...
103 |
104 | .vue-accordion ul li a h2 {
105 | ...
106 | }
107 | ```
108 |
109 | If you want to modify the styling, take a look at the `accordionClass` and `styles` props.
110 |
111 | ## Options
112 |
113 | ##### items
114 | Mandatory. An array of objects to create the panels inside the accordion. Each object must have this structure:
115 |
116 | ```
117 | {
118 | title: 'First',
119 | text: 'text',
120 | url: '#',
121 | image: '/images/one.jpg'
122 | }
123 | ```
124 |
125 | Take into consideration the width of the accordion and the images you use. If the image is shorter, you'll see a an awful grey background.
126 |
127 | ##### accordionClass
128 | Optional. A string bounded to the class attribute of the main div. Defaults to `vue-accordion`.
129 |
130 | ##### styles
131 | Optional. An object whose keys are other objects containing specific CSS properties to be bound to the elements created inside the accordion:
132 |
133 | ```js
134 | {
135 | // this will be bound to the style attribute of all `div`s inside the accordion
136 | div: {
137 | height: '350px'
138 | },
139 | // this will be bound to the style attribute of all `ul`s inside the accordion
140 | ul: {
141 | color: '#F00'
142 | },
143 | // this will be bound to the style attribute of all `li`s inside the accordion
144 | li: {
145 | fontSize: '15px'
146 | },
147 | // this will be bound to the style attribute of all `a`s inside the accordion
148 | a: {
149 | padding: '30px'
150 | },
151 | // this will be bound to the style attribute of all `h2`s inside the accordion
152 | h2: {
153 | marginTop: '100px'
154 | },
155 | // this will be bound to the style attribute of all `p`s inside the accordion
156 | p: {
157 | textTransform: 'uppercase'
158 | }
159 | }
160 | ```
161 |
162 | ## TODO
163 |
164 | - Tests
165 | - Router-link
166 |
167 | ## CREDITS
168 |
169 | Most of the CSS belongs to [this guy](http://michael-ferry.com/)
--------------------------------------------------------------------------------
/dist/vue-accordion.js:
--------------------------------------------------------------------------------
1 | !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=6)}([function(e,t){function n(e,t){var n=e[1]||"",o=e[3];if(!o)return n;if(t&&"function"==typeof btoa){var i=r(o);return[n].concat(o.sources.map(function(e){return"/*# sourceURL="+o.sourceRoot+e+" */"})).concat([i]).join("\n")}return[n].join("\n")}function r(e){return"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(e))))+" */"}e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var r=n(t,e);return t[2]?"@media "+t[2]+"{"+r+"}":r}).join("")},t.i=function(e,n){"string"==typeof e&&(e=[[null,e,""]]);for(var r={},o=0;on.parts.length&&(r.parts.length=n.parts.length)}else{for(var s=[],o=0;o