From 6371e7794d2fa9ba5b79f267219e50e885057342 Mon Sep 17 00:00:00 2001 From: bndw Date: Sat, 30 May 2020 12:33:16 -0700 Subject: Initial commit --- .circleci/config.yml | 20 +++++++++++++ Dockerfile | 2 ++ Makefile | 26 +++++++++++++++++ README.md | 72 ++++++----------------------------------------- package.json | 3 +- public/favicon.ico | Bin 3150 -> 0 bytes public/index.html | 5 ++-- public/logo192.png | Bin 5347 -> 0 bytes public/logo512.png | Bin 9664 -> 0 bytes public/manifest.json | 22 ++------------- src/App.css | 38 ------------------------- src/App.js | 32 ++++++++++----------- src/components/Card.js | 56 ++++++++++++++++++++++++++++++++++++ src/components/style.css | 47 +++++++++++++++++++++++++++++++ src/index.css | 13 --------- src/index.js | 2 +- src/light.min.css | 2 ++ src/style.css | 11 ++++++++ yarn.lock | 16 ++++++++++- 19 files changed, 211 insertions(+), 156 deletions(-) create mode 100644 .circleci/config.yml create mode 100644 Dockerfile create mode 100644 Makefile delete mode 100644 public/favicon.ico delete mode 100644 public/logo192.png delete mode 100644 public/logo512.png delete mode 100644 src/App.css create mode 100644 src/components/Card.js create mode 100644 src/components/style.css delete mode 100644 src/index.css create mode 100644 src/light.min.css create mode 100644 src/style.css 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 @@ +version: 2 +jobs: + build: + docker: + - image: circleci/node + steps: + - checkout + - setup_remote_docker + - run: yarn + - run: make build + - run: make publish + +workflows: + version: 2 + build: + jobs: + - build: + filters: + branches: + only: master diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..15ee3a9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,2 @@ +FROM nginx:stable-alpine +COPY 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 @@ +REPO ?= bndw/wifi-card +GITSHA=$(shell git rev-parse --short HEAD) +TAG_COMMIT=$(REPO):$(GITSHA) +TAG_LATEST=$(REPO):latest + +all: dev + +.PHONY: build +build: + yarn build + docker build -t $(TAG_LATEST) . + +.PHONY: dev +dev: + yarn start + +.PHONY: run +run: build + docker run --rm -p 8080:80 $(TAG_LATEST) + +.PHONY: publish +publish: + @docker login -u $(DOCKER_USER) -p $(DOCKER_PASS) + docker push $(TAG_LATEST) + @docker tag $(TAG_LATEST) $(TAG_COMMIT) + 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 @@ -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). +[![CircleCI](https://circleci.com/gh/bndw/wifi-card.svg?style=svg)](https://circleci.com/gh/bndw/wifi-card) -## Available Scripts +# WiFi Card -In the project directory, you can run: +Print your WiFi info on a neat little card and stick it on the fridge. +Use the QR code to connect phones. -### `yarn start` +## Running locally -Runs the app in the development mode.
-Open [http://localhost:3000](http://localhost:3000) to view it in the browser. - -The page will reload if you make edits.
-You will also see any lint errors in the console. - -### `yarn test` - -Launches the test runner in the interactive watch mode.
-See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. - -### `yarn build` - -Builds the app for production to the `build` folder.
-It correctly bundles React in production mode and optimizes the build for the best performance. - -The build is minified and the filenames include the hashes.
-Your app is ready to be deployed! - -See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. - -### `yarn eject` - -**Note: this is a one-way operation. Once you `eject`, you can’t go back!** - -If 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. - -Instead, 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. - -You 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. - -## Learn More - -You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). - -To learn React, check out the [React documentation](https://reactjs.org/). - -### Code Splitting - -This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting - -### Analyzing the Bundle Size - -This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size - -### Making a Progressive Web App - -This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app - -### Advanced Configuration - -This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration - -### Deployment - -This section has moved here: https://facebook.github.io/create-react-app/docs/deployment - -### `yarn build` fails to minify - -This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify +``` +make dev +``` diff --git a/package.json b/package.json index d28f3c5..cfb9dd9 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,12 @@ { - "name": "wifi-qr-code", + "name": "wifi-details", "version": "0.1.0", "private": true, "dependencies": { "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.3.2", "@testing-library/user-event": "^7.1.2", + "qrcode.react": "^1.0.0", "react": "^16.13.1", "react-dom": "^16.13.1", "react-scripts": "3.4.1" diff --git a/public/favicon.ico b/public/favicon.ico deleted file mode 100644 index bcd5dfd..0000000 Binary files a/public/favicon.ico and /dev/null 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 @@ - - React App + 📡 WiFi Login Card diff --git a/public/logo192.png b/public/logo192.png deleted file mode 100644 index fc44b0a..0000000 Binary files a/public/logo192.png and /dev/null differ diff --git a/public/logo512.png b/public/logo512.png deleted file mode 100644 index a4e47a6..0000000 Binary files a/public/logo512.png and /dev/null 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 @@ { - "short_name": "React App", - "name": "Create React App Sample", - "icons": [ - { - "src": "favicon.ico", - "sizes": "64x64 32x32 24x24 16x16", - "type": "image/x-icon" - }, - { - "src": "logo192.png", - "type": "image/png", - "sizes": "192x192" - }, - { - "src": "logo512.png", - "type": "image/png", - "sizes": "512x512" - } - ], + "short_name": "wifi-details", + "name": "wifi-details", + "icons": [], "start_url": ".", "display": "standalone", "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 @@ -.App { - text-align: center; -} - -.App-logo { - height: 40vmin; - pointer-events: none; -} - -@media (prefers-reduced-motion: no-preference) { - .App-logo { - animation: App-logo-spin infinite 20s linear; - } -} - -.App-header { - background-color: #282c34; - min-height: 100vh; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - font-size: calc(10px + 2vmin); - color: white; -} - -.App-link { - color: #61dafb; -} - -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} 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 @@ import React from 'react'; -import logo from './logo.svg'; -import './App.css'; +import Card from './components/Card'; +import './style.css'; function App() { return (
-
- logo -

- Edit src/App.js and save to reload. -

- - Learn React - -
+ +

WiFi Card

+ +

+ Print a simple card with your WiFi login details. Tape it to the fridge, keep it in your wallet, etc. +

+ +

+ Your information is never sent to the server. + View the source code. +

+ + +
); } 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 @@ +import React from 'react'; +import QRCode from 'qrcode.react'; +import './style.css'; + +class Card extends React.Component { + constructor(props) { + super(props); + this.state = {ssid: '', password: '', qrvalue: ''}; + this.handleSSIDChange = this.handleSSIDChange.bind(this); + this.handlePasswordChange= this.handlePasswordChange.bind(this); + } + + handleSSIDChange(event) { + this.setState({ssid: event.target.value}, () => this.generateqr()); + } + + handlePasswordChange(event) { + this.setState({password: event.target.value}, () => this.generateqr()); + } + + generateqr() { + const qrcode = `WIFI:T:WPA;S:${this.state.ssid};P:${this.state.password};;` + this.setState({qrvalue: qrcode}); + } + + render() { + return ( +
+ +
+ +
+
+ ) + } +} + +export 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 @@ +#print-area { + margin-top: 2em; + padding: 1em; +} +.details { + display: flex; + padding: 1em; +} +.details .text{ + margin: 0; +} +.details .text * { + margin: 0 1em; +} +.details .text input { + background-color: #fff; + border: solid 1px #ddd; + font-size: 1.4em; + font-weight: bold; + line-height: 2; +} +.print-btn { + padding-top: 2em; +} +.print-btn button { + color: #fff; + height: 50px; + width: 180px; + background-color: #0074d9; +} + +@media print { + body * { + visibility: hidden; + } + #print-area, #print-area * { + visibility: visible; + } + #print-area input { + border: none; + } + #print-area { + position: absolute; + left: 0; + top: 0; + } +} 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 @@ -body { - margin: 0; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', - 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', - sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -code { - font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', - monospace; -} 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 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import './index.css'; +import './light.min.css'; import App from './App'; import * as serviceWorker from './serviceWorker'; 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 @@ +@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} +/*# 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 @@ +body { + max-width: 650px; +} +.tag { + line-height: 1.6; +} + +iframe { + float: right; + margin: -2em; +} 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: kleur "^3.0.3" sisteransi "^1.0.4" -prop-types@^15.6.2, prop-types@^15.7.2: +prop-types@^15.6.0, prop-types@^15.6.2, prop-types@^15.7.2: version "15.7.2" resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5" integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ== @@ -8457,6 +8457,20 @@ q@^1.1.2: resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7" integrity sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc= +qr.js@0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/qr.js/-/qr.js-0.0.0.tgz#cace86386f59a0db8050fa90d9b6b0e88a1e364f" + integrity sha1-ys6GOG9ZoNuAUPqQ2baw6IoeNk8= + +qrcode.react@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/qrcode.react/-/qrcode.react-1.0.0.tgz#7e8889db3b769e555e8eb463d4c6de221c36d5de" + integrity sha512-jBXleohRTwvGBe1ngV+62QvEZ/9IZqQivdwzo9pJM4LQMoCM2VnvNBnKdjvGnKyDZ/l0nCDgsPod19RzlPvm/Q== + dependencies: + loose-envify "^1.4.0" + prop-types "^15.6.0" + qr.js "0.0.0" + qs@6.7.0: version "6.7.0" resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc" -- cgit v1.2.3