Skip to content

Commit 079ba38

Browse files
committed
#638 - Documentation added
1 parent 5d04223 commit 079ba38

File tree

5 files changed

+50
-1
lines changed

5 files changed

+50
-1
lines changed
80.7 KB
Loading
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Accordion
2+
3+
This control allows you to render an accordion control.
4+
5+
Here is an example of the control in action:
6+
7+
![Accordion control](../assets/accordion.png)
8+
9+
## How to use this control in your solutions
10+
11+
- 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.
12+
- In your component file, import the `Accordion` control as follows:
13+
14+
```TypeScript
15+
import { Accordion } from "@pnp/spfx-controls-react/lib/Accordion";
16+
```
17+
18+
- Use the `Accordion` control in your code as follows:
19+
20+
```TypeScript
21+
{
22+
sampleItems.map((item, index) => (
23+
<Accordion title={item.Question} defaultCollapsed={true} className={"itemCell"} key={index}>
24+
<div className={"itemContent"}>
25+
<div className={"itemResponse"}>{item.Reponse}</div>
26+
<div className={"itemIndex"}>{`Langue : ${item.Langue.Nom}`}</div>
27+
</div>
28+
</Accordion>
29+
))
30+
}
31+
```
32+
33+
## Implementation
34+
35+
The `Accordion` control can be configured with the following properties:
36+
37+
| Property | Type | Required | Description | Default |
38+
| ---- | ---- | ---- | ---- | ---- |
39+
| title | string | yes | The title in the accordion to display. | |
40+
| defaultCollapsed | boolean | no | Is the accordion by default collapsed? | false |
41+
| className | string | no | Additional class name to add to your accordion. | |
42+
43+
44+
![](https://telemetry.sharepointpnp.com/sp-dev-fx-controls-react/wiki/controls/Accordion)

docs/documentation/docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ telemetry.optOut();
4949

5050
The following controls are currently available:
5151

52+
- [Accordion](./controls/Accordion) (Control to render an accordion)
5253
- [Carousel](./controls/Carousel) (Control displays children elements with 'previous/next element' options)
5354
- [Charts](./controls/ChartControl) (makes it easy to integrate [Chart.js](https://www.chartjs.org/) charts into web part)
5455
- [ComboBoxListItemPicker](./controls/ComboBoxListItemPicker) (allows to select one or more items from a list)

docs/documentation/mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ site_name: '@pnp/spfx-controls-react'
22
nav:
33
- Home: 'index.md'
44
- Controls:
5+
- Accordion: 'controls/Accordion.md'
56
- Carousel: 'controls/Carousel.md'
67
- Charts:
78
- "ChartControl": 'controls/ChartControl.md'

src/controls/accordion/Accordion.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { IAccordionProps, IAccordionState } from './index';
44
import { css } from "@uifabric/utilities/lib/css";
55
import { DefaultButton } from 'office-ui-fabric-react/lib/components/Button';
66
import { IIconProps } from 'office-ui-fabric-react/lib/Icon';
7+
import * as telemetry from '../../common/telemetry';
78

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

1920
this.state = {
20-
expanded: props.defaultCollapsed == null ? false : !props.defaultCollapsed
21+
expanded: props.defaultCollapsed === null ? false : !props.defaultCollapsed
2122
};
23+
24+
telemetry.track('ReactAccordion', {});
2225
}
2326

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

0 commit comments

Comments
 (0)