Skip to content

Commit

Permalink
ugrade CRA version
Browse files Browse the repository at this point in the history
  • Loading branch information
atabel committed Jun 3, 2017
1 parent 5d7a50f commit 9b13709
Show file tree
Hide file tree
Showing 7 changed files with 1,453 additions and 841 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"private": true,
"devDependencies": {
"ava": "^0.19.1",
"babel-preset-react-app": "^2.2.0",
"babel-register": "^6.22.0",
"babel-preset-react-app": "^3.0.0",
"babel-register": "^6.24.1",
"cross-env": "^4.0.0",
"enzyme": "^2.8.2",
"flow-bin": "^0.46.0",
Expand All @@ -15,7 +15,7 @@
"lint-staged": "^3.4.1",
"prettier": "^1.3.1",
"react-addons-test-utils": "^15.5.1",
"react-scripts": "^0.9.5",
"react-scripts": "^1.0.6",
"react-test-renderer": "^15.5.4",
"sinon": "^2.2.0",
"sw-precache": "^5.1.1"
Expand All @@ -37,7 +37,7 @@
"scripts": {
"start": "react-scripts start",
"prebuild": "flow check && yarn test",
"build": "react-scripts build && sw-precache --config=sw-precache-config.js",
"build": "react-scripts build",
"test": "cross-env NODE_ENV=test ava",
"eject": "react-scripts eject",
"deploy": "yarn build && gh-pages -d build",
Expand Down
75 changes: 53 additions & 22 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,60 @@
<link rel="icon" type="image/png" sizes="144x144" href="%PUBLIC_URL%/icons/ms-touch-icon-144x144-precomposed.png">
<link rel="icon" type="image/png" sizes="192x192" href="%PUBLIC_URL%/icons/chrome-touch-icon-192x192.png">
<link rel="apple-touch-icon" type="image/png" sizes="152x152" href="%PUBLIC_URL%/icons/apple-touch-icon.png">

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.css">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
<style>
html, body, #root {
height: 100%;
}
#root {
overflow: hidden;
}
body {
font-family: 'Roboto', sans-serif;
}
* {
box-sizing: border-box;
}
/* https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.css */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}


html, body, #root { height: 100%; }
#root { overflow: hidden; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
}
html { box-sizing: border-box; }
*, *:before, *:after { box-sizing: inherit; }
</style>
<!--
Notice the use of %PUBLIC_URL% in the tag above.
Expand Down Expand Up @@ -63,12 +101,5 @@
To begin the development, run `npm start`.
To create a production bundle, use `npm run build`.
-->
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.register('/service-worker.js');
});
}
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion src/components/message-bubble.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const Media = ({url, title, description, image, embed, isOwnMessage}) => (
fontSize: 13,
}}
>
<a href={url} style={{color: 'inherit', textDecoration: 'inherit'}} target="_blank">
<a href={url} style={{color: 'inherit', textDecoration: 'inherit'}} target="_blank" rel="noopener noreferrer">
{title && <h3 style={{marginBottom: 8, fontWeight: 500}}>{title}</h3>}
{description && <p style={{fontStyle: 'italic', marginBottom: 8}}>{description}</p>}
{image && <img style={{width: '100%'}} src={image.url} alt={image.url} />}
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import configureStore from './store';
import {Provider} from 'react-redux';
import {BrowserRouter as Router, Route} from 'react-router-dom';
import PrivateRoute from './components/private-route';
import registerServiceWorker from './register-service-worker';

const initApp = () => {
const store = configureStore();
Expand All @@ -21,3 +22,4 @@ const initApp = () => {
};

initApp();
registerServiceWorker();
51 changes: 51 additions & 0 deletions src/register-service-worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// In production, we register a service worker to serve assets from local cache.

// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on the "N+1" visit to a page, since previously
// cached resources are updated in the background.

// To learn more about the benefits of this model, read https://goo.gl/KwvDNy.
// This link also includes instructions on opting out of this behavior.

export default function register() {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
navigator.serviceWorker
.register(swUrl)
.then(registration => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
// At this point, the old content will have been purged and
// the fresh content will have been added to the cache.
// It's the perfect time to display a "New content is
// available; please refresh." message in your web app.
console.log('New content is available; please refresh.');
} else {
// At this point, everything has been precached.
// It's the perfect time to display a
// "Content is cached for offline use." message.
console.log('Content is cached for offline use.');
}
}
};
};
})
.catch(error => {
console.error('Error during service worker registration:', error);
});
});
}
}

export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then(registration => {
registration.unregister();
});
}
}
45 changes: 0 additions & 45 deletions sw-precache-config.js

This file was deleted.

Loading

0 comments on commit 9b13709

Please sign in to comment.