1.0.3 • Published 2 years ago

@phemium-costaisa/accordion v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Accordion Web Component

Installation

 npm i @phemium-costaisa/accordion

Usage

In your HTML files:

 <edmbn-accordion header-title="Title" expanded bordered>
    <div slot="content">
        <ul>
            <li>Item 1</li>
            <li>Item 2</li>
            <li>Item 3</li>
        </ul>
    </div>
 </edmbn-accordion>

Include attribute slot="content" to all the content that you want to be inside the accordion.

Javascript or AngularJS (1.x)

<script src="./plugins/edmbn-accordion.js"></script>

Angular 2+

Somewhere in your project (e.g. main.ts):

import { defineCustomElements as accordionLoader } from 'edmbn-accordion/loader';
accordionLoader(window);

React

On your index.js:

import { defineCustomElements as accordionLoader } from 'edmbn-accordion/loader';
accordionLoader(window);

Vue

import { defineCustomElements as accordionLoader } from 'edmbn-accordion/loader';
Vue.config.ignoredElements = [/test-\w*/];
accordionLoader(window);

Properties

PropertyDefaultDescription
header-titleSet the accordion header title.
expandedfalseSet the default position.
borderedfalseSet border top and bottom by default on header.
lost-focus-closefalseWhether to close accordion when loosing focus.
observe-contentfalseSet to true when content is dynamic.
debugfalseSet to true for debugging logs.

Slots

NameDescription
contentHTML Content to put inside accordion when unfolded
rightHTML Content to put in the right part of the header

Customize CSS

VariableDefault
--header-height50px
--header-background-colorwhite
--header-button-colorblack
--header-button-width1.5rem
--header-text-colorblack
--header-font-weight700
--header-font-size1rem
--header-border-topvar(--border-width) var(--border-style) var(--border-color)
--header-border-bottomvar(--border-width) var(--border-style) var(--border-color)
--header-border-leftnone
--header-border-rightnone
--border-stylesolid
--border-width1px
--border-color#ccc

Contribute

git clone https://github.com/phemium/accordion.git
cd accordion

and run:

npm install
npm start

To build the component for production, run:

npm run build