-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
16,314 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
"targets": { | ||
"browsers": [ | ||
"last 2 versions", | ||
"safari >= 7" | ||
] | ||
} | ||
} | ||
], | ||
"@babel/preset-react", | ||
"@babel/preset-flow" | ||
], | ||
"plugins": [ | ||
"@babel/plugin-transform-runtime", | ||
"@babel/plugin-proposal-class-properties" | ||
] | ||
} | ||
|
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,82 @@ | ||
[ignore] | ||
.*/examples/.* | ||
.*/__tests__/.* | ||
.*.svg | ||
.*/scripts/.* | ||
.*/build/.* | ||
.*/packages/webiny-ui_LEGACY/.* | ||
|
||
[include] | ||
.*/node_modules/.* | ||
[libs] | ||
packages/webiny-api/flow-typed/npm | ||
[lints] | ||
[options] | ||
esproposal.class_static_fields=enable | ||
module.file_ext=.js | ||
module.file_ext=.jsx | ||
module.file_ext=.mjs | ||
module.file_ext=.md | ||
module.system.node.resolve_dirname=node_modules | ||
module.name_mapper='.*\.svg' -> 'empty/object' | ||
module.name_mapper='.*\.scss' -> 'empty/object' | ||
module.name_mapper='^webiny-\(.*\)/types$' -> '<PROJECT_ROOT>/packages/webiny-\1/types.js' | ||
module.name_mapper='^webiny-api/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-api/src/\1' | ||
module.name_mapper='^webiny-api-cms/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-api-cms/src/\1' | ||
module.name_mapper='^webiny-app/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-app/src/\1' | ||
module.name_mapper='^webiny-app-admin/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-app-admin/src/\1' | ||
module.name_mapper='^webiny-app-cms/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-app-cms/src/\1' | ||
module.name_mapper='^webiny-cms-editor/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-cms-editor/src/\1' | ||
module.name_mapper='^webiny-ui/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-ui/src/\1' | ||
module.name_mapper='^webiny-compose/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-compose/src/\1' | ||
module.name_mapper='^webiny-data-extractor/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-data-extractor/src/\1' | ||
module.name_mapper='^webiny-entity-memory/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-entity-memory/src/\1' | ||
module.name_mapper='^webiny-entity-mysql/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-entity-mysql/src/\1' | ||
module.name_mapper='^webiny-entity/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-entity/src/\1' | ||
module.name_mapper='^webiny-file-storage-local/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-file-storage-local/src/\1' | ||
module.name_mapper='^webiny-file-storage-s3/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-file-storage-s3/src/\1' | ||
module.name_mapper='^webiny-file-storage/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-file-storage/src/\1' | ||
module.name_mapper='^webiny-form/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-form/src/\1' | ||
module.name_mapper='^webiny-i18n-react/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-i18n-react/src/\1' | ||
module.name_mapper='^webiny-i18n/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-i18n/src/\1' | ||
module.name_mapper='^webiny-jimp/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-jimp/src/\1' | ||
module.name_mapper='^webiny-load-assets/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-load-assets/src/\1' | ||
module.name_mapper='^webiny-model/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-model/src/\1' | ||
module.name_mapper='^webiny-mysql-connection/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-mysql-connection/src/\1' | ||
module.name_mapper='^webiny-plugins/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-plugins/src/\1' | ||
module.name_mapper='^webiny-react-router/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-react-router/src/\1' | ||
module.name_mapper='^webiny-service-manager/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-service-manager/src/\1' | ||
module.name_mapper='^webiny-sql-table-mysql/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-sql-table-mysql/src/\1' | ||
module.name_mapper='^webiny-sql-table-sync/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-sql-table-sync/src/\1' | ||
module.name_mapper='^webiny-sql-table/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-sql-table/src/\1' | ||
module.name_mapper='^webiny-storybook-utils/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-storybook-utils/src/\1' | ||
module.name_mapper='^webiny-validation/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-validation/src/\1' | ||
|
||
[strict] | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
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,2 @@ | ||
* text=auto | ||
*.js text eol=lf |
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,13 @@ | ||
.idea | ||
.webpack | ||
.serverless | ||
.env | ||
.npmrc | ||
npm-debug.log | ||
node_modules | ||
.DS_Store | ||
coverage | ||
yarn-error.log | ||
dist/ | ||
storybook-static/ | ||
.changelog |
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 @@ | ||
module.exports = { | ||
printWidth: 100, | ||
parser: "babylon", | ||
tabWidth: 4 | ||
}; |
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 @@ | ||
import '@storybook/addon-knobs/register'; |
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,9 @@ | ||
import { configure } from '@storybook/react'; | ||
|
||
// automatically import all files ending in *.stories.js | ||
const req = require.context('../stories', true, /.stories.js$/); | ||
function loadStories() { | ||
req.keys().forEach(filename => req(filename)); | ||
} | ||
|
||
configure(loadStories, module); |
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,21 @@ | ||
// you can use this file to add your custom webpack plugins, loaders and anything you like. | ||
// This is just the basic way to add additional webpack configurations. | ||
// For more information refer the docs: https://storybook.js.org/configurations/custom-webpack-config | ||
|
||
// IMPORTANT | ||
// When you add this file, we won't add the default configurations which is similar | ||
// to "React Create App". This only has babel loader to load JavaScript. | ||
|
||
module.exports = { | ||
plugins: [ | ||
// your custom plugins | ||
], | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/, | ||
use: ["style-loader", "css-loader"] | ||
} | ||
] | ||
} | ||
}; |
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,22 @@ | ||
sudo: false | ||
language: node_js | ||
node_js: 8 | ||
|
||
cache: | ||
directories: | ||
- ~/.npm | ||
- ~/.cache | ||
|
||
notifications: | ||
email: false | ||
|
||
jobs: | ||
include: | ||
- stage: release | ||
node_js: lts/* | ||
script: npm run test:ci | ||
deploy: | ||
provider: script | ||
skip_cleanup: true | ||
script: | ||
- npm run release |
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 |
---|---|---|
@@ -1,2 +1,85 @@ | ||
# react-butterfiles | ||
Component for building file fields - from basic file inputs to drag and drop image galleries. | ||
# react-browse-files | ||
|
||
<p align="center"> | ||
<a href="https://travis-ci.org/adrian1358/react-browse-files.svg?branch=master"> | ||
<img alt="Build Status" src="https://travis-ci.org/adrian1358/react-browse-files.svg?branch=master"> | ||
</a> | ||
|
||
<img alt="Build Status" src="https://img.shields.io/npm/dw/react-browse-files.svg"> | ||
<img alt="Build Status" src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square"> | ||
<img alt="Build Status" src="https://img.shields.io/npm/types/react-browse-files.svg"> | ||
|
||
</p> | ||
|
||
A small component for building file upload fields of any type, for example a simple file upload button or | ||
an image gallery field with drag and drop support and preview of selected images. | ||
|
||
## Install | ||
``` | ||
npm install --save react-browse-files | ||
``` | ||
|
||
Or if you prefer yarn: | ||
``` | ||
yarn add react-browse-files | ||
``` | ||
|
||
## Quick Example: | ||
Create a simple upload button that accepts multiple PDF files (max 2MB per file / max 10MB for the whole selection). | ||
|
||
```javascript | ||
import BrowseFiles from "react-browse-files"; | ||
``` | ||
|
||
```javascript | ||
<BrowseFiles | ||
multiple={true} | ||
maxSize="2mb" | ||
multipleMaxSize="10mb" | ||
accept={["application/pdf","image/jpg","image/jpeg"]} | ||
onSuccess={files => this.setState({ files })} | ||
onError={errors => this.setState({ errors })} | ||
> | ||
{({ browseFiles }) => ( | ||
<> | ||
<button onClick={browseFiles}>Upload PDF</button> | ||
<ol> | ||
{this.state.files.map(file => ( | ||
<li key={file.name}>{file.name}</li> | ||
))} | ||
{this.state.errors.map(error => ( | ||
<li key={error.file.name}> | ||
{error.file.name} - {error.type} | ||
</li> | ||
))} | ||
</ol> | ||
</> | ||
)} | ||
</BrowseFiles> | ||
``` | ||
|
||
More examples on https://react-browse-files.netlify.com. | ||
|
||
## Props | ||
|
||
Component takes the following props: | ||
|
||
|
||
| Prop | Type | Default | Description | | ||
| :------------------ | :-------------------------------------- | :-------- | :-------------------------------------------------------------------------------------------------------------------- | | ||
| `accept` | `array` | `[]` | Defines which file types will be accepted. Example: `["application/pdf"]`. | | ||
| `multiple` | `boolean` | `false` | Allow multiple file selection by setting this prop to `true. | | ||
| `maxFileSize` | `string` | `"2mb"` | Defines maximum file size (bytes lib used behind the scenes). Example: `"10mb"` | | ||
| `multipleMaxFileSize` | `string` | `"10mb"` | Useful only if `multiple` prop is set to `true. Defines maximum file size of all selected files. | | ||
| `convertToBase64` | `boolean` | `false` | If `true`, selected files will also be converted to baser64 format (useful when working with images / thumbnails). | | ||
| `onSuccess` | `(files: Array<BrowseFilesFile>) => void` | `undefined` | Callback that will get executed once a valid file selection has been made (via browse files dialog or drag and drop). | | ||
| `onError` | `(errors: Array<FileError>) => void` | `undefined` | Callback that will get executed once an invalid file selection has been made. More info about possible errors below. | | ||
|
||
## Selection error types | ||
|
||
| Type | Description | ||
| :------------------ | :------------------- | ||
| `unsupportedFileType` | This can only happen via drag and drop since file browser dialog won't let users choose files of invalid type. | ||
| `maxSizeExceeded` | File size is greater than `maxFileSize` value. | ||
| `multipleMaxFileSize` | File size is greater than `maxFileSize` value. | ||
| `multipleNotAllowed` | This can only happen via drag and drop since file browser dialog won't let users choose files of invalid type. |
Oops, something went wrong.