Skip to content
This repository was archived by the owner on Jan 11, 2024. It is now read-only.

Commit 42ee22e

Browse files
authored
Merge pull request #1 from canopas/single-file-upload
Implement single file upload management
2 parents fb7b976 + d51b83a commit 42ee22e

39 files changed

+5169
-1
lines changed

.eslintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "next/core-web-vitals"
3+
}

.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
.yarn/install-state.gz
8+
9+
# testing
10+
/coverage
11+
12+
# next.js
13+
/.next/
14+
/out/
15+
/dist
16+
17+
# production
18+
/build
19+
20+
# misc
21+
.DS_Store
22+
*.pem
23+
24+
# debug
25+
npm-debug.log*
26+
yarn-debug.log*
27+
yarn-error.log*
28+
29+
# local env files
30+
.env*.local
31+
32+
.vscode/*
33+
34+
# vercel
35+
.vercel
36+
37+
# typescript
38+
*.tsbuildinfo
39+
next-env.d.ts
40+
41+
src/app/style.scss

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Canopas
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 268 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,268 @@
1-
# react-file-upload
1+
# File Management with Preview - Fully Customized
2+
3+
A versatile and user-friendly file management system built with React, Next.js and TypeScript that allows for single and multiple file uploading with a preview feature. It allows you to select files and preview them, returning an array of selected files. It allows customizing design by overriding the style classes.
4+
5+
<img src="./gifs/full.gif"/>
6+
7+
Checkout the live demo on, codesandbox <br />
8+
[![codesandbox.io](https://codesandbox.io/favicon.ico)](https://codesandbox.io/p/sandbox/cranky-breeze-r4hht7?file=%2Fsrc%2Fmain.js)
9+
10+
---
11+
12+
## Table of Contents
13+
14+
- [Features](#features)
15+
- [Getting Started](#getting-started)
16+
- [Prerequisites](#prerequisites)
17+
- [Installation](#installation)
18+
- [Examples](#examples)
19+
- [Canvas View](#canvas-view)
20+
- [Square View](#square-view)
21+
- [Horizontal Long Square View](#horizontal-long-square-view)
22+
- [Circular View](#circular-view)
23+
- [Over-ride CSS](#over-ride-css)
24+
- [Properties and Events](#properties-and-events)
25+
- [Usage](#usage)
26+
- [Contributing](#contributing)
27+
- [License](#license)
28+
- [Contact Information](#contact-information)
29+
30+
---
31+
32+
## Features
33+
34+
- **Single File Upload:** Users can upload or change a single file.
35+
- **Multiple File Management:** Easily manage multiple files.
36+
- **File Preview:** Provides a preview of uploaded files (e.g., images, videos, gifs).
37+
- **Responsive Design:** Ensures a seamless experience on various devices.
38+
- **Fully customized:** Customize file upload UI as per your requirements
39+
40+
---
41+
42+
## Getting Started
43+
44+
Follow below instructions to configure this package into your project.
45+
46+
### Prerequisites
47+
48+
Before you begin, make sure you have the following software installed:
49+
50+
- [Node.js](https://nodejs.org/) - v20.x
51+
- React with Next.js
52+
- sass
53+
54+
### Installation
55+
56+
Using npm:
57+
58+
```
59+
npm install @canopassoftware/vue-file-upload
60+
```
61+
62+
Using yarn:
63+
64+
```
65+
yarn add @canopassoftware/vue-file-upload
66+
```
67+
68+
---
69+
70+
## Examples
71+
72+
We are providing some examples with design. so, you can easily use it in your project.
73+
74+
### Canvas View
75+
76+
[view code](./examples/CanvasView.vue)
77+
78+
<img src="./gifs/canvas-view.gif"/>
79+
80+
### Square View
81+
82+
[view code](./examples/SquareView.vue)
83+
84+
<img src="./gifs/square-view.gif"/>
85+
86+
### Horizontal Long Square View
87+
88+
[view code](./examples/LongSquareView.vue)
89+
90+
<img src="./gifs/long-square-view.gif"/>
91+
92+
### Circular View
93+
94+
[view code](./examples/RoundView.vue)
95+
96+
<img src="./gifs/round-view.gif"/>
97+
98+
### Over-ride CSS
99+
100+
For over-riding the design of default buttons, you can over-ride it's CSS by class name. <br>
101+
For example., <br>
102+
103+
- Over-ride CSS of remove file button you can add it like,
104+
105+
```css
106+
.remove-btn {
107+
color: white;
108+
background-color: red;
109+
font-size: 25px;
110+
padding: 5px;
111+
}
112+
```
113+
114+
- Over-ride CSS of submit/upload file button you can add it like,
115+
116+
```css
117+
.upload-btn {
118+
color: white;
119+
background-color: rgb(51, 65, 85);
120+
font-size: 25px;
121+
padding: 5px 10px;
122+
}
123+
```
124+
125+
---
126+
127+
## Properties and Events
128+
129+
### props
130+
131+
- **callback="handleFileUploading"**
132+
133+
- `required`
134+
- **Description:** Add your upload callback function while receive the selected file/files
135+
136+
- **uploadedFile="setPreviewFileData"** - For single file component
137+
138+
- `required`
139+
- Uploaded file object with below format,
140+
```
141+
{
142+
fileType: string,
143+
fileUrl: string,
144+
fileName: string
145+
}
146+
```
147+
148+
- **uploadedFiles="setPreviewFilesData"** - For multiple file component
149+
150+
- `required`
151+
- Uploaded files array with below format,
152+
```
153+
[
154+
{
155+
fileType: string,
156+
fileUrl: string,
157+
fileName: string
158+
}
159+
]
160+
```
161+
162+
- **uploadBtnText="'Upload'"**
163+
164+
- **default** : Upload
165+
- Text for save or upload file button
166+
167+
- **progressBtnText="'Uploading...'"**
168+
169+
- **default** : Uploading...
170+
- Text for the progress bar, showing file uploading under the process
171+
172+
- **removeBtnText="'Uploading...'"**
173+
174+
- **default** : x
175+
- Text for remove file button
176+
177+
- **accept="'image/jpg, image/jpeg, image/png, video/mp4, audio/mp3, application/zip'"**
178+
179+
- Validation for file type. By default it will select all the type of file.
180+
181+
- **(filetype)Preview="'(file location)'"**
182+
- **default** : Default file icons as per file types
183+
- Set path for your customized icon if needed
184+
185+
---
186+
187+
## Usage
188+
189+
To manage and preview files with this library, follow these steps:
190+
191+
### Import the library into your file
192+
193+
```js
194+
// using CommonJS
195+
const { SingleFileUpload, MultipleFileUpload } = require("@canopassoftware/vue-file-upload");
196+
197+
OR
198+
// using esModules
199+
import { SingleFileUpload, MultipleFileUpload } from "@canopassoftware/vue-file-upload";
200+
```
201+
202+
### Creating custom UI with file preview
203+
204+
- You can customize file uploading UI in inner part of component.
205+
206+
### Single File Upload Management
207+
208+
```js
209+
"use client";
210+
211+
import Image from "next/image";
212+
import React, { useState } from "react";
213+
import { SingleFileUpload } from '@canopassoftware/vue-file-upload';
214+
215+
export default function App() {
216+
const [previewFileData, setPreviewFileData] = useState(
217+
{} as {
218+
previewType: string;
219+
previewUrl: string | ArrayBuffer | null;
220+
previewName: string;
221+
isDragging: boolean;
222+
}
223+
);
224+
225+
const handleFileUploading = async (file: any) => {
226+
await new Promise((resolve) => setTimeout(resolve, 2000));
227+
setPreviewFileData({
228+
previewType: "image",
229+
previewUrl: "https://picsum.photos/300/224",
230+
previewName: file.name,
231+
isDragging: false,
232+
});
233+
};
234+
```
235+
236+
```html
237+
return (
238+
<main className="min-h-screen flex flex-col justify-between p-5">
239+
<SingleFileUpload
240+
uploadedFile={setPreviewFileData}
241+
callback={handleFileUploading}
242+
uploadBtn={"Save"}
243+
progressBtn={"Saving..."}
244+
>
245+
</SingleFileUpload>
246+
</main>
247+
);
248+
}
249+
```
250+
251+
## Contributing
252+
253+
We welcome contributions from the community. To contribute to this project, please follow these guidelines:
254+
255+
- Fork the repository.
256+
- Create a new branch for your feature or bug fix.
257+
- Make your changes and commit them.
258+
- Push your changes to your fork.
259+
- Submit a pull request with a clear description of your changes.
260+
- Please ensure your code follows the project's coding standards and includes appropriate documentation.
261+
262+
## License
263+
264+
This project is licensed under the [MIT](https://github.com/canopas/vue-file-upload/blob/main/LICENSE).
265+
266+
## Contact Information
267+
268+
Vue file upload is owned and maintained by the [Canopas team](https://canopas.com/). You can reach out them on Github at [canopas](https://github.com/canopas) for questions or need support.

gifs/canvas-view.gif

32.2 MB
Loading

gifs/full.gif

6.64 MB
Loading

gifs/long-square-view.gif

7.35 MB
Loading

gifs/multiple-file-uploading.gif

43.1 MB
Loading

gifs/round-view.gif

28.7 MB
Loading

gifs/single-file-uploading.gif

3.85 MB
Loading

0 commit comments

Comments
 (0)