Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bndw committed May 31, 2020
1 parent e177a74 commit 6371e77
Show file tree
Hide file tree
Showing 19 changed files with 211 additions and 156 deletions.
20 changes: 20 additions & 0 deletions .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
2 changes: 2 additions & 0 deletions Dockerfile
@@ -0,0 +1,2 @@
FROM nginx:stable-alpine
COPY build /usr/share/nginx/html
26 changes: 26 additions & 0 deletions 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)
72 changes: 8 additions & 64 deletions 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.<br />
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.<br />
You will also see any lint errors in the console.

### `yarn test`

Launches the test runner in the interactive watch mode.<br />
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.<br />
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.<br />
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
```
3 changes: 2 additions & 1 deletion 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"
Expand Down
Binary file removed public/favicon.ico
Binary file not shown.
5 changes: 2 additions & 3 deletions public/index.html
Expand Up @@ -2,12 +2,11 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
content="Print a card for your WiFi login"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
Expand All @@ -24,7 +23,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>📡 WiFi Login Card</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
Binary file removed public/logo192.png
Binary file not shown.
Binary file removed public/logo512.png
Binary file not shown.
22 changes: 3 additions & 19 deletions 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",
Expand Down
38 changes: 0 additions & 38 deletions src/App.css

This file was deleted.

32 changes: 16 additions & 16 deletions 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 (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>

<h1>WiFi Card</h1>

<p className="tag">
Print a simple card with your WiFi login details. Tape it to the fridge, keep it in your wallet, etc.
</p>

<p className="tag">
Your information is never sent to the server.
View the <a href="https://github.com/bndw/wifi-details">source code</a>.
</p>

<Card />

</div>
);
}
Expand Down
56 changes: 56 additions & 0 deletions 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 (
<div>
<fieldset id="print-area">
<legend></legend>

<h1>WiFi Login</h1>
<hr/>

<div className="details">
<QRCode className="qrcode" value={this.state.qrvalue} size={175} />

<div className="text">
<label>Network name</label>
<input id="ssid" type="text" placeholder="Enter your WiFi Network" value={this.state.ssid} onChange={this.handleSSIDChange}/>
<label>Password</label>
<input id="password" type="text" placeholder="password" value={this.state.password} onChange={this.handlePasswordChange}/>
</div>
</div>

<p><span role="img" aria-label="mobile-phone">📸📱</span>Point your phone's camera at the QR Code to connect automatically</p>
</fieldset>
<div className="print-btn">
<button onClick={window.print}>Print</button>
</div>
</div>
)
}
}

export default Card;
47 changes: 47 additions & 0 deletions 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;
}
}
13 changes: 0 additions & 13 deletions src/index.css

This file was deleted.

2 changes: 1 addition & 1 deletion 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';

Expand Down

0 comments on commit 6371e77

Please sign in to comment.