diff options
author | pacien | 2018-10-10 02:50:40 +0200 |
---|---|---|
committer | pacien | 2018-10-10 02:50:40 +0200 |
commit | a3807bf0fbc406dc336c8a07e4d4426a510c7249 (patch) | |
tree | 1f2990b621025bc5b35d44880bf1f685466cb7b8 /src | |
parent | a0beb9d8a9e67cbdd95492b1e118c794ce442819 (diff) | |
download | jacoco-viewer-a3807bf0fbc406dc336c8a07e4d4426a510c7249.tar.gz |
Bootstrap React app
Diffstat (limited to 'src')
-rw-r--r-- | src/App.css | 32 | ||||
-rw-r--r-- | src/App.js | 28 | ||||
-rw-r--r-- | src/App.test.js | 9 | ||||
-rw-r--r-- | src/index.css | 14 | ||||
-rw-r--r-- | src/index.js | 12 | ||||
-rw-r--r-- | src/logo.svg | 7 | ||||
-rw-r--r-- | src/serviceWorker.js | 127 |
7 files changed, 229 insertions, 0 deletions
diff --git a/src/App.css b/src/App.css new file mode 100644 index 0000000..92f956e --- /dev/null +++ b/src/App.css | |||
@@ -0,0 +1,32 @@ | |||
1 | .App { | ||
2 | text-align: center; | ||
3 | } | ||
4 | |||
5 | .App-logo { | ||
6 | animation: App-logo-spin infinite 20s linear; | ||
7 | height: 40vmin; | ||
8 | } | ||
9 | |||
10 | .App-header { | ||
11 | background-color: #282c34; | ||
12 | min-height: 100vh; | ||
13 | display: flex; | ||
14 | flex-direction: column; | ||
15 | align-items: center; | ||
16 | justify-content: center; | ||
17 | font-size: calc(10px + 2vmin); | ||
18 | color: white; | ||
19 | } | ||
20 | |||
21 | .App-link { | ||
22 | color: #61dafb; | ||
23 | } | ||
24 | |||
25 | @keyframes App-logo-spin { | ||
26 | from { | ||
27 | transform: rotate(0deg); | ||
28 | } | ||
29 | to { | ||
30 | transform: rotate(360deg); | ||
31 | } | ||
32 | } | ||
diff --git a/src/App.js b/src/App.js new file mode 100644 index 0000000..7e261ca --- /dev/null +++ b/src/App.js | |||
@@ -0,0 +1,28 @@ | |||
1 | import React, { Component } from 'react'; | ||
2 | import logo from './logo.svg'; | ||
3 | import './App.css'; | ||
4 | |||
5 | class App extends Component { | ||
6 | render() { | ||
7 | return ( | ||
8 | <div className="App"> | ||
9 | <header className="App-header"> | ||
10 | <img src={logo} className="App-logo" alt="logo" /> | ||
11 | <p> | ||
12 | Edit <code>src/App.js</code> and save to reload. | ||
13 | </p> | ||
14 | <a | ||
15 | className="App-link" | ||
16 | href="https://reactjs.org" | ||
17 | target="_blank" | ||
18 | rel="noopener noreferrer" | ||
19 | > | ||
20 | Learn React | ||
21 | </a> | ||
22 | </header> | ||
23 | </div> | ||
24 | ); | ||
25 | } | ||
26 | } | ||
27 | |||
28 | export default App; | ||
diff --git a/src/App.test.js b/src/App.test.js new file mode 100644 index 0000000..a754b20 --- /dev/null +++ b/src/App.test.js | |||
@@ -0,0 +1,9 @@ | |||
1 | import React from 'react'; | ||
2 | import ReactDOM from 'react-dom'; | ||
3 | import App from './App'; | ||
4 | |||
5 | it('renders without crashing', () => { | ||
6 | const div = document.createElement('div'); | ||
7 | ReactDOM.render(<App />, div); | ||
8 | ReactDOM.unmountComponentAtNode(div); | ||
9 | }); | ||
diff --git a/src/index.css b/src/index.css new file mode 100644 index 0000000..cee5f34 --- /dev/null +++ b/src/index.css | |||
@@ -0,0 +1,14 @@ | |||
1 | body { | ||
2 | margin: 0; | ||
3 | padding: 0; | ||
4 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", | ||
5 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", | ||
6 | sans-serif; | ||
7 | -webkit-font-smoothing: antialiased; | ||
8 | -moz-osx-font-smoothing: grayscale; | ||
9 | } | ||
10 | |||
11 | code { | ||
12 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", | ||
13 | monospace; | ||
14 | } | ||
diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..0c5e75d --- /dev/null +++ b/src/index.js | |||
@@ -0,0 +1,12 @@ | |||
1 | import React from 'react'; | ||
2 | import ReactDOM from 'react-dom'; | ||
3 | import './index.css'; | ||
4 | import App from './App'; | ||
5 | import * as serviceWorker from './serviceWorker'; | ||
6 | |||
7 | ReactDOM.render(<App />, document.getElementById('root')); | ||
8 | |||
9 | // If you want your app to work offline and load faster, you can change | ||
10 | // unregister() to register() below. Note this comes with some pitfalls. | ||
11 | // Learn more about service workers: http://bit.ly/CRA-PWA | ||
12 | serviceWorker.unregister(); | ||
diff --git a/src/logo.svg b/src/logo.svg new file mode 100644 index 0000000..6b60c10 --- /dev/null +++ b/src/logo.svg | |||
@@ -0,0 +1,7 @@ | |||
1 | <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"> | ||
2 | <g fill="#61DAFB"> | ||
3 | <path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/> | ||
4 | <circle cx="420.9" cy="296.5" r="45.7"/> | ||
5 | <path d="M520.5 78.1z"/> | ||
6 | </g> | ||
7 | </svg> | ||
diff --git a/src/serviceWorker.js b/src/serviceWorker.js new file mode 100644 index 0000000..8859a0c --- /dev/null +++ b/src/serviceWorker.js | |||
@@ -0,0 +1,127 @@ | |||
1 | // In production, we register a service worker to serve assets from local cache. | ||
2 | |||
3 | // This lets the app load faster on subsequent visits in production, and gives | ||
4 | // it offline capabilities. However, it also means that developers (and users) | ||
5 | // will only see deployed updates on the "N+1" visit to a page, since previously | ||
6 | // cached resources are updated in the background. | ||
7 | |||
8 | // To learn more about the benefits of this model, read https://goo.gl/KwvDNy. | ||
9 | // This link also includes instructions on opting out of this behavior. | ||
10 | |||
11 | const isLocalhost = Boolean( | ||
12 | window.location.hostname === 'localhost' || | ||
13 | // [::1] is the IPv6 localhost address. | ||
14 | window.location.hostname === '[::1]' || | ||
15 | // 127.0.0.1/8 is considered localhost for IPv4. | ||
16 | window.location.hostname.match( | ||
17 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ | ||
18 | ) | ||
19 | ); | ||
20 | |||
21 | export function register(config) { | ||
22 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { | ||
23 | // The URL constructor is available in all browsers that support SW. | ||
24 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location); | ||
25 | if (publicUrl.origin !== window.location.origin) { | ||
26 | // Our service worker won't work if PUBLIC_URL is on a different origin | ||
27 | // from what our page is served on. This might happen if a CDN is used to | ||
28 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374 | ||
29 | return; | ||
30 | } | ||
31 | |||
32 | window.addEventListener('load', () => { | ||
33 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; | ||
34 | |||
35 | if (isLocalhost) { | ||
36 | // This is running on localhost. Let's check if a service worker still exists or not. | ||
37 | checkValidServiceWorker(swUrl, config); | ||
38 | |||
39 | // Add some additional logging to localhost, pointing developers to the | ||
40 | // service worker/PWA documentation. | ||
41 | navigator.serviceWorker.ready.then(() => { | ||
42 | console.log( | ||
43 | 'This web app is being served cache-first by a service ' + | ||
44 | 'worker. To learn more, visit https://goo.gl/SC7cgQ' | ||
45 | ); | ||
46 | }); | ||
47 | } else { | ||
48 | // Is not local host. Just register service worker | ||
49 | registerValidSW(swUrl, config); | ||
50 | } | ||
51 | }); | ||
52 | } | ||
53 | } | ||
54 | |||
55 | function registerValidSW(swUrl, config) { | ||
56 | navigator.serviceWorker | ||
57 | .register(swUrl) | ||
58 | .then(registration => { | ||
59 | registration.onupdatefound = () => { | ||
60 | const installingWorker = registration.installing; | ||
61 | installingWorker.onstatechange = () => { | ||
62 | if (installingWorker.state === 'installed') { | ||
63 | if (navigator.serviceWorker.controller) { | ||
64 | // At this point, the old content will have been purged and | ||
65 | // the fresh content will have been added to the cache. | ||
66 | // It's the perfect time to display a "New content is | ||
67 | // available; please refresh." message in your web app. | ||
68 | console.log('New content is available; please refresh.'); | ||
69 | |||
70 | // Execute callback | ||
71 | if (config.onUpdate) { | ||
72 | config.onUpdate(registration); | ||
73 | } | ||
74 | } else { | ||
75 | // At this point, everything has been precached. | ||
76 | // It's the perfect time to display a | ||
77 | // "Content is cached for offline use." message. | ||
78 | console.log('Content is cached for offline use.'); | ||
79 | |||
80 | // Execute callback | ||
81 | if (config.onSuccess) { | ||
82 | config.onSuccess(registration); | ||
83 | } | ||
84 | } | ||
85 | } | ||
86 | }; | ||
87 | }; | ||
88 | }) | ||
89 | .catch(error => { | ||
90 | console.error('Error during service worker registration:', error); | ||
91 | }); | ||
92 | } | ||
93 | |||
94 | function checkValidServiceWorker(swUrl, config) { | ||
95 | // Check if the service worker can be found. If it can't reload the page. | ||
96 | fetch(swUrl) | ||
97 | .then(response => { | ||
98 | // Ensure service worker exists, and that we really are getting a JS file. | ||
99 | if ( | ||
100 | response.status === 404 || | ||
101 | response.headers.get('content-type').indexOf('javascript') === -1 | ||
102 | ) { | ||
103 | // No service worker found. Probably a different app. Reload the page. | ||
104 | navigator.serviceWorker.ready.then(registration => { | ||
105 | registration.unregister().then(() => { | ||
106 | window.location.reload(); | ||
107 | }); | ||
108 | }); | ||
109 | } else { | ||
110 | // Service worker found. Proceed as normal. | ||
111 | registerValidSW(swUrl, config); | ||
112 | } | ||
113 | }) | ||
114 | .catch(() => { | ||
115 | c |