Skip to content

Commit

Permalink
#638 - Documentation added
Browse files Browse the repository at this point in the history
  • Loading branch information
estruyf committed Aug 24, 2020
1 parent 5d04223 commit 079ba38
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 1 deletion.
Binary file added docs/documentation/docs/assets/accordion.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions docs/documentation/docs/controls/Accordion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Accordion

This control allows you to render an accordion control.

Here is an example of the control in action:

![Accordion control](../assets/accordion.png)

## How to use this control in your solutions

- Check that you installed the `@pnp/spfx-controls-react` dependency. Check out the [getting started](../../#getting-started) page for more information about installing the dependency.
- In your component file, import the `Accordion` control as follows:

```TypeScript
import { Accordion } from "@pnp/spfx-controls-react/lib/Accordion";
```

- Use the `Accordion` control in your code as follows:

```TypeScript
{
sampleItems.map((item, index) => (
<Accordion title={item.Question} defaultCollapsed={true} className={"itemCell"} key={index}>
<div className={"itemContent"}>
<div className={"itemResponse"}>{item.Reponse}</div>
<div className={"itemIndex"}>{`Langue : ${item.Langue.Nom}`}</div>
</div>
</Accordion>
))
}
```

## Implementation

The `Accordion` control can be configured with the following properties:

| Property | Type | Required | Description | Default |
| ---- | ---- | ---- | ---- | ---- |
| title | string | yes | The title in the accordion to display. | |
| defaultCollapsed | boolean | no | Is the accordion by default collapsed? | false |
| className | string | no | Additional class name to add to your accordion. | |


![](https://telemetry.sharepointpnp.com/sp-dev-fx-controls-react/wiki/controls/Accordion)
1 change: 1 addition & 0 deletions docs/documentation/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ telemetry.optOut();

The following controls are currently available:

- [Accordion](./controls/Accordion) (Control to render an accordion)
- [Carousel](./controls/Carousel) (Control displays children elements with 'previous/next element' options)
- [Charts](./controls/ChartControl) (makes it easy to integrate [Chart.js](https://www.chartjs.org/) charts into web part)
- [ComboBoxListItemPicker](./controls/ComboBoxListItemPicker) (allows to select one or more items from a list)
Expand Down
1 change: 1 addition & 0 deletions docs/documentation/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ site_name: '@pnp/spfx-controls-react'
nav:
- Home: 'index.md'
- Controls:
- Accordion: 'controls/Accordion.md'
- Carousel: 'controls/Carousel.md'
- Charts:
- "ChartControl": 'controls/ChartControl.md'
Expand Down
5 changes: 4 additions & 1 deletion src/controls/accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { IAccordionProps, IAccordionState } from './index';
import { css } from "@uifabric/utilities/lib/css";
import { DefaultButton } from 'office-ui-fabric-react/lib/components/Button';
import { IIconProps } from 'office-ui-fabric-react/lib/Icon';
import * as telemetry from '../../common/telemetry';

/**
* Icon styles. Feel free to change them
Expand All @@ -17,8 +18,10 @@ export class Accordion extends React.Component<IAccordionProps, IAccordionState>
super(props);

this.state = {
expanded: props.defaultCollapsed == null ? false : !props.defaultCollapsed
expanded: props.defaultCollapsed === null ? false : !props.defaultCollapsed
};

telemetry.track('ReactAccordion', {});
}

public render(): React.ReactElement<IAccordionProps> {
Expand Down

0 comments on commit 079ba38

Please sign in to comment.