Skip to content

Commit

Permalink
Prettier formatting (bndw#33)
Browse files Browse the repository at this point in the history
* Add prettier

* Format code
  • Loading branch information
bndw authored Jul 4, 2021
1 parent 313e5f8 commit 52ff616
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 49 deletions.
12 changes: 4 additions & 8 deletions .github/workflows/master_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,14 @@ jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
-
name: Checkout
- name: Checkout
uses: actions/checkout@v2
-
name: Set up Docker
- name: Set up Docker
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and publish
- name: Build and publish
run: make build publish
9 changes: 3 additions & 6 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
- name: Checkout
uses: actions/checkout@v2
-
name: Set up Docker
- name: Set up Docker
uses: docker/setup-buildx-action@v1
-
name: Build
- name: Build
run: make build
5 changes: 5 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"trailingComma": "es5",
"semi": true,
"singleQuote": true
}
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM mhart/alpine-node:14 as builder
WORKDIR /tmp
COPY . .

RUN npx prettier --check . '!**/*.min.{css,js}'
RUN yarn && yarn build

###
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![ci](https://github.com/bndw/wifi-card/workflows/ci/badge.svg)

# 📶 WiFi Card
# 📶 WiFi Card

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

Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@
"main": "index.js",
"repository": "[email protected]:bndw/wifi-card.git",
"author": "bndw <[email protected]>",
"license": "MIT"
"license": "MIT",
"devDependencies": {
"prettier": "2.3.2"
}
}
10 changes: 5 additions & 5 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Print a card for your WiFi login"
/>
<meta name="description" content="Print a card for your WiFi login" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
Expand All @@ -25,7 +22,10 @@
<title>📡 WiFi Card</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app. Feel free to view the <a href="https://github.com/bndw/wifi-card">source code</a>.</noscript>
<noscript
>You need to enable JavaScript to run this app. Feel free to view the
<a href="https://github.com/bndw/wifi-card">source code</a>.</noscript
>
<div id="root"></div>
<!--
This HTML file is a template.
Expand Down
20 changes: 12 additions & 8 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
import React from 'react';
import Card from './components/Card';
import { Card } from './components/Card';
import './style.css';

function App() {
return (
<div className="App">

<h1><span role="img" aria-label="antenna-bars">📶</span>&nbsp; WiFi Card</h1>
<h1>
<span role="img" aria-label="antenna-bars">
📶
</span>
&nbsp; 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.
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 WiFi information is never sent to the server.
No tracking, analytics, or fingerprinting are used on this website.
View the <a href="https://github.com/bndw/wifi-card">source code</a>.
Your WiFi information is never sent to the server. No tracking,
analytics, or fingerprinting are used on this website. View the{' '}
<a href="https://github.com/bndw/wifi-card">source code</a>.
</p>

<Card />

</div>
);
}
Expand Down
56 changes: 38 additions & 18 deletions src/components/Card.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ import React, { useState, useEffect } from 'react';
import QRCode from 'qrcode.react';
import './style.css';

const Card = () => {
const [ssid, setSsid] = useState('');
const [password, setPassword] = useState('');
export const Card = () => {
const [network, setNetwork] = useState({
ssid: '',
password: '',
});
const [qrvalue, setQrvalue] = useState('');

const escape = (v) => {
const needsEscape = ['"', ';', ',', ':', '\\'];

let escaped = '';
for (let i = 0; i < v.length; i++) {
let c = v[i];
Expand All @@ -20,41 +22,59 @@ const Card = () => {
}

return escaped;
}
};

useEffect(() => {
let _ssid = escape(ssid),
_password = escape(password);

setQrvalue(`WIFI:T:WPA;S:${_ssid};P:${_password};;`);
}, [ssid, password]);
const ssid = escape(network.ssid);
const password = escape(network.password);
setQrvalue(`WIFI:T:WPA;S:${ssid};P:${password};;`);
}, [network]);

return (
<div>
<fieldset id="print-area">
<legend></legend>

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

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

<div className="text">
<label>Network name</label>
<input id="ssid" type="text" maxLength="32" placeholder="WiFi Network name" value={ssid} onChange={event => setSsid(event.target.value)} />
<input
id="ssid"
type="text"
maxLength="32"
placeholder="WiFi Network name"
value={network.ssid}
onChange={(e) => setNetwork({ ...network, ssid: e.target.value })}
/>
<label>Password</label>
<input id="password" type="text" maxLength="63" placeholder="Password" value={password} onChange={event => setPassword(event.target.value)} />
<input
id="password"
type="text"
maxLength="63"
placeholder="Password"
value={network.password}
onChange={(e) =>
setNetwork({ ...network, password: e.target.value })
}
/>
</div>
</div>

<p><span role="img" aria-label="mobile-phone">📸📱</span>Point your phone's camera at the QR Code to connect automatically</p>
<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;
);
};
5 changes: 3 additions & 2 deletions src/components/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
display: flex;
padding: 1em;
}
.details .text{
.details .text {
margin: 0;
}
.details .text * {
Expand Down Expand Up @@ -36,7 +36,8 @@
body * {
visibility: hidden;
}
#print-area, #print-area * {
#print-area,
#print-area * {
visibility: visible;
}
#print-area input {
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8811,6 +8811,11 @@ prepend-http@^1.0.0:
resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc"
integrity sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=

[email protected]:
version "2.3.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.3.2.tgz#ef280a05ec253712e486233db5c6f23441e7342d"
integrity sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ==

pretty-bytes@^5.3.0:
version "5.6.0"
resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-5.6.0.tgz#356256f643804773c82f64723fe78c92c62beaeb"
Expand Down

0 comments on commit 52ff616

Please sign in to comment.