Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Icon picker with localisation and documentation #485

Merged
merged 1 commit into from
Mar 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions docs/documentation/docs/controls/IconPicker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# IconPicker control

Control that allows to search and select an icon from office-ui-fabric-react icons.

## Overview
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.
![Icon Picker overview](../assets/IconPickerOverview.png)


## Displayed in the panel
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.
![Icon Picker panel](../assets/IconPickerPanel.gif)


## How to use this control

- 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.
- Import the following module to your component:

```TypeScript
import { IconPicker } from '@pnp/spfx-controls-react/lib/IconPicker';
```

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

```TypeScript
<IconPicker
buttonLabel={'Icon'}
onChange={(iconName: string) => { this.setState({icon: iconName}); }}
onSave={(iconName: string) => { this.setState({icon: iconName}); }}
/>
```

## Implementation

The IconPicker component can be configured with the following properties:

| Property | Type | Required | Description |
| ---- | ---- | ---- | ---- |
| buttonLabel | string | no | Specifies the label of the icon picker button. |
| onSave | (iconName: string) => void | yes | Handler when the icon has been selected and picker has been closed. |
| onChange | (iconName: string) => void | no | Handler when the icon selection has been changed. |
| disabled | boolean | no | Specifies if the picker button is disabled |
| buttonClassName | boolean | no | If provided, additional class name will be added to the picker button |
| panelClassName | boolean | no | If provided, additional class name will be added to the picker panel |
| currentIcon | boolean | no | Specifies default selected icon |

![](https://telemetry.sharepointpnp.com/sp-dev-fx-controls-react/wiki/controls/IconPicker)
1 change: 1 addition & 0 deletions docs/documentation/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ The following controls are currently available:
- [FilePicker](./controls/FilePicker) (control that allows to browse and select a file from various places)
- [FileTypeIcon](./controls/FileTypeIcon) (Control that shows the icon of a specified file path or application)
- [GridLayout](./controls/GridLayout) (control that renders a responsive grid layout for your web parts)
- [IconPicker](./controls/IconPicker) (control that allows to search and select an icon from office-ui-fabric icons)
- [IFrameDialog](./controls/IFrameDialog) (renders a Dialog with an iframe as a content)
- [ListItemPicker](./controls/ListItemPicker) (allows to select one or more items from a list)
- [ListPicker](./controls/ListPicker) (allows to select one or multiple available lists/libraries of the current site)
Expand Down
1 change: 1 addition & 0 deletions docs/documentation/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ nav:
- FilePicker: 'controls/FilePicker.md'
- FileTypeIcon: 'controls/FileTypeIcon.md'
- GridLayout: 'controls/GridLayout.md'
- IconPicker: 'controls/IconPicker.md'
- IFrameDialog: 'controls/IFrameDialog.md'
- IFramePanel: 'controls/IFramePanel.md'
- ListItemAttachments: 'controls/ListItemAttachments.md'
Expand Down
1 change: 1 addition & 0 deletions src/IconPicker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './controls/iconPicker/index';
30 changes: 30 additions & 0 deletions src/controls/iconPicker/IIconPickerProps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export interface IIconPickerProps {
/**
* call-back function when icon selection has been confirmed
*/
onSave(iconName: string): void;
/**
* call-back function when icon has changed
*/
onChange?(iconName: string): void;
/**
* Specifies the label of the icon picker button
*/
buttonLabel?: string;
/**
* Specifies if the picker button is disabled
*/
disabled?: boolean;
/**
* Specifies a custom className for the picker button
*/
buttonClassName?: string;
/**
* Specifies a custom className for the panel element
*/
panelClassName?: string;
/**
* initially selected icon
*/
currentIcon?: string;
}
5 changes: 5 additions & 0 deletions src/controls/iconPicker/IIconPickerState.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface IIconPickerState {
items: string[];
currentIcon?: string;
isPanelOpen: boolean;
}
Loading