0.4.5 • Published 7 years ago

react-sanfona-hash v0.4.5

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

react-sanfona

NPM info

Travis build status dependencies devDependency Status

React accordion component

giphy 1

Usage

CommonJS

Install via NPM:

npm install react-sanfona

Then:

import { Accordion, AccordionItem } from 'react-sanfona';

…

	render: function () {
		return (
			<Accordion>
				{[1, 2, 3, 4, 5].map((item) => {
					return (
						<AccordionItem title={`Item ${ item }`} slug={item} key={item}>
							<div>
								{`Item ${ item } content`}
								{item === 3 ? <p><img src="https://cloud.githubusercontent.com/assets/38787/8015584/2883817e-0bda-11e5-9662-b7daf40e8c27.gif" /></p> : null}
							</div>
						</AccordionItem>
					);
				})}
			</Accordion>
		);
	}

…

options / PropTypes

Accordion

PropertyTypeDescriptionDefault
allowMultipleBooleanAllow multiple items to be open at the same time.false
activeItemsArrayReceives either an array of indexes or a single index. Each index corresponds to the item order, starting from 0. Ex: activeItems={0}, activeItems=0, 1, 2[0]
openNextAccordionItemBooleanOpens the next accordion item after the previous one is closed. Defaults first one as active and applies for each accordion item except the last one. Not compatible when passing in a custom slugfalse
classNameStringCustom classname applied to root elementnull
styleObjectInline styles applied to root elementnull
onChangeFunctionTriggered when component updates and passes new state as an argumentnull
rootTagStringCustom HTML tag used for root element'div'

AccordionItem

PropertyTypeDescriptionDefault
titleString/ ObjectText or Object to display in header.null
slugString/NumberKey used in activeItems lookupnull
expandedBooleanIf item body should be expanded or notfalse
onExpandFunctionCallback for when item is expandednull
onCloseFunctionCallback for when item closesnull
classNameStringCustom classname applied to root item elementnull
bodyClassNameStringCustom classname applied to the accordion item bodynull
expandedClassNameStringCustom classname applied when accordion is expandednull
titleClassNameStringCustom classname applied to accordion item header textnull
disabledBooleanIf item should be expanded or notfalse
disabledClassNameStringCustom classname applied to accordion item header text when item is disablednull
rootTagStringCustom HTML tag used for root element'div'
titleTagStringCustom HTML tag used for title element'h3'
bodyTagStringCustom HTML tag used for body element'div'

Styling with classnames

ClassnameTargets
react-sanfonaAccordion container
react-sanfona-itemAccordionItem container
react-sanfona-item-expandedAccordionItem container when expanded
react-sanfona-item-titleAccordionItem header text
react-sanfona-item-bodyAccordionItem body container
react-sanfona-item-body-wrapperAccordionItem body children wrapper
react-sanfona-item-disabledAccordionItem is disabled

development

npm install

npm start // served on localhost:8080

npm test
0.4.5

7 years ago

0.4.4

7 years ago

0.4.3

7 years ago

0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago