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

[WIP] feature/upload-component #7

Merged
merged 3 commits into from
Oct 29, 2018
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ yarn-error.log*
npm-debug.log*
yarn-debug.log*
yarn-error.log*
/.cache
2 changes: 1 addition & 1 deletion .storybook/config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { configure } from '@storybook/react';

// automatically import all files ending in *.stories.js
const req = require.context('../stories', true, /.stories.js$/);
const req = require.context('../src', true, /.stories.tsx$/);
function loadStories() {
req.keys().forEach(filename => req(filename));
}
Expand Down
11 changes: 11 additions & 0 deletions .storybook/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const path = require('path');
const TSDocgenPlugin = require('react-docgen-typescript-webpack-plugin');
module.exports = (baseConfig, env, defaultConfig) => {
defaultConfig.module.rules.push({
test: /\.(ts|tsx)$/,
loader: require.resolve('awesome-typescript-loader')
});
defaultConfig.plugins.push(new TSDocgenPlugin());
defaultConfig.resolve.extensions.push('.ts', '.tsx');
return defaultConfig;
};
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
"@types/react": "^16.4.18",
"@types/react-dom": "^16.0.9",
"@types/react-redux": "^6.0.9",
"@types/storybook__react": "^3.0.9",
"awesome-typescript-loader": "^5.2.1",
"babel-loader": "^8.0.4",
"react-docgen-typescript-webpack-plugin": "^1.1.0",
"redux-devtools": "^3.4.1",
"redux-devtools-extension": "^2.13.5",
"typescript": "^3.1.3"
Expand Down
1 change: 1 addition & 0 deletions src/components/upload-demo/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import '~antd/dist/antd.css';
12 changes: 12 additions & 0 deletions src/components/upload-demo/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as React from 'react';
import Upload from './index';

import { storiesOf } from '@storybook/react';

storiesOf("upload-demo", module)
.add('default', () =>
<Upload
text={'Lorem ipsum dolor sit amet'}
hint={'Fusce malesuada magna leo, quis pharetra urna finibus nec. Sed vitae ex mauris. Mauris orci ex.'}
/>
);
41 changes: 41 additions & 0 deletions src/components/upload-demo/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Icon, message, Upload } from 'antd';
import { UploadChangeParam } from 'antd/lib/upload/interface';
import * as React from 'react';
const Dragger = Upload.Dragger;
import './index.css';

interface IProps {
text: string,
hint?: string
}

export class UploadDemo extends React.PureComponent<IProps> {
private readonly properties = {
action: '//jsonplaceholder.typicode.com/posts/', // todo setup S3 or similar
multiple: true,
name: 'file',
onChange(info: UploadChangeParam) {
const status = info.file.status;
if (status === 'done') {
message.success(`${info.file.name} file uploaded successfully.`);
} else if (status === 'error') {
message.error(`${info.file.name} file upload failed.`);
}
},
}

public render() {
const { text, hint } = this.props
return (
<Dragger {...this.properties}>
<p className="ant-upload-drag-icon">
<Icon type="file" />
</p>
<p className="ant-upload-text">{ text }</p>
<p className="ant-upload-hint">{ hint }</p>
</Dragger>
)
}
}

export default UploadDemo
19 changes: 0 additions & 19 deletions stories/index.stories.js

This file was deleted.

80 changes: 73 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,17 @@
"@types/prop-types" "*"
csstype "^2.2.0"

"@types/storybook__react@^3.0.9":
version "3.0.9"
resolved "https://registry.yarnpkg.com/@types/storybook__react/-/storybook__react-3.0.9.tgz#aac193f0c037ddfc2342bd027d720553ac089a56"
dependencies:
"@types/react" "*"
"@types/webpack-env" "*"

"@types/webpack-env@*":
version "1.13.6"
resolved "http://registry.npmjs.org/@types/webpack-env/-/webpack-env-1.13.6.tgz#128d1685a7c34d31ed17010fc87d6a12c1de6976"

"@webassemblyjs/ast@1.7.8":
version "1.7.8"
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.7.8.tgz#f31f480debeef957f01b623f27eabc695fa4fe8f"
Expand Down Expand Up @@ -1230,7 +1241,7 @@ ajv@^5.0.0, ajv@^5.1.5, ajv@^5.3.0:
fast-json-stable-stringify "^2.0.0"
json-schema-traverse "^0.3.0"

ajv@^6.1.0:
ajv@^6.1.0, ajv@^6.1.1:
version "6.5.4"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.5.4.tgz#247d5274110db653706b550fcc2b797ca28cfc59"
dependencies:
Expand Down Expand Up @@ -1597,6 +1608,19 @@ autoprefixer@^9.2.0:
postcss "^7.0.5"
postcss-value-parser "^3.3.1"

awesome-typescript-loader@^5.2.1:
version "5.2.1"
resolved "https://registry.yarnpkg.com/awesome-typescript-loader/-/awesome-typescript-loader-5.2.1.tgz#a41daf7847515f4925cdbaa3075d61f289e913fc"
dependencies:
chalk "^2.4.1"
enhanced-resolve "^4.0.0"
loader-utils "^1.1.0"
lodash "^4.17.5"
micromatch "^3.1.9"
mkdirp "^0.5.1"
source-map-support "^0.5.3"
webpack-log "^1.2.0"

aws-sign2@~0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8"
Expand Down Expand Up @@ -2838,7 +2862,7 @@ chalk@1.1.3, chalk@^1.1.3:
strip-ansi "^3.0.0"
supports-color "^2.0.0"

chalk@2.4.1, chalk@^2.0.0, chalk@^2.0.1, chalk@^2.3.0, chalk@^2.4.1:
chalk@2.4.1, chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0, chalk@^2.4.1:
version "2.4.1"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e"
dependencies:
Expand Down Expand Up @@ -3921,7 +3945,7 @@ enhanced-resolve@^3.0.0, enhanced-resolve@^3.4.0:
object-assign "^4.0.1"
tapable "^0.2.7"

enhanced-resolve@^4.1.0:
enhanced-resolve@^4.0.0, enhanced-resolve@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-4.1.0.tgz#41c7e0bfdfe74ac1ffe1e57ad6a5c6c9f3742a7f"
dependencies:
Expand Down Expand Up @@ -6385,10 +6409,23 @@ lodash.uniq@^4.5.0:
version "4.17.11"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"

log-symbols@^2.1.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-2.2.0.tgz#5740e1c5d6f0dfda4ad9323b5332107ef6b4c40a"
dependencies:
chalk "^2.0.1"

loglevel@^1.4.1:
version "1.6.1"
resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.6.1.tgz#e0fc95133b6ef276cdc8887cdaf24aa6f156f8fa"

loglevelnext@^1.0.1:
version "1.0.5"
resolved "https://registry.yarnpkg.com/loglevelnext/-/loglevelnext-1.0.5.tgz#36fc4f5996d6640f539ff203ba819641680d75a2"
dependencies:
es6-symbol "^3.1.1"
object.assign "^4.1.0"

longest@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097"
Expand Down Expand Up @@ -6543,7 +6580,7 @@ micromatch@^2.1.5, micromatch@^2.3.11:
parse-glob "^3.0.4"
regex-cache "^0.4.2"

micromatch@^3.1.10, micromatch@^3.1.4, micromatch@^3.1.8:
micromatch@^3.1.10, micromatch@^3.1.4, micromatch@^3.1.8, micromatch@^3.1.9:
version "3.1.10"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23"
dependencies:
Expand Down Expand Up @@ -6960,7 +6997,7 @@ object-copy@^0.1.0:
define-property "^0.2.5"
kind-of "^3.0.3"

object-keys@^1.0.12:
object-keys@^1.0.11, object-keys@^1.0.12:
version "1.0.12"
resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.12.tgz#09c53855377575310cca62f55bb334abff7b3ed2"

Expand All @@ -6970,6 +7007,15 @@ object-visit@^1.0.0:
dependencies:
isobject "^3.0.0"

object.assign@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.0.tgz#968bf1100d7956bb3ca086f006f846b3bc4008da"
dependencies:
define-properties "^1.1.2"
function-bind "^1.1.1"
has-symbols "^1.0.0"
object-keys "^1.0.11"

object.entries@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/object.entries/-/object.entries-1.0.4.tgz#1bf9a4dd2288f5b33f3a993d257661f05d161a5f"
Expand Down Expand Up @@ -8339,6 +8385,17 @@ react-dev-utils@^6.0.5:
strip-ansi "4.0.0"
text-table "0.2.0"

react-docgen-typescript-webpack-plugin@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/react-docgen-typescript-webpack-plugin/-/react-docgen-typescript-webpack-plugin-1.1.0.tgz#4bfb8c3312fce487083924842cf03f66177ab9df"
dependencies:
ajv "^6.1.1"
react-docgen-typescript "^1.2.3"

react-docgen-typescript@^1.2.3:
version "1.11.0"
resolved "https://registry.yarnpkg.com/react-docgen-typescript/-/react-docgen-typescript-1.11.0.tgz#9836c6276ed59766b22f9dac90e3718a916f847f"

react-docgen@^3.0.0-rc.1:
version "3.0.0-rc.1"
resolved "https://registry.yarnpkg.com/react-docgen/-/react-docgen-3.0.0-rc.1.tgz#a4e33dba1454459294276afdec87ef3958167eb0"
Expand Down Expand Up @@ -9283,7 +9340,7 @@ source-map-support@^0.4.15:
dependencies:
source-map "^0.5.6"

source-map-support@^0.5.0:
source-map-support@^0.5.0, source-map-support@^0.5.3:
version "0.5.9"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.9.tgz#41bc953b2534267ea2d605bccfa7bfa3111ced5f"
dependencies:
Expand Down Expand Up @@ -10166,7 +10223,7 @@ utils-merge@1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"

uuid@^3.0.1, uuid@^3.3.2:
uuid@^3.0.1, uuid@^3.1.0, uuid@^3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131"

Expand Down Expand Up @@ -10334,6 +10391,15 @@ webpack-hot-middleware@^2.24.3:
querystring "^0.2.0"
strip-ansi "^3.0.0"

webpack-log@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/webpack-log/-/webpack-log-1.2.0.tgz#a4b34cda6b22b518dbb0ab32e567962d5c72a43d"
dependencies:
chalk "^2.1.0"
log-symbols "^2.1.0"
loglevelnext "^1.0.1"
uuid "^3.1.0"

webpack-log@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/webpack-log/-/webpack-log-2.0.0.tgz#5b7928e0637593f119d32f6227c1e0ac31e1b47f"
Expand Down