1.0.2 • Published 6 years ago

@veams/component-accordion v1.0.2

Weekly downloads
29
License
MIT
Repository
github
Last release
6 years ago

Accordion

Description

The component represents a simple accordion with transitions and max-height.

Accordions are elements used to expand and collapse content that is broken into logical sections, much like tabs.

The accordion is based on the blueprint of Veams-Components and is a wrap-with component to support flexible content with predefined surrounded markup.

The accordion is jQuery-free (we use Veams-Query) and contains some accessiblity functionality.


Requirements


Installation

Installation with Veams

veams install component accordion
veams -i c accordion

Fields

accordion-usage.hbs

The partial is a \{{#wrapWith}} helper. Documentation for wrapWith helper.

accordion.hbs

Settings

ParameterTypeValueDescription
settings.accContextClassStringdefaultContext class of component.
settings.accClassesStringModifier classes for component.
settings.accJsOptionsObjectJavaScript options which gets stringified.

accordion__item.hbs

Settings

ParameterTypeDescription
settings.accNoWrapperBooleanHide wrapper div .accordion__item.
ParameterTypeDescription
accItemIdStringId of the accordion item.
accButtonStringButton text for accordion item.

JavaScript Options

The module gives you the possibility to override default options:

OptionTypeDefaultDescription
activeClassString'is-active'Define the active class for active elements.
accordionBtnString'[data-js-item='accordion-btn']'Define the element for accordion buttons.
accordionContentString'[data-js-item="accordion-content"]'Define the element for accordion content items.
calculatingClassString'is-calculating'Define the calculating class for the initial calculation cycle.
clickHandlerString'click'Define a click handler for the buttons.
closeClassString'is-closed'Define the closing class for accordion content items.
dataMaxAttrString'data-js-height'Define the attribute in which the calculated height is saved.
openAllOnInitBooleanfalseIf set to true, all panels stays open on render.
openByHashBooleanfalseIf set to true, panel can be opened by url hash referencing the id of the panel.
openClassBoolean'is-open'Define the opening class for accordion content items.
openIndexNumbernullIndex of panel to be opened on init (zero based).
openOnViewportsArray['tablet-s', 'tablet-l', 'desktop-s', 'desktop-m', 'desktop-l']Viewports on which the openIndex panel is opened on init.
removeStylesBooleanfalseIf set to true,
singleOpenBooleanfalseIf set to true, only one panel can be opened at the same time.
tabModeBooleanfalseIf set to true, the accordion behaves like a tab module (clicking on active button will not close the corresponding panel).
unresolvedClassString'is-unresolved'Define the unresolved class for the whole accordion which will be deleted after didMount() and render() is finished.

Sass Options

There are multiple global variables which you can change:

VariableValueDescription
$accordion-toggle-duration:300ms !defaultSpeed of toggling.
$accordion-transition-method:ease !defaultTransition method of toggle effect.
$accordion-icon-color:#666 !default+ icon color.
$accordion-icon-width:15px !default+ icon width.
$accordion-icon-height:2px !default+ icon height.
$accordion-btn-color:$accordion-icon-color !defaultAccordion button color.
$accordion-btn-bg-color:rgba(255, 255, 255, .5) !defaultBackground color of the accordion button.
$accordion-padding:1rem !defaultDefault padding which will be used in the accordion.
1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago