Skip to content

Commit 4dbd2ed

Browse files
committed
Merge branch 'feature/icon-picker' of https://github.com/Konradox/sp-dev-fx-controls-react into Konradox-feature/icon-picker
2 parents 198f9a8 + e715f59 commit 4dbd2ed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2179
-28
lines changed
58.9 KB
Loading
492 KB
Loading
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# IconPicker control
2+
3+
Control that allows to search and select an icon from office-ui-fabric-react icons.
4+
5+
## Overview
6+
The control allows selecting an icon from the list of icons available in the office-ui-fabric-react library. Icon list is a static copy of available icons. Currently, only one icon selection is supported.
7+
![Icon Picker overview](../assets/IconPickerOverview.png)
8+
9+
10+
## Displayed in the panel
11+
Icon picker always opens a new panel where you can pick an icon. The panel displays all the icons and maintains readability. Picker does not displays selected icon outside the panel.
12+
![Icon Picker panel](../assets/IconPickerPanel.gif)
13+
14+
15+
## How to use this control
16+
17+
- 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.
18+
- Import the following module to your component:
19+
20+
```TypeScript
21+
import { IconPicker } from '@pnp/spfx-controls-react/lib/IconPicker';
22+
```
23+
24+
- Use the `IconPicker` control in your code as follows:
25+
26+
```TypeScript
27+
<IconPicker
28+
buttonLabel={'Icon'}
29+
onChange={(iconName: string) => { this.setState({icon: iconName}); }}
30+
onSave={(iconName: string) => { this.setState({icon: iconName}); }}
31+
/>
32+
```
33+
34+
## Implementation
35+
36+
The IconPicker component can be configured with the following properties:
37+
38+
| Property | Type | Required | Description |
39+
| ---- | ---- | ---- | ---- |
40+
| buttonLabel | string | no | Specifies the label of the icon picker button. |
41+
| onSave | (iconName: string) => void | yes | Handler when the icon has been selected and picker has been closed. |
42+
| onChange | (iconName: string) => void | no | Handler when the icon selection has been changed. |
43+
| disabled | boolean | no | Specifies if the picker button is disabled |
44+
| buttonClassName | boolean | no | If provided, additional class name will be added to the picker button |
45+
| panelClassName | boolean | no | If provided, additional class name will be added to the picker panel |
46+
| currentIcon | boolean | no | Specifies default selected icon |
47+
48+
![](https://telemetry.sharepointpnp.com/sp-dev-fx-controls-react/wiki/controls/IconPicker)

docs/documentation/docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ The following controls are currently available:
4141
- [FileTypeIcon](./controls/FileTypeIcon) (Control that shows the icon of a specified file path or application)
4242
- [FolderExplorer](./controls/FolderExplorer) (Control that allows to browse the folders and sub-folders from a root folder)
4343
- [GridLayout](./controls/GridLayout) (control that renders a responsive grid layout for your web parts)
44+
- [IconPicker](./controls/IconPicker) (control that allows to search and select an icon from office-ui-fabric icons)
4445
- [IFrameDialog](./controls/IFrameDialog) (renders a Dialog with an iframe as a content)
4546
- [ListItemPicker](./controls/ListItemPicker) (allows to select one or more items from a list)
4647
- [ListPicker](./controls/ListPicker) (allows to select one or multiple available lists/libraries of the current site)

docs/documentation/mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ nav:
1818
- FileTypeIcon: 'controls/FileTypeIcon.md'
1919
- FolderExplorer: 'controls/FolderExplorer.md'
2020
- GridLayout: 'controls/GridLayout.md'
21+
- IconPicker: 'controls/IconPicker.md'
2122
- IFrameDialog: 'controls/IFrameDialog.md'
2223
- IFramePanel: 'controls/IFramePanel.md'
2324
- ListItemAttachments: 'controls/ListItemAttachments.md'

src/IconPicker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './controls/iconPicker/index';
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
export interface IIconPickerProps {
2+
/**
3+
* call-back function when icon selection has been confirmed
4+
*/
5+
onSave(iconName: string): void;
6+
/**
7+
* call-back function when icon has changed
8+
*/
9+
onChange?(iconName: string): void;
10+
/**
11+
* Specifies the label of the icon picker button
12+
*/
13+
buttonLabel?: string;
14+
/**
15+
* Specifies if the picker button is disabled
16+
*/
17+
disabled?: boolean;
18+
/**
19+
* Specifies a custom className for the picker button
20+
*/
21+
buttonClassName?: string;
22+
/**
23+
* Specifies a custom className for the panel element
24+
*/
25+
panelClassName?: string;
26+
/**
27+
* initially selected icon
28+
*/
29+
currentIcon?: string;
30+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export interface IIconPickerState {
2+
items: string[];
3+
currentIcon?: string;
4+
isPanelOpen: boolean;
5+
}

0 commit comments

Comments
 (0)