Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mattheu committed Oct 25, 2023
1 parent 197c2a4 commit 2c19211
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/components/InnerBlockSlider/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,26 +98,29 @@ The above example code creates a slider using the core image block as each slide

## Props

| Name | Type | Default | Description |
| --------------- | -------------- | ------- | --------------------------------------------- |
| `allowedBlock` | `string` | `''` | Block types to be allowed inside the slider |
| `slideLimit` | `integer` | `10` | Maximum number of slides. |
| `parentBlockId` | `string` | `''` | Client ID of parent block. This is required. |
| `externalCurrentItemIndex` | `string` | `null` | Optional. Current slide index. If you need to access to the current item index externally, then you need to manage that state externally. |
| `setExternalCurrentItemIndex` | `function` | `null` | Optional. Function to update the current slide index. If you need to access to the current item index externally, then you need to manage that state externally. |

| Name | Type | Default | Description |
| ---------------- | -------------- | ------- | --------------------------------------------- |
| `allowedBlock` | `string` | `''` | Block types to be allowed inside the slider |
| `slideLimit` | `integer` | `10` | Maximum number of slides. |
| `parentBlockId` | `string` | `''` | Client ID of parent block. This is required. |
| `showNavigation` | `bool` | `true` | Whether to show slide navigation/pagination. |

## Examples

### Managing the state externally.

If you need to sync the slider component state it with some other external functionality, you may need to manage state in your code. In order to to this, you need to import the InnerBlockSliderStateless rather than the standard container component exposed by the library.

```js
import InnerBlockSliderStateless from '@humanmade/block-editor-components';

const [ currentItemIndex, setCurrentItemIndex ] = useState( 0 );

<InnerBlockSlider
// ... other props
parentBlockId={ clientId }
externalCurrentItemIndex={ currentItemIndex }
setExternalCurrentItemIndex={ setCurrentItemIndex }
currentItemIndex={ currentItemIndex }
setCurrentItemIndex={ setCurrentItemIndex }
/>
```

Expand Down
3 changes: 3 additions & 0 deletions src/components/InnerBlockSlider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import InnerBlockSlider from './inner-block-slider.js';
/**
* InnerBlockSlider container component.
*
* This container component is recommended for typical usage, as it handles state management.
* However for further info on supported props, refer to the InnerBlockSlider component, as all props are passed through.
*
* @param {object} props Component props.
* @returns {React.ReactNode} Component.
*/
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export { default as FileControls } from './components/FileControls';
export { default as GenericServerSideEdit } from './components/GenericServerSideEdit';
export { default as ImageControl } from './components/ImageControl';
export { default as InnerBlockSlider } from './components/InnerBlockSlider';
export { default as InnerBlockSliderStateless } from './components/InnerBlockSlider/inner-block-slider';
export { default as LinkToolbar } from './components/LinkToolbar';
export { default as PlainTextWithLimit } from './components/PlainTextWithLimit';
export { default as PostTitleControl } from './components/PostTitleControl';
Expand Down

0 comments on commit 2c19211

Please sign in to comment.