Skip to content

Commit

Permalink
Merge pull request #1820 from pnp/imagePicker
Browse files Browse the repository at this point in the history
Image picker
  • Loading branch information
joaojmendes authored Oct 18, 2024
2 parents 142f17e + c1a3c05 commit 443fac4
Show file tree
Hide file tree
Showing 53 changed files with 4,230 additions and 1,346 deletions.
15 changes: 15 additions & 0 deletions .hintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": [
"development"
],
"hints": {
"axe/aria": "off",
"no-inline-styles": "off",
"axe/text-alternatives": [
"default",
{
"frame-title": "off"
}
]
}
}
Binary file added docs/documentation/docs/assets/ImagePicker00.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/documentation/docs/assets/ImagePicker01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/documentation/docs/assets/ImagePicker02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/documentation/docs/assets/ImagePicker03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/documentation/docs/assets/ImagePicker04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/documentation/docs/assets/ImagePicker05.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 67 additions & 0 deletions docs/documentation/docs/controls/ImagePicker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# HoverReactionsBar

This control allows you to select or Upload Image from SharePoint, Ondrive or Stock Images.

## ImagePicker

![imagepicker](../assets/ImagePicker00.png)

![imagepicker](../assets/ImagePicker01.png)

![imagepicker](../assets/ImagePicker02.png)

![imagepicker](../assets/ImagePicker03.png)

![imagepicker](../assets/ImagePicker04.png)

![imagepicker](../assets/ImagePicker05.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.
- Import the following modules to your component:

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

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

```Typescript

<ImagePicker
onFileSelected={handleFileSelected}
onDeleteFile={handleDeleteFile}
selectedFileUrl={selectedImageUrl}
context={appContext}
>
```

- With the `onFileSelect` property you can get the selected image:

```typescript
const handleFileSelected = React.useCallback(async (file: IFilePickerResult) => {
console.log("file", file);
}, []);
```

- With the `onDelete` property you can execute a callback after delete the image:

```typescript
const onDeleteFile = React.useCallback(async () => {
console.log("onDeleteFile");
}, []);
```

## Implementation

The HoverReactionsBar control can be configured with the following properties:

| Property | Type | Required | Description |
| --------------- | ------------------------------------------------- | -------- | ----------------------- |
| onFileSelected | onFileSelect: (file: IFilePickerResult ) => void; | yes | OnSelectedFile Callback |
| onDeleteFile | onDeleteFile: () => void | no | onDeleteFile CallBack |
| selectedFileUrl | string | no | Default Selected Image |
| context | BaseComponentContext | yes | Context |

![](https://telemetry.sharepointpnp.com/sp-dev-fx-controls-react/wiki/controls/ImagePicker)
Loading

0 comments on commit 443fac4

Please sign in to comment.