3.2.5 • Published 4 years ago

@stereorepo/accordion v3.2.5

Weekly downloads
103
License
ISC
Repository
github
Last release
4 years ago

Accordion 🔽

Alban 🔥 Accordion is the supreme, most modern and sexy accordion package ever made 💅

Installation

npm i -S @stereorepo/accordion

Usage

The easiest, most effective way to build an accordion is to use four html elements.

First: the container

Second: the clickable element

Third: the content wrapper

Fourth: the accordion content container

How it works on paper

The container will... contain (👏) all the elements you'll need to create magic.

The clickable element (frequently your accordion title) will allow us to reveal the accordion content when clicked.

Its first and only bro : the content wrapper.

The content wrapper will be the expanding/contracting element. We will change its max-height css property to reveal/hide the accordion content.

We need a content container to know the height of our actual content.

The html

<!-- ... -->
<div class="my-accordion js-accordion">
    <p class="js-accordion-title">My title</p>
    <div class="ph-content-wrapper js-accordion-content-wrapper">
        <div class="js-accordion-content">
            <!-- Inside put your content -->
        </div>
    </div>
</div>
<!-- ... -->

Example

// You can import the vanilla Accordion
import { Accordion } from '@stereosuper/accordion';
// or the Vue.js version of it
import { AccordionVue } from '@stereosuper/accordion';

// then instanciate it
const accordions = new Accordion({
    containerSelector: '.js-accordion',
    clickedSelector: '.js-accordion-title',
    contentWrapperSelector: '.js-accordion-content-wrapper',
    contentSelector: '.js-accordion-content',
    offsetY: 100,
    scrollDelay: 200,
    noScroll: false,
    silent: true
});

// and finally watch the magic happen
accordions.initializeAccordions();

initializeAccordions

containerSelector, clickedSelector, contentWrapperSelector, and contentSelector are the four main elements composing our accordion (see 👆 there).

offsetY

This is the amount of pixels of the margin you want between the top of your window and the top of your accordion... because, yeah, by default it automatically scrolls to the top of the clicked accordion 😏

scrollDelay

Seriously... just read the fuc**** title

noScroll

You can deactivate the scroll with you want... much less SWAG, but still cool.

silent

You can deactivate the console's errors if you want (for example if you don't use bodyRouter)

The scss placeholder

To easily add the css properties you need for the accordions to work you can use the %stereorepo-accordion scss placeholder.

@import '~@stereorepo/accordion/src/accordion';

// It will search for the any .ph-content-wrapper class inside your accordion and add to this element only the properties needed
.my-accordion {
    @extend %stereorepo-accordion;
}
3.2.5

4 years ago

3.2.2

4 years ago

3.2.1

4 years ago

3.2.0

4 years ago

3.1.2

4 years ago

3.1.1

4 years ago

3.1.0

4 years ago

3.0.16

4 years ago

3.0.15

4 years ago

3.0.14

4 years ago

3.0.13

4 years ago

3.0.12

4 years ago

3.0.11

4 years ago

3.0.10

4 years ago

3.0.9

4 years ago

3.0.8

4 years ago

3.0.7

4 years ago

3.0.6

4 years ago

3.0.5

4 years ago

3.0.4

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.1.9

4 years ago

2.1.5

4 years ago

2.1.4

4 years ago

2.1.3

4 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.6

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.6.13

5 years ago

1.6.12

5 years ago

1.6.11

5 years ago

1.6.8

5 years ago

1.6.7

5 years ago

1.6.6

5 years ago

1.6.5

5 years ago

1.6.4

5 years ago

1.6.3

5 years ago

1.6.2

5 years ago

1.6.0

5 years ago

1.5.11

5 years ago

1.5.10

5 years ago

1.5.9

5 years ago

1.5.8

5 years ago

1.5.4

5 years ago

1.5.2

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.14

5 years ago

1.4.13

5 years ago

1.4.12

5 years ago

1.4.11

5 years ago

1.4.10

5 years ago

1.4.9

5 years ago

1.4.8

5 years ago

1.4.7

5 years ago

1.4.6

5 years ago

1.4.5

5 years ago

1.4.4

5 years ago

1.4.3

5 years ago

1.3.9

5 years ago

1.3.8

5 years ago

1.3.7

5 years ago

1.3.6

5 years ago

1.3.5

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.10

5 years ago

1.2.9

5 years ago

1.2.8

5 years ago

1.2.7

5 years ago

1.2.6

5 years ago

1.2.2

5 years ago

1.2.0

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago