Skip to content

Commit ae15778

Browse files
committed
feat(examples): refactor examples to use CRA
1 parent c814be2 commit ae15778

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+20752
-151586
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,14 @@ That's it, You know everything to master React state management! Check some of t
185185

186186
*Beginner*
187187

188-
- [Clock Widget](https://solkimicreb.github.io/react-easy-state/examples/clock/dist) ([source](/examples/clock/)): a reusable clock widget with a tiny local state store.
189-
- [Stopwatch](https://solkimicreb.github.io/react-easy-state/examples/stopWatch/dist) ([source](/examples/stopWatch/)) ([tutorial](https://hackernoon.com/introducing-react-easy-state-1210a156fa16)): a stopwatch with a mix of normal and computed state properties.
188+
- [Clock Widget](https://solkimicreb.github.io/react-easy-state/examples/clock/build) ([source](/examples/clock/)): a reusable clock widget with a tiny local state store.
189+
- [Stopwatch](https://solkimicreb.github.io/react-easy-state/examples/stop-watch/build) ([source](/examples/stopWatch/)) ([tutorial](https://hackernoon.com/introducing-react-easy-state-1210a156fa16)): a stopwatch with a mix of normal and computed state properties.
190190

191191
*Advanced*
192192

193-
- [TodoMVC](https://solkimicreb.github.io/react-easy-state/examples/todoMVC/dist) ([source](/examples/todoMVC/)): a classic TodoMVC implementation with a lot of computed data and implicit reactivity.
194-
- [Contacts Table](https://solkimicreb.github.io/react-easy-state/examples/contacts/dist) ([source](/examples/contacts/)): a data grid implementation with a mix of global and local state.
195-
- [Beer Finder](https://solkimicreb.github.io/react-easy-state/examples/beerFinder/dist) ([source](/examples/beerFinder/)) ([tutorial](https://medium.com/@solkimicreb/design-patterns-with-react-easy-state-830b927acc7c)): an app with async actions and a mix of local and global state, which finds matching beers for your meal.
193+
- [TodoMVC](https://solkimicreb.github.io/react-easy-state/examples/todo-mvc/build) ([source](/examples/todoMVC/)): a classic TodoMVC implementation with a lot of computed data and implicit reactivity.
194+
- [Contacts Table](https://solkimicreb.github.io/react-easy-state/examples/contacts/build) ([source](/examples/contacts/)): a data grid implementation with a mix of global and local state.
195+
- [Beer Finder](https://solkimicreb.github.io/react-easy-state/examples/beer-finder/build) ([source](/examples/beerFinder/)) ([tutorial](https://medium.com/@solkimicreb/design-patterns-with-react-easy-state-830b927acc7c)): an app with async actions and a mix of local and global state, which finds matching beers for your meal.
196196

197197
## Articles
198198

__tests__/Clock.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22
import { mount } from 'enzyme'
33
import sinon from 'sinon'
4-
import App from '../examples/clock/App'
4+
import App from '../examples/clock/src/App'
55

66
describe('Clock App', () => {
77
const clock = sinon.useFakeTimers()

__tests__/Contacts.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import { mount } from 'enzyme'
3-
import App from '../examples/contacts/App'
3+
import App from '../examples/contacts/src/App'
44

55
describe('Contacts App', () => {
66
const app = mount(<App />)

__tests__/TodoMVC.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import { mount } from 'enzyme'
3-
import App from '../examples/todoMVC/App'
3+
import App from '../examples/todo-mvc/src/App'
44

55
describe('TodoMVC App', () => {
66
const app = mount(<App />)

examples/beer-finder/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# Beer Finder · [Live Demo](https://solkimicreb.github.io/react-easy-state/examples/beerFinder/dist)
1+
# Beer Finder · [Live Demo](https://solkimicreb.github.io/react-easy-state/examples/beer-finder/dist)
22

33
An app to find matching beers for your meal. It features networking and async actions with a mix of global and local state. The styling is partially done with the awesome [React Material UI](http://www.material-ui.com/#/) library.
Lines changed: 190 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,190 @@
1-
"use strict";var precacheConfig=[["/react-easy-state/examples/beer-finder/build/index.html","594fe3c38b40f80567036619503cbf40"],["/react-easy-state/examples/beer-finder/build/static/css/main.629c1060.css","a2f35a78fbcda6a481a585ec6d684ee5"],["/react-easy-state/examples/beer-finder/build/static/js/main.6cc66dc8.js","516f8d22aa6c480e65fdc34890dc31df"]],cacheName="sw-precache-v3-sw-precache-webpack-plugin-"+(self.registration?self.registration.scope:""),ignoreUrlParametersMatching=[/^utm_/],addDirectoryIndex=function(e,t){var n=new URL(e);return"/"===n.pathname.slice(-1)&&(n.pathname+=t),n.toString()},cleanResponse=function(e){return e.redirected?("body"in e?Promise.resolve(e.body):e.blob()).then(function(t){return new Response(t,{headers:e.headers,status:e.status,statusText:e.statusText})}):Promise.resolve(e)},createCacheKey=function(e,t,n,r){var a=new URL(e);return r&&a.pathname.match(r)||(a.search+=(a.search?"&":"")+encodeURIComponent(t)+"="+encodeURIComponent(n)),a.toString()},isPathWhitelisted=function(e,t){if(0===e.length)return!0;var n=new URL(t).pathname;return e.some(function(e){return n.match(e)})},stripIgnoredUrlParameters=function(e,t){var n=new URL(e);return n.hash="",n.search=n.search.slice(1).split("&").map(function(e){return e.split("=")}).filter(function(e){return t.every(function(t){return!t.test(e[0])})}).map(function(e){return e.join("=")}).join("&"),n.toString()},hashParamName="_sw-precache",urlsToCacheKeys=new Map(precacheConfig.map(function(e){var t=e[0],n=e[1],r=new URL(t,self.location),a=createCacheKey(r,hashParamName,n,/\.\w{8}\./);return[r.toString(),a]}));function setOfCachedUrls(e){return e.keys().then(function(e){return e.map(function(e){return e.url})}).then(function(e){return new Set(e)})}self.addEventListener("install",function(e){e.waitUntil(caches.open(cacheName).then(function(e){return setOfCachedUrls(e).then(function(t){return Promise.all(Array.from(urlsToCacheKeys.values()).map(function(n){if(!t.has(n)){var r=new Request(n,{credentials:"same-origin"});return fetch(r).then(function(t){if(!t.ok)throw new Error("Request for "+n+" returned a response with status "+t.status);return cleanResponse(t).then(function(t){return e.put(n,t)})})}}))})}).then(function(){return self.skipWaiting()}))}),self.addEventListener("activate",function(e){var t=new Set(urlsToCacheKeys.values());e.waitUntil(caches.open(cacheName).then(function(e){return e.keys().then(function(n){return Promise.all(n.map(function(n){if(!t.has(n.url))return e.delete(n)}))})}).then(function(){return self.clients.claim()}))}),self.addEventListener("fetch",function(e){if("GET"===e.request.method){var t,n=stripIgnoredUrlParameters(e.request.url,ignoreUrlParametersMatching),r="index.html";(t=urlsToCacheKeys.has(n))||(n=addDirectoryIndex(n,r),t=urlsToCacheKeys.has(n));var a="/react-easy-state/examples/beer-finder/build/index.html";!t&&"navigate"===e.request.mode&&isPathWhitelisted(["^(?!\\/__).*"],e.request.url)&&(n=new URL(a,self.location).toString(),t=urlsToCacheKeys.has(n)),t&&e.respondWith(caches.open(cacheName).then(function(e){return e.match(urlsToCacheKeys.get(n)).then(function(e){if(e)return e;throw Error("The cached response that was expected is missing.")})}).catch(function(t){return console.warn('Couldn\'t serve response for "%s" from cache: %O',e.request.url,t),fetch(e.request)}))}});
1+
'use strict'
2+
var precacheConfig = [
3+
[
4+
'/react-easy-state/examples/beer-finder/build/index.html',
5+
'594fe3c38b40f80567036619503cbf40'
6+
],
7+
[
8+
'/react-easy-state/examples/beer-finder/build/static/css/main.629c1060.css',
9+
'a2f35a78fbcda6a481a585ec6d684ee5'
10+
],
11+
[
12+
'/react-easy-state/examples/beer-finder/build/static/js/main.6cc66dc8.js',
13+
'516f8d22aa6c480e65fdc34890dc31df'
14+
]
15+
],
16+
cacheName =
17+
'sw-precache-v3-sw-precache-webpack-plugin-' +
18+
(self.registration ? self.registration.scope : ''),
19+
ignoreUrlParametersMatching = [/^utm_/],
20+
addDirectoryIndex = function (e, t) {
21+
var n = new URL(e)
22+
return n.pathname.slice(-1) === '/' && (n.pathname += t), n.toString()
23+
},
24+
cleanResponse = function (e) {
25+
return e.redirected
26+
? ('body' in e ? Promise.resolve(e.body) : e.blob()).then(function (t) {
27+
return new Response(t, {
28+
headers: e.headers,
29+
status: e.status,
30+
statusText: e.statusText
31+
})
32+
})
33+
: Promise.resolve(e)
34+
},
35+
createCacheKey = function (e, t, n, r) {
36+
var a = new URL(e)
37+
return (
38+
(r && a.pathname.match(r)) ||
39+
(a.search +=
40+
(a.search ? '&' : '') +
41+
encodeURIComponent(t) +
42+
'=' +
43+
encodeURIComponent(n)),
44+
a.toString()
45+
)
46+
},
47+
isPathWhitelisted = function (e, t) {
48+
if (e.length === 0) return !0
49+
var n = new URL(t).pathname
50+
return e.some(function (e) {
51+
return n.match(e)
52+
})
53+
},
54+
stripIgnoredUrlParameters = function (e, t) {
55+
var n = new URL(e)
56+
return (
57+
(n.hash = ''),
58+
(n.search = n.search
59+
.slice(1)
60+
.split('&')
61+
.map(function (e) {
62+
return e.split('=')
63+
})
64+
.filter(function (e) {
65+
return t.every(function (t) {
66+
return !t.test(e[0])
67+
})
68+
})
69+
.map(function (e) {
70+
return e.join('=')
71+
})
72+
.join('&')),
73+
n.toString()
74+
)
75+
},
76+
hashParamName = '_sw-precache',
77+
urlsToCacheKeys = new Map(
78+
precacheConfig.map(function (e) {
79+
var t = e[0],
80+
n = e[1],
81+
r = new URL(t, self.location),
82+
a = createCacheKey(r, hashParamName, n, /\.\w{8}\./)
83+
return [r.toString(), a]
84+
})
85+
)
86+
function setOfCachedUrls (e) {
87+
return e
88+
.keys()
89+
.then(function (e) {
90+
return e.map(function (e) {
91+
return e.url
92+
})
93+
})
94+
.then(function (e) {
95+
return new Set(e)
96+
})
97+
}
98+
self.addEventListener('install', function (e) {
99+
e.waitUntil(
100+
caches
101+
.open(cacheName)
102+
.then(function (e) {
103+
return setOfCachedUrls(e).then(function (t) {
104+
return Promise.all(
105+
Array.from(urlsToCacheKeys.values()).map(function (n) {
106+
if (!t.has(n)) {
107+
var r = new Request(n, { credentials: 'same-origin' })
108+
return fetch(r).then(function (t) {
109+
if (!t.ok) {
110+
throw new Error(
111+
'Request for ' +
112+
n +
113+
' returned a response with status ' +
114+
t.status
115+
)
116+
}
117+
return cleanResponse(t).then(function (t) {
118+
return e.put(n, t)
119+
})
120+
})
121+
}
122+
})
123+
)
124+
})
125+
})
126+
.then(function () {
127+
return self.skipWaiting()
128+
})
129+
)
130+
}),
131+
self.addEventListener('activate', function (e) {
132+
var t = new Set(urlsToCacheKeys.values())
133+
e.waitUntil(
134+
caches
135+
.open(cacheName)
136+
.then(function (e) {
137+
return e.keys().then(function (n) {
138+
return Promise.all(
139+
n.map(function (n) {
140+
if (!t.has(n.url)) return e.delete(n)
141+
})
142+
)
143+
})
144+
})
145+
.then(function () {
146+
return self.clients.claim()
147+
})
148+
)
149+
}),
150+
self.addEventListener('fetch', function (e) {
151+
if (e.request.method === 'GET') {
152+
var t,
153+
n = stripIgnoredUrlParameters(
154+
e.request.url,
155+
ignoreUrlParametersMatching
156+
),
157+
r = 'index.html';
158+
(t = urlsToCacheKeys.has(n)) ||
159+
((n = addDirectoryIndex(n, r)), (t = urlsToCacheKeys.has(n)))
160+
var a = '/react-easy-state/examples/beer-finder/build/index.html'
161+
!t &&
162+
e.request.mode === 'navigate' &&
163+
isPathWhitelisted(['^(?!\\/__).*'], e.request.url) &&
164+
((n = new URL(a, self.location).toString()),
165+
(t = urlsToCacheKeys.has(n))),
166+
t &&
167+
e.respondWith(
168+
caches
169+
.open(cacheName)
170+
.then(function (e) {
171+
return e.match(urlsToCacheKeys.get(n)).then(function (e) {
172+
if (e) return e
173+
throw Error(
174+
'The cached response that was expected is missing.'
175+
)
176+
})
177+
})
178+
.catch(function (t) {
179+
return (
180+
console.warn(
181+
'Couldn\'t serve response for "%s" from cache: %O',
182+
e.request.url,
183+
t
184+
),
185+
fetch(e.request)
186+
)
187+
})
188+
)
189+
}
190+
})

examples/beer-finder/build/static/js/main.6cc66dc8.js

Lines changed: 20156 additions & 2 deletions
Large diffs are not rendered by default.

examples/beerFinder/App.jsx

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/beerFinder/Beer.jsx

Lines changed: 0 additions & 31 deletions
This file was deleted.

examples/beerFinder/BeerList.jsx

Lines changed: 0 additions & 13 deletions
This file was deleted.

examples/beerFinder/NavBar.jsx

Lines changed: 0 additions & 12 deletions
This file was deleted.

examples/beerFinder/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/beerFinder/api.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

examples/beerFinder/appStore.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)