js-accordion
Example
Install
npm i js-accordion --save
In a browser:
Load ES module:
; //if is necesary.;
Usage
you must import the style in html or script.
html
this structure with your id
Section 1Section 1 Content...Section 2Section 2 Content...Section 3Section 3 Content...
Script
; // es6 example const id = 'accordion'const accordion = id config // config is a optional param
API
config
Attribute | type | default | example | description |
---|---|---|---|---|
maxHeight | String | 'none' | "150px" | set max height of accordion content when is opened |
withTransition | Boolean | true | true / false | effect when open and close |
withAutoClose | Boolean | true | true / false | close others accordions than you not click |
onToggle | Event | () => {} | (accordion) => {} | event when one content of accordion is opened. |
variables
- element : Root Accordion element
- config : Accordion config
- accordionItems: Array of Accordion Items, each accordion with heder and content.
functions
- update() : if you add new content, this update the accordion.
- toggleAccordion(accordion): if you want use it in javascript pass a accordion to close or open.
theme
you can change the default theme changing this css variables.
--
CI
pipeline
Branches | Stages | site |
---|---|---|
Staging | Staging | heroku |
Master | Production | Github Pages |
Conditions
- Use Sass for generate CSS
- Use ES6
- Use only Vanilla JS, without any JS framework
- Generate gh-page for publish
Bonus
- Add new section with Ajax content
Author
Alex Marcos Gutierrez
License
MIT