aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbndw <benjamindwoodward@gmail.com>2020-05-30 12:33:16 -0700
committerbndw <benjamindwoodward@gmail.com>2020-05-31 09:02:22 -0700
commit6371e7794d2fa9ba5b79f267219e50e885057342 (patch)
tree3441d6087befb8740d098c88385839ef20bb1b65
parente177a74c9ea505284c8debf086f785a43d88f90b (diff)
Initial commit
-rw-r--r--.circleci/config.yml20
-rw-r--r--Dockerfile2
-rw-r--r--Makefile26
-rw-r--r--README.md72
-rw-r--r--package.json3
-rw-r--r--public/favicon.icobin3150 -> 0 bytes
-rw-r--r--public/index.html5
-rw-r--r--public/logo192.pngbin5347 -> 0 bytes
-rw-r--r--public/logo512.pngbin9664 -> 0 bytes
-rw-r--r--public/manifest.json22
-rw-r--r--src/App.css38
-rw-r--r--src/App.js32
-rw-r--r--src/components/Card.js56
-rw-r--r--src/components/style.css47
-rw-r--r--src/index.css13
-rw-r--r--src/index.js2
-rw-r--r--src/light.min.css2
-rw-r--r--src/style.css11
-rw-r--r--yarn.lock16
19 files changed, 211 insertions, 156 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml
new file mode 100644
index 0000000..0367bfc
--- /dev/null
+++ b/.circleci/config.yml
@@ -0,0 +1,20 @@
1version: 2
2jobs:
3 build:
4 docker:
5 - image: circleci/node
6 steps:
7 - checkout
8 - setup_remote_docker
9 - run: yarn
10 - run: make build
11 - run: make publish
12
13workflows:
14 version: 2
15 build:
16 jobs:
17 - build:
18 filters:
19 branches:
20 only: master
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..15ee3a9
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,2 @@
1FROM nginx:stable-alpine
2COPY build /usr/share/nginx/html
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..2c22c89
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,26 @@
1REPO ?= bndw/wifi-card
2GITSHA=$(shell git rev-parse --short HEAD)
3TAG_COMMIT=$(REPO):$(GITSHA)
4TAG_LATEST=$(REPO):latest
5
6all: dev
7
8.PHONY: build
9build:
10 yarn build
11 docker build -t $(TAG_LATEST) .
12
13.PHONY: dev
14dev:
15 yarn start
16
17.PHONY: run
18run: build
19 docker run --rm -p 8080:80 $(TAG_LATEST)
20
21.PHONY: publish
22publish:
23 @docker login -u $(DOCKER_USER) -p $(DOCKER_PASS)
24 docker push $(TAG_LATEST)
25 @docker tag $(TAG_LATEST) $(TAG_COMMIT)
26 docker push $(TAG_COMMIT)
diff --git a/README.md b/README.md
index 9c40dcd..0cc628f 100644
--- a/README.md
+++ b/README.md
@@ -1,68 +1,12 @@
1This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 1[![CircleCI](https://circleci.com/gh/bndw/wifi-card.svg?style=svg)](https://circleci.com/gh/bndw/wifi-card)
2 2
3## Available Scripts 3# WiFi Card
4 4
5In the project directory, you can run: 5Print your WiFi info on a neat little card and stick it on the fridge.
6Use the QR code to connect phones.
6 7
7### `yarn start` 8## Running locally
8 9
9Runs the app in the development mode.<br /> 10```
10Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 11make dev
11 12```
12The page will reload if you make edits.<br />
13You will also see any lint errors in the console.
14
15### `yarn test`
16
17Launches the test runner in the interactive watch mode.<br />
18See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19
20### `yarn build`
21
22Builds the app for production to the `build` folder.<br />
23It correctly bundles React in production mode and optimizes the build for the best performance.
24
25The build is minified and the filenames include the hashes.<br />
26Your app is ready to be deployed!
27
28See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29
30### `yarn eject`
31
32**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33
34If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35
36Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37
38You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39
40## Learn More
41
42You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43
44To learn React, check out the [React documentation](https://reactjs.org/).
45
46### Code Splitting
47
48This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49
50### Analyzing the Bundle Size
51
52This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53
54### Making a Progressive Web App
55
56This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57
58### Advanced Configuration
59
60This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61
62### Deployment
63
64This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65
66### `yarn build` fails to minify
67
68This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
diff --git a/package.json b/package.json
index d28f3c5..cfb9dd9 100644
--- a/package.json
+++ b/package.json
@@ -1,11 +1,12 @@
1{ 1{
2 "name": "wifi-qr-code", 2 "name": "wifi-details",
3 "version": "0.1.0", 3 "version": "0.1.0",
4 "private": true, 4 "private": true,
5 "dependencies": { 5 "dependencies": {
6 "@testing-library/jest-dom": "^4.2.4", 6 "@testing-library/jest-dom": "^4.2.4",
7 "@testing-library/react": "^9.3.2", 7 "@testing-library/react": "^9.3.2",
8 "@testing-library/user-event": "^7.1.2", 8 "@testing-library/user-event": "^7.1.2",
9 "qrcode.react": "^1.0.0",
9 "react": "^16.13.1", 10 "react": "^16.13.1",
10 "react-dom": "^16.13.1", 11 "react-dom": "^16.13.1",
11 "react-scripts": "3.4.1" 12 "react-scripts": "3.4.1"
diff --git a/public/favicon.ico b/public/favicon.ico
deleted file mode 100644
index bcd5dfd..0000000
--- a/public/favicon.ico
+++ /dev/null
Binary files differ
diff --git a/public/index.html b/public/index.html
index aa069f2..1553b21 100644
--- a/public/index.html
+++ b/public/index.html
@@ -2,12 +2,11 @@
2<html lang="en"> 2<html lang="en">
3 <head> 3 <head>
4 <meta charset="utf-8" /> 4 <meta charset="utf-8" />
5 <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6 <meta name="viewport" content="width=device-width, initial-scale=1" /> 5 <meta name="viewport" content="width=device-width, initial-scale=1" />
7 <meta name="theme-color" content="#000000" /> 6 <meta name="theme-color" content="#000000" />
8 <meta 7 <meta
9 name="description" 8 name="description"
10 content="Web site created using create-react-app" 9 content="Print a card for your WiFi login"
11 /> 10 />
12 <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" /> 11 <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13 <!-- 12 <!--
@@ -24,7 +23,7 @@
24 work correctly both with client-side routing and a non-root public URL. 23 work correctly both with client-side routing and a non-root public URL.
25 Learn how to configure a non-root public URL by running `npm run build`. 24 Learn how to configure a non-root public URL by running `npm run build`.
26 --> 25 -->
27 <title>React App</title> 26 <title>📡 WiFi Login Card</title>
28 </head> 27 </head>
29 <body> 28 <body>
30 <noscript>You need to enable JavaScript to run this app.</noscript> 29 <noscript>You need to enable JavaScript to run this app.</noscript>
diff --git a/public/logo192.png b/public/logo192.png
deleted file mode 100644
index fc44b0a..0000000
--- a/public/logo192.png
+++ /dev/null
Binary files differ
diff --git a/public/logo512.png b/public/logo512.png
deleted file mode 100644
index a4e47a6..0000000
--- a/public/logo512.png
+++ /dev/null
Binary files differ
diff --git a/public/manifest.json b/public/manifest.json
index 080d6c7..46e96b6 100644
--- a/public/manifest.json
+++ b/public/manifest.json
@@ -1,23 +1,7 @@
1{ 1{
2 "short_name": "React App", 2 "short_name": "wifi-details",
3 "name": "Create React App Sample", 3 "name": "wifi-details",
4 "icons": [ 4 "icons": [],
5 {
6 "src": "favicon.ico",
7 "sizes": "64x64 32x32 24x24 16x16",
8 "type": "image/x-icon"
9 },
10 {
11 "src": "logo192.png",
12 "type": "image/png",
13 "sizes": "192x192"
14 },
15 {
16 "src": "logo512.png",
17 "type": "image/png",
18 "sizes": "512x512"
19 }
20 ],
21 "start_url": ".", 5 "start_url": ".",
22 "display": "standalone", 6 "display": "standalone",
23 "theme_color": "#000000", 7 "theme_color": "#000000",
diff --git a/src/App.css b/src/App.css
deleted file mode 100644
index 74b5e05..0000000
--- a/src/App.css
+++ /dev/null
@@ -1,38 +0,0 @@
1.App {
2 text-align: center;
3}
4
5.App-logo {
6 height: 40vmin;
7 pointer-events: none;
8}
9
10@media (prefers-reduced-motion: no-preference) {
11 .App-logo {
12 animation: App-logo-spin infinite 20s linear;
13 }
14}
15
16.App-header {
17 background-color: #282c34;
18 min-height: 100vh;
19 display: flex;
20 flex-direction: column;
21 align-items: center;
22 justify-content: center;
23 font-size: calc(10px + 2vmin);
24 color: white;
25}
26
27.App-link {
28 color: #61dafb;
29}
30
31@keyframes App-logo-spin {
32 from {
33 transform: rotate(0deg);
34 }
35 to {
36 transform: rotate(360deg);
37 }
38}
diff --git a/src/App.js b/src/App.js
index ce9cbd2..6ba42f0 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,24 +1,24 @@
1import React from 'react'; 1import React from 'react';
2import logo from './logo.svg'; 2import Card from './components/Card';
3import './App.css'; 3import './style.css';
4 4
5function App() { 5function App() {
6 return ( 6 return (
7 <div className="App"> 7 <div className="App">
8 <header className="App-header"> 8
9 <img src={logo} className="App-logo" alt="logo" /> 9 <h1>WiFi Card</h1>
10 <p> 10
11 Edit <code>src/App.js</code> and save to reload. 11 <p className="tag">
12 </p> 12 Print a simple card with your WiFi login details. Tape it to the fridge, keep it in your wallet, etc.
13 <a 13 </p>
14 className="App-link" 14
15 href="https://reactjs.org" 15 <p className="tag">
16 target="_blank" 16 Your information is never sent to the server.
17 rel="noopener noreferrer" 17 View the <a href="https://github.com/bndw/wifi-details">source code</a>.
18 > 18 </p>
19 Learn React 19
20 </a> 20 <Card />
21 </header> 21
22 </div> 22 </div>
23 ); 23 );
24} 24}
diff --git a/src/components/Card.js b/src/components/Card.js
new file mode 100644
index 0000000..c555a25
--- /dev/null
+++ b/src/components/Card.js
@@ -0,0 +1,56 @@
1import React from 'react';
2import QRCode from 'qrcode.react';
3import './style.css';
4
5class Card extends React.Component {
6 constructor(props) {
7 super(props);
8 this.state = {ssid: '', password: '', qrvalue: ''};
9 this.handleSSIDChange = this.handleSSIDChange.bind(this);
10 this.handlePasswordChange= this.handlePasswordChange.bind(this);
11 }
12
13 handleSSIDChange(event) {
14 this.setState({ssid: event.target.value}, () => this.generateqr());
15 }
16
17 handlePasswordChange(event) {
18 this.setState({password: event.target.value}, () => this.generateqr());
19 }
20
21 generateqr() {
22 const qrcode = `WIFI:T:WPA;S:${this.state.ssid};P:${this.state.password};;`
23 this.setState({qrvalue: qrcode});
24 }
25
26 render() {
27 return (
28 <div>
29 <fieldset id="print-area">
30 <legend></legend>
31
32 <h1>WiFi Login</h1>
33 <hr/>
34
35 <div className="details">
36 <QRCode className="qrcode" value={this.state.qrvalue} size={175} />
37
38 <div className="text">
39 <label>Network name</label>
40 <input id="ssid" type="text" placeholder="Enter your WiFi Network" value={this.state.ssid} onChange={this.handleSSIDChange}/>
41 <label>Password</label>
42 <input id="password" type="text" placeholder="password" value={this.state.password} onChange={this.handlePasswordChange}/>
43 </div>
44 </div>
45
46 <p><span role="img" aria-label="mobile-phone">📸📱</span>Point your phone's camera at the QR Code to connect automatically</p>
47 </fieldset>
48 <div className="print-btn">
49 <button onClick={window.print}>Print</button>
50 </div>
51 </div>
52 )
53 }
54}
55
56export default Card;
diff --git a/src/components/style.css b/src/components/style.css
new file mode 100644
index 0000000..e5b01e3
--- /dev/null
+++ b/src/components/style.css
@@ -0,0 +1,47 @@
1#print-area {
2 margin-top: 2em;
3 padding: 1em;
4}
5.details {
6 display: flex;
7 padding: 1em;
8}
9.details .text{
10 margin: 0;
11}
12.details .text * {
13 margin: 0 1em;
14}
15.details .text input {
16 background-color: #fff;
17 border: solid 1px #ddd;
18 font-size: 1.4em;
19 font-weight: bold;
20 line-height: 2;
21}
22.print-btn {
23 padding-top: 2em;
24}
25.print-btn button {
26 color: #fff;
27 height: 50px;
28 width: 180px;
29 background-color: #0074d9;
30}
31
32@media print {
33 body * {
34 visibility: hidden;
35 }
36 #print-area, #print-area * {
37 visibility: visible;
38 }
39 #print-area input {
40 border: none;
41 }
42 #print-area {
43 position: absolute;
44 left: 0;
45 top: 0;
46 }
47}
diff --git a/src/index.css b/src/index.css
deleted file mode 100644
index ec2585e..0000000
--- a/src/index.css
+++ /dev/null
@@ -1,13 +0,0 @@
1body {
2 margin: 0;
3 font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 sans-serif;
6 -webkit-font-smoothing: antialiased;
7 -moz-osx-font-smoothing: grayscale;
8}
9
10code {
11 font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 monospace;
13}
diff --git a/src/index.js b/src/index.js
index f5185c1..be3b97a 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,6 +1,6 @@
1import React from 'react'; 1import React from 'react';
2import ReactDOM from 'react-dom'; 2import ReactDOM from 'react-dom';
3import './index.css'; 3import './light.min.css';
4import App from './App'; 4import App from './App';
5import * as serviceWorker from './serviceWorker'; 5import * as serviceWorker from './serviceWorker';
6 6
diff --git a/src/light.min.css b/src/light.min.css
new file mode 100644
index 0000000..8ce73eb
--- /dev/null
+++ b/src/light.min.css
@@ -0,0 +1,2 @@
1@charset "UTF-8";body{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;line-height:1.4;max-width:800px;margin:20px auto;padding:0 10px;color:#363636;background:#fff;text-rendering:optimizeLegibility}button,input,textarea{transition:background-color .1s linear,border-color .1s linear,color .1s linear,box-shadow .1s linear,transform .1s ease}h1{font-size:2.2em;margin-top:0}h1,h2,h3,h4,h5,h6{margin-bottom:12px}h1,h2,h3,h4,h5,h6,strong{color:#000}b,h1,h2,h3,h4,h5,h6,strong,th{font-weight:600}blockquote{border-left:4px solid rgba(0,150,191,.67);margin:1.5em 0;padding:.5em 1em;font-style:italic}blockquote>footer{margin-top:10px;font-style:normal}address,blockquote cite{font-style:normal}a[href^=mailto]:before{content:"📧 "}a[href^=tel]:before{content:"📞 "}a[href^=sms]:before{content:"💬 "}button,input[type=button],input[type=checkbox],input[type=submit]{cursor:pointer}input:not([type=checkbox]):not([type=radio]),select{display:block}button,input,select,textarea{color:#000;background-color:#efefef;font-family:inherit;font-size:inherit;margin-right:6px;margin-bottom:6px;padding:10px;border:none;border-radius:6px;outline:none}button,input:not([type=checkbox]):not([type=radio]),select,textarea{-webkit-appearance:none}textarea{margin-right:0;width:100%;box-sizing:border-box;resize:vertical}button,input[type=button],input[type=submit]{padding-right:30px;padding-left:30px}button:hover,input[type=button]:hover,input[type=submit]:hover{background:#ddd}button:focus,input:focus,select:focus,textarea:focus{box-shadow:0 0 0 2px rgba(0,150,191,.67)}button:active,input[type=button]:active,input[type=checkbox]:active,input[type=radio]:active,input[type=submit]:active{transform:translateY(2px)}button:disabled,input:disabled,select:disabled,textarea:disabled{cursor:not-allowed;opacity:.5}::-webkit-input-placeholder{color:#949494}:-ms-input-placeholder{color:#949494}::-ms-input-placeholder{color:#949494}::placeholder{color:#949494}a{text-decoration:none;color:#0076d1}a:hover{text-decoration:underline}code,kbd{background:#efefef;color:#000;padding:5px;border-radius:6px}pre>code{padding:10px;display:block;overflow-x:auto}img{max-width:100%}hr{border:none;border-top:1px solid #dbdbdb}table{border-collapse:collapse;margin-bottom:10px;width:100%}td,th{padding:6px;text-align:left}th{border-bottom:1px solid #dbdbdb}tbody tr:nth-child(2n){background-color:#efefef}::-webkit-scrollbar{height:10px;width:10px}::-webkit-scrollbar-track{background:#efefef;border-radius:6px}::-webkit-scrollbar-thumb{background:#d5d5d5;border-radius:6px}::-webkit-scrollbar-thumb:hover{background:#c4c4c4}
2/*# sourceMappingURL=light.min.css.map */
diff --git a/src/style.css b/src/style.css
new file mode 100644
index 0000000..3e55788
--- /dev/null
+++ b/src/style.css
@@ -0,0 +1,11 @@
1body {
2 max-width: 650px;
3}
4.tag {
5 line-height: 1.6;
6}
7
8iframe {
9 float: right;
10 margin: -2em;
11}
diff --git a/yarn.lock b/yarn.lock
index 7478b39..cac9b9f 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -8373,7 +8373,7 @@ prompts@^2.0.1:
8373 kleur "^3.0.3" 8373 kleur "^3.0.3"
8374 sisteransi "^1.0.4" 8374 sisteransi "^1.0.4"
8375 8375
8376prop-types@^15.6.2, prop-types@^15.7.2: 8376prop-types@^15.6.0, prop-types@^15.6.2, prop-types@^15.7.2:
8377 version "15.7.2" 8377 version "15.7.2"
8378 resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5" 8378 resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
8379 integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ== 8379 integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
@@ -8457,6 +8457,20 @@ q@^1.1.2:
8457 resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7" 8457 resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7"
8458 integrity sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc= 8458 integrity sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=
8459 8459
8460qr.js@0.0.0:
8461 version "0.0.0"
8462 resolved "https://registry.yarnpkg.com/qr.js/-/qr.js-0.0.0.tgz#cace86386f59a0db8050fa90d9b6b0e88a1e364f"
8463 integrity sha1-ys6GOG9ZoNuAUPqQ2baw6IoeNk8=
8464
8465qrcode.react@^1.0.0:
8466 version "1.0.0"
8467 resolved "https://registry.yarnpkg.com/qrcode.react/-/qrcode.react-1.0.0.tgz#7e8889db3b769e555e8eb463d4c6de221c36d5de"
8468 integrity sha512-jBXleohRTwvGBe1ngV+62QvEZ/9IZqQivdwzo9pJM4LQMoCM2VnvNBnKdjvGnKyDZ/l0nCDgsPod19RzlPvm/Q==
8469 dependencies:
8470 loose-envify "^1.4.0"
8471 prop-types "^15.6.0"
8472 qr.js "0.0.0"
8473
8460qs@6.7.0: 8474qs@6.7.0:
8461 version "6.7.0" 8475 version "6.7.0"
8462 resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc" 8476 resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc"