import {Fragment} from 'react'; import CollapsePanel from 'sentry/components/collapsePanel'; import JSXNode from 'sentry/components/stories/jsxNode'; import JSXProperty from 'sentry/components/stories/jsxProperty'; import Matrix from 'sentry/components/stories/matrix'; import SideBySide from 'sentry/components/stories/sideBySide'; import SizingWindow from 'sentry/components/stories/sizingWindow'; import storyBook from 'sentry/stories/storyBook'; export default storyBook(CollapsePanel, story => { story('Basics', () => (

The expanded state will be set based on whether{' '} is larger than{' '} (default: 5).

Once expanded, cannot be collapsed again.

{({isExpanded, showMoreButton}) => (

isExpanded = {String(isExpanded)}

{showMoreButton}
)}
)); story('Bugs', () => (

Starting with items less than or equal to the collapseCount will return an incorrect isExpanded value.

{[6, 5, 4].map(items => ( {({isExpanded, showMoreButton}) => (

isExpanded = {String(isExpanded)}

{showMoreButton}
)}
))}
)); story('Rendering a list', () => { const allItems = ['one', 'two', 'three', 'four', 'five']; const collapseCount = 3; // Show 3 items to start return (

Typically you will render a portion of the list when the panel is collapsed, then all items when the panel is expanded.

{({isExpanded, showMoreButton}) => { const items = isExpanded ? allItems : allItems.slice(0, collapseCount); return (
    {items.map(item => (
  • {item}
  • ))}
{showMoreButton}
); }}
); }); story('Props', () => ( (

isExpanded = {String(isExpanded)}

{showMoreButton}
), ], }} selectedProps={['buttonTitle', 'disableBorder']} sizingWindowProps={{display: 'block'}} /> )); });