-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: added describe props api, styles, react-uploader-api via ref (#14)
* docs: added describe props api, styles, react-uploader-api via ref * feat: added className for wrapper * docs: added describe summary and Quick Features * feat: added userAgentIntegration
- Loading branch information
1 parent
45752f1
commit 5f2a1a2
Showing
6 changed files
with
127 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,44 +6,120 @@ | |
alt=""> | ||
</a> | ||
|
||
Uploadcare React Uploader. Allows you to use Uploader in React applications according to React canons. | ||
|
||
Welcome to the Uploadcare React Uploader documentation! | ||
This library allows you to seamlessly integrate Uploadcare file uploader into your React applications while adhering to | ||
React principles. | ||
|
||
[![Build Status][badge-build]][build-url] | ||
[![NPM version][npm-img]][npm-url] | ||
[![GitHub release][badge-release-img]][badge-release-url] | ||
[![Uploadcare stack on StackShare][badge-stack-img]][badge-stack-url] | ||
|
||
* [Summary about project](#summary-about-project) | ||
* [Quick Features](#quick-features) | ||
* [Install](#install) | ||
* [Common](#common) | ||
* [Usage](#usage) | ||
* [Regular](#regular) | ||
* [Inline](#inline) | ||
* [Minimal](#minimal) | ||
* [Props API](#props-api) | ||
* [Styles](#styles) | ||
* [File Uploader API](#file-uploader-api) | ||
* [Events](#events) | ||
* [Security issues](#security-issues) | ||
* [Feedback](#feedback) | ||
|
||
## Summary about project | ||
|
||
This documentation provides guidance on how to use the Uploadcare React Uploader in your projects, along with details | ||
about its features, installation process, usage examples, customization options, event handling, and security | ||
considerations. | ||
|
||
## Quick Features | ||
|
||
- Seamless integration with React applications | ||
- Three different upload options: Regular, Inline, and Minimal | ||
- Customizable styles | ||
- Access to File Uploader API | ||
- Comprehensive event handling | ||
|
||
## Install | ||
|
||
``` | ||
```bash | ||
npm i @uploadcare/react-uploader | ||
``` | ||
|
||
## Usage | ||
|
||
The Uploadcare React Uploader offers three main components for integration. | ||
Each component serves specific use cases and can be easily implemented into your project. | ||
|
||
### Regular | ||
|
||
```jsx | ||
import { FileUploaderRegular } from "@uploadcare/react-uploader"; | ||
import {FileUploaderRegular} from "@uploadcare/react-uploader"; | ||
|
||
<FileUploaderRegular pubkey="YOUR_PUBLIC_KEY"/>; | ||
``` | ||
|
||
### Inline | ||
|
||
```jsx | ||
import {FileUploaderInline} from "@uploadcare/react-uploader"; | ||
|
||
<FileUploaderInline pubkey="YOUR_PUBLIC_KEY"/>; | ||
``` | ||
|
||
### Minimal | ||
|
||
```jsx | ||
import {FileUploaderMinimal} from "@uploadcare/react-uploader"; | ||
|
||
<FileUploaderMinimal pubkey="YOUR_PUBLIC_KEY"/>; | ||
``` | ||
|
||
## Props API | ||
|
||
An easy way to connect React-Uploader to your project and utilize the available API props. | ||
We provide a full set of props that are used in blocks. For review we suggest you to look at | ||
the [documentation](uc-docs-file-uploader-options). | ||
|
||
## Styles | ||
|
||
You can customize the appearance of the React uploader using the className prop, which allows you to add custom CSS | ||
classes to the uploader `FileUploader[Regular | Minimal | Inline]` wrapper. | ||
|
||
```jsx | ||
import {FileUploaderRegular} from "@uploadcare/react-uploader"; | ||
|
||
<FileUploaderRegular className="fileUploaderWrapper" pubkey="YOUR_PUBLIC_KEY"/>; | ||
``` | ||
|
||
```css | ||
.fileUploaderWrapper lr-file-uploader-regular { | ||
} | ||
``` | ||
|
||
## File Uploader API | ||
|
||
It is possible to get ref on UploadCtxProvider via `ref`. In this way it is possible to additional uploader management | ||
methods. | ||
For convenience, we provide the ability to access the File Uploader API using `refUploadCtxProvider`. | ||
You can see what methods are available in `refUploadCtxProvider` in the [documentation][uc-docs-file-uploader-api]. | ||
It is important to note that we now pass all InstanceType from UploadCtxProvider. | ||
|
||
```jsx | ||
import React, { useRef } from "react"; | ||
import React, {useRef, useEffect} from "react"; | ||
import { | ||
FileUploaderRegular, | ||
UploadCtxProvider | ||
} from "@uploadcare/react-uploader"; | ||
|
||
const uploaderRef = useRef<InstanceType<UploadCtxProvider> | null>(null); | ||
const Example = () => { | ||
const uploaderRef = useRef < InstanceType < UploadCtxProvider > | null > (null); | ||
|
||
<FileUploaderRegular refUploadCtxProvider={uploaderRef} pubkey="YOUR_PUBLIC_KEY"/>; | ||
|
||
<FileUploaderRegular refUploadCtxProvider={uploaderRef} pubkey="YOUR_PUBLIC_KEY"/>; | ||
} | ||
``` | ||
|
||
## Events | ||
|
@@ -57,7 +133,7 @@ The principle of converting events from blocks to React Uploader: | |
Example: | ||
|
||
```jsx | ||
import { FileUploaderRegular } from "@uploadcare/react-uploader"; | ||
import {FileUploaderRegular} from "@uploadcare/react-uploader"; | ||
|
||
<FileUploaderRegular | ||
pubkey="YOUR_PUBLIC_KEY" | ||
|
@@ -109,12 +185,23 @@ request at [[email protected]][uc-email-hello]. | |
[uc-email-hello]: mailto:[email protected] | ||
|
||
[badge-stack-img]: https://img.shields.io/badge/tech-stack-0690fa.svg?style=flat | ||
|
||
[badge-stack-url]: https://stackshare.io/uploadcare/stacks/ | ||
|
||
[badge-release-img]: https://img.shields.io/github/release/uploadcare/react-components.svg | ||
|
||
[badge-release-url]: https://github.com/uploadcare/react-components/releases | ||
|
||
[npm-img]: http://img.shields.io/npm/v/@uploadcare/react-uploader.svg | ||
|
||
[npm-url]: https://www.npmjs.com/package/@uploadcare/react-uploader | ||
|
||
[badge-build]: https://github.com/uploadcare/react-components/actions/workflows/checks.yml/badge.svg | ||
|
||
[build-url]: https://github.com/uploadcare/react-components/actions/workflows/checks.yml | ||
|
||
[uc-docs-events]: https://uploadcare.com/docs/file-uploader/events/ | ||
|
||
[uc-docs-file-uploader-api]: https://uploadcare.com/docs/file-uploader/api | ||
|
||
[uc-docs-file-uploader-options]: https://uploadcare.com/docs/file-uploader/options/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { version, name } from "../../package.json"; | ||
|
||
export const getUserAgentIntegration = (pubkey: string) => { | ||
return `${name}/${version}/${pubkey} (JavaScript; React;)`; | ||
}; |