react-expandable-context

0.1.0 • Public • Published

react-expandable-context

React components to make anything to be expandable

Installation

npm i react-expandable-context

yarn add react-expandable-context

Usage

import Expandable from 'react-expandable-context';
 
function MyComponent(props) {
    return (
        <Expandable>
            <Expandable.Section id={'first'}>
                {({ handleClick, expanded }) => (
                    <>
                        <a id={'link'} onClick={handleClick}>
                            Header
                        </a>
                        <div id={'section-body'} expanded={expanded ? 'true' : 'false'}>
                            lorem
                        </div>)
                    </>
                )}
            </Expandable.Section>
            <Expandable.Section id={'second'}>
                {({ handleClick, expanded }) => (
                    <>
                        <a id={'link'} onClick={handleClick}>
                            Header
                        </a>
                        <div id={'section-body'} expanded={expanded ? 'true' : 'false'}>
                            lorem
                        </div>)
                    </>
                )}
            </Expandable.Section>
        </Expandable>
    );
}

TODO: document props

Package Sidebar

Install

npm i react-expandable-context

Weekly Downloads

3

Version

0.1.0

License

MIT

Unpacked Size

205 kB

Total Files

12

Last publish

Collaborators

  • jonathan-san