Skip to content

Commit 0814603

Browse files
committed
Use ts-react-toolbox
1 parent 3774e71 commit 0814603

File tree

12 files changed

+4278
-1253
lines changed

12 files changed

+4278
-1253
lines changed

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8.5.0

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
language: node_js
2+
node_js:
3+
- '8'
4+
cache: yarn
5+
script:
6+
- yarn
7+
- yarn test:ci
8+
notifications:
9+
email: false

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# react-preview-file
1+
# react-preview-file [![Build Status](https://travis-ci.org/zzarcon/react-preview-file.svg?branch=master)](https://travis-ci.org/zzarcon/react-preview-file)
22
> Efficient way of rendering an image preview from a File
33
44
# Installation

custom-typings/.gitkeep

Whitespace-only changes.

custom-typings/atlaskit.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module '@atlaskit/*';

example/app.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import * as React from 'react';
22
import {Component} from 'react';
3+
import {GHCorner} from 'react-gh-corner';
34
import FilePreview from '../src';
5+
import { AppWrapper } from './styled';
46

57
export interface AppState {
68
isPreviewVisible: boolean;
79
file?: File;
810
}
911

12+
const repoUrl = 'https://github.com/zzarcon/react-preview-file';
13+
1014
export default class App extends Component <{}, AppState> {
1115
state: AppState = {
1216
isPreviewVisible: true
@@ -38,12 +42,13 @@ export default class App extends Component <{}, AppState> {
3842

3943
render() {
4044
return (
41-
<div>
45+
<AppWrapper>
46+
<GHCorner openInNewTab href={repoUrl} />
4247
<input id="browse" type="file" onChange={this.onChange} />
4348
<button onClick={this.onToggle}>Toggle image</button>
4449
<br/>
4550
{this.renderPreview()}
46-
</div>
51+
</AppWrapper>
4752
)
4853
}
4954
}

example/assets/.gitkeep

Whitespace-only changes.

example/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8">
5-
<title>React File Preview</title>
5+
<title>React preview file</title>
66
</head>
77
<body>
88
<div id="app"></div>
9-
<script src="../index.js"></script>
9+
<script src="../example-bundle.js"></script>
1010
</body>
1111
</html>

example/styled.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import styled, {injectGlobal} from 'styled-components';
2+
3+
injectGlobal`
4+
body {
5+
font-family: Helvetica;
6+
background-color: #D8D1F5;
7+
}
8+
9+
* {
10+
box-sizing: content-box;
11+
}
12+
`;
13+
14+
export const AppWrapper = styled.div`
15+
background: white;
16+
padding: 20px;
17+
border-radius: 3px;
18+
width: 600px;
19+
margin: 20px auto;
20+
`;

example/utils.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import {Component} from 'react';
2+
3+
export class ToolboxApp<P, S> extends Component<P, S> {
4+
onCheckboxChange = (propName: any) => () => {
5+
const currentValue = (this.state as any)[propName];
6+
this.setState({ [propName]: !currentValue } as any);
7+
}
8+
9+
onFieldTextChange = (propName: any) => (e: any) => {
10+
const value = e.target.value;
11+
12+
(this as any).setState({
13+
[propName]: value
14+
});
15+
}
16+
}

package.json

Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,38 @@
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
77
"scripts": {
8-
"start": "webpack -w",
9-
"dev": "webpack-dev-server",
10-
"test": "jest",
11-
"test:ci": "jest --runInBand --coverage",
12-
"build": "NODE_ENV=production tsc -p ./tsconfig.prod.json",
13-
"release": "npm version patch && git push --tags && git push && npm publish",
14-
"prepublishOnly": "yarn test:ci && yarn build"
8+
"dev": "ts-react-toolbox dev",
9+
"test": "ts-react-toolbox test",
10+
"test:ci": "ts-react-toolbox test --runInBand --coverage",
11+
"build": "ts-react-toolbox build",
12+
"release": "ts-react-toolbox release",
13+
"bootstrap": "ts-react-toolbox init",
14+
"lint": "ts-react-toolbox lint",
15+
"static": "ts-react-toolbox publish",
16+
"format": "ts-react-toolbox format",
17+
"analyze": "ts-react-toolbox analyze"
1518
},
16-
"jest": {
17-
"moduleFileExtensions": [
18-
"ts",
19-
"tsx",
20-
"js"
21-
],
22-
"setupTestFrameworkScriptFile": "<rootDir>/setupTests.js",
23-
"transform": {
24-
"^.+\\.(ts|tsx)$": "<rootDir>/preprocessor.js"
25-
},
26-
"testMatch": [
27-
"**/__tests__/*.(ts|tsx)"
28-
],
29-
"resetMocks": true
30-
},
31-
"repository": "[email protected]:zzarcon/react-preview-file.git",
19+
"repository": "https://github.com/zzarcon/react-preview-file",
3220
"author": "Hector Leon Zarco Garcia <[email protected]>",
3321
"license": "MIT",
3422
"peerDependencies": {
35-
"react": "^16.2.0"
23+
"react": "^16.3.0"
3624
},
3725
"devDependencies": {
38-
"@types/enzyme": "^3.1.9",
39-
"@types/jest": "^22.1.4",
40-
"@types/react": "^16.0.40",
41-
"@types/react-dom": "^16.0.4",
42-
"awesome-typescript-loader": "^3.4.1",
43-
"enzyme": "^3.3.0",
44-
"enzyme-adapter-react-16": "^1.1.1",
45-
"jest": "^22.4.2",
46-
"react": "^16.2.0",
47-
"react-dom": "^16.2.0",
48-
"typescript": "^2.7.2",
49-
"webpack": "^3.10.0",
50-
"webpack-dev-server": "^2.11.1"
51-
}
52-
}
26+
"ts-react-toolbox": "^0.1.16"
27+
},
28+
"engines": {
29+
"node": ">=8.5.0"
30+
},
31+
"files": [
32+
"dist"
33+
],
34+
"keywords": [
35+
"react",
36+
"file",
37+
"preview",
38+
"image",
39+
"filereader",
40+
"createobjecturl"
41+
]
42+
}

0 commit comments

Comments
 (0)