Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
246eab9
sample app added
brauliodiez Mar 19, 2019
466dd45
work in progress hoc
brauliodiez Mar 19, 2019
87b6010
work in progress
brauliodiez Mar 19, 2019
3933278
peer dependecy added not working yet
brauliodiez Mar 19, 2019
72699b6
added alias to example to avoid having two react
brauliodiez Mar 19, 2019
e9ca9d3
config updated
brauliodiez Mar 20, 2019
2b1de3d
refactor config and added delay pending check
brauliodiez Mar 20, 2019
f4a8b88
cleaning up code
brauliodiez Mar 20, 2019
cf64578
update remove boolean explicit comparison
brauliodiez Mar 21, 2019
81a3ac5
fix existings hoc specs
nasdan Mar 21, 2019
fe82a6d
fix typo
nasdan Mar 21, 2019
c589cee
examples uploaded, not working
brauliodiez Mar 21, 2019
3c8d32d
add specs simulating progress with event emitter
nasdan Mar 21, 2019
2b74aee
Added delay specs. not working yet
nasdan Mar 22, 2019
189bbed
Fix autoclrf
nasdan Mar 22, 2019
65c66d5
sample areas working
brauliodiez Mar 22, 2019
ca01439
delay param fixed
brauliodiez Mar 22, 2019
e45f6b4
added comments
brauliodiez Mar 22, 2019
9d2110e
fixed config
brauliodiez Mar 22, 2019
2b80613
initial load plus fixes
brauliodiez Mar 22, 2019
82d51ed
Merge branch '#45-hooks-implementation' into v2/testing-hooks
brauliodiez Mar 23, 2019
e23fdd8
Merge pull request #46 from Lemoncode/v2/testing-hooks
brauliodiez Mar 23, 2019
8fc6fd0
starting hooks testing
brauliodiez Mar 23, 2019
877c472
testing timeout, almost there
brauliodiez Mar 24, 2019
95cda42
test passing but warning
brauliodiez Mar 24, 2019
d76dd61
timeout cases covered but got act warning
brauliodiez Mar 24, 2019
8ccf1b9
refactored setupconfig
brauliodiez Mar 26, 2019
31a5481
hoc testing passing
brauliodiez Mar 26, 2019
9e3f46f
HOC sample completed
brauliodiez Mar 26, 2019
df64fc2
rename example to examples
brauliodiez Mar 26, 2019
94a66f5
typescript work in progress
brauliodiez Mar 26, 2019
1e18e94
fix setupConfig
brauliodiez Mar 27, 2019
c14e1d5
fixed track promise
brauliodiez Mar 27, 2019
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
50 changes: 33 additions & 17 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Jest single run",
"program": "${workspaceRoot}/node_modules/jest/bin/jest.js",
"args": [
"--verbose",
"-i"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
]
}

{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Jest single run",
"program": "${workspaceRoot}/node_modules/jest/bin/jest.js",
"args": [
"--verbose",
"-i",
"--no-cache"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
{
"type": "node",
"request": "launch",
"name": "Jest watch run",
"program": "${workspaceRoot}/node_modules/jest/bin/jest.js",
"args": [
"--verbose",
"-i",
"--no-cache",
"--watchAll"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}
11 changes: 11 additions & 0 deletions examples/00-example-basic/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"presets": [
"@babel/preset-react",
[
"@babel/preset-env",
{
"useBuiltIns": "entry"
}
]
]
}
34 changes: 34 additions & 0 deletions examples/00-example-basic/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "webpack-by-example",
"version": "1.0.0",
"description": "In this sample we are going to setup a web project that can be easily managed\r by webpack.",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server --mode development --open",
"build": "rimraf dist && webpack --mode development",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.4.0",
"@babel/preset-env": "^7.4.0",
"@babel/preset-react": "^7.0.0",
"babel-loader": "^8.0.5",
"css-loader": "^2.1.1",
"html-webpack-plugin": "^3.2.0",
"mini-css-extract-plugin": "^0.5.0",
"rimraf": "^2.6.3",
"style-loader": "^0.23.1",
"webpack": "^4.29.6",
"webpack-cli": "^3.3.0",
"webpack-dev-server": "^3.2.1"
},
"dependencies": {
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react-loader-spinner": "^2.3.0",
"react-promise-tracker": "file:../../"
}
}
12 changes: 12 additions & 0 deletions examples/00-example-basic/src/api/fetch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export const fetchWithDelay = (url) => {
const promise = new Promise((resolve, reject) => {
setTimeout(() => {
resolve(fetch(url, {
method: 'GET',
})
.then((response) => response.json()));
}, 3000)
});

return promise;
}
9 changes: 9 additions & 0 deletions examples/00-example-basic/src/api/postAPI.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { fetchWithDelay } from './fetch';
const url = 'https://jsonplaceholder.typicode.com/posts';

const fetchPosts = () => fetchWithDelay(url)
.then((posts) => posts.slice(0, 10));

export const postAPI = {
fetchPosts,
};
8 changes: 8 additions & 0 deletions examples/00-example-basic/src/api/userAPI.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { fetchWithDelay } from './fetch';
const url = 'https://jsonplaceholder.typicode.com/users';

const fetchUsers = () => fetchWithDelay(url);

export const userAPI = {
fetchUsers,
};
11 changes: 11 additions & 0 deletions examples/00-example-basic/src/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.tables {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
}

.tables > div {
flex-basis: 50%;
margin-left: 1rem;
margin-right: 1rem;
}
59 changes: 59 additions & 0 deletions examples/00-example-basic/src/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React, { Component } from 'react';
import { trackPromise } from 'react-promise-tracker';
import { userAPI } from './api/userAPI';
import { postAPI } from './api/postAPI';
import { UserTable, PostTable, LoadButton } from './components';
import './app.css';

export class App extends Component {
constructor() {
super();

this.state = {
users: [],
posts: [],
};

this.onLoadTables = this.onLoadTables.bind(this);
}

onLoadTables() {
this.setState({
users: [],
posts: [],
});

trackPromise(
userAPI.fetchUsers()
.then((users) => {
this.setState({
users,
})
})
);

trackPromise(
postAPI.fetchPosts()
.then((posts) => {
this.setState({
posts,
})
})
);
}

render() {
return (
<div>
<LoadButton
onLoad={this.onLoadTables}
title="Load tables with delay"
/>
<div className="tables">
<UserTable users={this.state.users} />
<PostTable posts={this.state.posts} />
</div>
</div>
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './spinner';
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.spinner {
width: 100%;
height: 100%;
}

.spinner > div {
display: flex;
justify-content: center;
align-items: center;
}
30 changes: 30 additions & 0 deletions examples/00-example-basic/src/common/components/spinner/spinner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from "react";
import { usePromiseTracker } from "react-promise-tracker";
import Loader from "react-loader-spinner";
import "./spinner.css";

export const Spinner = (props) => {
const { promiseInProgress } = usePromiseTracker();

return (
promiseInProgress && (
<div className="spinner">
<Loader type="ThreeDots" color="#2BAD60" height="100" width="100" />
</div>
)
);
};

/*
export const Spinner = () => {
const { promiseInProgress } = usePromiseTracker();

return (
<>
promiseInProgress &&
<div className="spinner">
<Loader type="ThreeDots" color="#2BAD60" height="100" width="100" />
</div>
</>
);
};*/
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './table'
27 changes: 27 additions & 0 deletions examples/00-example-basic/src/common/components/table/table.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.title {
color: #000;
}

.table {
width: 100%;
max-width: 100%;
margin-bottom: 1rem;
background-color: transparent;
border-collapse: collapse;
}

.table thead th {
vertical-align: bottom;
border-bottom: 2px solid #248f4f;
}

.table td, .table th {
text-align: inherit;
padding: .75rem;
vertical-align: top;
border-top: 1px solid #248f4f;
}

.table tbody tr:nth-of-type(odd) {
background-color: rgba(43, 173, 96, .05);
}
16 changes: 16 additions & 0 deletions examples/00-example-basic/src/common/components/table/table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import './table.css';

export const Table = (props) => (
<div>
<h2 className="title">{props.title}</h2>
<table className="table">
<thead>
{props.headerRender()}
</thead>
<tbody>
{props.items.map(props.rowRender)}
</tbody>
</table>
</div>
);
3 changes: 3 additions & 0 deletions examples/00-example-basic/src/components/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './userTable';
export * from './postTable';
export * from './loadButton';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './loadButton';
26 changes: 26 additions & 0 deletions examples/00-example-basic/src/components/loadButton/loadButton.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.load-button {
cursor: pointer;
margin: 1rem;
color: #fff;
text-shadow: 1px 1px 0 #888;
background-color: #2BAD60;
border-color: #14522d;
display: inline-block;
font-weight: 400;
text-align: center;
white-space: nowrap;
vertical-align: middle;
border: 1px solid transparent;
padding: .375rem .75rem;
font-size: 1rem;
line-height: 1.5;
border-radius: .25rem;
outline: none;
}



.load-button:hover {
background-color: #248f4f;
border-color: #1e7b43;
}
11 changes: 11 additions & 0 deletions examples/00-example-basic/src/components/loadButton/loadButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';
import './loadButton.css';

export const LoadButton = (props) => (
<button
className="load-button"
onClick={props.onLoad}
>
{props.title}
</button>
);
9 changes: 9 additions & 0 deletions examples/00-example-basic/src/components/postTable/header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';

export const Header = (props) => (
<tr>
<th>Id</th>
<th>Title</th>
<th>Body</th>
</tr>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './table';
15 changes: 15 additions & 0 deletions examples/00-example-basic/src/components/postTable/row.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';

export const Row = (post) => (
<tr key={post.id}>
<td>
<span>{post.id}</span>
</td>
<td>
<span>{post.title}</span>
</td>
<td>
<span>{post.body}</span>
</td>
</tr>
);
13 changes: 13 additions & 0 deletions examples/00-example-basic/src/components/postTable/table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React, { Component } from 'react';
import { Table } from '../../common/components/table';
import { Header } from './header';
import { Row } from './row';

export const PostTable = (props) => (
<Table
title="Posts"
items={props.posts}
headerRender={Header}
rowRender={Row}
/>
);
Loading